tree-sitter-blade: Getting errors on certain files after the new update

I want to express my appreciation to Emran Ramezan and Yaegassy for this Treesitter parser for Laravel Blade. I’ve been enjoying it a lot, but since the latest update yesterday, I’ve encountered some errors. It seems to work well on certain Blade files, but on others, I’m facing issues.

I am using it with LazyVim. I am not sure whether it is due tree sitter update or some other plugin. I have also followed the upgrade guide to set up injections.scm file.

Screenshot of the file where I get the error:

Screenshot 2023-12-04 at 19 08 42

Screenshot of the file where there is no error:

Screenshot 2023-12-04 at 19 08 02

Error message

[Neo-tree ERROR] Error opening file: vim/_editor.lua:0: nvim_exec2()..BufReadPost Autocommands for "*": Vim(append):Error executing lua callback: ...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:21: Error executing lua: ...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:22: nvim_exec2()..BufReadPost Autocommands for "*"..FileType Autocommands for "*": Vim(append):Error executing lua callback: ...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:260: Ranges can only be made from 6 element long tables or nodes.
stack traceback:
	[C]: in function 'set_included_ranges'
	...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:260: in function 'parse'
	...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:312: in function 'fn'
	...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:326: in function 'for_each_child'
	...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:330: in function 'for_each_child'
	...1/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:311: in function 'parse'
	...r/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:89: in function '_create_parser'
	...r/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:131: in function 'get_parser'
	...r/neovim/0.9.1/share/nvim/runtime/lua/vim/treesitter.lua:459: in function 'start'
	...m/lazy/nvim-treesitter/lua/nvim-treesitter/highlight.lua:20: in function 'attach'
	...vim/lazy/nvim-treesitter/lua/nvim-treesitter/configs.lua:509: in function 'attach_module'
	...
	[C]: in function 'nvim_buf_call'
	...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:21: in function <...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:10>
	[C]: in function 'nvim_exec2'
	vim/_editor.lua: in function <vim/_editor.lua:0>
	[C]: in function 'pcall'
	...hare/nvim/lazy/neo-tree.nvim/lua/neo-tree/utils/init.lua:714: in function 'open_file'
	...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:729: in function 'open'
	...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:751: in function 'open_with_cmd'
	...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:760: in function 'open'
	...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:184: in function <...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:183>
stack traceback:
	[C]: in function 'nvim_cmd'
	...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:22: in function <...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:21>
	[C]: in function 'nvim_buf_call'
	...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:21: in function <...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:10>
	[C]: in function 'nvim_exec2'
	vim/_editor.lua: in function <vim/_editor.lua:0>
	[C]: in function 'pcall'
	...hare/nvim/lazy/neo-tree.nvim/lua/neo-tree/utils/init.lua:714: in function 'open_file'
	...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:729: in function 'open'
	...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:751: in function 'open_with_cmd'
	...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:760: in function 'open'
	...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:184: in function <...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:183>
stack traceback:
	[C]: in function 'nvim_buf_call'
	...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:21: in function <...brew/Cellar/neovim/0.9.1/share/nvim/runtime/filetype.lua:10>
	[C]: in function 'nvim_exec2'
	vim/_editor.lua: in function <vim/_editor.lua:0>
	[C]: in function 'pcall'
	...hare/nvim/lazy/neo-tree.nvim/lua/neo-tree/utils/init.lua:714: in function 'open_file'
	...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:729: in function 'open'
	...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:751: in function 'open_with_cmd'
	...y/neo-tree.nvim/lua/neo-tree/sources/common/commands.lua:760: in function 'open'
	...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:184: in function <...o-tree.nvim/lua/neo-tree/sources/filesystem/commands.lua:183>

About this issue

  • Original URL
  • State: open
  • Created 7 months ago
  • Reactions: 1
  • Comments: 17 (10 by maintainers)

Most upvoted comments

Also when ever I insert a comment it always insert html comment , to get blade comment I have to insert them manually.

This is expected if you’re using treesitter based commenting—the reason is that most of the time you’re going to be in an html node instead of a blade node since most of the file is html

@ZayRTun definitely keep me posted here and do let us know if you managed to find the root of the problem! Would be interesting to know for future reference!

@EmranMR I will look into this like you said, maybe there is something wrong with my lazyvim setup, I am not sure. But anyway thanks to you for all this, been using ur tree sitter the whole day without any issue.

Maybe the configuration picking .php as syntax instead of .blade.php?

@ZayRTun That does not seem to be an issue with tree-sitter-blade by the looks of it. There were no errors parsing your code using cli, and Nova seem to be functioning fine, picking up everything as well, but I got some insights for you!

Nova With Blade turned on

Screenshot 2023-12-05 at 09 02 01

Nova with tree-sitter-blade turned off.

  • The following is the code editor, with html chosen as the syntax for the document, NOT the blade (as if it is .php or .html)
Screenshot 2023-12-05 at 09 03 31

How to fix?

It seems there is certainly something wrong with your NeoVim config or how it is installed, quite strange the issue started after the update though! Maybe head over to the NeoVim installation discussion, reference this issue and see if anyone can help? Unfortunately, I am not a NeoVim user myself, so all I can do is to just debug using cli and Nova 😬

@ZayRTun I just released v0.9.1 and I now have 0 bugs or errors when running tests on your code, using cli or in Nova. If that does not fix your problem I am afraid it is likely a problem with NeoVim config?

Regardless keep me posted here! 👍

