]> git.eshelyaron.com Git - emacs.git/commit
Add baseline tree-sitter indent rule for C-like languages
authorYuan Fu <casouri@gmail.com>
Sat, 30 Nov 2024 04:43:09 +0000 (20:43 -0800)
committerEshel Yaron <me@eshelyaron.com>
Wed, 4 Dec 2024 17:03:02 +0000 (18:03 +0100)
commit8997ebf8b443510cf755e0152845d603716971df
treeffe8db5a4f068e2457d21532502fa28b6c818bce
parent9a7136e82539019760112b17f10463e93ff17d3d
Add baseline tree-sitter indent rule for C-like languages

I found a really good baseline indent rule that handles a wide
range of situations very well.  Now major modes can just start
with this rule and add exceptions on top.

This is worth mentioning in the manual, but that'll be a large
change, and doesn't have to be included in this commit.

* lisp/progmodes/c-ts-common.el:

(c-ts-common-list-indent-style): New variable.
(c-ts-common--standalone-parent):
(c-ts-common--prev-standalone-sibling):
(c-ts-common-parent-ignore-preproc):
(c-ts-common-baseline-indent-rule): New function.

* lisp/treesit.el (treesit--indent-prev-line-node): New function.
(treesit-simple-indent-presets): Add new preset.

(cherry picked from commit e37cd4fa597beaec3b491edb1b15ea0c19e72be4)
lisp/progmodes/c-ts-common.el
lisp/treesit.el