diff --git a/ale_linters/json/jq.vim b/ale_linters/json/jq.vim index 2f36a29e10..ad1da2694e 100644 --- a/ale_linters/json/jq.vim +++ b/ale_linters/json/jq.vim @@ -5,7 +5,7 @@ call ale#Set('json_jq_filters', '.') " Matches patterns like the following: " parse error: Expected another key-value pair at line 4, column 3 -let s:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$' +let s:pattern = 'parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$' function! ale_linters#json#jq#Handle(buffer, lines) abort return ale#util#MapMatches(a:lines, s:pattern, {match -> { diff --git a/ale_linters/python/bandit.vim b/ale_linters/python/bandit.vim index ba48c3a840..b343a1c56b 100644 --- a/ale_linters/python/bandit.vim +++ b/ale_linters/python/bandit.vim @@ -45,7 +45,7 @@ function! ale_linters#python#bandit#GetCommand(buffer) abort endif endif - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run bandit' \ : '' diff --git a/ale_linters/python/flake8.vim b/ale_linters/python/flake8.vim index 12dca84a93..2685f61a33 100644 --- a/ale_linters/python/flake8.vim +++ b/ale_linters/python/flake8.vim @@ -74,7 +74,7 @@ endfunction function! ale_linters#python#flake8#GetCommand(buffer, version) abort let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run flake8' \ : '' diff --git a/ale_linters/python/flakehell.vim b/ale_linters/python/flakehell.vim index 9ff0f18fa9..a5b466b803 100644 --- a/ale_linters/python/flakehell.vim +++ b/ale_linters/python/flakehell.vim @@ -74,7 +74,7 @@ endfunction function! ale_linters#python#flakehell#GetCommand(buffer, version) abort let l:executable = ale_linters#python#flakehell#GetExecutable(a:buffer) - if (l:executable =~? 'pipenv\|poetry\|uv$') + if (l:executable =~? '\(pipenv\|poetry\|uv\)$') let l:exec_args = ' run flakehell' elseif (l:executable is? 'python') let l:exec_args = ' -m flakehell' diff --git a/ale_linters/python/jedils.vim b/ale_linters/python/jedils.vim index 46b2896b91..2d4a97c356 100644 --- a/ale_linters/python/jedils.vim +++ b/ale_linters/python/jedils.vim @@ -28,7 +28,7 @@ endfunction function! ale_linters#python#jedils#GetCommand(buffer) abort let l:executable = ale_linters#python#jedils#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run jedi-language-server' \ : '' let l:env_string = '' diff --git a/ale_linters/python/mypy.vim b/ale_linters/python/mypy.vim index 586a4381f8..27d2726bf8 100644 --- a/ale_linters/python/mypy.vim +++ b/ale_linters/python/mypy.vim @@ -49,7 +49,7 @@ endfunction function! ale_linters#python#mypy#GetCommand(buffer) abort let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run mypy' \ : '' diff --git a/ale_linters/python/prospector.vim b/ale_linters/python/prospector.vim index c40f25c5db..29aad06066 100644 --- a/ale_linters/python/prospector.vim +++ b/ale_linters/python/prospector.vim @@ -35,7 +35,7 @@ endfunction function! ale_linters#python#prospector#GetCommand(buffer) abort let l:executable = ale_linters#python#prospector#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run prospector' \ : '' diff --git a/ale_linters/python/pycln.vim b/ale_linters/python/pycln.vim index 774c6b04cf..23d4867614 100644 --- a/ale_linters/python/pycln.vim +++ b/ale_linters/python/pycln.vim @@ -42,7 +42,7 @@ endfunction function! ale_linters#python#pycln#GetCommand(buffer, version) abort let l:executable = ale_linters#python#pycln#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pycln' \ : '' diff --git a/ale_linters/python/pycodestyle.vim b/ale_linters/python/pycodestyle.vim index bd3584b80e..282e545b62 100644 --- a/ale_linters/python/pycodestyle.vim +++ b/ale_linters/python/pycodestyle.vim @@ -30,7 +30,7 @@ endfunction function! ale_linters#python#pycodestyle#GetCommand(buffer) abort let l:executable = ale_linters#python#pycodestyle#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pycodestyle' \ : '' diff --git a/ale_linters/python/pydocstyle.vim b/ale_linters/python/pydocstyle.vim index b012dd436f..6293df7b9f 100644 --- a/ale_linters/python/pydocstyle.vim +++ b/ale_linters/python/pydocstyle.vim @@ -29,7 +29,7 @@ endfunction function! ale_linters#python#pydocstyle#GetCommand(buffer) abort let l:executable = ale_linters#python#pydocstyle#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pydocstyle' \ : '' diff --git a/ale_linters/python/pyflakes.vim b/ale_linters/python/pyflakes.vim index fc0a3fa74f..f46772dcc6 100644 --- a/ale_linters/python/pyflakes.vim +++ b/ale_linters/python/pyflakes.vim @@ -29,7 +29,7 @@ endfunction function! ale_linters#python#pyflakes#GetCommand(buffer) abort let l:executable = ale_linters#python#pyflakes#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pyflakes' \ : '' diff --git a/ale_linters/python/pylama.vim b/ale_linters/python/pylama.vim index 6555b40911..626974f847 100644 --- a/ale_linters/python/pylama.vim +++ b/ale_linters/python/pylama.vim @@ -30,7 +30,7 @@ endfunction function! ale_linters#python#pylama#RunWithVersionCheck(buffer) abort let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pylama' \ : '' @@ -59,7 +59,7 @@ endfunction function! ale_linters#python#pylama#GetCommand(buffer, version) abort let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pylama' \ : '' diff --git a/ale_linters/python/pylint.vim b/ale_linters/python/pylint.vim index 90aa5f1c23..ba69d6660d 100644 --- a/ale_linters/python/pylint.vim +++ b/ale_linters/python/pylint.vim @@ -44,7 +44,7 @@ endfunction function! ale_linters#python#pylint#GetCommand(buffer, version) abort let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pylint' \ : '' diff --git a/ale_linters/python/pylsp.vim b/ale_linters/python/pylsp.vim index d3db6e82c5..75ec38842a 100644 --- a/ale_linters/python/pylsp.vim +++ b/ale_linters/python/pylsp.vim @@ -43,7 +43,7 @@ endfunction function! ale_linters#python#pylsp#GetCommand(buffer) abort let l:executable = ale_linters#python#pylsp#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pylsp' \ : '' let l:env_string = '' diff --git a/ale_linters/python/pyre.vim b/ale_linters/python/pyre.vim index 177f1cb59e..745d669acc 100644 --- a/ale_linters/python/pyre.vim +++ b/ale_linters/python/pyre.vim @@ -28,7 +28,7 @@ endfunction function! ale_linters#python#pyre#GetCommand(buffer) abort let l:executable = ale_linters#python#pyre#GetExecutable(a:buffer) - let l:exec_args = (l:executable =~? 'pipenv\|poetry\|uv$' ? ' run pyre' : '') . ' persistent' + let l:exec_args = (l:executable =~? '\(pipenv\|poetry\|uv\)$' ? ' run pyre' : '') . ' persistent' return ale#Escape(l:executable) . l:exec_args endfunction diff --git a/ale_linters/python/pyright.vim b/ale_linters/python/pyright.vim index 993ed0750e..95443a1394 100644 --- a/ale_linters/python/pyright.vim +++ b/ale_linters/python/pyright.vim @@ -70,7 +70,7 @@ endfunction function! ale_linters#python#pyright#GetCommand(buffer) abort let l:executable = ale_linters#python#pyright#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pyright-langserver' \ : '' let l:env_string = '' diff --git a/ale_linters/python/refurb.vim b/ale_linters/python/refurb.vim index 7f92948a58..1acd4ceeef 100644 --- a/ale_linters/python/refurb.vim +++ b/ale_linters/python/refurb.vim @@ -41,7 +41,7 @@ endfunction function! ale_linters#python#refurb#GetCommand(buffer) abort let l:executable = ale_linters#python#refurb#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run refurb' \ : '' diff --git a/ale_linters/python/ruff.vim b/ale_linters/python/ruff.vim index 25ae2d9194..8eb551642d 100644 --- a/ale_linters/python/ruff.vim +++ b/ale_linters/python/ruff.vim @@ -47,7 +47,7 @@ endfunction function! ale_linters#python#ruff#GetCommand(buffer, version) abort let l:executable = ale_linters#python#ruff#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run ruff' \ : '' diff --git a/ale_linters/python/unimport.vim b/ale_linters/python/unimport.vim index 06dbc4360d..1496fc42b1 100644 --- a/ale_linters/python/unimport.vim +++ b/ale_linters/python/unimport.vim @@ -28,7 +28,7 @@ endfunction function! ale_linters#python#unimport#GetCommand(buffer) abort let l:executable = ale_linters#python#unimport#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run unimport' \ : '' diff --git a/ale_linters/python/vulture.vim b/ale_linters/python/vulture.vim index 2ac05e435f..c44638b978 100644 --- a/ale_linters/python/vulture.vim +++ b/ale_linters/python/vulture.vim @@ -47,7 +47,7 @@ endfunction function! ale_linters#python#vulture#GetCommand(buffer) abort let l:executable = ale_linters#python#vulture#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run vulture' \ : '' let l:lint_dest = ale#Var(a:buffer, 'python_vulture_change_directory') diff --git a/ale_linters/sql/sqlfluff.vim b/ale_linters/sql/sqlfluff.vim index 4381e1ab88..91d69c124e 100644 --- a/ale_linters/sql/sqlfluff.vim +++ b/ale_linters/sql/sqlfluff.vim @@ -52,16 +52,24 @@ function! ale_linters#sql#sqlfluff#Handle(buffer, version, lines) abort if ale#semver#GTE(a:version, [3, 0, 0]) for l:violation in get(l:json, 'violations', []) - call add(l:output, { + let l:err = { \ 'filename': l:json.filepath, \ 'lnum': l:violation.start_line_no, - \ 'end_lnum': l:violation.end_line_no, \ 'col': l:violation.start_line_pos, - \ 'end_col': l:violation.end_line_pos, \ 'text': l:violation.description, \ 'code': l:violation.code, \ 'type': 'W', - \}) + \} + + if has_key(l:violation, 'end_line_no') + let l:err.end_lnum = l:violation.end_line_no + endif + + if has_key(l:violation, 'end_line_pos') + let l:err.end_col = l:violation.end_line_pos + endif + + call add(l:output, l:err) endfor else for l:violation in get(l:json, 'violations', []) diff --git a/ale_linters/yaml/actionlint.vim b/ale_linters/yaml/actionlint.vim index 5afe6d481e..902da7296d 100644 --- a/ale_linters/yaml/actionlint.vim +++ b/ale_linters/yaml/actionlint.vim @@ -20,9 +20,32 @@ function! ale_linters#yaml#actionlint#GetCommand(buffer) abort let l:options .= ale#Pad('-oneline') endif + let l:configfile = ale_linters#yaml#actionlint#GitRepoHasConfig(a:buffer) + + if !empty(l:configfile) + let l:options .= ale#Pad('-config-file ' . l:configfile) + endif + return '%e' . ale#Pad(l:options) . ' - ' endfunction +" If we have a actionlint.yml or actionlint.yaml in our github directory +" use that as our config file. +function! ale_linters#yaml#actionlint#GitRepoHasConfig(buffer) abort + let l:filename = expand('#' . a:buffer . ':p') + let l:configfilebase = substitute(l:filename, '\.github/.*', '.github/actionlint.','') + + for l:ext in ['yml', 'yaml'] + let l:configfile = l:configfilebase . l:ext + + if filereadable(l:configfile) + return l:configfile + endif + endfor + + return '' +endfunction + function! ale_linters#yaml#actionlint#Handle(buffer, lines) abort " Matches patterns line the following: ".github/workflows/main.yml:19:0: could not parse as YAML: yaml: line 19: mapping values are not allowed in this context [yaml-syntax] diff --git a/ale_linters/yaml/yq.vim b/ale_linters/yaml/yq.vim new file mode 100644 index 0000000000..35aef654c0 --- /dev/null +++ b/ale_linters/yaml/yq.vim @@ -0,0 +1,22 @@ +" Author: axhav +call ale#Set('yaml_yq_executable', 'yq') +call ale#Set('yaml_yq_options', '') +call ale#Set('yaml_yq_filters', '.') + +" Matches patterns like the following: +let s:pattern = '^Error\:.* line \(\d\+\)\: \(.\+\)$' + +function! ale_linters#yaml#yq#Handle(buffer, lines) abort + return ale#util#MapMatches(a:lines, s:pattern, {match -> { + \ 'lnum': match[1] + 0, + \ 'text': match[2], + \}}) +endfunction + +call ale#linter#Define('yaml', { +\ 'name': 'yq', +\ 'executable': {b -> ale#Var(b, 'yaml_yq_executable')}, +\ 'output_stream': 'stderr', +\ 'command': '%e', +\ 'callback': 'ale_linters#yaml#yq#Handle', +\}) diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim index 0f9fdb5dff..4ff04bac81 100644 --- a/autoload/ale/fix/registry.vim +++ b/autoload/ale/fix/registry.vim @@ -207,6 +207,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['python'], \ 'description': 'Fix Python files with yapf.', \ }, +\ 'yq': { +\ 'function': 'ale#fixers#yq#Fix', +\ 'suggested_filetypes': ['yaml'], +\ 'description': 'Fix YAML files with yq.', +\ }, \ 'rubocop': { \ 'function': 'ale#fixers#rubocop#Fix', \ 'suggested_filetypes': ['ruby'], @@ -327,6 +332,11 @@ let s:default_registry = { \ 'suggested_filetypes': ['go'], \ 'description': 'Fix Go files imports with goimports.', \ }, +\ 'golangci_lint': { +\ 'function': 'ale#fixers#golangci_lint#Fix', +\ 'suggested_filetypes': ['go'], +\ 'description': 'Fix Go files with golangci-lint.', +\ }, \ 'golines': { \ 'function': 'ale#fixers#golines#Fix', \ 'suggested_filetypes': ['go'], @@ -672,6 +682,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/autoflake.vim b/autoload/ale/fixers/autoflake.vim index c25300516a..9f8b04fc73 100644 --- a/autoload/ale/fixers/autoflake.vim +++ b/autoload/ale/fixers/autoflake.vim @@ -30,7 +30,7 @@ endfunction function! ale#fixers#autoflake#Fix(buffer) abort let l:executable = ale#fixers#autoflake#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run autoflake' \ : '' diff --git a/autoload/ale/fixers/autoimport.vim b/autoload/ale/fixers/autoimport.vim index 686da124b3..8d35419efa 100644 --- a/autoload/ale/fixers/autoimport.vim +++ b/autoload/ale/fixers/autoimport.vim @@ -30,7 +30,7 @@ endfunction function! ale#fixers#autoimport#Fix(buffer) abort let l:executable = ale#fixers#autoimport#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run autoimport' \ : '' diff --git a/autoload/ale/fixers/autopep8.vim b/autoload/ale/fixers/autopep8.vim index 6b5adfce90..f9af46f85d 100644 --- a/autoload/ale/fixers/autopep8.vim +++ b/autoload/ale/fixers/autopep8.vim @@ -30,7 +30,7 @@ endfunction function! ale#fixers#autopep8#Fix(buffer) abort let l:executable = ale#fixers#autopep8#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run autopep8' \ : '' diff --git a/autoload/ale/fixers/black.vim b/autoload/ale/fixers/black.vim index 4fe239ffc7..624e5459d1 100644 --- a/autoload/ale/fixers/black.vim +++ b/autoload/ale/fixers/black.vim @@ -32,7 +32,7 @@ function! ale#fixers#black#Fix(buffer) abort let l:executable = ale#fixers#black#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry\|uv$' + if l:executable =~? '\(pipenv\|poetry\|uv\)$' call extend(l:cmd, ['run', 'black']) endif diff --git a/autoload/ale/fixers/cljfmt.vim b/autoload/ale/fixers/cljfmt.vim new file mode 100644 index 0000000000..dbcf10d8fc --- /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/autoload/ale/fixers/golangci_lint.vim b/autoload/ale/fixers/golangci_lint.vim new file mode 100644 index 0000000000..596f159000 --- /dev/null +++ b/autoload/ale/fixers/golangci_lint.vim @@ -0,0 +1,32 @@ +" Author: Ian Stapleton Cordasco +" Description: Run golangci-lint with the --fix flag to autofix some issues + +call ale#Set('go_golangci_lint_options', '') +call ale#Set('go_golangci_lint_executable', 'golangci-lint') +call ale#Set('go_golangci_lint_package', 1) + +function! ale#fixers#golangci_lint#GetCommand(buffer) abort + let l:filename = expand('#' . a:buffer . ':t') + let l:executable = ale#Var(a:buffer, 'go_golangci_lint_executable') + let l:options = ale#Var(a:buffer, 'go_golangci_lint_options') . ' --fix' + let l:package_mode = ale#Var(a:buffer, 'go_golangci_lint_package') + let l:env = ale#go#EnvString(a:buffer) + + + if l:package_mode + return l:env . ale#Escape(l:executable) + \ . ' run ' + \ . l:options + endif + + return l:env . ale#Escape(l:executable) + \ . ' run ' + \ . l:options + \ . ' ' . ale#Escape(l:filename) +endfunction + +function! ale#fixers#golangci_lint#Fix(buffer) abort + return { + \ 'command': ale#fixers#golangci_lint#GetCommand(a:buffer), + \} +endfunction diff --git a/autoload/ale/fixers/isort.vim b/autoload/ale/fixers/isort.vim index c4eef3cc39..45083ee8e3 100644 --- a/autoload/ale/fixers/isort.vim +++ b/autoload/ale/fixers/isort.vim @@ -31,7 +31,7 @@ function! ale#fixers#isort#GetCmd(buffer) abort let l:executable = ale#fixers#isort#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry\|uv$' + if l:executable =~? '\(pipenv\|poetry\|uv\)$' call extend(l:cmd, ['run', 'isort']) endif @@ -42,7 +42,7 @@ function! ale#fixers#isort#FixForVersion(buffer, version) abort let l:executable = ale#fixers#isort#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry\|uv$' + if l:executable =~? '\(pipenv\|poetry\|uv\)$' call extend(l:cmd, ['run', 'isort']) endif diff --git a/autoload/ale/fixers/pycln.vim b/autoload/ale/fixers/pycln.vim index 4ee2373d85..ca15cc4e7c 100644 --- a/autoload/ale/fixers/pycln.vim +++ b/autoload/ale/fixers/pycln.vim @@ -42,7 +42,7 @@ endfunction function! ale#fixers#pycln#GetCommand(buffer) abort let l:executable = ale#fixers#pycln#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run pycln' \ : '' @@ -53,7 +53,7 @@ function! ale#fixers#pycln#FixForVersion(buffer, version) abort let l:executable = ale#fixers#pycln#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry\|uv$' + if l:executable =~? '\(pipenv\|poetry\|uv\)$' call extend(l:cmd, ['run', 'pycln']) endif diff --git a/autoload/ale/fixers/pyflyby.vim b/autoload/ale/fixers/pyflyby.vim index f6f289e3dc..d5c2d23560 100644 --- a/autoload/ale/fixers/pyflyby.vim +++ b/autoload/ale/fixers/pyflyby.vim @@ -33,7 +33,7 @@ function! ale#fixers#pyflyby#Fix(buffer) abort let l:executable = ale#fixers#pyflyby#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry\|uv$' + if l:executable =~? '\(pipenv\|poetry\|uv\)$' call extend(l:cmd, ['run', 'tidy-imports']) endif diff --git a/autoload/ale/fixers/reorder_python_imports.vim b/autoload/ale/fixers/reorder_python_imports.vim index 3cc76a9f02..6e10c1d618 100644 --- a/autoload/ale/fixers/reorder_python_imports.vim +++ b/autoload/ale/fixers/reorder_python_imports.vim @@ -30,7 +30,7 @@ endfunction function! ale#fixers#reorder_python_imports#Fix(buffer) abort let l:executable = ale#fixers#reorder_python_imports#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run reorder-python-imports' \ : '' diff --git a/autoload/ale/fixers/ruff.vim b/autoload/ale/fixers/ruff.vim index c2bea3e351..c0c3cd624f 100644 --- a/autoload/ale/fixers/ruff.vim +++ b/autoload/ale/fixers/ruff.vim @@ -41,7 +41,7 @@ endfunction function! ale#fixers#ruff#GetCommand(buffer) abort let l:executable = ale#fixers#ruff#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run ruff' \ : '' @@ -52,7 +52,7 @@ function! ale#fixers#ruff#FixForVersion(buffer, version) abort let l:executable = ale#fixers#ruff#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry\|uv$' + if l:executable =~? '\(pipenv\|poetry\|uv\)$' call extend(l:cmd, ['run', 'ruff']) endif diff --git a/autoload/ale/fixers/ruff_format.vim b/autoload/ale/fixers/ruff_format.vim index e852dd2447..cfa7b76d8e 100644 --- a/autoload/ale/fixers/ruff_format.vim +++ b/autoload/ale/fixers/ruff_format.vim @@ -41,7 +41,7 @@ endfunction function! ale#fixers#ruff_format#GetCommand(buffer) abort let l:executable = ale#fixers#ruff_format#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run ruff' \ : '' @@ -52,7 +52,7 @@ function! ale#fixers#ruff_format#Fix(buffer) abort let l:executable = ale#fixers#ruff_format#GetExecutable(a:buffer) let l:cmd = [ale#Escape(l:executable)] - if l:executable =~? 'pipenv\|poetry\|uv$' + if l:executable =~? '\(pipenv\|poetry\|uv\)$' call extend(l:cmd, ['run', 'ruff']) endif diff --git a/autoload/ale/fixers/yapf.vim b/autoload/ale/fixers/yapf.vim index 22822a6e1e..cbc3d46d50 100644 --- a/autoload/ale/fixers/yapf.vim +++ b/autoload/ale/fixers/yapf.vim @@ -29,7 +29,7 @@ endfunction function! ale#fixers#yapf#Fix(buffer) abort let l:executable = ale#fixers#yapf#GetExecutable(a:buffer) - let l:exec_args = l:executable =~? 'pipenv\|poetry\|uv$' + let l:exec_args = l:executable =~? '\(pipenv\|poetry\|uv\)$' \ ? ' run yapf' \ : '' diff --git a/autoload/ale/fixers/yq.vim b/autoload/ale/fixers/yq.vim new file mode 100644 index 0000000000..b9bf70070e --- /dev/null +++ b/autoload/ale/fixers/yq.vim @@ -0,0 +1,22 @@ +call ale#Set('yaml_yq_executable', 'yq') +call ale#Set('yaml_yq_options', '') +call ale#Set('yaml_yq_filters', '.') + +function! ale#fixers#yq#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'yaml_yq_executable') +endfunction + +function! ale#fixers#yq#Fix(buffer) abort + let l:options = ale#Var(a:buffer, 'yaml_yq_options') + let l:filters = ale#Var(a:buffer, 'yaml_yq_filters') + + if empty(l:filters) + return 0 + endif + + return { + \ 'command': ale#Escape(ale#fixers#yq#GetExecutable(a:buffer)) + \ . ' ' . l:filters . ' ' + \ . l:options, + \} +endfunction diff --git a/doc/ale-clojure.txt b/doc/ale-clojure.txt index 3ff367f668..54872de706 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 fddf3d1f7c..40d9210c30 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` @@ -728,6 +729,7 @@ Notes: * `yamlfix` * `yamlfmt` * `yamllint` + * `yq` * YANG * `yang-lsp` * Zeek diff --git a/doc/ale-yaml.txt b/doc/ale-yaml.txt index a6741c8320..fc52dc73bc 100644 --- a/doc/ale-yaml.txt +++ b/doc/ale-yaml.txt @@ -366,5 +366,43 @@ g:ale_yaml_gitlablint_options *g:ale_yaml_gitlablint_options This variable can be set to pass additional options to gll. +=============================================================================== +yq *ale-yaml-yq* + +Website: https://github.com/mikefarah/yq + + +Installation +------------------------------------------------------------------------------- + +Install yq: > + + wget https://github.com/mikefarah/yq/releases/download/${VERSION}/${BINARY}.tar.gz -O - | tar xz && mv ${BINARY} /usr/bin/yq + +Options +------------------------------------------------------------------------------- + +g:ale_yaml_yq_executable *g:ale_yaml_yq_executable* + *b:ale_yaml_yq_executable* + Type: |String| + Default: `'yq'` + + This variable can be set to change the path to yq. + + +g:ale_yaml_yq_options *g:ale_yaml_yq_options* + *b:ale_yaml_yq_options* + Type: |String| + Default: `''` + + This variable can be set to pass additional options to yq. + +g:ale_yaml_yq_filters *g:ale_yaml_yq_filters + *b:ale_yaml_yq_filters* + Type: |String| + Default: `'.'` + + This option can be changed to pass additional filters to yq + =============================================================================== vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index cbfd5e2f26..3d7e8f5a94 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| @@ -3516,6 +3517,7 @@ documented in additional help files. yamlfmt...............................|ale-yaml-yamlfmt| yamllint..............................|ale-yaml-yamllint| gitlablint............................|ale-yaml-gitlablint| + yq....................................|ale-yaml-yq| yang....................................|ale-yang-options| yang-lsp..............................|ale-yang-lsp| zeek....................................|ale-zeek-options| diff --git a/supported-tools.md b/supported-tools.md index a48429541b..c6a99de02c 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) @@ -737,6 +738,7 @@ formatting. * [yamlfix](https://lyz-code.github.io/yamlfix) * [yamlfmt](https://github.com/google/yamlfmt) * [yamllint](https://yamllint.readthedocs.io/) + * [yq](https://github.com/mikefarah/yq) * YANG * [yang-lsp](https://github.com/theia-ide/yang-lsp) * Zeek diff --git a/test/fixers/test_cljfmt_fixer_callback.vader b/test/fixers/test_cljfmt_fixer_callback.vader new file mode 100644 index 0000000000..984689fbda --- /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, + \} + diff --git a/test/fixers/test_golangci_lint_fixer_callback.vader b/test/fixers/test_golangci_lint_fixer_callback.vader new file mode 100644 index 0000000000..3487d6f51b --- /dev/null +++ b/test/fixers/test_golangci_lint_fixer_callback.vader @@ -0,0 +1,48 @@ +Before: + Save g:ale_go_go111module + Save g:ale_go_golangci_lint_executable + Save g:ale_go_golangci_lint_options + Save g:ale_go_golangci_lint_package + + " Use an invalid global executable, so we don't match it. + let g:ale_go_golangci_lint_executable = 'xxxinvalid' + let g:ale_go_golangci_lint_options = '' + + call ale#test#SetDirectory('/testplugin/test/fixers') + call ale#test#SetFilename('../test-files/go/testfile.go') +After: + Restore + + unlet! b:ale_go_go111module + + call ale#test#RestoreDirectory() + +Execute(The golangci-lint callback should return the correct default values): + + AssertEqual + \ { + \ 'command': ale#Escape('xxxinvalid') . ' run --fix', + \ }, + \ ale#fixers#golangci_lint#Fix(bufnr('')) + +Execute(The golangci-lint callback should include custom golangci-lint options): + let g:ale_go_golangci_lint_options = "--new --config /dev/null" + + AssertEqual + \ { + \ 'command': ale#Escape('xxxinvalid') + \ . ' run ' . g:ale_go_golangci_lint_options . ' --fix', + \ }, + \ ale#fixers#golangci_lint#Fix(bufnr('')) + +Execute(The golangci-lint callback should support per-file mode): + let g:ale_go_golangci_lint_package = 0 + + AssertEqual + \ { + \ 'command': ale#Escape('xxxinvalid') + \ . ' run ' + \ . g:ale_go_golangci_lint_options + \ . ' --fix ' . ale#Escape('testfile.go'), + \ }, + \ ale#fixers#golangci_lint#Fix(bufnr('')) diff --git a/test/handler/test_jq_handler.vader b/test/handler/test_jq_handler.vader index cbe23b966a..1653bd3d60 100644 --- a/test/handler/test_jq_handler.vader +++ b/test/handler/test_jq_handler.vader @@ -16,3 +16,15 @@ Execute (Should parse error correctly): \ ale_linters#json#jq#Handle(0, [ \ 'parse error: Expected another array element at line 1, column 9' \ ]) + + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 9, + \ 'text': 'Expected another array element', + \ } + \ ], + \ ale_linters#json#jq#Handle(0, [ + \ 'jq: parse error: Expected another array element at line 1, column 9' + \ ]) diff --git a/test/handler/test_sql_sqlfluff_handler.vader b/test/handler/test_sql_sqlfluff_handler.vader index c7a4c291dd..74508ee9ab 100644 --- a/test/handler/test_sql_sqlfluff_handler.vader +++ b/test/handler/test_sql_sqlfluff_handler.vader @@ -69,7 +69,15 @@ Execute(The sqlfluff handler should handle basic warnings with version newer tha \ 'code': 'L009', \ 'text': 'Files must end with a single trailing newline.', \ }, + \ { + \ 'filename': 'schema.sql', + \ 'lnum': 3, + \ 'col': 21, + \ 'type': 'W', + \ 'code': 'TMP', + \ 'text': "Undefined jinja template variable: 'a_jinja_templated_table'", + \ }, \ ], \ ale_linters#sql#sqlfluff#Handle(bufnr(''), [3, 0, 0], [ - \ '[{"filepath": "schema.sql", "violations": [{"start_line_no": 1, "end_line_no":1, "start_line_pos": 8, "end_line_pos":12, "code": "L010", "description": "Keywords must be consistently upper case."}, {"start_line_no": 13, "end_line_no":13, "start_line_pos": 2, "end_line_pos":20, "code": "L003", "description": "Expected 1 indentation, found 0 [compared to line 12]"}, {"start_line_no": 16, "end_line_no":16, "start_line_pos": 1, "end_line_pos":5, "code": "L009", "description": "Files must end with a single trailing newline."}]}]', + \ '[{"filepath": "schema.sql", "violations": [{"start_line_no": 1, "end_line_no":1, "start_line_pos": 8, "end_line_pos":12, "code": "L010", "description": "Keywords must be consistently upper case."}, {"start_line_no": 13, "end_line_no":13, "start_line_pos": 2, "end_line_pos":20, "code": "L003", "description": "Expected 1 indentation, found 0 [compared to line 12]"}, {"start_line_no": 16, "end_line_no":16, "start_line_pos": 1, "end_line_pos":5, "code": "L009", "description": "Files must end with a single trailing newline."}, {"start_line_no": 3, "start_line_pos": 21, "code": "TMP", "description": "Undefined jinja template variable: ''a_jinja_templated_table''"}]}]', \ ]) diff --git a/test/handler/test_yq_handler.vader b/test/handler/test_yq_handler.vader new file mode 100644 index 0000000000..861bf9e401 --- /dev/null +++ b/test/handler/test_yq_handler.vader @@ -0,0 +1,19 @@ +Before: + runtime ale_linters/yaml/yq.vim + +After: + call ale#linter#Reset() + +Execute (Should parse error correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 2, + \ 'text': "did not find expected ',' or ']'", + \ } + \ ], + \ ale_linters#yaml#yq#Handle(bufnr(''), [ + \ "Error: bad file '-': yaml: line 2: did not find expected ',' or ']'" + \ ]) + + diff --git a/test/linter/test_yq.vader b/test/linter/test_yq.vader new file mode 100644 index 0000000000..e2e7dcd100 --- /dev/null +++ b/test/linter/test_yq.vader @@ -0,0 +1,8 @@ +Before: + call ale#assert#SetUpLinterTest('yaml', 'yq') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'yq', ale#Escape('yq')