gbprod / tree-sitter-gitcommit

A tree-sitter grammar for gitcommit messages
Do What The F*ck You Want To Public License
62 stars 8 forks source link

Second line below commit title not highlighted #66

Closed smlx closed 5 months ago

smlx commented 5 months ago

I would expect the second line to be highlighted with @error, but it is not. It does appear as an ERROR node in the tree, but there is no highlighting.

screenshot_2024-05-19-152551

Here's the non-treesitter default neovim highlighting to show what I would expect for the second line:

screenshot_2024-05-19-152612

It looks like the highlighting might have been removed in #58 when this line was deleted from highlights.scm:

(ERROR) @error
gbprod commented 5 months ago

In Neovim, applied queries are here : https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/gitcommit/highlights.scm

The ERROR node capture has been removed here: https://github.com/nvim-treesitter/nvim-treesitter/commit/107e61afb7129d637ea6c3c68b97a22194b0bf16 please refer to the PR comments to understand why it was removed : https://github.com/nvim-treesitter/nvim-treesitter/pull/5572

Anyway, if you want it back, you can create your own query (https://github.com/nvim-treesitter/nvim-treesitter?tab=readme-ov-file#adding-queries) by creating a queries/gitcommit/highlights.scm file in your neovin config with this content :

; extends

(ERROR) @error
smlx commented 5 months ago

Oh that works perfectly. Thanks for the background info and for helping me understand nvim-treesitter a bit better!