mirror of
https://github.com/amix/vimrc
synced 2025-08-02 11:04:59 +08:00
Updated vim plugins
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
" Author: Jon Parise <jon@indelible.org>
|
||||
" Description: elixir-ls integration (https://github.com/JakeBecker/elixir-ls)
|
||||
" Description: ElixirLS integration (https://github.com/JakeBecker/elixir-ls)
|
||||
|
||||
call ale#Set('elixir_elixir_ls_release', 'elixir-ls')
|
||||
call ale#Set('elixir_elixir_ls_config', {})
|
||||
|
||||
function! ale_linters#elixir#elixir_ls#GetExecutable(buffer) abort
|
||||
let l:dir = ale#path#Simplify(ale#Var(a:buffer, 'elixir_elixir_ls_release'))
|
||||
@ -15,5 +16,6 @@ call ale#linter#Define('elixir', {
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable_callback': 'ale_linters#elixir#elixir_ls#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#elixir#elixir_ls#GetExecutable',
|
||||
\ 'project_root_callback': 'ale#handlers#elixir#FindMixProjectRoot',
|
||||
\ 'project_root_callback': 'ale#handlers#elixir#FindMixUmbrellaRoot',
|
||||
\ 'lsp_config_callback': ale#VarFunc('elixir_elixir_ls_config'),
|
||||
\})
|
||||
|
@ -1,10 +1,21 @@
|
||||
" Author: neersighted <bjorn@neersighted.com>
|
||||
" Description: golint for Go files
|
||||
|
||||
call ale#Set('go_golint_executable', 'golint')
|
||||
call ale#Set('go_golint_options', '')
|
||||
|
||||
function! ale_linters#go#golint#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'go_golint_options')
|
||||
|
||||
return '%e'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'golint',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'executable': 'golint',
|
||||
\ 'command': 'golint %t',
|
||||
\ 'executable_callback': ale#VarFunc('go_golint_executable'),
|
||||
\ 'command_callback': 'ale_linters#go#golint#GetCommand',
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
@ -1,6 +1,12 @@
|
||||
" Author: Patrick Lewis - https://github.com/patricklewis, thenoseman - https://github.com/thenoseman
|
||||
" Description: haml-lint for Haml files
|
||||
|
||||
call ale#Set('haml_hamllint_executable', 'haml-lint')
|
||||
|
||||
function! ale_linters#haml#hamllint#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'haml_hamllint_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#haml#hamllint#GetCommand(buffer) abort
|
||||
let l:prefix = ''
|
||||
|
||||
@ -21,7 +27,7 @@ function! ale_linters#haml#hamllint#GetCommand(buffer) abort
|
||||
endif
|
||||
|
||||
return (!empty(l:prefix) ? l:prefix . ' ' : '')
|
||||
\ . 'haml-lint'
|
||||
\ . ale_linters#haml#hamllint#GetExecutable(a:buffer)
|
||||
\ . (!empty(l:hamllint_config_file_path) ? ' --config ' . ale#Escape(l:hamllint_config_file_path) : '')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
@ -45,7 +51,7 @@ endfunction
|
||||
|
||||
call ale#linter#Define('haml', {
|
||||
\ 'name': 'hamllint',
|
||||
\ 'executable': 'haml-lint',
|
||||
\ 'executable_callback': 'ale_linters#haml#hamllint#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#haml#hamllint#GetCommand',
|
||||
\ 'callback': 'ale_linters#haml#hamllint#Handle'
|
||||
\})
|
||||
|
@ -2,9 +2,11 @@
|
||||
" Description: checkstyle for Java files
|
||||
|
||||
function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v\[(WARN|ERROR)\] [a-zA-Z]?:?[^:]+:(\d+):(\d+)?:? (.*) \[(.+)\]$'
|
||||
let l:output = []
|
||||
|
||||
" modern checkstyle versions
|
||||
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, {
|
||||
\ 'type': l:match[1] is? 'WARN' ? 'W' : 'E',
|
||||
@ -15,13 +17,24 @@ function! ale_linters#java#checkstyle#Handle(buffer, lines) abort
|
||||
\})
|
||||
endfor
|
||||
|
||||
" old checkstyle versions
|
||||
let l:pattern = '\v(.+):(\d+): ([^:]+): (.+)$'
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'type': l:match[3] is? 'warning' ? 'W' : 'E',
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#checkstyle#GetCommand(buffer) abort
|
||||
return 'checkstyle '
|
||||
\ . ale#Var(a:buffer, 'java_checkstyle_options')
|
||||
\ . ' %t'
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
|
||||
if !exists('g:ale_java_checkstyle_options')
|
||||
@ -33,4 +46,5 @@ call ale#linter#Define('java', {
|
||||
\ 'executable': 'checkstyle',
|
||||
\ 'command_callback': 'ale_linters#java#checkstyle#GetCommand',
|
||||
\ 'callback': 'ale_linters#java#checkstyle#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
||||
|
@ -2,15 +2,17 @@
|
||||
" Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac
|
||||
|
||||
call ale#Set('java_javalsp_jar', 'javacs.jar')
|
||||
call ale#Set('java_javalsp_executable', 'java')
|
||||
|
||||
function! ale_linters#java#javalsp#Executable(buffer) abort
|
||||
return 'java'
|
||||
return ale#Var(a:buffer, 'java_javalsp_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#java#javalsp#Command(buffer) abort
|
||||
let l:jar = ale#Var(a:buffer, 'java_javalsp_jar')
|
||||
let l:executable = ale_linters#java#javalsp#Executable(a:buffer)
|
||||
|
||||
return ale#Escape('java -cp ' . l:jar . ' -Xverify:none org.javacs.Main')
|
||||
return ale#Escape(l:executable) . ' -cp ' . l:jar . ' -Xverify:none org.javacs.Main'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('java', {
|
||||
|
@ -1,6 +1,8 @@
|
||||
" Author: Spencer Wood <https://github.com/scwood>, Adriaan Zonnenberg <amz@adriaan.xyz>
|
||||
" Description: This file adds support for checking PHP with php-cli
|
||||
|
||||
call ale#Set('php_php_executable', 'php')
|
||||
|
||||
function! ale_linters#php#php#Handle(buffer, lines) abort
|
||||
" Matches patterns like the following:
|
||||
"
|
||||
@ -30,8 +32,8 @@ endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'php',
|
||||
\ 'executable': 'php',
|
||||
\ 'executable_callback': ale#VarFunc('php_php_executable'),
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'command': 'php -l -d error_reporting=E_ALL -d display_errors=1 -d log_errors=0 --',
|
||||
\ 'command': '%e -l -d error_reporting=E_ALL -d display_errors=1 -d log_errors=0 --',
|
||||
\ 'callback': 'ale_linters#php#php#Handle',
|
||||
\})
|
||||
|
@ -6,15 +6,40 @@ let g:ale_php_phpstan_executable = get(g:, 'ale_php_phpstan_executable', 'phpsta
|
||||
let g:ale_php_phpstan_level = get(g:, 'ale_php_phpstan_level', '4')
|
||||
let g:ale_php_phpstan_configuration = get(g:, 'ale_php_phpstan_configuration', '')
|
||||
|
||||
function! ale_linters#php#phpstan#GetCommand(buffer) abort
|
||||
function! ale_linters#php#phpstan#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'php_phpstan_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phpstan#VersionCheck(buffer) abort
|
||||
let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer)
|
||||
|
||||
" If we have previously stored the version number in a cache, then
|
||||
" don't look it up again.
|
||||
if ale#semver#HasVersion(l:executable)
|
||||
" Returning an empty string skips this command.
|
||||
return ''
|
||||
endif
|
||||
|
||||
let l:executable = ale#Escape(l:executable)
|
||||
|
||||
return l:executable . ' --version'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#php#phpstan#GetCommand(buffer, version_output) abort
|
||||
let l:configuration = ale#Var(a:buffer, 'php_phpstan_configuration')
|
||||
let l:configuration_option = !empty(l:configuration)
|
||||
\ ? ' -c ' . l:configuration
|
||||
\ : ''
|
||||
|
||||
let l:executable = ale_linters#php#phpstan#GetExecutable(a:buffer)
|
||||
let l:version = ale#semver#GetVersion(l:executable, a:version_output)
|
||||
let l:error_format = ale#semver#GTE(l:version, [0, 10, 3])
|
||||
\ ? ' --error-format raw'
|
||||
\ : ' --errorFormat raw'
|
||||
|
||||
return '%e analyze -l'
|
||||
\ . ale#Var(a:buffer, 'php_phpstan_level')
|
||||
\ . ' --errorFormat raw'
|
||||
\ . l:error_format
|
||||
\ . l:configuration_option
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
@ -40,7 +65,10 @@ endfunction
|
||||
|
||||
call ale#linter#Define('php', {
|
||||
\ 'name': 'phpstan',
|
||||
\ 'executable_callback': ale#VarFunc('php_phpstan_executable'),
|
||||
\ 'command_callback': 'ale_linters#php#phpstan#GetCommand',
|
||||
\ 'executable_callback': 'ale_linters#php#phpstan#GetExecutable',
|
||||
\ 'command_chain': [
|
||||
\ {'callback': 'ale_linters#php#phpstan#VersionCheck'},
|
||||
\ {'callback': 'ale_linters#php#phpstan#GetCommand'},
|
||||
\ ],
|
||||
\ 'callback': 'ale_linters#php#phpstan#Handle',
|
||||
\})
|
||||
|
@ -110,6 +110,7 @@ function! ale_linters#python#flake8#Handle(buffer, lines) abort
|
||||
let l:item = {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'vcol': 1,
|
||||
\ 'text': l:match[4],
|
||||
\ 'code': l:code,
|
||||
\ 'type': 'W',
|
||||
|
@ -13,36 +13,6 @@ function! ale_linters#ruby#rubocop#GetCommand(buffer) abort
|
||||
\ . ' --stdin ' . ale#Escape(expand('#' . a:buffer . ':p'))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#ruby#rubocop#Handle(buffer, lines) abort
|
||||
try
|
||||
let l:errors = json_decode(a:lines[0])
|
||||
catch
|
||||
return []
|
||||
endtry
|
||||
|
||||
if !has_key(l:errors, 'summary')
|
||||
\|| l:errors['summary']['offense_count'] == 0
|
||||
\|| empty(l:errors['files'])
|
||||
return []
|
||||
endif
|
||||
|
||||
let l:output = []
|
||||
|
||||
for l:error in l:errors['files'][0]['offenses']
|
||||
let l:start_col = l:error['location']['column'] + 0
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:error['location']['line'] + 0,
|
||||
\ 'col': l:start_col,
|
||||
\ 'end_col': l:start_col + l:error['location']['length'] - 1,
|
||||
\ 'code': l:error['cop_name'],
|
||||
\ 'text': l:error['message'],
|
||||
\ 'type': ale_linters#ruby#rubocop#GetType(l:error['severity']),
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#ruby#rubocop#GetType(severity) abort
|
||||
if a:severity is? 'convention'
|
||||
\|| a:severity is? 'warning'
|
||||
@ -57,5 +27,5 @@ call ale#linter#Define('ruby', {
|
||||
\ 'name': 'rubocop',
|
||||
\ 'executable_callback': ale#VarFunc('ruby_rubocop_executable'),
|
||||
\ 'command_callback': 'ale_linters#ruby#rubocop#GetCommand',
|
||||
\ 'callback': 'ale_linters#ruby#rubocop#Handle',
|
||||
\ 'callback': 'ale#ruby#HandleRubocopOutput',
|
||||
\})
|
||||
|
@ -1,9 +1,28 @@
|
||||
" Author: KabbAmine - https://github.com/KabbAmine,
|
||||
" Ben Falconer <ben@falconers.me.uk>
|
||||
" Author: sQVe - https://github.com/sQVe
|
||||
|
||||
call ale#Set('sass_sasslint_executable', 'sass-lint')
|
||||
call ale#Set('sass_sasslint_options', '')
|
||||
call ale#Set('sass_sasslint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale_linters#sass#sasslint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'sass_sasslint', [
|
||||
\ 'node_modules/sass-lint/bin/sass-lint.js',
|
||||
\ 'node_modules/.bin/sass-lint',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#sass#sasslint#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#sass#sasslint#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'sass_sasslint_options')
|
||||
|
||||
return ale#node#Executable(a:buffer, l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -v -q -f compact %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('sass', {
|
||||
\ 'name': 'sasslint',
|
||||
\ 'executable': 'sass-lint',
|
||||
\ 'command_callback': 'ale#handlers#sasslint#GetCommand',
|
||||
\ 'executable_callback': 'ale_linters#sass#sasslint#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#sass#sasslint#GetCommand',
|
||||
\ 'callback': 'ale#handlers#css#HandleCSSLintFormat',
|
||||
\})
|
||||
|
@ -1,18 +1,28 @@
|
||||
" Author: KabbAmine - https://github.com/KabbAmine, Ben Falconer
|
||||
" <ben@falconers.me.uk>
|
||||
" Author: sQVe - https://github.com/sQVe
|
||||
|
||||
call ale#Set('scss_sasslint_executable', 'sass-lint')
|
||||
call ale#Set('scss_sasslint_options', '')
|
||||
call ale#Set('scss_sasslint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale_linters#scss#sasslint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'scss_sasslint', [
|
||||
\ 'node_modules/sass-lint/bin/sass-lint.js',
|
||||
\ 'node_modules/.bin/sass-lint',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#scss#sasslint#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape('sass-lint')
|
||||
\ . ' -v'
|
||||
\ . ' -q'
|
||||
\ . ' -f compact'
|
||||
\ . ' %t'
|
||||
let l:executable = ale_linters#scss#sasslint#GetExecutable(a:buffer)
|
||||
let l:options = ale#Var(a:buffer, 'scss_sasslint_options')
|
||||
|
||||
return ale#node#Executable(a:buffer, l:executable)
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -v -q -f compact %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('scss', {
|
||||
\ 'name': 'sasslint',
|
||||
\ 'executable': 'sass-lint',
|
||||
\ 'executable_callback': 'ale_linters#scss#sasslint#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#scss#sasslint#GetCommand',
|
||||
\ 'callback': 'ale#handlers#css#HandleCSSLintFormat',
|
||||
\})
|
||||
|
@ -1,6 +1,24 @@
|
||||
" Author: David Mohundro <david@mohundro.com>
|
||||
" Author: David Mohundro <david@mohundro.com>, Gordon Fontenot <gordon@fonten.io>
|
||||
" Description: swiftlint for swift files
|
||||
|
||||
call ale#Set('swift_swiftlint_executable', 'swiftlint')
|
||||
call ale#Set('swift_swiftlint_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale_linters#swift#swiftlint#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'swift_swiftlint', [
|
||||
\ 'Pods/SwiftLint/swiftlint',
|
||||
\ 'ios/Pods/SwiftLint/swiftlint',
|
||||
\ 'swiftlint',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#swift#swiftlint#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#swift#swiftlint#GetExecutable(a:buffer)
|
||||
let l:args = 'lint --use-stdin'
|
||||
|
||||
return ale#Escape(l:executable)
|
||||
\ . ' ' .l:args
|
||||
endfunction
|
||||
|
||||
function! ale_linters#swift#swiftlint#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):(\d+)?:? ([^:]+): (.+)$'
|
||||
@ -8,10 +26,10 @@ function! ale_linters#swift#swiftlint#Handle(buffer, lines) abort
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:item = {
|
||||
\ 'lnum': str2nr(l:match[2]),
|
||||
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
|
||||
\ 'text': l:match[5],
|
||||
\}
|
||||
\ 'lnum': str2nr(l:match[2]),
|
||||
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
|
||||
\ 'text': l:match[5],
|
||||
\}
|
||||
|
||||
if l:match[4] is# 'error'
|
||||
let l:item.type = 'E'
|
||||
@ -45,7 +63,7 @@ endfunction
|
||||
|
||||
call ale#linter#Define('swift', {
|
||||
\ 'name': 'swiftlint',
|
||||
\ 'executable': 'swiftlint',
|
||||
\ 'command': 'swiftlint lint --use-stdin',
|
||||
\ 'executable_callback': 'ale_linters#swift#swiftlint#GetExecutable',
|
||||
\ 'command_callback': 'ale_linters#swift#swiftlint#GetCommand',
|
||||
\ 'callback': 'ale_linters#swift#swiftlint#Handle',
|
||||
\})
|
||||
|
@ -8,20 +8,26 @@ function! ale_linters#tex#lacheck#Handle(buffer, lines) abort
|
||||
"
|
||||
" "book.tex", line 37: possible unwanted space at "{"
|
||||
" "book.tex", line 38: missing `\ ' after "etc."
|
||||
let l:pattern = '^".\+", line \(\d\+\): \(.\+\)$'
|
||||
let l:pattern = '^"\(.\+\)", line \(\d\+\): \(.\+\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
" lacheck follows `\input{}` commands. If the cwd is not the same as the
|
||||
" file in the buffer then it will fail to find the inputed items. We do not
|
||||
" want warnings from those items anyway
|
||||
if !empty(matchstr(l:match[2], '^Could not open ".\+"$'))
|
||||
if !empty(matchstr(l:match[3], '^Could not open ".\+"$'))
|
||||
continue
|
||||
endif
|
||||
|
||||
" lacheck follows `\input{}` commands. We are only interested in
|
||||
" reporting errors for the current buffer only.
|
||||
if empty(matchstr(fnamemodify(l:match[1], ':t'), fnamemodify(bufname(a:buffer), ':t')))
|
||||
continue
|
||||
endif
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'text': l:match[2],
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': 'W',
|
||||
\})
|
||||
endfor
|
||||
|
Reference in New Issue
Block a user