bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#66159: 30.0.50; lua-ts-mode semantic indentation problems


From: john muhl
Subject: bug#66159: 30.0.50; lua-ts-mode semantic indentation problems
Date: Sun, 24 Sep 2023 10:06:50 -0500

Andrey Listopadov <andreyorst@gmail.com> writes:

> I've been editing Lua using the long-existing lua-mode[1] and it works
> well enough for me, but it's indentation implementation is very slow.
> Indenting a file with just 600 lines takes several seconds on my
> machine.  So when I saw that Emacs now features a lua-ts-mode package
> in its core, I tried to move to it, in hopes that it would be faster.

Thanks for trying.

> However, a lot of code is now indented differently, not how I used to,
> and this creates a lot of noise in commits, as I often re-indent the
> whole buffer before saving the file. Here are some examples.

The "then" and table examples should indent how you like with the
attached patch. Arguments and parameters now also work like your table
example so you can have:

  local function fn(a, b, c,
                    another) end

  fn(1,
     2,
     3,
     {a="first",
      b="second"})

> 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:
>
> function lowest_entropy_cell(world)
> |   local lowest,res=math.huge,nil
> |   for y=1,world.height do
> |   |   for x=1,world.width do
> |   |   |   local cell=world:get(x,y)
> |   |   |   if cell.is_set then
> |   |   |   |   local e=cell_enthropy(cell)
> |   |   |   |   trace(e)
> |   |   |   |   if e <= lowest then
> |   |   |   |   |   lowest,res=e,{x,y}
> |   end end end end
> |   return res or {math.random(world.width),math.random(world.height)}
> end

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.

> Should I expect this to be the default new way of indenting or the
> indentation can be made to match the lua-mode where it is sensible?

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

Attachment: 0001-Improve-indentation-in-lus-ts-mode-Bug-66159.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]