mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-27 03:47:37 +00:00
Deploy PR #1431 preview
This commit is contained in:
parent
d6d24954b0
commit
be19704dba
4 changed files with 105 additions and 4 deletions
|
|
@ -114,7 +114,8 @@
|
|||
</ul><li><a href="#ch-autocmds-augroups">Autocommands and Autogroups</a>
|
||||
<ul><li><a href="#sec-vim-augroups">Autogroups (vim.augroups)</a>
|
||||
<li><a href="#sec-vim-autocmds">Autocommands (vim.autocmds)</a>
|
||||
</li></ul></li>
|
||||
</ul><li><a href="#queries--vim-treesitter-queries">Queries (vim.treesitter.queries)</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</details>
|
||||
|
|
@ -609,6 +610,20 @@ Vimscript) for the same autocommand. Choose one.</p>
|
|||
<p>These definitions are automatically translated into the necessary Lua code to
|
||||
configure <code>vim.api.nvim_create_augroup</code> and <code>vim.api.nvim_create_autocmd</code> when
|
||||
Neovim starts.</p>
|
||||
<h1 id="queries--vim-treesitter-queries">Queries (<code>vim.treesitter.queries</code>)</h1>
|
||||
<p>Queries allow you to change Neovim's behavior based on Tree-sitter.<br>
|
||||
Read more about it in the
|
||||
<a href="https://neovim.io/doc/user/treesitter/#_treesitter-queries">neovim docs</a>.</p>
|
||||
<p><strong>Example:</strong></p>
|
||||
<p>In the following example, we are creating a custom injection, to highlight the
|
||||
Lua string after <code>mkLuaInline</code>.</p>
|
||||
<pre class="highlight"><code class="language-nix"><span style="color:rgb(97,175,239);">foo</span> <span style="color:rgb(171,178,191);">=</span> <span style="color:rgb(171,178,191);">mkLuaInline</span> <span style="color:rgb(152,195,121);">''</span><span style="color:rgb(152,195,121);"></span><br><span style="color:rgb(152,195,121);"> function bar()</span><br><span style="color:rgb(152,195,121);"> return 'foobar'</span><br><span style="color:rgb(152,195,121);"> end</span><br><span style="color:rgb(152,195,121);">''</span><span style="color:rgb(132,139,152);">;</span><br></code></pre>
|
||||
<pre class="highlight"><code class="language-nix"><span style="color:rgb(132,139,152);">{</span><br> <span style="color:rgb(86,182,194);">vim</span><span style="color:rgb(132,139,152);">.</span><span style="color:rgb(86,182,194);">treesitter</span><span style="color:rgb(132,139,152);">.</span><span style="color:rgb(86,182,194);">queries</span> <span style="color:rgb(171,178,191);">=</span> <span style="color:rgb(132,139,152);">[</span><span style="color:rgb(132,139,152);">{</span><br> <span style="color:rgb(86,182,194);">type</span> <span style="color:rgb(171,178,191);">=</span> <span style="color:rgb(152,195,121);">"</span><span style="color:rgb(152,195,121);">injections</span><span style="color:rgb(152,195,121);">"</span><span style="color:rgb(132,139,152);">;</span><br> <span style="color:rgb(86,182,194);">filetypes</span> <span style="color:rgb(171,178,191);">=</span> <span style="color:rgb(132,139,152);">[</span><span style="color:rgb(152,195,121);">"</span><span style="color:rgb(152,195,121);">nix</span><span style="color:rgb(152,195,121);">"</span><span style="color:rgb(132,139,152);">]</span><span style="color:rgb(132,139,152);">;</span><br> <span style="color:rgb(86,182,194);">content</span> <span style="color:rgb(171,178,191);">=</span> <span style="color:rgb(152,195,121);">''</span><span style="color:rgb(152,195,121);"></span><br><span style="color:rgb(152,195,121);"> ;; extends</span><br><span style="color:rgb(152,195,121);"></span><br><span style="color:rgb(152,195,121);"> ((apply_expression</span><br><span style="color:rgb(152,195,121);"> function: (variable_expression</span><br><span style="color:rgb(152,195,121);"> name: (identifier) @_func</span><br><span style="color:rgb(152,195,121);"> (#eq? @_func "mkLuaInline"))</span><br><span style="color:rgb(152,195,121);"></span><br><span style="color:rgb(152,195,121);"> argument: (indented_string_expression</span><br><span style="color:rgb(152,195,121);"> (string_fragment) @injection.content)</span><br><span style="color:rgb(152,195,121);"></span><br><span style="color:rgb(152,195,121);"> (#set! injection.language "lua")</span><br><span style="color:rgb(152,195,121);"> (#set! injection.combined)))</span><br><span style="color:rgb(152,195,121);"> </span><span style="color:rgb(152,195,121);">''</span><span style="color:rgb(132,139,152);">;</span><br> <span style="color:rgb(132,139,152);">}</span><span style="color:rgb(132,139,152);">]</span><span style="color:rgb(132,139,152);">;</span><br><span style="color:rgb(132,139,152);">}</span><br></code></pre>
|
||||
<p>This will generate a <code>queries/nix/injections.scm</code> in a Neovim runtime directory.</p>
|
||||
<div class="admonition note">
|
||||
<p class="admonition-title">Note</p>
|
||||
<p>When multiple queries match the same <code>filetype</code> and <code>type</code>, they are merged.</p>
|
||||
</div>
|
||||
</body></html><!-- deno-fmt-ignore-start --></main>
|
||||
</div>
|
||||
|
||||
|
|
@ -647,7 +662,8 @@ Neovim starts.</p>
|
|||
</ul><li><a href="#ch-autocmds-augroups">Autocommands and Autogroups</a>
|
||||
<ul><li><a href="#sec-vim-augroups">Autogroups (vim.augroups)</a>
|
||||
<li><a href="#sec-vim-autocmds">Autocommands (vim.autocmds)</a>
|
||||
</li></ul></li>
|
||||
</ul><li><a href="#queries--vim-treesitter-queries">Queries (vim.treesitter.queries)</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue