-
-
Notifications
You must be signed in to change notification settings - Fork 376
[BUG] <BUG> nvim-treesitter-textobjects keymaps not working due to outdated config methods #4216
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Plugin
nvim-treesitter-textobjects
Nixpkgs Release
unstable
Home Manager Release
None
I have read the FAQ
- I have read the FAQ and my bug is not listed there.
Description
nvim-treesitter plugin had some breaking changes in the past several months, so now both
require("nvim-treesitter.configs").setup({
textobjects = {
select = {
enable = true,
keymaps = {
aa = "@parameter.outer",
ab = "@block.outer",
ac = "@call.outer",
ia = "@parameter.inner",
ib = "@block.inner",
ic = "@call.inner",
},
lookahead = true,
},
},
})and
require("nvim-treesitter").setup({
textobjects = {
select = {
enable = true,
keymaps = {
aa = "@parameter.outer",
ab = "@block.outer",
ac = "@call.outer",
ia = "@parameter.inner",
ib = "@block.inner",
ic = "@call.inner",
},
lookahead = true,
},
},
})can not set the "select" omaps.
Instead, according to treesitter-textobjects github mainpage, one must use general keymap configs e.g.
vim.keymap.set({ "x", "o" }, "am", function()
require "nvim-treesitter-textobjects.select".select_textobject("@function.outer", "textobjects")
end)
vim.keymap.set({ "x", "o" }, "im", 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)
-- 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)That is to say, now the "select" and other functionality must be called by using require "nvim-treesitter-textobjects.<function name>".<function's function>. However, treesitter-textobjects/ hasn't been updated for 5 months. This should be fixed.
Looking forward to more discussions.
Minimal, Reproducible Example (MRE)
programs.nixvim = {
enable = true;
plugins = {
treesitter.enable = true;
treesitter-textobjects = {
enable = true;
settings.select = {
enable = true;
keymaps = {
"ia" = "@parameter.inner";
};
};
};
};
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working