fix(treesitter): don't spam query errors in the highlighter

**Problem:** An erroneous query in the treesitter highlighter gives a
deluge of errors that makes the editor almost unusable.

**Solution:** Detach the highlighter after an error is detected, so that
it only gets displayed once (per highlighter instance).
This commit is contained in:
Riley Bruins authored and Christian Clason committed 2025-02-19 19:13:16 +01:00
1 parent 36f44b3121
commit b0bbe25c48
1 file changed
+6 -1
+6 -1
View File
@@ -232,7 +232,12 @@ end
---@return vim.treesitter.highlighter.Query
function TSHighlighter:get_query(lang)
if not self._queries[lang] then
self._queries[lang] = TSHighlighterQuery.new(lang)
local success, result = pcall(TSHighlighterQuery.new, lang)
if not success then
self:destroy()
error(result)
end
self._queries[lang] = result
end
return self._queries[lang]