1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
return {
'nvim-treesitter/nvim-treesitter',
version = false, -- last release is way too old
build = ':TSUpdate',
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 },
rainbow = {
enable = true,
extended_mode = true,
max_file_lines = nil,
},
ensure_installed = {
'asm',
'astro',
'bash',
'c',
'cpp',
'css',
'csv',
'diff',
'desktop',
'git_config',
'git_rebase',
'gitattributes',
'gitcommit',
'gitignore',
'go',
'gomod',
'gosum',
'gowork',
'groovy',
'html',
'ini',
'java',
'javascript',
'jsdoc',
'json',
'jsonc',
'kotlin',
'latex',
'linkerscript',
'lua',
'luadoc',
'luap',
'make',
'markdown',
'markdown_inline',
'mermaid',
'nix',
'pem',
'printf',
'python',
'query',
'regex',
'rust',
'scheme',
'sql',
'ssh_config',
'tmux',
'toml',
'tsx',
'typescript',
'vim',
'vimdoc',
'xml',
'yaml',
'zig',
'comment',
'gotmpl',
'hyprlang',
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<C-space>',
node_incremental = '<C-space>',
scope_incremental = false,
node_decremental = '<bs>',
},
},
textobjects = {
move = {
enable = true,
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
local ft_to_lang = require('nvim-treesitter.parsers').ft_to_lang
---@diagnostic disable-next-line: duplicate-set-field
require('nvim-treesitter.parsers').ft_to_lang = function(ft)
if ft == 'zsh' then
return 'bash'
end
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,
}
|