diff --git a/nvim/.config/nvim/lua/plugins.lua b/nvim/.config/nvim/lua/plugins.lua index bd92775..2db2a60 100644 --- a/nvim/.config/nvim/lua/plugins.lua +++ b/nvim/.config/nvim/lua/plugins.lua @@ -129,7 +129,8 @@ local init = function () } -- For C, Lua and Rust use { - 'nvim-treesitter/nvim-treesitter', + 'nvim-treesitter/nvim-treesitter-textobjects', + requires = { 'nvim-treesitter/nvim-treesitter' }, config = "require('treesitter')", } -- All writing needs diff --git a/nvim/.config/nvim/lua/treesitter.lua b/nvim/.config/nvim/lua/treesitter.lua index 00f80f4..f8d3673 100644 --- a/nvim/.config/nvim/lua/treesitter.lua +++ b/nvim/.config/nvim/lua/treesitter.lua @@ -1,6 +1,28 @@ require'nvim-treesitter.configs'.setup { ensure_installed = { "bash", "c", "clojure", "cpp", "fennel", "fish", "java", "javascript", "jsdoc", "json", "lua", "nix", "python", "rust", "toml" }, - highlight = { - enable = true, + highlight = { enable = true, }, + textobjects = { + select = { + enable = true, + keymaps = { + ["ab"] = "@block.outer" , + ["ib"] = "@block.inner" , + ["aC"] = "@call.outer" , + ["iC"] = "@call.inner" , + ["ao"] = "@class.outer" , + ["io"] = "@class.inner" , + ["at"] = "@comment.outer" , + ["ac"] = "@conditional.outer", + ["ic"] = "@conditional.inner", + ["af"] = "@function.outer" , + ["if"] = "@function.inner" , + ["al"] = "@loop.outer" , + ["il"] = "@loop.inner" , + ["ap"] = "@parameter.outer" , + ["ip"] = "@parameter.inner" , + ["is"] = "@scopename.inner" , + ["as"] = "@statement.outer" , + }, + }, }, }