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

Inconsistent Grammar

Open asmodeus812 opened this issue 3 years ago • 3 comments

Problem description

Hi. I have noticed some inconsistencies between the java grammar in treemacs' port for emacs and nvim for example here are two screens of the same code that are missing some things image image

As you can see annotations are coloured as are keywords, variable usage is not coloured at all, member function calls as well. Vscode and nvim are consistent and look the same while in emacs it seems that only partial highlight is done.

asmodeus812 avatar Jan 11 '22 07:01 asmodeus812

maybe the extensions are using different versions of tree-sitter-java?

raghav-deepsource avatar Apr 06 '22 08:04 raghav-deepsource

I dont think so, the emacs ts highlighting is no better than a plain regex from what i see.

asmodeus812 avatar Apr 07 '22 04:04 asmodeus812

I believe the difference you see stems from the fact that both emacs-tree-sitter (using tree-sitter-langs) and NeoVim maintain their own highlights.scm file. https://github.com/emacs-tree-sitter/tree-sitter-langs/blob/master/queries/java/highlights.scm you can see that the highlights.scm file used by emacs-tree-sitter hasn't been updated in over two years and even differs from the queries/highlights.scm from this repository. I also believe that the NeoVim tree-sitter maintainers further enhance their highlights.scm files, which could also contribute to the difference you observe.

Unfortunately, there is no escape in that, as the highlight tags used in this repo, in the Emacs highlighter and the NeoVim highlighter naturally differ (the names may differ, NeoVim could have more highlighting tags, etc). That way, it's hard to contribute to the original grammar repository any enhancements to the highlighting queries that any one of these editors make.

Of course, there are similarities between the highlighting tags, but the process is manual and the maintainers do this for free on their spare time. If you feel inclined, I'd suggest you take a look at the highlighting queries made by NeoVim and then replicate those to the Emacs implementation, following the stylistic patterns from the other highlighting queries in the implementation.

catarinacps avatar May 14 '22 23:05 catarinacps