diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index 61f54c1..5e10172 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -136,6 +136,8 @@ local init = function () -- For C, Lua and Rust use { 'nvim-treesitter/nvim-treesitter', + 'nvim-treesitter/nvim-treesitter-textobjects', + 'nvim-treesitter/nvim-treesitter-refactor', config = "require('treesitter')", } -- All writing needs diff --git a/nvim/.config/nvim/lua/treesitter.lua b/nvim/.config/nvim/lua/treesitter.lua index 3c4ff15..5cce23d 100644 --- a/nvim/.config/nvim/lua/treesitter.lua +++ b/nvim/.config/nvim/lua/treesitter.lua @@ -3,4 +3,53 @@ require'nvim-treesitter.configs'.setup { highlight = { enable = true, }, + textobjects = { + select = { + enable = true, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + }, + }, + swap = { + enable = true, + swap_next = { + ["gs"] = "@parameter.inner", + }, + swap_previous = { + ["gS"] = "@parameter.inner", + }, + }, + move = { + enable = true, + goto_next_start = { + ["]f"] = "@function.outer", + ["]]"] = "@class.outer", + }, + goto_next_end = { + ["]F"] = "@function.outer", + ["]["] = "@class.outer", + }, + goto_previous_start = { + ["[f"] = "@function.outer", + ["[["] = "@class.outer", + }, + goto_previous_end = { + ["[F"] = "@function.outer", + ["[]"] = "@class.outer", + }, + }, + }, + refactor = { + highlight_definitions = { enable = true }, + highlight_current_scope = { enable = false }, + smart_rename = { + enable = true, + keymaps = { + smart_rename = "grr", + }, + }, + }, }