From 3875bb2a74885205fae844748438b224f868936a Mon Sep 17 00:00:00 2001 From: qwjyh Date: Sun, 12 Mar 2023 23:31:18 +0900 Subject: [PATCH] update: nvim: add tree-sitter --- dotfiles/neovim/init.lua | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 4229292..d255886 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -33,10 +33,14 @@ require('lazy').setup({ dependencies = { 'hrsh7th/cmp-nvim-lsp', -- LSP 'L3MON4D3/LuaSnip', -- snippets - 'saadparwaiz1/cmp_luasnip', + 'saadparwaiz1/cmp_luasnip', -- nvim-cmp source for LuaSnip 'kdheepak/cmp-latex-symbols', -- latex math }, }, + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + }, }) @@ -94,6 +98,28 @@ end -- lualine require('lualine_setup') +----------------------------------------------------------- +-- Treesitter +-- manually install parsers with `:TSInstall ` +require'nvim-treesitter.configs'.setup { + highlight = { + enable = true, + }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "gnn", + node_incremental = "grn", + scope_incremental = "grc", + node_decremental = "grm", + }, + }, + indent = { + enable = true, + }, +} + + ----------------------------------------------------------- -- LSP config @@ -129,7 +155,7 @@ local on_attach = function(client, bufnr) vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, bufopts) vim.keymap.set('n', 'rn', vim.lsp.buf.rename, bufopts) vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, bufopts) - vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts) + vim.keymap.set('n', 'grf', vim.lsp.buf.references, bufopts) vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) end