-
Notifications
You must be signed in to change notification settings - Fork 242
Description
Is your feature request related to a problem? Please describe.
I'm switching to the main branch and all is good, but when defining mappings as documented https://github.com/nvim-treesitter/nvim-treesitter-textobjects/tree/main?tab=readme-ov-file#text-objects-select it would be great if we could get "user friendly" descriptions for each text object.
Describe the solution you'd like
A function we can import that converts @function.outer, etc into something a bit more "friendly", eg: "outer function" at it's simplest. But ideally each text object would have a "description" defined that could be retrieved and used for keymaps/etc.
Describe alternatives you've considered
Right now I'm just converting @foo.bar into bar foo using gsub:
local keymaps = {
-- You can use the capture groups defined in textobjects.scm
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
}
for keys, query in pairs(keymaps) do
-- Convert "@foo.bar" into "bar foo"
local desc = query:sub(2):gsub('(%a+).(%a+)', '%2 %1')
vim.keymap.set({ "x", "o" }, keys, function()
select.select_textobject(query, "textobjects")
end, { desc = desc })
endAdditional context
Add any other context or screenshots about the feature request here.