1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Improve indentation in 'lua-ts-mode' (bug#70785)

* lisp/progmodes/lua-ts-mode.el (lua-ts--simple-indent-rules):
- Ignore comments when aligning arguments, parameters and fields.
- Apply simpler rules to simpler usage of anonymous functions.
- Better handling of table as a function argument.
(lua-ts--comment-first-sibling-matcher):
(lua-ts--first-real-sibling-anchor):
(lua-ts--last-arg-function-call-matcher):
(lua-ts--top-level-function-call-matcher): New function.
(lua-ts--g-parent):
(lua-ts--g-g-parent): New function.
(lua-ts--g-g-g-parent): Use it.
* test/lisp/progmodes/lua-ts-mode-resources/indent.erts:
Add tests.
This commit is contained in:
john muhl 2024-05-03 15:51:01 -05:00 committed by Yuan Fu
parent 4eb363acc8
commit 73d2b829f0
No known key found for this signature in database
GPG key ID: 56E19BC57664A442
2 changed files with 97 additions and 6 deletions

View file

@ -66,6 +66,10 @@ end
return f
end
f6(function()
print'ok'
end)
;(function ()
return true
end)()
@ -118,6 +122,10 @@ function f6(...)
return f
end
f6(function()
print'ok'
end)
;(function ()
return true
end)()
@ -406,6 +414,15 @@ a = 1,
b = 2,
},
nil)
Test(nil, {
a = 1,
b = 2,
})
fn( -- comment
1,
2)
=-=
h(
"string",
@ -443,6 +460,15 @@ Test({
b = 2,
},
nil)
Test(nil, {
a = 1,
b = 2,
})
fn( -- comment
1,
2)
=-=-=
Name: Parameter Indent
@ -464,6 +490,9 @@ local f3 = function( a, b,
c, d )
print(a,b,c,d)
end
local f4 = function(-- comment
a, b, c)
=-=
function f1(
a,
@ -481,6 +510,9 @@ local f3 = function( a, b,
c, d )
print(a,b,c,d)
end
local f4 = function(-- comment
a, b, c)
=-=-=
Name: Table Indent
@ -506,6 +538,10 @@ a = 1,
b = 2,
c = 3,
}
local a = { -- hello world!
b = 10
}
=-=
local Other = {
First={up={Step=true,Jump=true},
@ -527,6 +563,10 @@ local Other = {
b = 2,
c = 3,
}
local a = { -- hello world!
b = 10
}
=-=-=
Name: Continuation Indent