summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ale_linters/dafny/dafny.vim2
-rw-r--r--ale_linters/java/checkstyle.vim2
-rwxr-xr-x[-rw-r--r--]ale_linters/php/intelephense.vim4
-rw-r--r--ale_linters/ruby/sorbet.vim5
-rw-r--r--ale_linters/salt/salt_lint.vim32
-rw-r--r--autoload/ale/fix/registry.vim5
-rw-r--r--autoload/ale/fixers/gofmt.vim3
-rw-r--r--autoload/ale/fixers/yamlfix.vim25
-rw-r--r--doc/ale-ruby.txt10
-rw-r--r--doc/ale-salt.tmt43
-rw-r--r--doc/ale-supported-languages-and-tools.txt3
-rw-r--r--doc/ale-yaml.txt38
-rw-r--r--doc/ale.txt3
-rw-r--r--supported-tools.md3
-rw-r--r--test/command_callback/python_paths/with_virtualenv/env/Scripts/yamlfix.exe0
-rwxr-xr-xtest/command_callback/python_paths/with_virtualenv/env/bin/yamlfix0
-rw-r--r--test/command_callback/test_sorbet_command_callback.vader7
-rw-r--r--test/fixers/test_gofmt_fixer_callback.vader14
-rw-r--r--test/fixers/test_yamlfix_fixer_callback.vader50
-rw-r--r--test/handler/test_dafny_handler.vader4
-rw-r--r--test/handler/test_salt_salt_lint.vader34
21 files changed, 265 insertions, 22 deletions
diff --git a/ale_linters/dafny/dafny.vim b/ale_linters/dafny/dafny.vim
index b5b90675..e6021d99 100644
--- a/ale_linters/dafny/dafny.vim
+++ b/ale_linters/dafny/dafny.vim
@@ -6,7 +6,7 @@ function! ale_linters#dafny#dafny#Handle(buffer, lines) abort
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
- \ 'bufnr': a:buffer,
+ \ 'filename': l:match[1],
\ 'col': l:match[3] + 0,
\ 'lnum': l:match[2] + 0,
\ 'text': l:match[5],
diff --git a/ale_linters/java/checkstyle.vim b/ale_linters/java/checkstyle.vim
index ec7339d1..f00734e0 100644
--- a/ale_linters/java/checkstyle.vim
+++ b/ale_linters/java/checkstyle.vim
@@ -9,7 +9,7 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
let l:output = []
" modern checkstyle versions
- let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$'
+ let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]'
for l:match in ale#util#GetMatches(a:lines, l:pattern)
call add(l:output, {
diff --git a/ale_linters/php/intelephense.vim b/ale_linters/php/intelephense.vim
index e9e07d1f..aca619e3 100644..100755
--- a/ale_linters/php/intelephense.vim
+++ b/ale_linters/php/intelephense.vim
@@ -18,8 +18,8 @@ function! ale_linters#php#intelephense#GetProjectRoot(buffer) abort
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
endfunction
-function! ale_linters#php#intelephense#GetInitializationOptions() abort
- return ale#Get('php_intelephense_config')
+function! ale_linters#php#intelephense#GetInitializationOptions(buffer) abort
+ return ale#Var(a:buffer, 'php_intelephense_config')
endfunction
call ale#linter#Define('php', {
diff --git a/ale_linters/ruby/sorbet.vim b/ale_linters/ruby/sorbet.vim
index cae0683c..c67e20cc 100644
--- a/ale_linters/ruby/sorbet.vim
+++ b/ale_linters/ruby/sorbet.vim
@@ -1,14 +1,17 @@
call ale#Set('ruby_sorbet_executable', 'srb')
call ale#Set('ruby_sorbet_options', '')
+call ale#Set('ruby_sorbet_enable_watchman', 0)
function! ale_linters#ruby#sorbet#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'ruby_sorbet_executable')
let l:options = ale#Var(a:buffer, 'ruby_sorbet_options')
+ let l:enable_watchman = ale#Var(a:buffer, 'ruby_sorbet_enable_watchman')
return ale#ruby#EscapeExecutable(l:executable, 'srb')
\ . ' tc'
\ . (!empty(l:options) ? ' ' . l:options : '')
- \ . ' --lsp --disable-watchman'
+ \ . ' --lsp'
+ \ . (l:enable_watchman ? '' : ' --disable-watchman')
endfunction
call ale#linter#Define('ruby', {
diff --git a/ale_linters/salt/salt_lint.vim b/ale_linters/salt/salt_lint.vim
new file mode 100644
index 00000000..d2027119
--- /dev/null
+++ b/ale_linters/salt/salt_lint.vim
@@ -0,0 +1,32 @@
+" Author: Benjamin BINIER <poulpatine@gmail.com>
+" Description: salt-lint, saltstack linter
+
+call ale#Set('salt_salt_lint_executable', 'salt-lint')
+call ale#Set('salt_salt_lint_options', '')
+
+function! ale_linters#salt#salt_lint#GetCommand(buffer) abort
+ return '%e' . ale#Pad(ale#Var(a:buffer, 'salt_salt_lint_options'))
+ \ . ' --json'
+endfunction
+
+function! ale_linters#salt#salt_lint#Handle(buffer, lines) abort
+ let l:output = []
+
+ for l:error in ale#util#FuzzyJSONDecode(a:lines, [])
+ call add(l:output, {
+ \ 'lnum': l:error.linenumber + 0,
+ \ 'code': l:error.id + 0,
+ \ 'text': l:error.message,
+ \ 'type': l:error.severity is# 'HIGH' ? 'E' : 'W',
+ \})
+ endfor
+
+ return l:output
+endfunction
+
+call ale#linter#Define('salt', {
+\ 'name': 'salt-lint',
+\ 'executable': {b -> ale#Var(b, 'salt_salt_lint_executable')},
+\ 'command': function('ale_linters#salt#salt_lint#GetCommand'),
+\ 'callback': 'ale_linters#salt#salt_lint#Handle'
+\})
diff --git a/autoload/ale/fix/registry.vim b/autoload/ale/fix/registry.vim
index 3a88ede1..0f146faa 100644
--- a/autoload/ale/fix/registry.vim
+++ b/autoload/ale/fix/registry.vim
@@ -110,6 +110,11 @@ let s:default_registry = {
\ 'suggested_filetypes': [],
\ 'description': 'Remove all trailing whitespace characters at the end of every line.',
\ },
+\ 'yamlfix': {
+\ 'function': 'ale#fixers#yamlfix#Fix',
+\ 'suggested_filetypes': ['yaml'],
+\ 'description': 'Fix yaml files with yamlfix.',
+\ },
\ 'yapf': {
\ 'function': 'ale#fixers#yapf#Fix',
\ 'suggested_filetypes': ['python'],
diff --git a/autoload/ale/fixers/gofmt.vim b/autoload/ale/fixers/gofmt.vim
index d5a539b9..b9cfbb58 100644
--- a/autoload/ale/fixers/gofmt.vim
+++ b/autoload/ale/fixers/gofmt.vim
@@ -11,9 +11,6 @@ function! ale#fixers#gofmt#Fix(buffer) abort
return {
\ 'command': l:env . ale#Escape(l:executable)
- \ . ' -l -w'
\ . (empty(l:options) ? '' : ' ' . l:options)
- \ . ' %t',
- \ 'read_temporary_file': 1,
\}
endfunction
diff --git a/autoload/ale/fixers/yamlfix.vim b/autoload/ale/fixers/yamlfix.vim
new file mode 100644
index 00000000..966556c9
--- /dev/null
+++ b/autoload/ale/fixers/yamlfix.vim
@@ -0,0 +1,25 @@
+" Author: lyz-code
+" Description: Fixing yaml files with yamlfix.
+
+call ale#Set('yaml_yamlfix_executable', 'yamlfix')
+call ale#Set('yaml_yamlfix_options', '')
+call ale#Set('yaml_yamlfix_use_global', get(g:, 'ale_use_global_executables', 0))
+
+function! ale#fixers#yamlfix#Fix(buffer) abort
+ let l:options = ale#Var(a:buffer, 'yaml_yamlfix_options')
+
+ let l:executable = ale#python#FindExecutable(
+ \ a:buffer,
+ \ 'yaml_yamlfix',
+ \ ['yamlfix'],
+ \)
+
+ if !executable(l:executable)
+ return 0
+ endif
+
+ return {
+ \ 'command': ale#path#BufferCdString(a:buffer)
+ \ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -',
+ \}
+endfunction
diff --git a/doc/ale-ruby.txt b/doc/ale-ruby.txt
index 8815404a..edc6144a 100644
--- a/doc/ale-ruby.txt
+++ b/doc/ale-ruby.txt
@@ -177,6 +177,16 @@ g:ale_ruby_sorbet_options *g:ale_ruby_sorbet_options*
This variable can be changed to modify flags given to sorbet.
+g:ale_ruby_sorbet_enable_watchman *g:ale_ruby_sorbet_enable_watchman*
+ *b:ale_ruby_sorbet_enable_watchman*
+ Type: |Number|
+ Default: `0`
+
+ Whether or not to use watchman to let the LSP server to know about changes
+ to files from outside of vim. Defaults to disable watchman because it
+ requires watchman to be installed separately from sorbet.
+
+
===============================================================================
standardrb *ale-ruby-standardrb*
diff --git a/doc/ale-salt.tmt b/doc/ale-salt.tmt
new file mode 100644
index 00000000..ac500d37
--- /dev/null
+++ b/doc/ale-salt.tmt
@@ -0,0 +1,43 @@
+===============================================================================
+ALE SALT Integration *ale-salt-options*
+
+===============================================================================
+salt-lint *ale-salt-salt-lint*
+
+Website: https://github.com/warpnet/salt-lint
+
+
+Installation
+-------------------------------------------------------------------------------
+
+Install salt-lint in your a virtualenv directory, locally, or globally: >
+
+ pip install salt-lint # After activating virtualenv
+ pip install --user salt-lint # Install to ~/.local/bin
+ sudo pip install salt-lint # Install globally
+
+See |g:ale_virtualenv_dir_names| for configuring how ALE searches for
+virtualenv directories.
+
+
+Options
+-------------------------------------------------------------------------------
+
+g:ale_salt_salt-lint_executable *g:ale_salt_salt_lint_executable*
+ *b:ale_salt_salt_lint_executable*
+ Type: |String|
+ Default: `'salt-lint'`
+
+ This variable can be set to change the path to salt-lint.
+
+
+g:ale_salt_salt-lint_options *g:ale_salt_salt-lint_options*
+ *b:ale_salt_salt-lint_options*
+ Type: |String|
+ Default: `''`
+
+ This variable can be set to pass additional options to salt-lint.
+
+
+===============================================================================
+ vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index f4673ec0..4844d0aa 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -428,6 +428,8 @@ Notes:
* `rust-analyzer`
* `rustc` (see |ale-integration-rust|)
* `rustfmt`
+* Salt
+ * `salt-lint`
* Sass
* `sass-lint`
* `stylelint`
@@ -524,6 +526,7 @@ Notes:
* YAML
* `prettier`
* `swaglint`
+ * `yamlfix`
* `yamllint`
* YANG
* `yang-lsp`
diff --git a/doc/ale-yaml.txt b/doc/ale-yaml.txt
index c9a12ea1..61bfc139 100644
--- a/doc/ale-yaml.txt
+++ b/doc/ale-yaml.txt
@@ -15,7 +15,6 @@ Install prettier either globally or locally: >
npm install prettier -g # global
npm install prettier # local
<
-
===============================================================================
swaglint *ale-yaml-swaglint*
@@ -49,6 +48,43 @@ g:ale_yaml_swaglint_use_global *g:ale_yaml_swaglint_use_global*
See |ale-integrations-local-executables|
+===============================================================================
+yamlfix *ale-yaml-yamlfix*
+
+Website: https://lyz-code.github.io/yamlfix
+
+
+Installation
+-------------------------------------------------------------------------------
+
+Install yamlfix: >
+
+ pip install yamlfix
+<
+
+Options
+-------------------------------------------------------------------------------
+g:ale_yaml_yamlfix_executable *g:ale_yaml_yamlfix_executable*
+ *b:ale_yaml_yamlfix_executable*
+ Type: |String|
+ Default: `'yamlfix'`
+
+ See |ale-integrations-local-executables|
+
+
+g:ale_yaml_yamlfix_options *g:ale_yaml_yamlfix_options*
+ *b:ale_yaml_yamlfix_options*
+ Type: |String|
+ Default: `''`
+
+ This variable can be set to pass extra options to yamlfix.
+
+g:ale_yaml_yamlfix_use_global *g:ale_yaml_yamlfix_use_global*
+ *b:ale_yaml_yamlfix_use_global*
+ Type: |Number|
+ Default: `get(g:, 'ale_use_global_executables', 0)`
+
+ See |ale-integrations-local-executables|
===============================================================================
yamllint *ale-yaml-yamllint*
diff --git a/doc/ale.txt b/doc/ale.txt
index 00f43aa5..d23e6fb6 100644
--- a/doc/ale.txt
+++ b/doc/ale.txt
@@ -2882,6 +2882,8 @@ documented in additional help files.
rls...................................|ale-rust-rls|
rustc.................................|ale-rust-rustc|
rustfmt...............................|ale-rust-rustfmt|
+ salt....................................|ale-salt-options|
+ salt-lint.............................|ale-salt-salt-lint|
sass....................................|ale-sass-options|
sasslint..............................|ale-sass-sasslint|
stylelint.............................|ale-sass-stylelint|
@@ -2971,6 +2973,7 @@ documented in additional help files.
yaml....................................|ale-yaml-options|
prettier..............................|ale-yaml-prettier|
swaglint..............................|ale-yaml-swaglint|
+ yamlfix...............................|ale-yaml-yamlfix|
yamllint..............................|ale-yaml-yamllint|
yang....................................|ale-yang-options|
yang-lsp..............................|ale-yang-lsp|
diff --git a/supported-tools.md b/supported-tools.md
index e1ac8873..9d70b6b2 100644
--- a/supported-tools.md
+++ b/supported-tools.md
@@ -437,6 +437,8 @@ formatting.
* [rust-analyzer](https://github.com/rust-analyzer/rust-analyzer) :warning:
* [rustc](https://www.rust-lang.org/) :warning:
* [rustfmt](https://github.com/rust-lang-nursery/rustfmt)
+* Salt
+ * [salt-lint](https://github.com/warpnet/salt-lint)
* Sass
* [sass-lint](https://www.npmjs.com/package/sass-lint)
* [stylelint](https://github.com/stylelint/stylelint)
@@ -533,6 +535,7 @@ formatting.
* YAML
* [prettier](https://github.com/prettier/prettier)
* [swaglint](https://github.com/byCedric/swaglint)
+ * [yamlfix](https://lyz-code.github.io/yamlfix)
* [yamllint](https://yamllint.readthedocs.io/)
* YANG
* [yang-lsp](https://github.com/theia-ide/yang-lsp)
diff --git a/test/command_callback/python_paths/with_virtualenv/env/Scripts/yamlfix.exe b/test/command_callback/python_paths/with_virtualenv/env/Scripts/yamlfix.exe
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/python_paths/with_virtualenv/env/Scripts/yamlfix.exe
diff --git a/test/command_callback/python_paths/with_virtualenv/env/bin/yamlfix b/test/command_callback/python_paths/with_virtualenv/env/bin/yamlfix
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/python_paths/with_virtualenv/env/bin/yamlfix
diff --git a/test/command_callback/test_sorbet_command_callback.vader b/test/command_callback/test_sorbet_command_callback.vader
index b46e90a4..fe758635 100644
--- a/test/command_callback/test_sorbet_command_callback.vader
+++ b/test/command_callback/test_sorbet_command_callback.vader
@@ -5,6 +5,7 @@ Before:
let g:ale_ruby_sorbet_executable = 'srb'
let g:ale_ruby_sorbet_options = ''
+ let g:ale_ruby_sorbet_enable_watchman = 0
After:
call ale#assert#TearDownLinterTest()
@@ -13,6 +14,12 @@ Execute(Executable should default to srb):
AssertLinter 'srb', ale#Escape('srb')
\ . ' tc --lsp --disable-watchman'
+Execute(Able to enable watchman):
+ let g:ale_ruby_sorbet_enable_watchman = 1
+
+ AssertLinter 'srb', ale#Escape('srb')
+ \ . ' tc --lsp'
+
Execute(Should be able to set a custom executable):
let g:ale_ruby_sorbet_executable = 'bin/srb'
diff --git a/test/fixers/test_gofmt_fixer_callback.vader b/test/fixers/test_gofmt_fixer_callback.vader
index 16659655..99407173 100644
--- a/test/fixers/test_gofmt_fixer_callback.vader
+++ b/test/fixers/test_gofmt_fixer_callback.vader
@@ -21,10 +21,7 @@ Execute(The gofmt callback should return the correct default values):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
- \ 'command': ale#Escape('xxxinvalid')
- \ . ' -l -w'
- \ . ' %t',
+ \ 'command': ale#Escape('xxxinvalid'),
\ },
\ ale#fixers#gofmt#Fix(bufnr(''))
@@ -35,11 +32,8 @@ Execute(The gofmt callback should include custom gofmt options):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
- \ . ' -l -w'
- \ . ' ' . g:ale_go_gofmt_options
- \ . ' %t',
+ \ . ' ' . g:ale_go_gofmt_options,
\ },
\ ale#fixers#gofmt#Fix(bufnr(''))
@@ -50,9 +44,7 @@ Execute(The gofmt callback should support Go environment variables):
AssertEqual
\ {
- \ 'read_temporary_file': 1,
\ 'command': ale#Env('GO111MODULE', 'off')
- \ . ale#Escape('xxxinvalid') . ' -l -w'
- \ . ' %t',
+ \ . ale#Escape('xxxinvalid')
\ },
\ ale#fixers#gofmt#Fix(bufnr(''))
diff --git a/test/fixers/test_yamlfix_fixer_callback.vader b/test/fixers/test_yamlfix_fixer_callback.vader
new file mode 100644
index 00000000..3ffda91e
--- /dev/null
+++ b/test/fixers/test_yamlfix_fixer_callback.vader
@@ -0,0 +1,50 @@
+Before:
+ Save g:ale_python_yamlfix_executable
+ Save g:ale_python_yamlfix_options
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_python_yamlfix_executable = 'xxxinvalid'
+ let g:ale_python_yamlfix_options = ''
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+ silent cd ..
+ silent cd command_callback
+ let g:dir = getcwd()
+
+ let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
+
+After:
+ Restore
+
+ unlet! b:bin_dir
+
+ call ale#test#RestoreDirectory()
+
+Execute(The yamlfix callback should return the correct default values):
+ AssertEqual
+ \ 0,
+ \ ale#fixers#yamlfix#Fix(bufnr(''))
+
+ silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.yaml')
+ AssertEqual
+ \ {
+ \ 'command': ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/yamlfix')) . ' -',
+ \ },
+ \ ale#fixers#yamlfix#Fix(bufnr(''))
+
+Execute(The yamlfix callback should respect custom options):
+ let g:ale_yaml_yamlfix_options = '--multi-line=3 --trailing-comma'
+
+ AssertEqual
+ \ 0,
+ \ ale#fixers#yamlfix#Fix(bufnr(''))
+
+ silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.yaml')
+ AssertEqual
+ \ {
+ \ 'command': ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/yamlfix'))
+ \ . ' --multi-line=3 --trailing-comma -',
+ \ },
+ \ ale#fixers#yamlfix#Fix(bufnr(''))
diff --git a/test/handler/test_dafny_handler.vader b/test/handler/test_dafny_handler.vader
index 674f691d..797d348e 100644
--- a/test/handler/test_dafny_handler.vader
+++ b/test/handler/test_dafny_handler.vader
@@ -8,14 +8,14 @@ Execute(The Dafny handler should parse output correctly):
AssertEqual
\ [
\ {
- \ 'bufnr': 0,
+ \ 'filename': 'File.dfy',
\ 'col': 45,
\ 'lnum': 123,
\ 'text': 'A precondition for this call might not hold.',
\ 'type': 'E'
\ },
\ {
- \ 'bufnr': 0,
+ \ 'filename': 'File.dfy',
\ 'col': 90,
\ 'lnum': 678,
\ 'text': 'This is the precondition that might not hold.',
diff --git a/test/handler/test_salt_salt_lint.vader b/test/handler/test_salt_salt_lint.vader
new file mode 100644
index 00000000..7e234785
--- /dev/null
+++ b/test/handler/test_salt_salt_lint.vader
@@ -0,0 +1,34 @@
+Before:
+ runtime ale_linters/salt/salt_lint.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The salt handler should parse lines correctly and show error in severity HIGH):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 5,
+ \ 'code': 207,
+ \ 'text': 'File modes should always be encapsulated in quotation marks',
+ \ 'type': 'E'
+ \ }
+ \ ],
+ \ ale_linters#salt#salt_lint#Handle(255, [
+ \ '[{"id": "207", "message": "File modes should always be encapsulated in quotation marks", "filename": "test.sls", "linenumber": 5, "line": " - mode: 0755", "severity": "HIGH"}]'
+ \ ])
+
+
+Execute(The salt handler should parse lines correctly and show error in severity not HIGH):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 27,
+ \ 'code': 204,
+ \ 'text': 'Lines should be no longer that 160 chars',
+ \ 'type': 'W'
+ \ }
+ \ ],
+ \ ale_linters#salt#salt_lint#Handle(255, [
+ \ '[{"id": "204", "message": "Lines should be no longer that 160 chars", "filename": "test2.sls", "linenumber": 27, "line": "this line is definitely longer than 160 chars, this line is definitely longer than 160 chars, this line is definitely longer than 160 chars", "severity": "VERY_LOW"}]'
+ \ ])