alemuller / tree-sitter-make

MIT License
44 stars 16 forks source link

Substitution reference is not highlighted #11

Closed kiryph closed 2 years ago

kiryph commented 2 years ago

Consider this part of a Makefile:

sources := $(objects:.o=.c)
sources := $(patsubst %.o,%.c,$(objects))

(from https://www.gnu.org/software/make/manual/html_node/Text-Functions.html)

and this screenshot of neovim with treesitter syntax highlighting: Screenshot 2022-09-03 at 08 43 38

:TSPlaygroundToggle reveals following syntax tree:

variable_assignment [0, 0] - [1, 0]
  name: word [0, 0] - [0, 7]
  value: text [0, 11] - [0, 27]
    substitution_reference [0, 11] - [0, 27]
      text: word [0, 13] - [0, 20]
      pattern: word [0, 21] - [0, 23]
      replacement: word [0, 24] - [0, 26]
variable_assignment [1, 0] - [2, 0]
  name: word [1, 0] - [1, 7]
  value: text [1, 11] - [1, 41]
    function_call [1, 11] - [1, 41]
      arguments [1, 22] - [1, 40]
        argument: text [1, 22] - [1, 40]
          variable_reference [1, 30] - [1, 40]
            word [1, 32] - [1, 39]

I would expect that the dollar sign with the parentheses are highlighted in the first line.

kiryph commented 2 years ago

Sorry, this was a mix up on my side. I had installed nvim-treesitter with its own highlights.scm which is responsible for not highlighting dollar and its parentheses of substitution references.

https://github.com/nvim-treesitter/nvim-treesitter/blob/73cd1f189bf19e99af9b1349cdca590a40b985b0/queries/make/highlights.scm

If one has installed nvim-treesitter with its own highlights.scm but want to use highlights.scm of this repository, you can install it in ~/.config/nvim/queries/make/highlights.scm which has higher priority as, e.g. the Packer.nvim path:

wget -P ~/.config/nvim/queries/make/ https://raw.githubusercontent.com/alemuller/tree-sitter-make/main/queries/highlights.scm