diff --git a/config/nvim/after/plugin/nvim-tree.lua b/config/nvim/after/plugin/nvim-tree.lua index 35bcf65..d1bdb35 100644 --- a/config/nvim/after/plugin/nvim-tree.lua +++ b/config/nvim/after/plugin/nvim-tree.lua @@ -25,6 +25,6 @@ plugin.setup { }, } -vim.keymap.set('n', 'tt', 'NvimTreeToggle') -vim.keymap.set('n', 'tf', 'NvimTreeFindFileToggle') +vim.keymap.set('n', 'nn', 'NvimTreeToggle') +vim.keymap.set('n', 'nf', 'NvimTreeFindFileToggle') diff --git a/config/nvim/after/plugin/treesitter.lua b/config/nvim/after/plugin/treesitter.lua new file mode 100644 index 0000000..96bf623 --- /dev/null +++ b/config/nvim/after/plugin/treesitter.lua @@ -0,0 +1,89 @@ +local ok, configs = pcall(require, 'nvim-treesitter.configs') +if not ok then return end + +configs.setup { + ensure_installed = { + 'bash', + 'c', + 'cpp', + 'haskell', + 'help', + 'html', + 'javascript', + 'latex', + 'lua', + 'make', + 'markdown', + 'python', + 'toml', + 'vim', + 'yaml', + }, + + highlight = { + enable = true, + disable = { + 'help', + }, + }, + + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', -- mapped in normal mode + node_incremental = '', -- mapped in visual mode + node_decremental = '', -- mapped in visual mode + scope_incremental = nil, -- disbaled, normally mapped in visual mode + }, + }, + + refactor = { + highlight_definitions = { enable = true }, + highlight_current_scope = { enable = false }, + + smart_rename = { + enable = true, + keymaps = { + smart_rename = 'grr', + }, + }, + + navigation = { + enable = true, + keymaps = { + goto_definition = 'gd', -- default: 'gnd' + list_definitions = nil, -- disabled, default: 'gnD' + list_definitions_toc = 'gO', + goto_next_usage = '', + goto_previous_usage = '', + }, + }, + }, + + textobjects = { + select = { + enable = true, + keymaps = { + ['ab'] = '@block.outer', + ['ib'] = '@block.inner', + ['ac'] = '@conditional.outer', + ['ic'] = '@conditional.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['al'] = '@loop.outer', + ['il'] = '@loop.inner', + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + }, + }, + }, + + playground = { + enable = true, + }, +} + +vim.keymap.set('n', 'tp', 'TSPlaygroundToggle') +vim.keymap.set('n', 'th', 'TSHighlightCapturesUnderCursor') +vim.keymap.set('n', 'tn', 'TSNodeUnderCursor') + diff --git a/config/nvim/lua/fs/plugins.lua b/config/nvim/lua/fs/plugins.lua index 2d6402b..535d6a9 100644 --- a/config/nvim/lua/fs/plugins.lua +++ b/config/nvim/lua/fs/plugins.lua @@ -40,11 +40,17 @@ packer.startup(function(use) use 'ntpeters/vim-better-whitespace' use 'godlygeek/tabular' use 'tpope/vim-commentary' - use 'mg979/vim-visual-multi' + -- use 'mg979/vim-visual-multi' -- git -------------------------------------------------------------------- use 'tpope/vim-fugitive' + -- Treesitter ------------------------------------------------------------- + use 'nvim-treesitter/nvim-treesitter' + use 'nvim-treesitter/nvim-treesitter-refactor' + use 'nvim-treesitter/nvim-treesitter-textobjects' + use 'nvim-treesitter/playground' + -- Filetypes -------------------------------------------------------------- use 'elzr/vim-json' use 'keith/swift.vim'