diff options
| author | john muhl | 2024-05-03 15:51:01 -0500 |
|---|---|---|
| committer | Yuan Fu | 2024-05-08 20:36:37 -0700 |
| commit | 73d2b829f06124fec8b65eebc68e87da48808086 (patch) | |
| tree | ff90d3d6472c1b4f8627e688ae20d87540ed5021 /test | |
| parent | 4eb363acc825ef3aaa5468ab5e206ecab5883acb (diff) | |
| download | emacs-73d2b829f06124fec8b65eebc68e87da48808086.tar.gz emacs-73d2b829f06124fec8b65eebc68e87da48808086.zip | |
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.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/progmodes/lua-ts-mode-resources/indent.erts | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/lisp/progmodes/lua-ts-mode-resources/indent.erts b/test/lisp/progmodes/lua-ts-mode-resources/indent.erts index 48184160b4d..ba7bad1b452 100644 --- a/test/lisp/progmodes/lua-ts-mode-resources/indent.erts +++ b/test/lisp/progmodes/lua-ts-mode-resources/indent.erts | |||
| @@ -66,6 +66,10 @@ end | |||
| 66 | return f | 66 | return f |
| 67 | end | 67 | end |
| 68 | 68 | ||
| 69 | f6(function() | ||
| 70 | print'ok' | ||
| 71 | end) | ||
| 72 | |||
| 69 | ;(function () | 73 | ;(function () |
| 70 | return true | 74 | return true |
| 71 | end)() | 75 | end)() |
| @@ -118,6 +122,10 @@ function f6(...) | |||
| 118 | return f | 122 | return f |
| 119 | end | 123 | end |
| 120 | 124 | ||
| 125 | f6(function() | ||
| 126 | print'ok' | ||
| 127 | end) | ||
| 128 | |||
| 121 | ;(function () | 129 | ;(function () |
| 122 | return true | 130 | return true |
| 123 | end)() | 131 | end)() |
| @@ -406,6 +414,15 @@ a = 1, | |||
| 406 | b = 2, | 414 | b = 2, |
| 407 | }, | 415 | }, |
| 408 | nil) | 416 | nil) |
| 417 | |||
| 418 | Test(nil, { | ||
| 419 | a = 1, | ||
| 420 | b = 2, | ||
| 421 | }) | ||
| 422 | |||
| 423 | fn( -- comment | ||
| 424 | 1, | ||
| 425 | 2) | ||
| 409 | =-= | 426 | =-= |
| 410 | h( | 427 | h( |
| 411 | "string", | 428 | "string", |
| @@ -443,6 +460,15 @@ Test({ | |||
| 443 | b = 2, | 460 | b = 2, |
| 444 | }, | 461 | }, |
| 445 | nil) | 462 | nil) |
| 463 | |||
| 464 | Test(nil, { | ||
| 465 | a = 1, | ||
| 466 | b = 2, | ||
| 467 | }) | ||
| 468 | |||
| 469 | fn( -- comment | ||
| 470 | 1, | ||
| 471 | 2) | ||
| 446 | =-=-= | 472 | =-=-= |
| 447 | 473 | ||
| 448 | Name: Parameter Indent | 474 | Name: Parameter Indent |
| @@ -464,6 +490,9 @@ local f3 = function( a, b, | |||
| 464 | c, d ) | 490 | c, d ) |
| 465 | print(a,b,c,d) | 491 | print(a,b,c,d) |
| 466 | end | 492 | end |
| 493 | |||
| 494 | local f4 = function(-- comment | ||
| 495 | a, b, c) | ||
| 467 | =-= | 496 | =-= |
| 468 | function f1( | 497 | function f1( |
| 469 | a, | 498 | a, |
| @@ -481,6 +510,9 @@ local f3 = function( a, b, | |||
| 481 | c, d ) | 510 | c, d ) |
| 482 | print(a,b,c,d) | 511 | print(a,b,c,d) |
| 483 | end | 512 | end |
| 513 | |||
| 514 | local f4 = function(-- comment | ||
| 515 | a, b, c) | ||
| 484 | =-=-= | 516 | =-=-= |
| 485 | 517 | ||
| 486 | Name: Table Indent | 518 | Name: Table Indent |
| @@ -506,6 +538,10 @@ a = 1, | |||
| 506 | b = 2, | 538 | b = 2, |
| 507 | c = 3, | 539 | c = 3, |
| 508 | } | 540 | } |
| 541 | |||
| 542 | local a = { -- hello world! | ||
| 543 | b = 10 | ||
| 544 | } | ||
| 509 | =-= | 545 | =-= |
| 510 | local Other = { | 546 | local Other = { |
| 511 | First={up={Step=true,Jump=true}, | 547 | First={up={Step=true,Jump=true}, |
| @@ -527,6 +563,10 @@ local Other = { | |||
| 527 | b = 2, | 563 | b = 2, |
| 528 | c = 3, | 564 | c = 3, |
| 529 | } | 565 | } |
| 566 | |||
| 567 | local a = { -- hello world! | ||
| 568 | b = 10 | ||
| 569 | } | ||
| 530 | =-=-= | 570 | =-=-= |
| 531 | 571 | ||
| 532 | Name: Continuation Indent | 572 | Name: Continuation Indent |