[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Tree-sitter indentation for js-mode & cc-mode
From: |
Yuan Fu |
Subject: |
Tree-sitter indentation for js-mode & cc-mode |
Date: |
Wed, 26 Oct 2022 18:43:00 -0700 |
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
- Tree-sitter indentation for js-mode & cc-mode,
Yuan Fu <=
- Re: Tree-sitter indentation for js-mode & cc-mode, Theodor Thornhill, 2022/10/27
- Re: Tree-sitter indentation for js-mode & cc-mode, Theodor Thornhill, 2022/10/27
- Re: Tree-sitter indentation for js-mode & cc-mode, Yuan Fu, 2022/10/27
- Re: Tree-sitter indentation for js-mode & cc-mode, Theodor Thornhill, 2022/10/27
- Re: Tree-sitter indentation for js-mode & cc-mode, Yuan Fu, 2022/10/28
- Re: Tree-sitter indentation for js-mode & cc-mode, Theodor Thornhill, 2022/10/28
- Re: Tree-sitter indentation for js-mode & cc-mode, Theodor Thornhill, 2022/10/28
- Re: Tree-sitter indentation for js-mode & cc-mode, Yuan Fu, 2022/10/28
- Re: Tree-sitter indentation for js-mode & cc-mode, Theodor Thornhill, 2022/10/28