From b107ad071256b85023f0acd6857485ce46d5fb9b Mon Sep 17 00:00:00 2001 From: qwjyh Date: Mon, 13 Mar 2023 00:33:09 +0900 Subject: [PATCH] update: nvim: add tree-sitter text object --- dotfiles/neovim/init.lua | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/dotfiles/neovim/init.lua b/dotfiles/neovim/init.lua index 34e6d28..fc265c8 100644 --- a/dotfiles/neovim/init.lua +++ b/dotfiles/neovim/init.lua @@ -43,6 +43,9 @@ require('lazy').setup({ { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", + dependencies = { + "nvim-treesitter/nvim-treesitter-textobjects", + }, }, }) @@ -120,6 +123,49 @@ require'nvim-treesitter.configs'.setup { indent = { enable = true, }, + textobjects = { + select = { + enable = true, + lookahead = true, + keymaps = { + ['aa'] = '@parameter.outer', + ['ia'] = '@parameter.inner', + ['af'] = '@function.outer', + ['if'] = '@function.inner', + ['ac'] = '@class.outer', + ['ic'] = '@class.inner', + }, + }, + move = { + enable = true, + set_jumps = true, + goto_next_start = { + [']m'] = '@function.outer', + [']]'] = '@class.outer', + }, + goto_next_end = { + [']M'] = '@function.outer', + [']['] = '@class.outer', + }, + goto_previous_start = { + ['[m'] = '@function.outer', + ['[['] = '@class.outer', + }, + goto_previous_end = { + ['[M'] = '@function.outer', + ['[]'] = '@class.outer', + }, + }, + swap = { + enable = true, + swap_next = { + ['a'] = '@parameter.inner', + }, + swap_previous = { + ['A'] = '@parameter.inner', + }, + }, + }, }