GNU bug report logs - #66159
30.0.50; lua-ts-mode semantic indentation problems

Previous Next

Package: emacs;

Reported by: Andrey Listopadov <andreyorst <at> gmail.com>

Date: Fri, 22 Sep 2023 19:41:02 UTC

Severity: normal

Tags: patch

Found in version 30.0.50

Fixed in version 30.1

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Andrey Listopadov <andreyorst <at> gmail.com>
To: john muhl <jm <at> pub.pink>
Cc: 66159 <at> debbugs.gnu.org, Philip Kaludercic <philipk <at> posteo.net>, Eli Zaretskii <eliz <at> gnu.org>
Subject: bug#66159: 30.0.50; lua-ts-mode semantic indentation problems
Date: Tue, 26 Sep 2023 22:21:35 +0300
john muhl <jm <at> pub.pink> writes:

> Eli Zaretskii <eliz <at> gnu.org> writes:
>
>>> > Another thing that bothers me is that I prefer Gassanenko-style packing
>>> > of `end' keywords so that they vertically align with the scope of the
>>> > opened block, as it saves so much vertical space and is easier for me to
>>> > read, but lua-ts-mode moves it to the latest innermost indentation
>>> > level, as opposed to the outermost depending on the count of ends in the
>>> > line itself:
>>>
>>> I don't see any reason not to support that style but I'm not sure how to
>>> do it. A patch would be welcome but I'll try to figure it out sometime.
>>
>> Maybe introduce indentation styles into lua-ts-mode, like CC Mode and
>> c-ts-mode have?
>
> I’ll have a look at what the c-ts-mode styles do and see what might be
> applicable. In this case the changes can be accommodated by default.

In my opinion, this isn't distinct enough to introduce a new style.
But it's up to you to decide, of course - I'm all for better editing
experience for Lua!

>> A far as I understand it, in the `lua-mode' the overall line indentation
>> is computed via subtracting indentation for every `end' in that line,
>> e.g. `end end end' subtracts `lua-indent-level three times from current
>> indent level.
>
> Thanks for the explanation. The attached patch should make end packing
> work now.

I've tried your latest patch and indeed `end' now pack themselves as in
the lua-mode.  Thank you very much!

>>> Sure. It's a new mode so nothing is really set in stone. Let me know if
>>> you have other suggestions.

I noticed that the `do' keyword is indented similarly to `then' before
the patch when put on the new line:

for i=1,10
    do
    print(i)
end

I'm not sure if that's a proper way to indent it or not though, but `do'
usually signifies start of the scope, so perhaps it shouldn't be
indented in this case.

There are also some weirdness in semantic navigation, but it's more
likely that I'm just not used to new ts-backed navigation yet.

Thanks for your work on lua-ts-mode, it's much more snappy editing
experience now!

If you're willing to dig into some (pretty crazy) involved examples, I
can send here some really convoluted nested anonymous functions that
currently are indented in a weird way in both modes. Neither does it
exactly right in my opiion, but I also don't know if there is the right
way to indent this.  I can send these examples later this week once I
finish an article I'm working on rightnow.

--
Andrey Listopadov




This bug report was last modified 1 year and 267 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.