-
-
Notifications
You must be signed in to change notification settings - Fork 9
Description
When using nvim-treesitter/nvim-treesitter
with tree-sitter-rst
, whenever I have a .. code-block
directive, editing any text within the code block seems to break treesitter parsing for the rest of the file.
MRE:
repro.lua
vim.env.LAZY_STDPATH = '.repro'
load(vim.fn.system('curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua'))()
require('lazy.minit').repro {
spec = {
{
'nvim-treesitter/nvim-treesitter',
config = function()
require('nvim-treesitter.configs').setup {
ensure_installed = { 'rst', 'python' },
auto_install = true,
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
}
end,
},
},
}
Run nvim test.rst -u repro.lua
and paste
``text``
.. code-block:: python
for i in range(10):
pass
``text``
Running :InspectTree
then gives
(document ; [0, 0] - [8, 0]
(paragraph ; [0, 0] - [0, 8]
(literal)) ; [0, 0] - [0, 8]
(directive ; [2, 0] - [4, 12]
name: (type) ; [2, 3] - [2, 13]
body: (body ; [2, 16] - [4, 12]
(arguments) ; [2, 16] - [2, 22]
(content ; [3, 3] - [4, 12]
(module ; [3, 3] - [4, 12]
(for_statement ; [3, 3] - [4, 12]
left: (identifier) ; [3, 7] - [3, 8]
right: (call ; [3, 12] - [3, 21]
function: (identifier) ; [3, 12] - [3, 17]
arguments: (argument_list ; [3, 17] - [3, 21]
(integer))) ; [3, 18] - [3, 20]
body: (block ; [4, 8] - [4, 12]
(pass_statement))))))) ; [4, 8] - [4, 12]
(paragraph ; [6, 0] - [6, 8]
(literal))) ; [6, 0] - [6, 8]
If I then put my cursor on the pass
and press o
to create a newline after it, only the first text
gets highlighted and the tree now looks like
(document ; [0, 0] - [9, 0]
(paragraph ; [0, 0] - [0, 8]
(literal)) ; [0, 0] - [0, 8]
(ERROR ; [2, 0] - [7, 8]
(type))) ; [2, 3] - [2, 13]
The second text
is also now part of the error node. An undo to revert the file back to what it was prior doesn't fix the tree:
(document ; [0, 0] - [8, 0]
(paragraph ; [0, 0] - [0, 8]
(literal)) ; [0, 0] - [0, 8]
(ERROR ; [2, 0] - [6, 8]
(type))) ; [2, 3] - [2, 13]
Closing and reopening the file fixes the tree (I think since it reparses the file), but any subsequent edit to the code block makes the rest of the document an error node again. Putting a new line right under the code-block directive also seems to force a reparse.