feat(neovim): set up nvim-treesitter
This commit is contained in:
parent
64a9bc40cb
commit
9c769cdec0
|
@ -21,7 +21,10 @@ let
|
||||||
EOF
|
EOF
|
||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
home.packages = with pkgs; [ graphviz ];
|
home.packages = with pkgs; [
|
||||||
|
gcc # required for nvim-treesitter
|
||||||
|
graphviz
|
||||||
|
];
|
||||||
|
|
||||||
programs.neovim = {
|
programs.neovim = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -36,7 +39,6 @@ in {
|
||||||
lightline-vim
|
lightline-vim
|
||||||
nerdtree
|
nerdtree
|
||||||
vim-startify
|
vim-startify
|
||||||
vim-polyglot
|
|
||||||
vim-visual-multi
|
vim-visual-multi
|
||||||
vim-surround
|
vim-surround
|
||||||
vim-commentary
|
vim-commentary
|
||||||
|
@ -49,9 +51,14 @@ in {
|
||||||
vim-closetag
|
vim-closetag
|
||||||
auto-pairs
|
auto-pairs
|
||||||
camelcasemotion
|
camelcasemotion
|
||||||
argtextobj-vim
|
|
||||||
wmgraphviz-vim
|
wmgraphviz-vim
|
||||||
|
|
||||||
|
# use :TSInstall & :TSUpdate to manage parsers
|
||||||
|
nvim-treesitter
|
||||||
|
nvim-treesitter-context
|
||||||
|
nvim-treesitter-refactor
|
||||||
|
nvim-treesitter-textobjects
|
||||||
|
|
||||||
nvim-lspconfig
|
nvim-lspconfig
|
||||||
# nvim-dap
|
# nvim-dap
|
||||||
|
|
||||||
|
@ -63,10 +70,11 @@ in {
|
||||||
readFile ./init.vim # + readFile ./vim-surround-fix.vim
|
readFile ./init.vim # + readFile ./vim-surround-fix.vim
|
||||||
+ readFile ./which-key.vim + readFile ./test.vim
|
+ readFile ./which-key.vim + readFile ./test.vim
|
||||||
+ vimLua (readFile ./lsp/extensions.lua) + readFile ./lsp/lsp.vim
|
+ vimLua (readFile ./lsp/extensions.lua) + readFile ./lsp/lsp.vim
|
||||||
+ vimLua (readFile ./lsp/lsp.lua);
|
+ vimLua (readFile ./lsp/lsp.lua) + vimLua (readFile ./treesitter.lua);
|
||||||
withNodeJs = true;
|
withNodeJs = true;
|
||||||
withPython = false;
|
withPython = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
xdg.configFile."nvim/filetype.vim".source = ./filetype.vim;
|
||||||
xdg.configFile."nvim/scripts.vim".source = ./scripts.vim;
|
xdg.configFile."nvim/scripts.vim".source = ./scripts.vim;
|
||||||
}
|
}
|
||||||
|
|
2
home/editors/neovim/filetype.vim
Normal file
2
home/editors/neovim/filetype.vim
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
au BufRead,BufNewFile *.nix set filetype=nix
|
||||||
|
|
47
home/editors/neovim/treesitter.lua
Normal file
47
home/editors/neovim/treesitter.lua
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
-- TODO install parsers declaratively instead of :TSInstall & :TSUpdate
|
||||||
|
|
||||||
|
require'nvim-treesitter.configs'.setup {
|
||||||
|
ensure_installed = 'all',
|
||||||
|
highlight = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
indent = {
|
||||||
|
enable = true,
|
||||||
|
},
|
||||||
|
refactor = {
|
||||||
|
highlight_definitions = { enable = true },
|
||||||
|
highlight_current_scope = { enable = true },
|
||||||
|
navigation = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
goto_definition_lsp_fallback = "gnd",
|
||||||
|
list_definitions = "gnD",
|
||||||
|
list_definitions_toc = "gO",
|
||||||
|
goto_next_usage = "<a-*>",
|
||||||
|
goto_previous_usage = "<a-#>",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
incremental_selection = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
init_selection = "<CR>",
|
||||||
|
scope_incremental = "<CR>",
|
||||||
|
node_incremental = "<TAB>",
|
||||||
|
node_decremental = "<S-TAB>",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
textobjects = {
|
||||||
|
select = {
|
||||||
|
enable = true,
|
||||||
|
keymaps = {
|
||||||
|
["af"] = "@function.outer",
|
||||||
|
["if"] = "@function.inner",
|
||||||
|
["ac"] = "@class.outer",
|
||||||
|
["ic"] = "@class.inner",
|
||||||
|
["aa"] = "@parameter.outer",
|
||||||
|
["ia"] = "@parameter.inner",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
Loading…
Reference in a new issue