From 2fa9dd97eddf54fe4fe01449612722399aa05d1c Mon Sep 17 00:00:00 2001 From: Kisaragi Hiu Date: Tue, 21 Jun 2022 06:21:27 +0900 Subject: [PATCH] Add stylua (#105) --- CHANGELOG.md | 5 +++++ apheleia.el | 2 ++ test/formatters/installers/stylua.bash | 6 ++++++ test/formatters/samplecode/stylua/in.lua | 20 ++++++++++++++++++++ test/formatters/samplecode/stylua/out.lua | 22 ++++++++++++++++++++++ 5 files changed, 55 insertions(+) create mode 100644 test/formatters/installers/stylua.bash create mode 100644 test/formatters/samplecode/stylua/in.lua create mode 100644 test/formatters/samplecode/stylua/out.lua 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"