diff options
-rw-r--r-- | ale_linters/clojure/clj_kondo.vim | 34 | ||||
-rw-r--r-- | doc/ale-clojure.txt | 7 | ||||
-rw-r--r-- | doc/ale-supported-languages-and-tools.txt | 1 | ||||
-rw-r--r-- | doc/ale.txt | 1 | ||||
-rw-r--r-- | supported-tools.md | 1 | ||||
-rw-r--r-- | test/handler/test_clojure_clj_kondo_handler.vader | 75 |
6 files changed, 119 insertions, 0 deletions
diff --git a/ale_linters/clojure/clj_kondo.vim b/ale_linters/clojure/clj_kondo.vim new file mode 100644 index 00000000..5dd11c12 --- /dev/null +++ b/ale_linters/clojure/clj_kondo.vim @@ -0,0 +1,34 @@ +" Author: Masashi Iizuka <liquidz.uo@gmail.com> +" Description: linter for clojure using clj-kondo https://github.com/borkdude/clj-kondo + +function! ale_linters#clojure#clj_kondo#HandleCljKondoFormat(buffer, lines) abort + " output format + " <filename>:<line>:<column>: <issue type>: <message> + let l:pattern = '\v^[a-zA-Z]?:?[^:]+:(\d+):(\d+):? ((Exception|error|warning): ?(.+))$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + let l:type = 'E' + + if l:match[4] is? 'warning' + let l:type = 'W' + endif + + call add(l:output, { + \ 'lnum': l:match[1] + 0, + \ 'col': l:match[2] + 0, + \ 'text': l:match[3], + \ 'type': l:type, + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('clojure', { +\ 'name': 'clj-kondo', +\ 'output_stream': 'stdout', +\ 'executable': 'clj-kondo', +\ 'command': 'clj-kondo --lint %t', +\ 'callback': 'ale_linters#clojure#clj_kondo#HandleCljKondoFormat', +\}) diff --git a/doc/ale-clojure.txt b/doc/ale-clojure.txt index a83e336f..2bf00c03 100644 --- a/doc/ale-clojure.txt +++ b/doc/ale-clojure.txt @@ -3,6 +3,13 @@ ALE Clojure Integration *ale-clojure-options* =============================================================================== +clj-kondo *ale-clojure-clj-kondo* + +A minimal and opinionated linter for code that sparks joy. + +https://github.com/borkdude/clj-kondo + +=============================================================================== joker *ale-clojure-joker* Joker is a small Clojure interpreter and linter written in Go. diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 0051fd6a..eff2e607 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -74,6 +74,7 @@ Notes: * `cookstyle` * `foodcritic` * Clojure + * `clj-kondo` * `joker` * CloudFormation * `cfn-python-lint` diff --git a/doc/ale.txt b/doc/ale.txt index 7b1b32fd..6d78fd89 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -1867,6 +1867,7 @@ documented in additional help files. cookstyle.............................|ale-chef-cookstyle| foodcritic............................|ale-chef-foodcritic| clojure.................................|ale-clojure-options| + clj-kondo.............................|ale-clojure-clj-kondo| 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 1d448407..74cea65c 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -83,6 +83,7 @@ formatting. * [cookstyle](https://docs.chef.io/cookstyle.html) * [foodcritic](http://www.foodcritic.io/) * Clojure + * [clj-kondo](https://github.com/borkdude/clj-kondo) * [joker](https://github.com/candid82/joker) * CloudFormation * [cfn-python-lint](https://github.com/awslabs/cfn-python-lint) diff --git a/test/handler/test_clojure_clj_kondo_handler.vader b/test/handler/test_clojure_clj_kondo_handler.vader new file mode 100644 index 00000000..45db9049 --- /dev/null +++ b/test/handler/test_clojure_clj_kondo_handler.vader @@ -0,0 +1,75 @@ +Before: + runtime ale_linters/clojure/clj_kondo.vim + +After: + call ale#linter#Reset() + +Execute(the clojure clj-kondo handler should be able to handle errors): + AssertEqual + \ [ + \ { + \ 'lnum': 123, + \ 'col': 44, + \ 'type': 'E', + \ 'text': 'error: Unexpected )', + \ }, + \ ], + \ ale_linters#clojure#clj_kondo#HandleCljKondoFormat(0, [ + \ 'test.clj:123:44: error: Unexpected )', + \ ]) + +Execute(the clojure clj-kondo handler should be able to handle warnings): + AssertEqual + \ [ + \ { + \ 'lnum': 654, + \ 'col': 321, + \ 'type': 'W', + \ 'text': 'warning: inline def', + \ } + \ ], + \ ale_linters#clojure#clj_kondo#HandleCljKondoFormat(0, [ + \ 'test.clj:654:321: warning: inline def' + \ ]) + +Execute(the clojure clj-kondo handler should be able to handle exceptions): + AssertEqual + \ [ + \ { + \ 'lnum': 123, + \ 'col': 321, + \ 'type': 'E', + \ 'text': 'Exception: something horrible happen', + \ } + \ ], + \ ale_linters#clojure#clj_kondo#HandleCljKondoFormat(0, [ + \ 'test.clj:123:321: Exception: something horrible happen' + \ ]) + +Execute(the clojure clj-kondo handler should be able to handle errors from stdin): + AssertEqual + \ [ + \ { + \ 'lnum': 16, + \ 'col': 1, + \ 'type': 'E', + \ 'text': 'error: Unexpected )', + \ }, + \ ], + \ ale_linters#clojure#clj_kondo#HandleCljKondoFormat(0, [ + \ '<stdin>:16:1: error: Unexpected )', + \ ]) + +Execute(the clojure clj-kondo handler should be able to handle windows files): + AssertEqual + \ [ + \ { + \ 'lnum': 123, + \ 'col': 44, + \ 'type': 'E', + \ 'text': 'error: Unexpected )', + \ } + \ ], + \ ale_linters#clojure#clj_kondo#HandleCljKondoFormat(0, [ + \ 'C:\my\operating\system\is\silly\core.clj:123:44: error: Unexpected )', + \ ]) |