treesitter: use new on_bytes interface

This will significantly reduce the parsing work
needed e.g. when rehighlighting after every keypress
in insert mode.

Also add safety check for tree-sitter trying to read
past the end of a line. This can happen after we sent
an incorrect buffer update.
This commit is contained in:
Björn Linse
2020-03-21 19:55:19 +01:00
parent bc86f76c0a
commit 9437327d5e
3 changed files with 36 additions and 30 deletions

View File

@@ -60,7 +60,7 @@ function TSHighlighter.new(query, bufnr, ft)
ft,
{
on_changedtree = function(...) self:on_changedtree(...) end,
on_lines = function() self.root = self.parser:parse():root() end
on_bytes = function() self.root = self.parser:parse():root() end
}
)