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

Syntax highlighting does not use git.commentchar for highlighting comments

Open alewis001 opened this issue 1 year ago • 3 comments

Currently, syntax highlighting assumes # is the comment character used in Git Commit messages. The comment character used in Git Commit messages can be configured using core.commentChar in .gitconfig. That functionality is commonly used to change the comment character to something else such that an issue tracker number can be used at the beginning of the commit message such as: #123: Some changes.

If possible, the syntax highlighting would read the configuration to determine the comment character instead of assuming # and highlight comments based on the configured character.

alewis001 avatar Jul 11 '23 10:07 alewis001

Hey, that's really interesting ! I don't know if it's possible to do that with tree-sitter but I will do some research.

I don't have much time right now but I'll work on it :sweat_smile:

gbprod avatar Jul 27 '23 08:07 gbprod

That's all I can and would ask for 😄 and thank you for any time you can spend looking at this.

I'll try to do some digging myself. Neovim, treesitter, etc. are somewhat new to me so don't hold your breath though 😄

alewis001 avatar Jul 27 '23 09:07 alewis001

I'm probably only telling you what you already know but, just in case this helps at all... https://tree-sitter.github.io/tree-sitter/creating-parsers#external-scanners

It says...

Many languages have some tokens whose structure is impossible or inconvenient to describe with a regular expression

...and...

..in order to add custom logic for recognizing certain tokens.

So, I'm hoping those statements mean that this could be used to in some way read the commentchar config and then detect the comment token without affecting the rest of the parser too heavily.

alewis001 avatar Jul 27 '23 09:07 alewis001