Skip to content

Commit b928148

Browse files
committed
HACK: manually perform an edit after parsing
1 parent a38c08a commit b928148

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lua/quicker/treesitter.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ function M._attach_lang(buf, lang, regions, register_cbs)
9393
-- which means it only parses visible areas (the on_win and on_line callback),
9494
-- so if we modify the buffer, unvisited area's state get unsynced.
9595
pcall(parser.parse, parser, true)
96+
-- Hack: we need to manually perform an edit, otherwise delete an entire line
97+
-- will cause all highlights to disappear.
98+
vim.api.nvim_buf_call(buf, function()
99+
local cache_z_reg = vim.fn.getreginfo("z")
100+
vim.cmd([[norm! "zx"zP]])
101+
vim.fn.setreg("z", cache_z_reg)
102+
end)
96103
end
97104

98105
return M

0 commit comments

Comments
 (0)