feat: nvim-treesitter
This commit is contained in:
parent
c310916b13
commit
e4d1f92cb2
3 changed files with 94 additions and 0 deletions
|
@ -55,6 +55,39 @@ with final.pkgs.lib; let
|
|||
flash-nvim
|
||||
which-key-nvim
|
||||
gitsigns-nvim
|
||||
|
||||
# Treesitter
|
||||
(nvim-treesitter.withPlugins (
|
||||
plugins:
|
||||
with plugins; [
|
||||
bash
|
||||
diff
|
||||
html
|
||||
gitignore
|
||||
javascript
|
||||
jsdoc
|
||||
json
|
||||
jsonc
|
||||
just
|
||||
lua
|
||||
luadoc
|
||||
markdown
|
||||
markdown_inline
|
||||
nix
|
||||
just
|
||||
printf
|
||||
python
|
||||
query
|
||||
regex
|
||||
toml
|
||||
tsx
|
||||
typescript
|
||||
vim
|
||||
vimdoc
|
||||
xml
|
||||
yaml
|
||||
]
|
||||
))
|
||||
];
|
||||
|
||||
extraPackages = with pkgs; [
|
||||
|
|
5
nvim/lua/plugins/treesitter/init.lua
Normal file
5
nvim/lua/plugins/treesitter/init.lua
Normal file
|
@ -0,0 +1,5 @@
|
|||
local req = MarleyVim.local_require('plugins.treesitter')
|
||||
|
||||
return {
|
||||
req('nvim-treesitter'),
|
||||
}
|
56
nvim/lua/plugins/treesitter/nvim-treesitter.lua
Normal file
56
nvim/lua/plugins/treesitter/nvim-treesitter.lua
Normal file
|
@ -0,0 +1,56 @@
|
|||
return {
|
||||
event = { 'BufReadPost', 'BufWritePost', 'BufNewFile', 'DeferredUIEnter' },
|
||||
keys = {
|
||||
{ '<C-space>', desc = 'increment selection' },
|
||||
{ '<BS>', desc = 'decrement selection', mode = 'x' },
|
||||
},
|
||||
before = function()
|
||||
require('lz.n').trigger_load('which-key.nvim')
|
||||
end,
|
||||
after = function()
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
require('nvim-treesitter.configs').setup({
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
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 = {
|
||||
[']f'] = '@function.outer',
|
||||
[']c'] = '@class.outer',
|
||||
[']a'] = '@parameter.inner',
|
||||
},
|
||||
goto_next_end = {
|
||||
[']F'] = '@function.outer',
|
||||
[']C'] = '@class.outer',
|
||||
[']A'] = '@parameter.inner',
|
||||
},
|
||||
goto_previous_start = {
|
||||
['[f'] = '@function.outer',
|
||||
['[c'] = '@class.outer',
|
||||
['[a'] = '@parameter.inner',
|
||||
},
|
||||
goto_previous_end = {
|
||||
['[F'] = '@function.outer',
|
||||
['[C'] = '@class.outer',
|
||||
['[A'] = '@parameter.inner',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
require('which-key').add({
|
||||
{ '<BS>', desc = 'decrement selection', mode = 'x' },
|
||||
{ '<C-space>', desc = 'increment selection', mode = { 'x', 'n' } },
|
||||
})
|
||||
end,
|
||||
}
|
Loading…
Reference in a new issue