0

I'm using emacs-plus and I had treesitter priorly installed. Other modes like python-ts-mode work fine. However, c++-ts-mode is void and does not exist as a variable. In addition, when I call c++-mode interactively, it is not available (but it is set as the major-mode in *.cpp buffers).

Has anyone experienced this issue and knows of a fix?

12
  • Use C-h f to check the defintion. Paste something from the resulting buffer into your question. Commented Jun 29, 2024 at 22:25
  • The functions are void, as I mentioned @db48x. The definition does not exist. Commented Jun 30, 2024 at 0:27
  • I get c++-ts-mode is an autoloaded interactive Lisp function in ‘c-ts-mode.el’ for the first and c++-mode is an autoloaded interactive subr-native-elisp in ‘cc-mode.el’. for the second. So something is screwy with your setup. What version of Emacs are you running? Commented Jun 30, 2024 at 0:52
  • Yea I understand @NickD . There are other issues as well with my set-up that occur sporadically, but c++-ts-mode not existing and c++-mode not being available interactively are the two most prominent. It's on a M1 Pro Macbook. Commented Jun 30, 2024 at 0:55
  • These two should be available with recent Emacs (at least 29.3 and later). If you are running such a recent version, then you have to fix your setup. If you are running an older version, you might need to upgrade. So check your version with M-x emacs-version and add it to your question. Commented Jun 30, 2024 at 0:59

1 Answer 1

0

I suggest to use this package to solve major problems with treesit. If your grammars are correctly installed go further, if not, follow the indications on that page. If you have treesitter, it will be a good idea to remove it, since the package above make use of built-in treesit. What you need to add further is the below snippet, to reckognize the file types and start the c++-ts-mode hook:

(add-to-list 'auto-mode-alist '("\\(\\.ii\\|\\.\\(CC?\\|HH?\\)\\|\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\|\\.\\(cc\\|hh\\)\\)\\'" . c++-ts-mode)) ;; optional (add-hook 'c++-ts-mode-hook 'lsp-deferred) (add-hook 'c++-ts-mode-hook #'highlight-indent-guides-mode) 

Then open a .cpp file and verify the major mode with C-h m.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.