c-ts-mode

Homepage: https://www.gnu.org/software/emacs

Author: Theodor Thornhill

Summary

Tree-sitter support for C and C++

Commentary

This package provides major modes for C and C++, plus some handy
functions that are useful generally to major modes for C-like
languages.

This package provides `c-ts-mode' for C, `c++-ts-mode' for C++, and
`c-or-c++-ts-mode' which automatically chooses the right mode for
C/C++ header files.

To use these modes by default, assuming you have the respective
tree-sitter grammars available, do one of the following:

- If you have both C and C++ grammars installed, add

   (require 'c-ts-mode)

  to your init file.

- Add one or mode of the following to your init file:

   (add-to-list 'major-mode-remap-alist '(c-mode . c-ts-mode))
   (add-to-list 'major-mode-remap-alist '(c++-mode . c++-ts-mode))
   (add-to-list 'major-mode-remap-alist '(c-or-c++-mode . c-or-c++-ts-mode))

  If you have only C grammar available, use only the first one; if
  you have only the C++ grammar, use only the second one.

- Customize 'auto-mode-alist' to turn one or more of the modes
  automatically.  For example:

    (add-to-list 'auto-mode-alist
                 '("\\(\\.ii\\|\\.\\(CC?\\|HH?\\)\\|\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\|\\.\\(cc\\|hh\\)\\)\\'"
                   . c++-ts-mode))

  will turn on the c++-ts-mode for C++ source files.

You can also turn on these modes manually in a buffer.  Doing so
will set up Emacs to use the C/C++ modes defined here for other
files, provided that you have the corresponding parser grammar
libraries installed.

Dependencies

Reverse dependencies