diff options
-rw-r--r-- | ale_linters/java/checkstyle.vim | 2 | ||||
-rw-r--r-- | ale_linters/java/eclipselsp.vim | 22 | ||||
-rw-r--r-- | ale_linters/kotlin/ktlint.vim | 2 | ||||
-rw-r--r-- | ale_linters/puppet/puppet.vim | 7 | ||||
-rw-r--r-- | ale_linters/sh/bashate.vim | 43 | ||||
-rw-r--r-- | ale_linters/zig/zls.vim | 20 | ||||
-rw-r--r-- | autoload/ale/fixers/ktlint.vim | 3 | ||||
-rw-r--r-- | autoload/ale/handlers/ktlint.vim | 2 | ||||
-rw-r--r-- | doc/ale-java.txt | 24 | ||||
-rw-r--r-- | doc/ale-sh.txt | 23 | ||||
-rw-r--r-- | doc/ale-supported-languages-and-tools.txt | 3 | ||||
-rw-r--r-- | doc/ale-zig.txt | 33 | ||||
-rw-r--r-- | doc/ale.txt | 3 | ||||
-rw-r--r-- | supported-tools.md | 3 | ||||
-rw-r--r-- | test/command_callback/test_bashate_command_callback.vader | 15 | ||||
-rw-r--r-- | test/command_callback/test_checkstyle_command_callback.vader | 4 | ||||
-rw-r--r-- | test/command_callback/test_zig_zls_callbacks.vader | 15 | ||||
-rw-r--r-- | test/command_callback/zig-zls-project/build.zig | 0 | ||||
-rw-r--r-- | test/fixers/test_ktlint_fixer_callback.vader | 6 | ||||
-rw-r--r-- | test/handler/test_bashate_handler.vader | 36 | ||||
-rw-r--r-- | test/handler/test_puppet_handler.vader | 12 |
21 files changed, 249 insertions, 29 deletions
diff --git a/ale_linters/java/checkstyle.vim b/ale_linters/java/checkstyle.vim index 7901ff7e..ec7339d1 100644 --- a/ale_linters/java/checkstyle.vim +++ b/ale_linters/java/checkstyle.vim @@ -52,7 +52,7 @@ endfunction function! ale_linters#java#checkstyle#GetCommand(buffer) abort let l:options = ale#Var(a:buffer, 'java_checkstyle_options') let l:config_option = ale#Var(a:buffer, 'java_checkstyle_config') - let l:config = l:options !~# '\v(^| )-c' && !empty(l:config_option) + let l:config = l:options !~# '\v(^| )-c ' && !empty(l:config_option) \ ? s:GetConfig(a:buffer, l:config_option) \ : '' diff --git a/ale_linters/java/eclipselsp.vim b/ale_linters/java/eclipselsp.vim index 2bfec043..c981b749 100644 --- a/ale_linters/java/eclipselsp.vim +++ b/ale_linters/java/eclipselsp.vim @@ -20,25 +20,32 @@ endfunction function! ale_linters#java#eclipselsp#JarPath(buffer) abort let l:path = ale_linters#java#eclipselsp#TargetPath(a:buffer) + if has('win32') + let l:platform = 'win32' + elseif has('macunix') + let l:platform = 'macosx' + else + let l:platform = 'linux' + endif + " Search jar file within repository path when manually built using mvn - let l:repo_path = l:path . '/org.eclipse.jdt.ls.product/target/repository' - let l:files = globpath(l:repo_path, '**/plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) + let l:files = globpath(l:path, '**/'.l:platform.'/**/plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) - if len(l:files) == 1 + if len(l:files) > 1 return l:files[0] endif " Search jar file within VSCode extensions folder. - let l:files = globpath(l:path, '**/plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) + let l:files = globpath(l:path, '**/'.l:platform.'/plugins/org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) - if len(l:files) == 1 + if len(l:files) > 1 return l:files[0] endif " Search jar file within system package path let l:files = globpath('/usr/share/java/jdtls/plugins', 'org.eclipse.equinox.launcher_\d\.\d\.\d\d\d\.*\.jar', 1, 1) - if len(l:files) == 1 + if len(l:files) > 1 return l:files[0] endif @@ -166,7 +173,8 @@ function! ale_linters#java#eclipselsp#RunWithVersionCheck(buffer) abort return ale#command#Run( \ a:buffer, \ l:command, - \ function('ale_linters#java#eclipselsp#CommandWithVersion') + \ function('ale_linters#java#eclipselsp#CommandWithVersion'), + \ { 'output_stream': 'both' } \) endfunction diff --git a/ale_linters/kotlin/ktlint.vim b/ale_linters/kotlin/ktlint.vim index f0384005..0bb64b19 100644 --- a/ale_linters/kotlin/ktlint.vim +++ b/ale_linters/kotlin/ktlint.vim @@ -6,5 +6,5 @@ call ale#linter#Define('kotlin', { \ 'executable': 'ktlint', \ 'command': function('ale#handlers#ktlint#GetCommand'), \ 'callback': 'ale#handlers#ktlint#Handle', -\ 'lint_file': 1 +\ 'output_stream': 'stderr' \}) diff --git a/ale_linters/puppet/puppet.vim b/ale_linters/puppet/puppet.vim index b4afe9ac..59228dc8 100644 --- a/ale_linters/puppet/puppet.vim +++ b/ale_linters/puppet/puppet.vim @@ -9,13 +9,14 @@ function! ale_linters#puppet#puppet#Handle(buffer, lines) abort " Error: Could not parse for environment production: Syntax error at '='; expected '}' at /root/puppetcode/modules/pancakes/manifests/init.pp:5" " Error: Could not parse for environment production: Syntax error at 'parameter1' (file: /tmp/modules/mariadb/manifests/slave.pp, line: 4, column: 5) " Error: Illegal attempt to assign to 'a Name'. Not an assignable reference (file: /tmp/modules/waffles/manifests/syrup.pp, line: 5, column: 11) - let l:pattern = '^Error:\%(.*:\)\? \(.\+\) \((file:\|at\) .\+\.pp\(, line: \|:\)\(\d\+\)\(, column: \|:\)\=\(\d*\)' + " Error: Could not parse for environment production: Syntax error at end of input (file: /tmp/modules/bob/manifests/init.pp) + let l:pattern = '^Error:\%(.*:\)\? \(.\+\) \((file:\|at\) .\+\.pp\(\(, line: \|:\)\(\d\+\)\(, column: \|:\)\=\(\d*\)\|)$\)' let l:output = [] for l:match in ale#util#GetMatches(a:lines, l:pattern) call add(l:output, { - \ 'lnum': l:match[4] + 0, - \ 'col': l:match[6] + 0, + \ 'lnum': l:match[5] + 0, + \ 'col': l:match[7] + 0, \ 'text': l:match[1], \}) endfor diff --git a/ale_linters/sh/bashate.vim b/ale_linters/sh/bashate.vim new file mode 100644 index 00000000..3cd84245 --- /dev/null +++ b/ale_linters/sh/bashate.vim @@ -0,0 +1,43 @@ +" Author: hsanson <hsanson@gmail.com> +" Description: Lints sh files using bashate +" URL: https://github.com/openstack/bashate + +call ale#Set('sh_bashate_executable', 'bashate') +call ale#Set('sh_bashate_options', '') + +function! ale_linters#sh#bashate#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'sh_bashate_executable') +endfunction + +function! ale_linters#sh#bashate#GetCommand(buffer) abort + let l:options = ale#Var(a:buffer, 'sh_bashate_options') + let l:executable = ale_linters#sh#bashate#GetExecutable(a:buffer) + + return ale#Escape(l:executable) . ' ' . l:options . ' ' . '%t' +endfunction + +function! ale_linters#sh#bashate#Handle(buffer, lines) abort + " Matches patterns line the following: + " + " /path/to/script/file:694:1: E003 Indent not multiple of 4 + let l:pattern = ':\(\d\+\):\(\d\+\): \(.*\)$' + let l:output = [] + + for l:match in ale#util#GetMatches(a:lines, l:pattern) + call add(l:output, { + \ 'lnum': str2nr(l:match[1]), + \ 'col': str2nr(l:match[2]), + \ 'text': l:match[3], + \}) + endfor + + return l:output +endfunction + +call ale#linter#Define('sh', { +\ 'name': 'bashate', +\ 'output_stream': 'stdout', +\ 'executable': function('ale_linters#sh#bashate#GetExecutable'), +\ 'command': function('ale_linters#sh#bashate#GetCommand'), +\ 'callback': 'ale_linters#sh#bashate#Handle', +\}) diff --git a/ale_linters/zig/zls.vim b/ale_linters/zig/zls.vim new file mode 100644 index 00000000..1390f6b1 --- /dev/null +++ b/ale_linters/zig/zls.vim @@ -0,0 +1,20 @@ +" Author: CherryMan <skipper308@hotmail.ca> +" Description: A language server for Zig + +call ale#Set('zig_zls_executable', 'zls') +call ale#Set('zig_zls_config', {}) + +function! ale_linters#zig#zls#GetProjectRoot(buffer) abort + let l:build_rs = ale#path#FindNearestFile(a:buffer, 'build.zig') + + return !empty(l:build_rs) ? fnamemodify(l:build_rs, ':h') : '' +endfunction + +call ale#linter#Define('zig', { +\ 'name': 'zls', +\ 'lsp': 'stdio', +\ 'lsp_config': {b -> ale#Var(b, 'zig_zls_config')}, +\ 'executable': {b -> ale#Var(b, 'zig_zls_executable')}, +\ 'command': '%e', +\ 'project_root': function('ale_linters#zig#zls#GetProjectRoot'), +\}) diff --git a/autoload/ale/fixers/ktlint.vim b/autoload/ale/fixers/ktlint.vim index cb975d6c..64d1340d 100644 --- a/autoload/ale/fixers/ktlint.vim +++ b/autoload/ale/fixers/ktlint.vim @@ -3,7 +3,6 @@ function! ale#fixers#ktlint#Fix(buffer) abort return { - \ 'command': ale#handlers#ktlint#GetCommand(a:buffer) . ' --format', - \ 'read_temporary_file': 1, + \ 'command': ale#handlers#ktlint#GetCommand(a:buffer) . ' --format' \} endfunction diff --git a/autoload/ale/handlers/ktlint.vim b/autoload/ale/handlers/ktlint.vim index ad999485..77e7ab66 100644 --- a/autoload/ale/handlers/ktlint.vim +++ b/autoload/ale/handlers/ktlint.vim @@ -13,7 +13,7 @@ function! ale#handlers#ktlint#GetCommand(buffer) abort return ale#Escape(l:executable) \ . (empty(l:options) ? '' : ' ' . l:options) \ . (empty(l:rulesets) ? '' : ' ' . l:rulesets) - \ . ' %t' + \ . ' --stdin' endfunction function! ale#handlers#ktlint#GetRulesets(buffer) abort diff --git a/doc/ale-java.txt b/doc/ale-java.txt index d2001ca7..2e736d90 100644 --- a/doc/ale-java.txt +++ b/doc/ale-java.txt @@ -131,18 +131,26 @@ javalsp *ale-java-javalsp* To enable Java LSP linter you need to download and build the vscode-javac language server from https://github.com/georgewfraser/java-language-server. -Simply download the source code and then build a distribution: - scripts/link_mac.sh +Before building the language server you need to install pre-requisites: npm, +maven, and protobuf. You also need to have Java 13 and JAVA_HOME properly +set. -or +After downloading the source code and installing all pre-requisites you can +build the language server with the included build.sh script: - scripts/link_windows.sh + scripts/build.sh -This generates a dist/mac or dist/windows directory that contains the -language server. To let ALE use this language server you need to set the +This will create launch scripts for Linux, Mac, and Windows in the dist folder +within the repo: + + - lang_server_linux.sh + - lang_server_mac.sh + - lang_server_windows.sh + +To let ALE use this language server you need to set the g:ale_java_javalsp_executable variable to the absolute path of the launcher -executable in this directory. +executable for your platform. g:ale_java_javalsp_executable *g:ale_java_javalsp_executable* *b:ale_java_javalsp_executable* @@ -152,7 +160,7 @@ g:ale_java_javalsp_executable *g:ale_java_javalsp_executable* This variable must be set to the absolute path of the language server launcher executable. For example: > - let g:ale_java_javalsp_executable=/java-language-server/dist/mac/bin/launcher + let g:ale_java_javalsp_executable=/java-language-server/dist/lang_server_linux.sh < g:ale_java_javalsp_config *g:ale_java_javalsp_config* diff --git a/doc/ale-sh.txt b/doc/ale-sh.txt index 3eac9038..7897d0ce 100644 --- a/doc/ale-sh.txt +++ b/doc/ale-sh.txt @@ -3,6 +3,29 @@ ALE Shell Integration *ale-sh-options* =============================================================================== +bashate *ale-sh-bashate* + +g:ale_sh_bashate_executable *g:ale_sh_bashate_executable* + *b:ale_sh_bashate_executable* + Type: |String| + Default: `'bashate'` + + This variable sets executable used for bashate. + + +g:ale_sh_bashate_options *g:ale_sh_bashate_options* + *b:ale_sh_bashate_options* + Type: |String| + Default: `''` + + With this variable we are able to pass extra arguments for bashate. For + example to ignore the indentation rule: + +> + let g:ale_sh_shellcheck_options = '-i E003' +< + +=============================================================================== sh-language-server *ale-sh-language-server* g:ale_sh_language_server_executable *g:ale_sh_language_server_executable* diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt index 6e69b53b..3e9b4c1e 100644 --- a/doc/ale-supported-languages-and-tools.txt +++ b/doc/ale-supported-languages-and-tools.txt @@ -31,6 +31,7 @@ Notes: * Awk * `gawk` * Bash + * `bashate` * `language-server` * `shell` (-n flag) * `shellcheck` @@ -512,3 +513,5 @@ Notes: * `yamllint` * YANG * `yang-lsp` +* Zig + * `zls` diff --git a/doc/ale-zig.txt b/doc/ale-zig.txt new file mode 100644 index 00000000..70a53bbb --- /dev/null +++ b/doc/ale-zig.txt @@ -0,0 +1,33 @@ +=============================================================================== +ALE Zig Integration *ale-zig-options* + *ale-integration-zig* + +=============================================================================== +Integration Information + + Currently, the only supported linter for zig is zls. + +=============================================================================== +zls *ale-zig-zls* + +g:ale_zig_zls_executable *g:ale_zig_zls_executable* + *b:ale_zig_zls_executable* + Type: |String| + Default: `'zls'` + + This variable can be modified to change the executable path for `zls`. + + +g:ale_zig_zls_config *g:ale_zig_zls_config* + *b:ale_zig_zls_config* + Type: |Dictionary| + Default: `{}` + + WARNING: As of writing, zls does not support receiving configuration + from the client. This variable is a PLACEHOLDER until it does. + + Dictionary with configuration settings for zls. + + +=============================================================================== + vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: diff --git a/doc/ale.txt b/doc/ale.txt index a9b39034..8c6f5e61 100644 --- a/doc/ale.txt +++ b/doc/ale.txt @@ -2602,6 +2602,7 @@ documented in additional help files. sasslint..............................|ale-scss-sasslint| stylelint.............................|ale-scss-stylelint| sh......................................|ale-sh-options| + bashate...............................|ale-sh-bashate| sh-language-server....................|ale-sh-language-server| shell.................................|ale-sh-shell| shellcheck............................|ale-sh-shellcheck| @@ -2678,6 +2679,8 @@ documented in additional help files. yamllint..............................|ale-yaml-yamllint| yang....................................|ale-yang-options| yang-lsp..............................|ale-yang-lsp| + zig.....................................|ale-zig-options| + zls...................................|ale-zig-zls| =============================================================================== diff --git a/supported-tools.md b/supported-tools.md index c6d9f795..1f1eb1ac 100644 --- a/supported-tools.md +++ b/supported-tools.md @@ -40,6 +40,7 @@ formatting. * Awk * [gawk](https://www.gnu.org/software/gawk/) * Bash + * [bashate](https://github.com/openstack/bashate) * [language-server](https://github.com/mads-hartmann/bash-language-server) * shell [-n flag](https://www.gnu.org/software/bash/manual/bash.html#index-set) * [shellcheck](https://www.shellcheck.net/) @@ -521,3 +522,5 @@ formatting. * [yamllint](https://yamllint.readthedocs.io/) * YANG * [yang-lsp](https://github.com/theia-ide/yang-lsp) +* Zig + * [zls](https://github.com/zigtools/zls) diff --git a/test/command_callback/test_bashate_command_callback.vader b/test/command_callback/test_bashate_command_callback.vader new file mode 100644 index 00000000..714cf690 --- /dev/null +++ b/test/command_callback/test_bashate_command_callback.vader @@ -0,0 +1,15 @@ +Before: + call ale#assert#SetUpLinterTest('sh', 'bashate') + call ale#test#SetFilename('test.sh') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default bashate command should be correct): + AssertLinter 'bashate', ale#Escape('bashate') . ' %t' + +Execute(The bashate command should accept options): + let b:ale_sh_bashate_options = '-i E310 --max-line-length 100' + + AssertLinter 'bashate', + \ ale#Escape('bashate') . ' -i E310 --max-line-length 100 %t' diff --git a/test/command_callback/test_checkstyle_command_callback.vader b/test/command_callback/test_checkstyle_command_callback.vader index 7a9f26b3..5824df87 100644 --- a/test/command_callback/test_checkstyle_command_callback.vader +++ b/test/command_callback/test_checkstyle_command_callback.vader @@ -20,11 +20,11 @@ Execute(The checkstyle executable should be configurable): \ . ' %s' Execute(Custom options should be supported): - let b:ale_java_checkstyle_options = '--foobar' + let b:ale_java_checkstyle_options = '--foobar -cp -classpath /path/to/checkstyle-8.7-all.jar' AssertLinter 'checkstyle', \ ale#Escape('checkstyle') - \ . ' --foobar' + \ . ' --foobar -cp -classpath /path/to/checkstyle-8.7-all.jar' \ . ' -c ' . ale#Escape('/google_checks.xml') \ . ' %s' diff --git a/test/command_callback/test_zig_zls_callbacks.vader b/test/command_callback/test_zig_zls_callbacks.vader new file mode 100644 index 00000000..6e42cc4b --- /dev/null +++ b/test/command_callback/test_zig_zls_callbacks.vader @@ -0,0 +1,15 @@ +Before: + call ale#assert#SetUpLinterTest('zig', 'zls') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default executable path should be correct): + AssertLinter 'zls', ale#Escape('zls') + +Execute(The project root should be detected correctly): + AssertLSPProject '' + + call ale#test#SetFilename('zig-zls-project/main.zig') + + AssertLSPProject ale#path#Simplify(g:dir . '/zig-zls-project') diff --git a/test/command_callback/zig-zls-project/build.zig b/test/command_callback/zig-zls-project/build.zig new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/zig-zls-project/build.zig diff --git a/test/fixers/test_ktlint_fixer_callback.vader b/test/fixers/test_ktlint_fixer_callback.vader index 47b37788..ba01a409 100644 --- a/test/fixers/test_ktlint_fixer_callback.vader +++ b/test/fixers/test_ktlint_fixer_callback.vader @@ -21,9 +21,8 @@ Execute(The ktlint callback should return the correct default values): AssertEqual \ { \ 'command': ale#Escape('xxxinvalid') - \ . ' %t' + \ . ' --stdin' \ . ' --format', - \ 'read_temporary_file': 1, \ }, \ ale#fixers#ktlint#Fix(bufnr('')) @@ -37,8 +36,7 @@ Execute(The ktlint callback should include custom ktlint options): \ 'command': ale#Escape('xxxinvalid') \ . ' ' . g:ale_kotlin_ktlint_options \ . ' --ruleset /path/to/custom/ruleset.jar' - \ . ' %t' + \ . ' --stdin' \ . ' --format', - \ 'read_temporary_file': 1, \ }, \ ale#fixers#ktlint#Fix(bufnr('')) diff --git a/test/handler/test_bashate_handler.vader b/test/handler/test_bashate_handler.vader new file mode 100644 index 00000000..b61bb956 --- /dev/null +++ b/test/handler/test_bashate_handler.vader @@ -0,0 +1,36 @@ +Before: + runtime ale_linters/sh/bashate.vim + +After: + call ale#linter#Reset() + +Execute(The bashate handler should handle basic errors): + AssertEqual + \ [ + \ { + \ 'lnum': 777, + \ 'col': 1, + \ 'text': 'E003 Indent not multiple of 4', + \ }, + \ { + \ 'lnum': 783, + \ 'col': 1, + \ 'text': 'E020 Function declaration not in format ^function name {$', + \ }, + \ { + \ 'lnum': 786, + \ 'col': 1, + \ 'text': 'E010 The "do" should be on same line as for', + \ }, + \ { + \ 'lnum': 791, + \ 'col': 1, + \ 'text': 'E006 Line too long', + \ }, + \ ], + \ ale_linters#sh#bashate#Handle(bufnr(''), [ + \ 'run:777:1: E003 Indent not multiple of 4', + \ 'run:783:1: E020 Function declaration not in format ^function name {$', + \ 'run:786:1: E010 The "do" should be on same line as for', + \ 'run:791:1: E006 Line too long', + \ ]) diff --git a/test/handler/test_puppet_handler.vader b/test/handler/test_puppet_handler.vader index e03cd42d..03adc9f0 100644 --- a/test/handler/test_puppet_handler.vader +++ b/test/handler/test_puppet_handler.vader @@ -63,3 +63,15 @@ Execute(The puppet handler should correctly parse errors that are reported befor \ ale_linters#puppet#puppet#Handle(255, [ \ "Error: Illegal attempt to assign to 'a Name'. Not an assignable reference (file: /tmp/modules/waffles/manifests/syrup.pp, line: 5, column: 11)", \ ]) +Execute(The puppet handler should parse lines when end of input is the location): + AssertEqual + \ [ + \ { + \ 'lnum': 0, + \ 'col': 0, + \ 'text': "Syntax error at end of input" + \ }, + \ ], + \ ale_linters#puppet#puppet#Handle(255, [ + \ "Error: Could not parse for environment production: Syntax error at end of input (file: /tmp//modules/test/manifests/init.pp)", + \ ]) |