Describe the bug
nvim-treesitter-textobjects movement functions (e.g. goto_next_start) throw a Lua error when no Treesitter parser is available for the current buffer, instead of failing silently.
Selection textobjects (e.g. select_textobject) do not error in the same situation, which leads to inconsistent behavior within the plugin.
To Reproduce
- Open a filetype without an installed Treesitter parser (e.g.
:e test.txt)
- Define a mapping using
goto_next_start, e.g.:
vim.keymap.set('n', ']m', function()
require('nvim-treesitter-textobjects.move')
.goto_next_start('@function.outer', 'textobjects')
end)
- Press
]m
- Observe Lua error:
attempt to perform arithmetic on local 'score' (a nil value)
Expected behavior
Movement functions should behave like selection textobjects and fail silently / no-op when:
- no Treesitter parser is available, or
- no valid matches are found
They should not raise Lua errors.
Output of :checkhealth nvim-treesitter
Details
(omitted / not relevant — issue occurs specifically when no parser is installed)
Output of nvim --version
NVIM v0.12.1
Build type: Release
Additional context
Describe the bug
nvim-treesitter-textobjectsmovement functions (e.g.goto_next_start) throw a Lua error when no Treesitter parser is available for the current buffer, instead of failing silently.Selection textobjects (e.g.
select_textobject) do not error in the same situation, which leads to inconsistent behavior within the plugin.To Reproduce
:e test.txt)goto_next_start, e.g.:]mExpected behavior
Movement functions should behave like selection textobjects and fail silently / no-op when:
They should not raise Lua errors.
Output of
:checkhealth nvim-treesitterDetails
(omitted / not relevant — issue occurs specifically when no parser is installed)
Output of
nvim --versionAdditional context