Add cljfmt fixer for clojure files (#4860)

This commit is contained in:
rudolf ordoyne 2024-11-16 20:22:36 -06:00 committed by GitHub
parent 5cc6b933b1
commit defb0ea336
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 46 additions and 0 deletions

View File

@ -672,6 +672,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['ruby'], \ 'suggested_filetypes': ['ruby'],
\ 'description': 'A formatter for Ruby source code', \ '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. " Reset the function registry to the default entries.

View File

@ -0,0 +1,14 @@
" Author: rudolf ordoyne <rudolfordoyne@protonmail.com>
" 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

View File

@ -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. 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* joker *ale-clojure-joker*

View File

@ -112,6 +112,7 @@ Notes:
* `foodcritic`!! * `foodcritic`!!
* Clojure * Clojure
* `clj-kondo` * `clj-kondo`
* `cljfmt`
* `joker` * `joker`
* CloudFormation * CloudFormation
* `cfn-python-lint` * `cfn-python-lint`

View File

@ -2946,6 +2946,7 @@ documented in additional help files.
foodcritic............................|ale-chef-foodcritic| foodcritic............................|ale-chef-foodcritic|
clojure.................................|ale-clojure-options| clojure.................................|ale-clojure-options|
clj-kondo.............................|ale-clojure-clj-kondo| clj-kondo.............................|ale-clojure-clj-kondo|
cljfmt................................|ale-clojure-cljfmt|
joker.................................|ale-clojure-joker| joker.................................|ale-clojure-joker|
cloudformation..........................|ale-cloudformation-options| cloudformation..........................|ale-cloudformation-options|
cfn-python-lint.......................|ale-cloudformation-cfn-python-lint| cfn-python-lint.......................|ale-cloudformation-cfn-python-lint|

View File

@ -121,6 +121,7 @@ formatting.
* [foodcritic](http://www.foodcritic.io/) :floppy_disk: * [foodcritic](http://www.foodcritic.io/) :floppy_disk:
* Clojure * Clojure
* [clj-kondo](https://github.com/borkdude/clj-kondo) * [clj-kondo](https://github.com/borkdude/clj-kondo)
* [cljfmt](https://github.com/weavejester/cljfmt)
* [joker](https://github.com/candid82/joker) * [joker](https://github.com/candid82/joker)
* CloudFormation * CloudFormation
* [cfn-python-lint](https://github.com/awslabs/cfn-python-lint) * [cfn-python-lint](https://github.com/awslabs/cfn-python-lint)

View File

@ -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,
\}