You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working with Vue SFC files that embed TypeScript, (modified) HTML, and CSS. The injections seem to work perfectly — I can confirm that via :InspectTree.
However, none of the Treesitter textobject mappings (for selection, movement, etc.) are active by default. According to this issue, this appears to be expected behavior, and the mappings need to be manually redefined for injected languages.
I managed to get selection mappings working using the following setup:
localfunctionon_vue_file_open()
vim.keymap.set({ "o", "x" }, "af",
"<cmd>lua require'nvim-treesitter.textobjects.select'.select_textobject('@function.outer')<CR>")
vim.keymap.set({ "o", "x" }, "if",
"<cmd>lua require'nvim-treesitter.textobjects.select'.select_textobject('@function.inner')<CR>")
vim.keymap.set({ "o", "x" }, "ac",
"<cmd>lua require'nvim-treesitter.textobjects.select'.select_textobject('@class.outer')<CR>")
vim.keymap.set({ "o", "x" }, "ic",
"<cmd>lua require'nvim-treesitter.textobjects.select'.select_textobject('@class.inner')<CR>")
endvim.api.nvim_create_autocmd("BufEnter", {
pattern="*.vue",
callback=on_vue_file_open,
})
That works fine for selection, but I haven’t been able to figure out how to restore or redefine movement mappings (goto_next_start, goto_previous_end, etc.) inside Vue files.
Questions:
Is there a way to manually rebind those movement keys per buffer or filetype?
Is there a cleaner or more idiomatic way to do this kind of remapping just for .vue files?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi there 👋
I'm currently working with Vue SFC files that embed TypeScript, (modified) HTML, and CSS. The injections seem to work perfectly — I can confirm that via
:InspectTree
.However, none of the Treesitter textobject mappings (for selection, movement, etc.) are active by default. According to this issue, this appears to be expected behavior, and the mappings need to be manually redefined for injected languages.
I managed to get selection mappings working using the following setup:
That works fine for selection, but I haven’t been able to figure out how to restore or redefine movement mappings (
goto_next_start
,goto_previous_end
, etc.) inside Vue files.Questions:
.vue
files?Thanks a lot in advance 🙏
Beta Was this translation helpful? Give feedback.
All reactions