return { { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate", }, { "nvim-treesitter/playground", dependencies = { "nvim-treesitter/nvim-treesitter" }, cmd = { "TSPlaygroundToggle", "TSHighlightCapturesUnderCursor", "TSNodeUnderCursor", }, }, { "nvim-treesitter/nvim-treesitter-context", event = "VeryLazy", dependencies = { "nvim-treesitter/nvim-treesitter" }, cmd = { "TSContextEnable", "TSContextDisable", "TSContextToggle" }, keys = { -- stylua: ignore start { "[c", function() require("treesitter-context").go_to_context() end, desc = "Go to context start", }, { "c", function() require("treesitter-context").toggle() end, desc = "Toggle context view", }, -- stylua: ignore end }, opts = { enable = true }, config = function(_, opts) require("treesitter-context").setup(opts) vim.api.nvim_set_hl(0, "TreesitterContext", { bg = "#555555" }) vim.api.nvim_set_hl(0, "TreesitterContextLineNumber", { link = "Special" }) end, }, { "nvim-treesitter/nvim-treesitter-textobjects", branch = "main", dependencies = { "nvim-treesitter/nvim-treesitter" }, init = function() -- Disable entire built-in ftplugin mappings to avoid conflicts. -- See https://github.com/neovim/neovim/tree/master/runtime/ftplugin for built-in ftplugins. vim.g.no_plugin_maps = true end, config = function() require("nvim-treesitter-textobjects").setup({ select = { lookahead = true, selection_modes = { ["@parameter.outer"] = "v", -- charwise ["@function.outer"] = "V", -- linewise ["@class.outer"] = "V", }, }, }) vim.keymap.set("n", "a", function() require("nvim-treesitter-textobjects.swap").swap_next("@parameter.inner") end) vim.keymap.set("n", "A", function() require("nvim-treesitter-textobjects.swap").swap_previous("@parameter.outer") end) vim.keymap.set({ "x", "o" }, "af", function() require("nvim-treesitter-textobjects.select").select_textobject("@function.outer", "textobjects") end) vim.keymap.set({ "x", "o" }, "if", function() require("nvim-treesitter-textobjects.select").select_textobject("@function.inner", "textobjects") end) vim.keymap.set({ "x", "o" }, "ac", function() require("nvim-treesitter-textobjects.select").select_textobject("@class.outer", "textobjects") end) vim.keymap.set({ "x", "o" }, "ic", function() require("nvim-treesitter-textobjects.select").select_textobject("@class.inner", "textobjects") end) vim.keymap.set({ "x", "o" }, "ap", function() require("nvim-treesitter-textobjects.select").select_textobject("@parameter.outer", "textobjects") end) vim.keymap.set({ "x", "o" }, "ip", function() require("nvim-treesitter-textobjects.select").select_textobject("@parameter.inner", "textobjects") end) vim.keymap.set({ "x", "o" }, "ar", function() require("nvim-treesitter-textobjects.select").select_textobject("@return_type.outer", "textobjects") end) vim.keymap.set({ "x", "o" }, "ir", function() require("nvim-treesitter-textobjects.select").select_textobject("@return_type.inner", "textobjects") end) -- You can also use captures from other query groups like `locals.scm` vim.keymap.set({ "x", "o" }, "as", function() require("nvim-treesitter-textobjects.select").select_textobject("@local.scope", "locals") end) end, }, }