GNU bug report logs -
#68054
[PATCH] Add tree-sitter indent rule for lexical decls in js/typescript
Previous Next
Reported by: Noah Peart <noah.v.peart <at> gmail.com>
Date: Wed, 27 Dec 2023 06:22:01 UTC
Severity: wishlist
Tags: patch
Done: Stefan Kangas <stefankangas <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #52 received at 68054 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
> js-ts-mode now has the exact same indentation
I'm not sure what you meant by this - did you mean js-ts-mode has
the same indentation for non-multivar declarations as the examples
shown above? js-ts-mode is still missing indentation rules for multiple
decl statements.
The patch would work for js-ts-mode as well, but I didn't want to copy the
code between the files.
So much of the grammar is shared between js-ts-mode and
typescript-ts-mode, it might be worth combining - neovim uses an ecma
grammar
from which they both inherit.
On Thu, May 2, 2024 at 6:26 AM Noah Peart <noah.v.peart <at> gmail.com> wrote:
> Ok, here is an updated patch for option 3. The indentation looks like the
> examples
> you've provided - it's the same indentation as in js-mode for these cases.
>
>
> On Thu, Apr 25, 2024 at 6:06 PM Dmitry Gutov <dmitry <at> gutov.dev> wrote:
>
>> On 26/04/2024 01:48, Noah Peart wrote:
>> > Ok, I can make a patch for option 3 (the same as js-mode) instead. It's
>> > implementation is the simplest also. Would that work?
>>
>> I'd be okay with it, yes, thank you. If only because it's good to have
>> similar defaults in both modes, and evolve them together until one is
>> deprecated.
>>
>> FTR, the option more in line with my previous explanation would be
>> option 3, I think. Rhere's no real need to implement it right now, I
>> guess, but for illustration:
>>
>> const a =
>> (x: string): string => {
>> return x + x;
>> },
>> bbb =
>> {
>> "x": 0
>> },
>> cccc =
>> 1,
>> ddddd = 0;
>>
>> const bbb =
>> {
>> "x": 0
>> }, a = (x: string): string => {
>> return x + x;
>> },
>> bbb = {
>> "x": 0
>> },
>> cccc = 1,
>> ddddd = 0;
>>
>> js-mode also has by necessity the below exceptions: when the first
>> variable's value starts on the same line, and it's multiline (usually
>> that means that the same line ends with a {), then its indentation level
>> goes back to the statement, not to the "const" keyword:
>>
>> const a = (x: string): string => {
>> return x + x;
>> }
>>
>> var bbb = {
>> "x": 0
>> }
>>
>> This is basically to support the non-multivar declarations better.
>> js-ts-mode now has the exact same indentation; these cases might come up
>> when you change how the first two cases indent, however.
>>
>
[Message part 2 (text/html, inline)]
This bug report was last modified 191 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.