Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Bartek thindil Jasicki 2019-10-31 09:42:58 +01:00
commit 3e4a23cb14
24 changed files with 202 additions and 33 deletions

View file

@ -20,7 +20,7 @@ function! ale_linters#cpp#clangcheck#GetCommand(buffer) abort
" being generated. These are only added if no build directory can be
" detected.
return '%e -analyze %s'
\ . (empty(l:build_dir) ? ' -extra-arg -Xclang -extra-arg -analyzer-output=text' : '')
\ . (empty(l:build_dir) ? ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics': '')
\ . ale#Pad(l:user_options)
\ . (!empty(l:build_dir) ? ' -p ' . ale#Escape(l:build_dir) : '')
endfunction

View file

@ -2,6 +2,7 @@
" Description: plugin for Psalm, static analyzer for PHP
call ale#Set('psalm_langserver_executable', 'psalm')
call ale#Set('psalm_langserver_options', '')
call ale#Set('psalm_langserver_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#php#psalm#GetProjectRoot(buffer) abort
@ -10,12 +11,16 @@ function! ale_linters#php#psalm#GetProjectRoot(buffer) abort
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
endfunction
function! ale_linters#php#psalm#GetCommand(buffer) abort
return '%e --language-server' . ale#Pad(ale#Var(a:buffer, 'psalm_langserver_options'))
endfunction
call ale#linter#Define('php', {
\ 'name': 'psalm',
\ 'lsp': 'stdio',
\ 'executable': {b -> ale#node#FindExecutable(b, 'psalm_langserver', [
\ 'vendor/bin/psalm',
\ ])},
\ 'command': '%e --language-server',
\ 'command': function('ale_linters#php#psalm#GetCommand'),
\ 'project_root': function('ale_linters#php#psalm#GetProjectRoot'),
\})

View file

@ -267,14 +267,22 @@ function! ale#assert#TearDownLinterTest() abort
endif
endfunction
function! ale#assert#SetUpFixerTest(filetype, name) abort
function! ale#assert#SetUpFixerTest(filetype, name, ...) abort
" If the suffix of the option names format is different, an additional
" argument can be used for that instead.
if a:0 > 1
throw 'Too many arguments'
endif
" Set up a marker so ALE doesn't create real random temporary filenames.
let g:ale_create_dummy_temporary_file = 1
let l:function_name = ale#fix#registry#GetFunc(a:name)
let s:FixerFunction = function(l:function_name)
let l:prefix = 'ale_' . a:filetype . '_' . a:name
let l:option_suffix = get(a:000, 0, a:name)
let l:prefix = 'ale_' . a:filetype . '_'
\ . substitute(l:option_suffix, '-', '_', 'g')
let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix'
for l:key in filter(keys(g:), b:filter_expr)
@ -286,7 +294,7 @@ function! ale#assert#SetUpFixerTest(filetype, name) abort
unlet b:[l:key]
endfor
execute 'runtime autoload/ale/fixers/' . a:name . '.vim'
execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim'
if !exists('g:dir')
call ale#test#SetDirectory('/testplugin/test/fixers')

View file

@ -235,6 +235,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['haskell'],
\ 'description': 'Refactor Haskell files with stylish-haskell.',
\ },
\ 'purty': {
\ 'function': 'ale#fixers#purty#Fix',
\ 'suggested_filetypes': ['purescript'],
\ 'description': 'Format PureScript files with purty.',
\ },
\ 'ocamlformat': {
\ 'function': 'ale#fixers#ocamlformat#Fix',
\ 'suggested_filetypes': ['ocaml'],
@ -350,6 +355,11 @@ let s:default_registry = {
\ 'suggested_filetypes': ['nix'],
\ 'description': 'A formatter for Nix code',
\ },
\ 'html-beautify': {
\ 'function': 'ale#fixers#html_beautify#Fix',
\ 'suggested_filetypes': ['html', 'htmldjango'],
\ 'description': 'Fix HTML files with html-beautify.',
\ },
\}
" Reset the function registry to the default entries.

View file

@ -0,0 +1,21 @@
" Author: WhyNotHugo <hugo@barrera.io>
" Description: Lint HTML files with html-beautify.
"
call ale#Set('html_beautify_executable', 'html-beautify')
call ale#Set('html_beautify_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('html_beautify_options', '')
call ale#Set('html_beautify_change_directory', 1)
function! ale#fixers#html_beautify#Fix(buffer) abort
let l:executable = ale#python#FindExecutable(
\ a:buffer,
\ 'html_beautify',
\ ['html-beautify']
\)
let l:options = ale#Var(a:buffer, 'html_beautify_options')
return {
\ 'command': ale#Escape(l:executable). ' ' . l:options . ' -',
\}
endfunction

