renzmann / treesit-auto

Automatic installation, usage, and fallback for tree-sitter major modes in Emacs 29
GNU General Public License v3.0
386 stars 29 forks source link

Fix grammar of C++ #106

Open abougouffa opened 4 months ago

abougouffa commented 4 months ago

It seems like the new treesitter-cpp grammar breaks syntax highlighting for C++.

I've done a bisecting of the revisions of the grammar and found that the last working version is v0.22.0. More info is available on this discussion.

You can check the issue on a vanilla Emacs using:

Buggy version (latest commit)

emacs -Q -l treesit-cpp-buggy.el

;; treesit-cpp-buggy.el
(setq treesit-language-source-alist
      '((cpp "https://github.com/tree-sitter/tree-sitter-cpp" nil nil nil nil)))
(treesit-install-language-grammar 'cpp)

Working version (v0.22.0)

emacs -Q -l treesit-cpp-fixed.el

;; treesit-cpp-fixed.el
(setq treesit-language-source-alist
      '((cpp "https://github.com/tree-sitter/tree-sitter-cpp" "v0.22.0" nil nil nil)))
(treesit-install-language-grammar 'cpp)