From 6f9a770e8e8b3fe3ad6b582a77cd7697b33f082a Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Sun, 29 Oct 2023 19:30:59 -0700 Subject: [PATCH] Add support for the ruff formatter --- apheleia-formatters.el | 5 +++-- test/formatters/installers/ruff.bash | 1 + test/formatters/samplecode/ruff/in.py | 4 ++++ test/formatters/samplecode/ruff/out.py | 3 +++ 4 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 test/formatters/installers/ruff.bash create mode 100644 test/formatters/samplecode/ruff/in.py create mode 100644 test/formatters/samplecode/ruff/out.py diff --git a/apheleia-formatters.el b/apheleia-formatters.el index 84aa5167..3f52b523 100644 --- a/apheleia-formatters.el +++ b/apheleia-formatters.el @@ -121,6 +121,7 @@ "--stderr" "--format" "quiet" "--fail-level" "fatal")) (ruby-standard . ("standardrb" "--stdin" filepath "--fix" "--stderr" "--format" "quiet" "--fail-level" "fatal")) + (ruff . ("ruff" "format" filepath)) (shfmt . ("shfmt" "-filename" filepath "-ln" (cl-case (bound-and-true-p sh-shell) @@ -345,8 +346,8 @@ and then write the formatted output back to the remote machine. Note some features of `apheleia' (such as `file' in `apheleia-formatters') is not compatible with this option and formatters relying on them will crash." :type '(choice (const :tag "Run the formatter on the local machine" local) - (const :tag "Run the formatter on the remote machine" remote) - (const :tag "Disable formatting for remote buffers" cancel)) + (const :tag "Run the formatter on the remote machine" remote) + (const :tag "Disable formatting for remote buffers" cancel)) :group 'apheleia) (defvar-local apheleia--current-process nil diff --git a/test/formatters/installers/ruff.bash b/test/formatters/installers/ruff.bash new file mode 100644 index 00000000..12000be9 --- /dev/null +++ b/test/formatters/installers/ruff.bash @@ -0,0 +1 @@ +apt-get install -y ruff diff --git a/test/formatters/samplecode/ruff/in.py b/test/formatters/samplecode/ruff/in.py new file mode 100644 index 00000000..21cdcdb0 --- /dev/null +++ b/test/formatters/samplecode/ruff/in.py @@ -0,0 +1,4 @@ +def asdjf ( l, + a): + 3 + +4 diff --git a/test/formatters/samplecode/ruff/out.py b/test/formatters/samplecode/ruff/out.py new file mode 100644 index 00000000..0a63d131 --- /dev/null +++ b/test/formatters/samplecode/ruff/out.py @@ -0,0 +1,3 @@ +def asdjf(l, a): + 3 + +4