View file

@ -0,0 +1,22 @@
" Author: iclanzan <sorin@iclanzan.com>
" Description: Integration of purty with ALE.
call ale#Set('purescript_purty_executable', 'purty')
function! ale#fixers#purty#GetExecutable(buffer) abort
let l:executable = ale#Var(a:buffer, 'purescript_purty_executable')
return ale#Escape(l:executable)
endfunction
function! ale#fixers#purty#Fix(buffer) abort
let l:executable = ale#fixers#purty#GetExecutable(a:buffer)
return {
\ 'command': l:executable
\ . ' --write'
\ . ' %t',
\ 'read_temporary_file': 1,
\}
endfunction

View file

@ -3,6 +3,7 @@
call ale#Set('stylelint_executable', 'stylelint')
call ale#Set('stylelint_use_global', get(g:, 'ale_use_global_executables', 0))
call ale#Set('stylelint_options', '')
function! ale#fixers#stylelint#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'stylelint', [
@ -13,10 +14,14 @@ endfunction
function! ale#fixers#stylelint#Fix(buffer) abort
let l:executable = ale#fixers#stylelint#GetExecutable(a:buffer)
let l:options = ale#Var(a:buffer, 'stylelint_options')
return {
\ 'command': ale#node#Executable(a:buffer, l:executable)
\ . ' --fix %t',
\ 'command': ale#path#BufferCdString(a:buffer)
\ . ale#node#Executable(a:buffer, l:executable)
\ . ' %t'
\ . ale#Pad(l:options)
\ . ' --fix',
\ 'read_temporary_file': 1,
\}
endfunction

View file

@ -23,6 +23,8 @@ let g:ale_sign_offset = get(g:, 'ale_sign_offset', 1000000)
let g:ale_sign_column_always = get(g:, 'ale_sign_column_always', 0)
let g:ale_sign_highlight_linenrs = get(g:, 'ale_sign_highlight_linenrs', 0)
let s:supports_sign_groups = has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
if !hlexists('ALEErrorSign')
highlight link ALEErrorSign error
endif
@ -149,7 +151,7 @@ function! ale#sign#GetSignName(sublist) abort
endfunction
function! s:PriorityCmd() abort
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if s:supports_sign_groups
return ' priority=' . g:ale_sign_priority . ' '
else
return ''
@ -157,7 +159,7 @@ function! s:PriorityCmd() abort
endfunction
function! s:GroupCmd() abort
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if s:supports_sign_groups
return ' group=ale '
else
return ' '
@ -175,7 +177,7 @@ function! ale#sign#ReadSigns(buffer) abort
endfunction
function! ale#sign#ParsePattern() abort
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if s:supports_sign_groups
" Matches output like :
" line=4 id=1 group=ale name=ALEErrorSign
" строка=1 id=1000001 группа=ale имя=ALEErrorSign
@ -460,7 +462,7 @@ endfunction
" Remove all signs.
function! ale#sign#Clear() abort
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if s:supports_sign_groups
sign unplace group=ale *
else
sign unplace *

View file

@ -9,6 +9,16 @@ fecs *ale-html-fecs*
and both of them reads `./.fecsrc` as the default configuration file.
See: |ale-javascript-fecs|.
===============================================================================
html-beautify *ale-html-beautify*
g:ale_html_beautify_options *g:ale_html_beautify_options*
*b:ale_html_beautify_options*
Type: |String|
Default: `''`
This variable can be changed to modify flags given to html-beautify.
===============================================================================
htmlhint *ale-html-htmlhint*

View file

@ -189,6 +189,13 @@ g:ale_php_psalm_executable *g:ale_php_psalm_executable*
This variable sets the executable used for psalm.
g:ale_psalm_langserver_options *g:ale_psalm_langserver_options*
*b:ale_psalm_langserver_options*
Type: |String|
Default: `''`
This variable can be set to pass additional options to psalm.
===============================================================================
php-cs-fixer *ale-php-php-cs-fixer*

View file

@ -29,5 +29,14 @@ g:ale_purescript_ls_config g:ale_purescript_ls_config
\ 'buildCommand': 'spago build -- --json-errors'
\ }
\}
===============================================================================
purty *ale-purescript-purty*
g:ale_purescript_purty_executable *g:ale_purescript_purty_executable*
*b:ale_purescript_purty_executable*
Type: |String|
Default: `'purty'`
This variable can be changed to use a different executable for purty.
===============================================================================
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl:

