Nvim-treesitter configuration: Difference between revisions

From wikinotes
Line 64: Line 64:
<blockquote>
<blockquote>
I don't think folds can be customized without changing the plugin sourcecode.<br>
I don't think folds can be customized without changing the plugin sourcecode.<br>
I think all searches are appended, you cannot remove builtin searches.
I think all searches are appended, you cannot remove builtin searches.<br>
 
<syntaxhighlight lang="scheme">
; queries/python/folds.scm
 
(function_definition) @fold
(class_definition) @fold
</syntaxhighlight>
</blockquote><!-- Folds -->
</blockquote><!-- Folds -->
</blockquote><!-- Customizing Features -->
</blockquote><!-- Customizing Features -->
https://neovim.io/doc/user/api.html#API
https://neovim.io/doc/user/api.html#API

Revision as of 04:20, 18 July 2021

Locations

~/.config/nvim/init.vim neovim config
~/.vim/queries/**/* language-specific module configs

Enabling Features

Modules

Enable modules within your init.nvim

# ~/.config/nvim/init.vim

lua <<EOF
require'nvim-treesitter.configs'.setup {
  highlight = {
    enable = true,

    -- when true, enables vim syntaxhighlighting alongside tree-sitters
    -- true/false or a list of languages
    additional_vim_regex_highlighting = false,
  },

  incremental_selection = {
    enable = true;
  },

  indent = {
    enable = true;
  },
}
EOF

Folds

Adjust the foldmethods/foldexprs for languages you'd like to fold using tree-sitter.

set foldmethod=expr
set foldexpr=nvim_treesitter#foldexpr()

Customizing Features

Basics

Default configuration of features is set within the queries directory in .scm files.
In the code, these are read using nvim_get_runtime_file which layers files from ~/.vim overtop of these files.
Simply override the settings within your .vim directory.

Folds

I don't think folds can be customized without changing the plugin sourcecode.
I think all searches are appended, you cannot remove builtin searches.

; queries/python/folds.scm

(function_definition) @fold
(class_definition) @fold

https://neovim.io/doc/user/api.html#API