Hey @ZayRTun thanks for that, Ok so I ran some tests, found a few bugs but unrelated to your problem I think (#41 & #42) haha. so.

The tree-sitter-blade parse the files correctly, with no errors:

; File ONE
(blade [0, 0] - [31, 0]
  (text [0, 0] - [3, 10])
  (php_statement [3, 10] - [3, 57]
    (bracket_start [3, 10] - [3, 12])
    (php_only [3, 13] - [3, 54])
    (bracket_end [3, 55] - [3, 57]))
  (text [3, 57] - [11, 41])
  (php_statement [11, 41] - [11, 59]
    (bracket_start [11, 41] - [11, 43])
    (php_only [11, 44] - [11, 56])
    (bracket_end [11, 57] - [11, 59]))
  (text [11, 59] - [13, 15])
  (php_statement [13, 15] - [13, 50]
    (bracket_start [13, 15] - [13, 17])
    (php_only [13, 18] - [13, 47])
    (bracket_end [13, 48] - [13, 50]))
  (text [13, 50] - [23, 20]
    (comment [16, 8] - [21, 12]
      (text [17, 8] - [21, 8])))
  (php_statement [23, 20] - [23, 44]
    (bracket_start [23, 20] - [23, 22])
    (php_only [23, 23] - [23, 41])
    (bracket_end [23, 42] - [23, 44]))
  (text [23, 44] - [24, 21])
  (php_statement [24, 21] - [24, 43]
    (bracket_start [24, 21] - [24, 23])
    (php_only [24, 24] - [24, 40])
    (bracket_end [24, 41] - [24, 43]))
  (text [24, 43] - [28, 13])
  (php_statement [28, 13] - [28, 24]
    (bracket_start [28, 13] - [28, 15])
    (php_only [28, 16] - [28, 22])
    (bracket_end [28, 22] - [28, 24]))
  (php_statement [28, 25] - [28, 41]
    (bracket_start [28, 25] - [28, 27])
    (php_only [28, 27] - [28, 39])
    (bracket_end [28, 39] - [28, 41]))
  (text [28, 41] - [31, 0]))
; File TWO

(blade [0, 0] - [142, 0]
  (text [0, 0] - [16, 24])
  (php_statement [16, 24] - [16, 45]
    (bracket_start [16, 24] - [16, 26])
    (php_only [16, 27] - [16, 42])
    (bracket_end [16, 43] - [16, 45]))
  (text [17, 20] - [28, 33])
  (php_statement [28, 33] - [28, 57]
    (bracket_start [28, 33] - [28, 35])
    (php_only [28, 36] - [28, 55])
    (bracket_end [28, 55] - [28, 57]))
  (text [28, 57] - [50, 36])
  (php_statement [50, 36] - [50, 57]
    (bracket_start [50, 36] - [50, 38])
    (php_only [50, 39] - [50, 54])
    (bracket_end [50, 55] - [50, 57]))
  (text [50, 57] - [52, 28])
  (keyword [52, 28] - [52, 33]
    (directive [52, 28] - [52, 33]))
  (text [54, 28] - [59, 32])
  (php_statement [59, 32] - [59, 51]
    (bracket_start [59, 32] - [59, 34])
    (php_only [59, 35] - [59, 48])
    (bracket_end [59, 49] - [59, 51]))
  (text [60, 28] - [110, 16])
  (php_statement [110, 16] - [110, 37]
    (bracket_start [110, 16] - [110, 18])
    (php_only [110, 19] - [110, 34])
    (bracket_end [110, 35] - [110, 37]))
  (text [111, 12] - [118, 20])
  (php_statement [118, 20] - [118, 44]
    (bracket_start [118, 20] - [118, 22])
    (php_only [118, 23] - [118, 42])
    (bracket_end [118, 42] - [118, 44]))
  (text [119, 16] - [121, 20])
  (php_statement [121, 20] - [121, 45]
    (bracket_start [121, 20] - [121, 22])
    (php_only [121, 23] - [121, 43])
    (bracket_end [121, 43] - [121, 45]))
  (text [122, 16] - [127, 44])
  (php_statement [127, 44] - [127, 65]
    (bracket_start [127, 44] - [127, 46])
    (php_only [127, 47] - [127, 62])
    (bracket_end [127, 63] - [127, 65]))
  (text [127, 65] - [128, 20])
  (keyword [128, 20] - [128, 25]
    (directive [128, 20] - [128, 25]))
  (text [130, 20] - [135, 24])
  (php_statement [135, 24] - [135, 43]
    (bracket_start [135, 24] - [135, 26])
    (php_only [135, 27] - [135, 40])
    (bracket_end [135, 41] - [135, 43]))
  (text [136, 20] - [142, 0]))

Here is how they look in Nova, for the second file I had a close look and I could not find any issues, but the first file there is a tiny bug 🐞

Screenshot 2023-12-04 at 17 48 29

Can you do me a favour and delete this line in the first file and see if it works?

    {{-- <link rel="stylesheet" href="https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700&display=swap"> --}}

Hey @ZayRTun ! Thank you for the kind words

Mmm can you comment out the ‘php_only’ stuff in injections.scm and try again? it might be because NVim is trying to find a parser that does not exist? We are still waiting for that to merge with tree-sitter-php

;((php_only) @injection.content
;    (#set! injection.combined)
;    (#set! injection.language php_only))
;((parameter) @injection.content
;    (#set! injection.language php_only))

You know the file without any errors, is that also with the v0.9.0?

If that fixed the issue please do let me know and I will amend the stubs, to avoid confusion until #5 dependancy is fixed! 😊