View file

@ -195,6 +195,7 @@ Notes:
* HTML
* `alex`!!
* `fecs`
* `html-beautify`
* `HTMLHint`
* `prettier`
* `proselint`
@ -349,6 +350,7 @@ Notes:
* `puppet-lint`
* PureScript
* `purescript-language-server`
* `purty`
* Python
* `autopep8`
* `bandit`

View file

@ -2294,6 +2294,7 @@ documented in additional help files.
terraform-fmt.........................|ale-hcl-terraform-fmt|
html....................................|ale-html-options|
fecs..................................|ale-html-fecs|
html-beautify.........................|ale-html-beautify|
htmlhint..............................|ale-html-htmlhint|
tidy..................................|ale-html-tidy|
prettier..............................|ale-html-prettier|
@ -2418,6 +2419,7 @@ documented in additional help files.
puppet-languageserver.................|ale-puppet-languageserver|
purescript..............................|ale-purescript-options|
purescript-language-server............|ale-purescript-language-server|
purty.................................|ale-purescript-purty|
pyrex (cython)..........................|ale-pyrex-options|
cython................................|ale-pyrex-cython|
python..................................|ale-python-options|

View file

@ -204,6 +204,7 @@ formatting.
* HTML
* [alex](https://github.com/wooorm/alex) :floppy_disk:
* [fecs](http://fecs.baidu.com/)
* [html-beautify](https://beautifier.io/)
* [HTMLHint](http://htmlhint.com/)
* [prettier](https://github.com/prettier/prettier)
* [proselint](http://proselint.com/)
@ -358,6 +359,7 @@ formatting.
* [puppet-lint](https://puppet-lint.com)
* PureScript
* [purescript-language-server](https://github.com/nwolverson/purescript-language-server)
* [purty](https://gitlab.com/joneshf/purty)
* Python
* [autopep8](https://github.com/hhatto/autopep8)
* [bandit](https://github.com/PyCQA/bandit) :warning:

View file

@ -7,7 +7,7 @@ After:
Execute(The executable should be configurable):
AssertLinter 'clang-check',
\ ale#Escape('clang-check')
\ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text'
\ . ' -analyze %s --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics'
let b:ale_cpp_clangcheck_executable = 'foobar'
@ -15,7 +15,7 @@ Execute(The executable should be configurable):
" being generated.
AssertLinter 'foobar',
\ ale#Escape('foobar')
\ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text'
\ . ' -analyze %s --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics'
Execute(The options should be configurable):
let b:ale_cpp_clangcheck_options = '--something'
@ -23,7 +23,7 @@ Execute(The options should be configurable):
AssertLinter 'clang-check',
\ ale#Escape('clang-check')
\ . ' -analyze %s'
\ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text'
\ . ' --extra-arg=-Xclang --extra-arg=-analyzer-output=text --extra-arg=-fno-color-diagnostics'
\ . ' --something'
Execute(The build directory should be used when set):

View file

@ -22,6 +22,14 @@ Execute(Vendor executables should be detected):
\ . '/psalm-project/vendor/bin/psalm'
\ )) . ' --language-server'
Execute(User provided options should be used):
let g:ale_psalm_langserver_options = '--my-user-provided-option my-value'
AssertLinter 'psalm',
\ ale#Escape('psalm')
\ . ' --language-server --my-user-provided-option my-value'
Execute(The project path should be correct for .git directories):
call ale#test#SetFilename('psalm-project/test.php')

View file

@ -0,0 +1,16 @@
Before:
call ale#assert#SetUpFixerTest('html', 'html-beautify', 'beautify')
call ale#test#SetDirectory('/testplugin/test/fixers')
silent cd ..
silent cd command_callback
After:
Restore
call ale#assert#TearDownFixerTest()
Execute(The html-beautify callback should return the correct default command):
AssertEqual
\ {'command': '''html-beautify'' -'},
\ ale#fixers#html_beautify#Fix(bufnr(''))

View file

@ -0,0 +1,24 @@
Before:
Save g:ale_purescript_purty_executable
" Use an invalid global executable, so we don't match it.
let g:ale_purescript_purty_executable = 'my-special-purty'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The purty callback should return the correct options):
call ale#test#SetFilename('../purescript_files/testfile.purs')
AssertEqual
\ {
\ 'command': ale#Escape('my-special-purty')
\ . ' --write'
\ . ' %t',
\ 'read_temporary_file': 1,
\ },
\ ale#fixers#purty#Fix(bufnr(''))

View file

@ -1,17 +1,33 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
call ale#assert#SetUpFixerTest('css', 'stylelint')
After:
call ale#test#RestoreDirectory()
call ale#assert#TearDownFixerTest()
Execute(The executable path should be correct):
Execute(The stylelint callback should return the correct default values):
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.css')
AssertEqual
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command': (has('win32') ? 'node.exe ' : '')
\ 'command': ale#path#CdString(expand('%:p:h'))
\ . (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js'))
\ . ' --fix %t',
\ },
\ ale#fixers#stylelint#Fix(bufnr(''))
\ . ' %t'
\ . ' --fix',
\ }
Execute(The stylelint callback should include custom stylelint options):
let g:ale_stylelint_options = '--cache'
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.css')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#path#CdString(expand('%:p:h'))
\ . (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js'))
\ . ' %t'
\ . ' --cache'
\ . ' --fix',
\ }

View file

@ -32,7 +32,7 @@ Before:
function! CollectSigns()
redir => l:output
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
silent exec 'sign place group=ale'
else
silent exec 'sign place'

View file

@ -1,5 +1,5 @@
Execute (Parsing English signs should work):
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[9, 1000001, 'ALEWarningSign']]],
\ ale#sign#ParseSigns([
@ -16,7 +16,7 @@ Execute (Parsing English signs should work):
endif
Execute (Parsing Russian signs should work):
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[1, 1000001, 'ALEErrorSign']]],
\ ale#sign#ParseSigns([' строка=1 id=1000001 группа=ale имя=ALEErrorSign'])
@ -27,7 +27,7 @@ Execute (Parsing Russian signs should work):
endif
Execute (Parsing Japanese signs should work):
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[1, 1000001, 'ALEWarningSign']]],
\ ale#sign#ParseSigns([' 行=1 識別子=1000001 グループ=ale 名前=ALEWarningSign'])
@ -38,7 +38,7 @@ Execute (Parsing Japanese signs should work):
endif
Execute (Parsing Spanish signs should work):
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[12, 1000001, 'ALEWarningSign']]],
\ ale#sign#ParseSigns([' línea=12 id=1000001 grupo=ale nombre=ALEWarningSign'])
@ -49,7 +49,7 @@ Execute (Parsing Spanish signs should work):
endif
Execute (Parsing Italian signs should work):
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[1, 1000001, 'ALEWarningSign']]],
\ ale#sign#ParseSigns([' riga=1 id=1000001, gruppo=ale nome=ALEWarningSign'])
@ -60,7 +60,7 @@ Execute (Parsing Italian signs should work):
endif
Execute (Parsing German signs should work):
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [0, [[235, 1000001, 'ALEErrorSign']]],
\ ale#sign#ParseSigns([' Zeile=235 id=1000001 Gruppe=ale Name=ALEErrorSign'])
@ -71,7 +71,7 @@ Execute (Parsing German signs should work):
endif
Execute (The sign parser should indicate if the dummy sign is set):
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
AssertEqual
\ [1, [[1, 1000001, 'ALEErrorSign']]],
\ ale#sign#ParseSigns([

View file

@ -68,7 +68,7 @@ Before:
function! ParseSigns()
redir => l:output
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
silent sign place group=ale
else
silent sign place
@ -152,7 +152,7 @@ Execute(The current signs should be set for running a job):
\ ParseSigns()
Execute(Loclist items with sign_id values should be kept):
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('')
exec 'sign place 1000348 group=ale line=15 name=ALEErrorSign buffer=' . bufnr('')
exec 'sign place 1000349 group=ale line=16 name=ALEWarningSign buffer=' . bufnr('')
@ -297,7 +297,7 @@ Execute(No exceptions should be thrown when setting signs for invalid buffers):
Execute(Signs should be removed when lines have multiple sign IDs on them):
" We can fail to remove signs if there are multiple signs on one line,
" say after deleting lines in Vim, etc.
if has('nvim-0.4.0') || (v:version >= 801 && has('patch614'))
if has('nvim-0.4.2') || (v:version >= 801 && has('patch614'))
exec 'sign place 1000347 group=ale line=3 name=ALEErrorSign buffer=' . bufnr('')
exec 'sign place 1000348 group=ale line=3 name=ALEWarningSign buffer=' . bufnr('')
exec 'sign place 1000349 group=ale line=10 name=ALEErrorSign buffer=' . bufnr('')