diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 0f9fdb5d..e2dd2618 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -672,6 +672,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['ruby'], \ 'description': 'A formatter for Ruby source code', \ }, +\ 'cljfmt': { +\ 'function': 'ale#fixers#cljfmt#Fix', +\ 'suggested_filetypes': ['clojure'], +\ 'description': 'formatter and linter for clojure files', +\ }, \} " Reset the function registry to the default entries. diff --git a/autoload/ale/fixers/cljfmt.vim b/autoload/ale/fixers/cljfmt.vim new file mode 100644 index 00000000..dbcf10d8 --- /dev/null +++ b/autoload/ale/fixers/cljfmt.vim @@ -0,0 +1,14 @@ +" Author: rudolf ordoyne +" Description: Support for cljfmt https://github.com/weavejester/cljfmt + +call ale#Set('clojure_cljfmt_executable', 'cljfmt') + +function! ale#fixers#cljfmt#Fix(buffer) abort + let l:executable = ale#Var(a:buffer, 'clojure_cljfmt_executable') + + return { + \ 'command': ale#Escape(l:executable) . ' fix %t', + \ 'read_temporary_file': 1, + \} +endfunction + diff --git a/doc/ale-clojure.txt b/doc/ale-clojure.txt index 3ff367f6..54872de7 100644 --- a/doc/ale-clojure.txt +++ b/doc/ale-clojure.txt @@ -16,6 +16,18 @@ g:ale_clojure_clj_kondo_options *g:ale_clojure_clj_kondo_options* This variable can be changed to modify options passed to clj-kondo. +=============================================================================== +cljfmt *ale-clojure-cljfmt* + +cljfmt is a linter and fixer for Clojure code, with defaults adhering to the +Clojure Style Guide (see https://guide.clojure.style/ ) + +https://github.com/weavejester/cljfmt + +Linting options are not configurable by ale, but instead are controlled by +Leiningen, or a cljfmt file in the current or parent directories. + +see https://github.com/weavejester/cljfmt#Configuration for more information. =============================================================================== joker *ale-clojure-joker* diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index fddf3d1f..6a11d4aa 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -112,6 +112,7 @@ Notes: * `foodcritic`!! * Clojure * `clj-kondo` + * `cljfmt` * `joker` * CloudFormation * `cfn-python-lint` diff --git a/doc/ale.txt b/doc/ale.txt index cbfd5e2f..1d62fd2d 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2946,6 +2946,7 @@ documented in additional help files. foodcritic............................|ale-chef-foodcritic| clojure.................................|ale-clojure-options| clj-kondo.............................|ale-clojure-clj-kondo| + cljfmt................................|ale-clojure-cljfmt| joker.................................|ale-clojure-joker| cloudformation..........................|ale-cloudformation-options| cfn-python-lint.......................|ale-cloudformation-cfn-python-lint| diff --git a/supported-tools.md b/supported-tools.md index a4842954..985f0f46 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -121,6 +121,7 @@ formatting. * [foodcritic](http://www.foodcritic.io/) :floppy_disk: * Clojure * [clj-kondo](https://github.com/borkdude/clj-kondo) + * [cljfmt](https://github.com/weavejester/cljfmt) * [joker](https://github.com/candid82/joker) * CloudFormation * [cfn-python-lint](https://github.com/awslabs/cfn-python-lint) diff --git a/test/fixers/test_cljfmt_fixer_callback.vader b/test/fixers/test_cljfmt_fixer_callback.vader new file mode 100644 index 00000000..984689fb --- /dev/null +++ b/test/fixers/test_cljfmt_fixer_callback.vader @@ -0,0 +1,12 @@ +Before: + call ale#assert#SetUpFixerTest('clojure', 'cljfmt') + +After: + call ale#assert#TearDownFixerTest() + +Execute(The cljfmt callback should return the correct default values): + AssertFixer { + \ 'command': ale#Escape('cljfmt') . ' fix %t', + \ 'read_temporary_file': 1, + \} +