diff --git a/modules/nvim.lua b/modules/nvim.lua index 144dfe6..6d31a53 100644 --- a/modules/nvim.lua +++ b/modules/nvim.lua @@ -39,6 +39,7 @@ local start_plugins = { ["nvim-lint"] = { url = "https://github.com/mfussenegger/nvim-lint.git" }, ["nvim-lspconfig"] = { url = "https://github.com/neovim/nvim-lspconfig.git" }, ["nvim-treesitter"] = { url = "https://github.com/nvim-treesitter/nvim-treesitter.git" }, + ["nvim-treesitter-textobjects"] = { url = "https://github.com/nvim-treesitter/nvim-treesitter-textobjects.git" }, ["vim-surround"] = { url = "https://github.com/tpope/vim-surround.git" }, ["vim-tmux-navigator"] = { url = "https://github.com/christoomey/vim-tmux-navigator.git" }, ["cmp-cmdline"] = { url = "https://github.com/hrsh7th/cmp-cmdline.git", revision = "main" }, diff --git a/site-modules/core/files/vim/plugin/treesitter.lua b/site-modules/core/files/vim/plugin/treesitter.lua index 3027f43..606f6d4 100644 --- a/site-modules/core/files/vim/plugin/treesitter.lua +++ b/site-modules/core/files/vim/plugin/treesitter.lua @@ -1,16 +1,49 @@ require("nvim-treesitter.configs").setup { auto_install = true, playground = { enable = true }, - indent = { enable = false }, + indent = { enable = true }, rainbow = { enable = true }, highlight = { -- `false` will disable the whole extension enable = true, - additional_vim_regex_highlighting = true, + additional_vim_regex_highlighting = false, + }, + textobjects = { + select = { + enable = true, + keymaps = { + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["aa"] = "@parameter.outer", -- this is also arguments + ["ia"] = "@parameter.inner", -- this is also arguments + ["ab"] = "@block.outer", + ["ib"] = "@block.inner", + ["ac"] = "@comment.outer", + ["ic"] = "@comment.inner", + }, + }, + move = { + enable = true, + set_jumps = true, + goto_next_start = { + ["]f"] = "@function.outer", + }, + goto_previous_start = { + ["[f"] = "@function.outer", + }, + }, + swap = { + enable = true, + swap_next = { + ["L"] = "@parameter.inner", + }, + swap_previous = { + ["H"] = "@parameter.inner", + }, + }, }, } - vim.opt.foldmethod = "expr" vim.opt.foldexpr = "nvim_treesitter#foldexpr()" vim.opt.foldenable = false