all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Tree-sitter indentation for js-mode & cc-mode
@ 2022-10-27  1:43 Yuan Fu
  2022-10-27  9:11 ` Theodor Thornhill
  0 siblings, 1 reply; 14+ messages in thread
From: Yuan Fu @ 2022-10-27  1:43 UTC (permalink / raw)
  To: emacs-devel; +Cc: Theodor Thornhill

I did some work to allow tree-sitter indentation engine to plug in to c-offset-alist. Currently in a tree-sitter indent rule, we have

(MATCHER ANCHOR OFFSET)

OFFSET is normally an integer, but now it can also be a syntax symbol recognized by cc-mode’s indentation engine. In that case, tree-sitter indent calculates the indent using c-calc-offset, passing the syntax symbol and anchor position to it, and c-calc-offset will give us the integer offset based on c-offset-alist.

I’ve written indent rules for js-mode, they are in js-treesit-cc-indent-rules. Overall it works pretty well. Theo, could you give it a try? From my testing it is already an improvement from the original rules. I didn’t finish the JSX part and just copied your original rules for JSX. In the future I can probably port that to cc-style too.

I also added imenu support for js-mode and ts-mode, and navigation for python-mode.

Yuan


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-10-29  6:54 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-27  1:43 Tree-sitter indentation for js-mode & cc-mode Yuan Fu
2022-10-27  9:11 ` Theodor Thornhill
2022-10-27  9:28   ` Theodor Thornhill
2022-10-27  9:58     ` Theodor Thornhill
2022-10-27 15:21   ` Yuan Fu
2022-10-27 18:36     ` Theodor Thornhill
2022-10-28  8:15       ` Yuan Fu
2022-10-28  8:59         ` Theodor Thornhill
2022-10-28  9:10         ` Theodor Thornhill
2022-10-28 19:43           ` Yuan Fu
2022-10-28 19:49             ` Theodor Thornhill
2022-10-29  1:05               ` Yuan Fu
2022-10-29  5:53             ` Eli Zaretskii
2022-10-29  6:54               ` Yuan Fu

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.