mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-27 11:55:22 +00:00
neovim/queries: init and add an example injection
This commit is contained in:
parent
d9ba7f0a9e
commit
6fe9ecd995
6 changed files with 181 additions and 4 deletions
|
|
@ -21,4 +21,5 @@ configuring/keybinds.md
|
|||
configuring/dags.md
|
||||
configuring/dag-entries.md
|
||||
configuring/autocmds.md
|
||||
configuring/queries.md
|
||||
```
|
||||
|
|
|
|||
46
docs/manual/configuring/queries.md
Normal file
46
docs/manual/configuring/queries.md
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
# Queries (`vim.treesitter.queries`)
|
||||
|
||||
Queries allow you to change Neovim's behavior based on Tree-sitter.\
|
||||
Read more about it in the
|
||||
[neovim docs](https://neovim.io/doc/user/treesitter/#_treesitter-queries).
|
||||
|
||||
**Example:**
|
||||
|
||||
In the following example, we are creating a custom injection, to highlight the
|
||||
Lua string after `mkLuaInline`.
|
||||
|
||||
```nix
|
||||
foo = mkLuaInline ''
|
||||
function bar()
|
||||
return 'foobar'
|
||||
end
|
||||
'';
|
||||
```
|
||||
|
||||
```nix
|
||||
{
|
||||
vim.treesitter.queries = [{
|
||||
type = "injections";
|
||||
filetypes = ["nix"];
|
||||
content = ''
|
||||
;; extends
|
||||
|
||||
((apply_expression
|
||||
function: (variable_expression
|
||||
name: (identifier) @_func
|
||||
(#eq? @_func "mkLuaInline"))
|
||||
|
||||
argument: (indented_string_expression
|
||||
(string_fragment) @injection.content)
|
||||
|
||||
(#set! injection.language "lua")
|
||||
(#set! injection.combined)))
|
||||
'';
|
||||
}];
|
||||
}
|
||||
```
|
||||
|
||||
This will generate a `queries/nix/injections.scm` in a Neovim runtime directory.
|
||||
|
||||
> [!NOTE]
|
||||
> When multiple queries match the same `filetype` and `type`, they are merged.
|
||||
|
|
@ -271,6 +271,11 @@
|
|||
|
||||
[Snoweuph](https://github.com/snoweuph)
|
||||
|
||||
- Added {option}`vim.treesitter.queries` to support adding custom queries.
|
||||
|
||||
- Added injections for `vim.treesitter.queries.*.content` as `query` and
|
||||
`mkLualine ""` as `lua`.
|
||||
|
||||
- Added `vim.lsp.presets.<name>` to contain LSP configurations. This allows for
|
||||
more flexibility in nvf and reuse of LSPs across languages. Dropped
|
||||
`deprecatedSingleOrListOf` in favor of `listOf` for the affected LSP options.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue