tree-sitter-vim icon indicating copy to clipboard operation
tree-sitter-vim copied to clipboard

bug: Some highlighting problems

Open brianhuster opened this issue 3 months ago • 0 comments

Did you check existing issues?

  • [x] I have read all the tree-sitter docs if it relates to using the parser
  • [x] I have searched the existing issues

Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)

NA

Describe the bug

This is screenshot with Treesitter enabled

Image

This is screenshot with Treesitter disabled (using legacy syntax in Neovim)

Image

So there are 2 problems as seen in the first image (compared to the second one):

  • Treesitter parses mksession! as repl (command), while I think it should be parsed as (unknown_command_name) (bang), because it comes right after the command_name RestartStatement
  • Treesitter doesn't even recognizes interpolation syntax (in line 3 in the screenshot)

Steps To Reproduce/Bad Parse Tree

  1. nvim --clean test.vim
  2. Paste the following code to test.vim
command -nargs=0 RestartSession
	\ mksession!
	\|exe $"restart source {'Session.vim'->fnamemodify(':p')->fnameescape()} | call delete(v:this_session)"
  1. See the highlighting with legacy syntax. Run :lua vim.treesitter.start() to see Treesitter highlighting

This is the parsing tree of the above code

  (command_statement ; [0, 0] - [1, 13]
    (command_attribute ; [0, 8] - [0, 16]
      val: (integer_literal)) ; [0, 15] - [0, 16]
    name: (command_name) ; [0, 17] - [0, 31]
    repl: (command)) ; [1, 2] - [1, 13]
  (execute_statement ; [2, 3] - [2, 102]
    (ERROR ; [2, 7] - [2, 88]
      (keyword) ; [2, 9] - [2, 16]
      (keyword) ; [2, 17] - [2, 23]
      (keyword) ; [2, 26] - [2, 33]
      (keyword) ; [2, 40] - [2, 51]
      (keyword) ; [2, 59] - [2, 70]
      (keyword) ; [2, 76] - [2, 80]
      (keyword)) ; [2, 81] - [2, 87]
    (scoped_identifier ; [2, 88] - [2, 102]
      (scope) ; [2, 88] - [2, 90]
      (identifier))) ; [2, 90] - [2, 102]
  (ERROR) ; [2, 102] - [2, 104]

Expected Behavior/Parse Tree

  1. Should highlight mksession as a command name
  2. Should support string interpolation

Repro

No response

brianhuster avatar Aug 28 '25 16:08 brianhuster