Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Bartek thindil Jasicki 2021-01-08 09:43:19 +01:00
commit 7b1ed2733e
12 changed files with 158 additions and 13 deletions

View File

@ -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],

4
ale_linters/php/intelephense.vim Normal file → Executable file
View File

@ -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', {

View File

@ -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'
\})

View File

@ -2,24 +2,35 @@
" Description: Fixing Python imports with isort.
call ale#Set('python_isort_executable', 'isort')
call ale#Set('python_isort_options', '')
call ale#Set('python_isort_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('python_isort_options', '')
call ale#Set('python_isort_auto_pipenv', 0)
function! ale#fixers#isort#GetExecutable(buffer) abort
if (ale#Var(a:buffer, 'python_auto_pipenv') || ale#Var(a:buffer, 'python_isort_auto_pipenv'))
\ && ale#python#PipenvPresent(a:buffer)
return 'pipenv'
endif
return ale#python#FindExecutable(a:buffer, 'python_isort', ['isort'])
endfunction
function! ale#fixers#isort#Fix(buffer) abort
let l:options = ale#Var(a:buffer, 'python_isort_options')
let l:executable = ale#python#FindExecutable(
\ a:buffer,
\ 'python_isort',
\ ['isort'],
\)
let l:executable = ale#fixers#isort#GetExecutable(a:buffer)
if !executable(l:executable)
let l:exec_args = l:executable =~? 'pipenv$'
\ ? ' run isort'
\ : ''
if !executable(l:executable) && l:executable isnot# 'pipenv'
return 0
endif
return {
\ 'command': ale#path#BufferCdString(a:buffer)
\ . ale#Escape(l:executable) . (!empty(l:options) ? ' ' . l:options : '') . ' -',
\ . ale#Escape(l:executable) . l:exec_args
\ . (!empty(l:options) ? ' ' . l:options : '') . ' -',
\}
endfunction

View File

@ -280,6 +280,15 @@ g:ale_python_isort_use_global *g:ale_python_isort_use_global*
See |ale-integrations-local-executables|
g:ale_python_isort_auto_pipenv *g:ale_python_isort_auto_pipenv*
*b:ale_python_isort_auto_pipenv*
Type: |Number|
Default: `0`
Detect whether the file is inside a pipenv, and set the executable to `pipenv`
if true. This is overridden by a manually-set executable.
===============================================================================
mypy *ale-python-mypy*

43
doc/ale-salt.tmt Normal file
View File

@ -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:

View File

@ -429,6 +429,8 @@ Notes:
* `rust-analyzer`
* `rustc` (see |ale-integration-rust|)
* `rustfmt`
* Salt
* `salt-lint`
* Sass
* `sass-lint`
* `stylelint`

View File

@ -2883,6 +2883,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|

View File

@ -438,6 +438,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)

View File

@ -5,6 +5,7 @@ Before:
" Use an invalid global executable, so we don't match it.
let g:ale_python_isort_executable = 'xxxinvalid'
let g:ale_python_isort_options = ''
let g:ale_python_isort_auto_pipenv = 0
call ale#test#SetDirectory('/testplugin/test/fixers')
silent cd ..
@ -48,3 +49,12 @@ Execute(The isort callback should respect custom options):
\ . ' --multi-line=3 --trailing-comma -',
\ },
\ ale#fixers#isort#Fix(bufnr(''))
Execute(Pipenv is detected when python_isort_auto_pipenv is set):
let g:ale_python_isort_auto_pipenv = 1
call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
AssertEqual
\ {'command': ale#path#BufferCdString(bufnr('')) . ale#Escape('pipenv') . ' run isort -'},
\ ale#fixers#isort#Fix(bufnr(''))

View File

@ -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.',

View File

@ -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"}]'
\ ])