feat(neovim): set up nvim-treesitter

This commit is contained in:
Felix Schröter 2021-03-04 20:03:38 +01:00
parent 64a9bc40cb
commit 9c769cdec0
No known key found for this signature in database
GPG key ID: 910ACB9F6BD26F58
3 changed files with 61 additions and 4 deletions

View file

@ -21,7 +21,10 @@ let
EOF
'';
in {
home.packages = with pkgs; [ graphviz ];
home.packages = with pkgs; [
gcc # required for nvim-treesitter
graphviz
];
programs.neovim = {
enable = true;
@ -36,7 +39,6 @@ in {
lightline-vim
nerdtree
vim-startify
vim-polyglot
vim-visual-multi
vim-surround
vim-commentary
@ -49,9 +51,14 @@ in {
vim-closetag
auto-pairs
camelcasemotion
argtextobj-vim
wmgraphviz-vim
# use :TSInstall & :TSUpdate to manage parsers
nvim-treesitter
nvim-treesitter-context
nvim-treesitter-refactor
nvim-treesitter-textobjects
nvim-lspconfig
# nvim-dap
@ -63,10 +70,11 @@ in {
readFile ./init.vim # + readFile ./vim-surround-fix.vim
+ readFile ./which-key.vim + readFile ./test.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;
withPython = false;
};
xdg.configFile."nvim/filetype.vim".source = ./filetype.vim;
xdg.configFile."nvim/scripts.vim".source = ./scripts.vim;
}

View file

@ -0,0 +1,2 @@
au BufRead,BufNewFile *.nix set filetype=nix

View 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",
},
},
},
}