Support lua-ts-mode in align.el
* lisp/align.el (align-rules-list): Add lua-ts-mode. (Bug#66466) * lisp/progmodes/lua-ts-mode.el (lua-ts-mode): Indent region before aligning. * test/lisp/align-tests.el (align-lua): * test/lisp/align-resources/lua-ts-mode.erts: Add tests.
This commit is contained in:
parent
cb89cbc406
commit
a838bcb23c
4 changed files with 89 additions and 1 deletions
|
@ -577,7 +577,18 @@ The possible settings for `align-region-separate' are:
|
|||
"="
|
||||
(group (zero-or-more (syntax whitespace)))))
|
||||
(group . (1 2))
|
||||
(modes . '(conf-toml-mode toml-ts-mode))))
|
||||
(modes . '(conf-toml-mode toml-ts-mode lua-mode lua-ts-mode)))
|
||||
|
||||
(double-dash-comment
|
||||
(regexp . ,(rx (group (zero-or-more (syntax whitespace)))
|
||||
"--"
|
||||
(zero-or-more nonl)))
|
||||
(modes . '(lua-mode lua-ts-mode))
|
||||
(column . comment-column)
|
||||
(valid . ,(lambda ()
|
||||
(save-excursion
|
||||
(goto-char (match-beginning 1))
|
||||
(not (bolp)))))))
|
||||
"A list describing all of the available alignment rules.
|
||||
The format is:
|
||||
|
||||
|
|
|
@ -443,6 +443,9 @@ Calls REPORT-FN directly."
|
|||
"function"))
|
||||
symbol-end)))))
|
||||
|
||||
;; Align.
|
||||
(setq-local align-indent-before-aligning t)
|
||||
|
||||
(treesit-major-mode-setup))
|
||||
|
||||
(add-hook 'flymake-diagnostic-functions #'lua-ts-flymake-luacheck nil 'local))
|
||||
|
|
67
test/lisp/align-resources/lua-ts-mode.erts
Normal file
67
test/lisp/align-resources/lua-ts-mode.erts
Normal file
|
@ -0,0 +1,67 @@
|
|||
Name: align assignments
|
||||
|
||||
=-=
|
||||
local first=1
|
||||
local s <const> =2
|
||||
local last=3
|
||||
=-=
|
||||
local first = 1
|
||||
local s <const> = 2
|
||||
local last = 3
|
||||
=-=-=
|
||||
|
||||
Name: align fields
|
||||
|
||||
=-=
|
||||
local Table={
|
||||
first=1,
|
||||
second=2,
|
||||
last=3,
|
||||
}
|
||||
=-=
|
||||
local Table = {
|
||||
first = 1,
|
||||
second = 2,
|
||||
last = 3,
|
||||
}
|
||||
=-=-=
|
||||
|
||||
Name: align comments
|
||||
|
||||
=-=
|
||||
local first-- 1
|
||||
local second -- 2
|
||||
local last -- 3
|
||||
=-=
|
||||
local first -- 1
|
||||
local second -- 2
|
||||
local last -- 3
|
||||
=-=-=
|
||||
|
||||
Name: align assignments and comments
|
||||
|
||||
=-=
|
||||
local first=1-- one
|
||||
local second=2 -- two
|
||||
local last=3 -- three
|
||||
=-=
|
||||
local first = 1 -- one
|
||||
local second = 2 -- two
|
||||
local last = 3 -- three
|
||||
=-=-=
|
||||
|
||||
Name: align fields and comments
|
||||
|
||||
=-=
|
||||
local T={
|
||||
first=1,--one
|
||||
second=2, --two
|
||||
last=3, --three
|
||||
}
|
||||
=-=
|
||||
local T = {
|
||||
first = 1, --one
|
||||
second = 2, --two
|
||||
last = 3, --three
|
||||
}
|
||||
=-=-=
|
|
@ -49,6 +49,13 @@
|
|||
(ert-test-erts-file (ert-resource-file "latex-mode.erts")
|
||||
(test-align-transform-fun #'latex-mode)))
|
||||
|
||||
(ert-deftest align-lua ()
|
||||
(skip-unless (treesit-ready-p 'lua))
|
||||
(let ((comment-column 20)
|
||||
(indent-tabs-mode nil))
|
||||
(ert-test-erts-file (ert-resource-file "lua-ts-mode.erts")
|
||||
(test-align-transform-fun #'lua-ts-mode))))
|
||||
|
||||
(ert-deftest align-python ()
|
||||
(ert-test-erts-file (ert-resource-file "python-mode.erts")
|
||||
(test-align-transform-fun #'python-mode)))
|
||||
|
|
Loading…
Add table
Reference in a new issue