aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKisaragi Hiu <mail@kisaragi-hiu.com>2022-06-21 06:21:27 +0900
committerGitHub <noreply@github.com>2022-06-20 14:21:27 -0700
commit2fa9dd97eddf54fe4fe01449612722399aa05d1c (patch)
tree38f5e76a82b9738da63db498cdc6a759196257ad
parent67853e98b190cc735a8ad31bd1de64f76f2990c4 (diff)
Add stylua (#105)
-rw-r--r--CHANGELOG.md5
-rw-r--r--apheleia.el2
-rw-r--r--test/formatters/installers/stylua.bash6
-rw-r--r--test/formatters/samplecode/stylua/in.lua20
-rw-r--r--test/formatters/samplecode/stylua/out.lua22
5 files changed, 55 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03b9088..245fbd1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,11 @@ The format is based on [Keep a Changelog].
### Enhancements
* shfmt uses 4 spaces instead of tabs by default.
+### Formatters
+* [stylua](https://github.com/JohnnyMorganz/StyLua) for Lua ([#105]).
+
+[#105]: https://github.com/raxod502/apheleia/pull/105
+
## 3.0 (released 2022-06-01)
### Breaking changes
* The arguments of formatters defined as Elisp functions has changed.
diff --git a/apheleia.el b/apheleia.el
index f7b8154..ec8e33c 100644
--- a/apheleia.el
+++ b/apheleia.el
@@ -936,6 +936,7 @@ being run, for diagnostic purposes."
(phpcs . ("apheleia-phpcs"))
(prettier . (npx "prettier" "--stdin-filepath" filepath))
(shfmt . ("shfmt" "-i" "4"))
+ (stylua . ("stylua" "-"))
(rustfmt . ("rustfmt" "--quiet" "--emit" "stdout"))
(terraform . ("terraform" "fmt" "-")))
"Alist of code formatting commands.
@@ -1064,6 +1065,7 @@ function: %s" command)))
(kotlin-mode . ktlint)
(latex-mode . latexindent)
(LaTeX-mode . latexindent)
+ (lua-mode . stylua)
(nix-mode . nixfmt)
(python-mode . black)
(ruby-mode . prettier)
diff --git a/test/formatters/installers/stylua.bash b/test/formatters/installers/stylua.bash
new file mode 100644
index 0000000..40bc0d3
--- /dev/null
+++ b/test/formatters/installers/stylua.bash
@@ -0,0 +1,6 @@
+ver="$(latest_release JohnnyMorganz/StyLua | sed 's/^v//')"
+
+wget "https://github.com/JohnnyMorganz/StyLua/releases/download/v${ver}/stylua-linux.zip" -O stylua.zip
+unzip stylua.zip
+chmod +x stylua
+cp stylua /usr/local/bin/
diff --git a/test/formatters/samplecode/stylua/in.lua b/test/formatters/samplecode/stylua/in.lua
new file mode 100644
index 0000000..ba0cf49
--- /dev/null
+++ b/test/formatters/samplecode/stylua/in.lua
@@ -0,0 +1,20 @@
+ too_many_spaces = true
+
+-- stylua: ignore
+local function foo ()
+ return 1,
+ 2,
+ 3
+end
+
+local many, vars = function() return true end
+
+local function what_indent ()
+noindent = true
+ if noindent then
+ x = false
+ end
+ return x
+end
+
+local y = 'Double quotes are used'
diff --git a/test/formatters/samplecode/stylua/out.lua b/test/formatters/samplecode/stylua/out.lua
new file mode 100644
index 0000000..c1ea1d9
--- /dev/null
+++ b/test/formatters/samplecode/stylua/out.lua
@@ -0,0 +1,22 @@
+too_many_spaces = true
+
+-- stylua: ignore
+local function foo ()
+ return 1,
+ 2,
+ 3
+end
+
+local many, vars = function()
+ return true
+end
+
+local function what_indent()
+ noindent = true
+ if noindent then
+ x = false
+ end
+ return x
+end
+
+local y = "Double quotes are used"