summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/plugins')
-rw-r--r--.config/nvim/lua/plugins/nvim-treesitter.lua92
1 files changed, 81 insertions, 11 deletions
diff --git a/.config/nvim/lua/plugins/nvim-treesitter.lua b/.config/nvim/lua/plugins/nvim-treesitter.lua
index 39184cf..b9b7c44 100644
--- a/.config/nvim/lua/plugins/nvim-treesitter.lua
+++ b/.config/nvim/lua/plugins/nvim-treesitter.lua
@@ -1,19 +1,80 @@
return {
'nvim-treesitter/nvim-treesitter',
+ version = false, -- last release is way too old
build = ':TSUpdate',
- config = function()
- ---@type userdata
- ---@diagnostic disable-next-line: missing-fields
- require('nvim-treesitter.configs').setup({
- auto_install = true,
- highlight = { enable = true },
- indent = { enable = true },
- rainbow = {
+ lazy = false, -- It's only 2ms it's fine
+ cmd = { 'TSUpdateSync', 'TSUpdate', 'TSInstall' },
+ keys = {
+ { '<c-space>', desc = 'Increment Selection' },
+ { '<bs>', desc = 'Decrement Selection', mode = 'x' },
+ },
+ ---@type TSConfig
+ ---@diagnostic disable-next-line: missing-fields
+ opts = {
+ highlight = { enable = true },
+ indent = { enable = true },
+ auto_install = true,
+ rainbow = {
+ enable = true,
+ extended_mode = true,
+ max_file_lines = nil,
+ },
+
+ ensure_installed = {
+ 'bash',
+ 'c',
+ 'diff',
+ 'html',
+ 'javascript',
+ 'jsdoc',
+ 'json',
+ 'jsonc',
+ 'lua',
+ 'luadoc',
+ 'luap',
+ 'markdown',
+ 'markdown_inline',
+ 'printf',
+ 'python',
+ 'query',
+ 'regex',
+ 'toml',
+ 'tsx',
+ 'typescript',
+ 'vim',
+ 'vimdoc',
+ 'xml',
+ 'yaml',
+ },
+
+ incremental_selection = {
+ enable = true,
+ keymaps = {
+ init_selection = '<C-space>',
+ node_incremental = '<C-space>',
+ scope_incremental = false,
+ node_decremental = '<bs>',
+ },
+ },
+
+ textobjects = {
+ move = {
enable = true,
- extended_mode = true,
- max_file_lines = nil,
+ goto_next_start = {
+ ['gf'] = '@function.outer',
+ ['gc'] = '@class.outer',
+ ['ga'] = '@parameter.inner',
+ },
+ goto_previous_start = {
+ ['gF'] = '@function.outer',
+ ['gC'] = '@class.outer',
+ ['gA'] = '@parameter.inner',
+ },
},
- })
+ },
+ },
+ config = function(_, opts)
+ require('nvim-treesitter.configs').setup(opts)
-- HACK: Workaround to have syntax highlighting in zsh until a zsh parser is added
-- https://github.com/nvim-treesitter/nvim-treesitter/issues/655
@@ -26,4 +87,13 @@ return {
return ft_to_lang(ft)
end
end,
+ init = function(plugin)
+ -- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early
+ -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which
+ -- no longer trigger the **nvim-treesitter** module to be loaded in time.
+ -- Luckily, the only things that those plugins need are the custom queries, which we make available
+ -- during startup.
+ require('lazy.core.loader').add_to_rtp(plugin)
+ require('nvim-treesitter.query_predicates')
+ end,
}