Updated plugins
This commit is contained in:
parent
8e54cbc92e
commit
a7a471a207
265 changed files with 7773 additions and 1880 deletions
26
sources_non_forked/ale/ale_linters/ada/adals.vim
Normal file
26
sources_non_forked/ale/ale_linters/ada/adals.vim
Normal file
|
@ -0,0 +1,26 @@
|
|||
" Author: Bartek Jasicki http://github.com/thindil
|
||||
" Description: Support for Ada Language Server
|
||||
|
||||
call ale#Set('ada_adals_executable', 'ada_language_server')
|
||||
call ale#Set('ada_adals_project', 'default.gpr')
|
||||
call ale#Set('ada_adals_encoding', 'utf-8')
|
||||
|
||||
function! ale_linters#ada#adals#GetAdaLSConfig(buffer) abort
|
||||
return {
|
||||
\ 'ada.projectFile': ale#Var(a:buffer, 'ada_adals_project'),
|
||||
\ 'ada.defaultCharset': ale#Var(a:buffer, 'ada_adals_encoding')
|
||||
\}
|
||||
endfunction
|
||||
|
||||
function! ale_linters#ada#adals#GetRootDirectory(buffer) abort
|
||||
return fnamemodify(bufname(a:buffer), ':p:h')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('ada', {
|
||||
\ 'name': 'adals',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#Var(b, 'ada_adals_executable')},
|
||||
\ 'command': '%e',
|
||||
\ 'project_root': function('ale_linters#ada#adals#GetRootDirectory'),
|
||||
\ 'lsp_config': function('ale_linters#ada#adals#GetAdaLSConfig')
|
||||
\})
|
|
@ -1,4 +1,4 @@
|
|||
" Author: Bjorn Neergaard <bjorn@neersighted.com>
|
||||
" Authors: Bjorn Neergaard <bjorn@neersighted.com>, Vytautas Macionis <vytautas.macionis@manomail.de>
|
||||
" Description: ansible-lint for ansible-yaml files
|
||||
|
||||
call ale#Set('ansible_ansible_lint_executable', 'ansible-lint')
|
||||
|
@ -7,7 +7,7 @@ function! ale_linters#ansible#ansible_lint#GetExecutable(buffer) abort
|
|||
return ale#Var(a:buffer, 'ansible_ansible_lint_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort
|
||||
function! ale_linters#ansible#ansible_lint#Handle(buffer, version, lines) abort
|
||||
for l:line in a:lines[:10]
|
||||
if match(l:line, '^Traceback') >= 0
|
||||
return [{
|
||||
|
@ -18,11 +18,34 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort
|
|||
endif
|
||||
endfor
|
||||
|
||||
let l:version_group = ale#semver#GTE(a:version, [5, 0, 0]) ? '>=5.0.0' : '<5.0.0'
|
||||
let l:output = []
|
||||
|
||||
if '>=5.0.0' is# l:version_group
|
||||
" Matches patterns line the following:
|
||||
" test.yml:3:148: syntax-check 'var' is not a valid attribute for a Play
|
||||
" roles/test/tasks/test.yml:8: [package-latest] [VERY_LOW] Package installs should not use latest
|
||||
" D:\test\tasks\test.yml:8: [package-latest] [VERY_LOW] package installs should not use latest
|
||||
let l:pattern = '\v^(%([a-zA-Z]:)?[^:]+):(\d+):%((\d+):)? %(\[([-[:alnum:]]+)\]) %(\[([_[:alnum:]]+)\]) (.*)$'
|
||||
let l:error_codes = { 'VERY_HIGH': 'E', 'HIGH': 'E', 'MEDIUM': 'W', 'LOW': 'W', 'VERY_LOW': 'W', 'INFO': 'I' }
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
if ale#path#IsBufferPath(a:buffer, l:match[1])
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'text': l:match[6],
|
||||
\ 'code': l:match[4],
|
||||
\ 'type': l:error_codes[l:match[5]],
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
if '<5.0.0' is# l:version_group
|
||||
" Matches patterns line the following:
|
||||
"
|
||||
" test.yml:35: [EANSIBLE0002] Trailing whitespace
|
||||
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?: \[?([[:alnum:]]+)\]? (.*)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:code = l:match[4]
|
||||
|
@ -43,14 +66,38 @@ function! ale_linters#ansible#ansible_lint#Handle(buffer, lines) abort
|
|||
\})
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#ansible#ansible_lint#GetCommand(buffer, version) abort
|
||||
let l:commands = {
|
||||
\ '>=5.0.0': '%e --parseable-severity -x yaml',
|
||||
\ '<5.0.0': '%e -p %t'
|
||||
\}
|
||||
let l:command = ale#semver#GTE(a:version, [5, 0]) ? l:commands['>=5.0.0'] : l:commands['<5.0.0']
|
||||
|
||||
return l:command
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('ansible', {
|
||||
\ 'name': 'ansible_lint',
|
||||
\ 'aliases': ['ansible', 'ansible-lint'],
|
||||
\ 'executable': function('ale_linters#ansible#ansible_lint#GetExecutable'),
|
||||
\ 'command': '%e -p %t',
|
||||
\ 'callback': 'ale_linters#ansible#ansible_lint#Handle',
|
||||
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale_linters#ansible#ansible_lint#GetExecutable(buffer),
|
||||
\ '%e --version',
|
||||
\ function('ale_linters#ansible#ansible_lint#GetCommand'),
|
||||
\ )},
|
||||
\ 'callback': {buffer, lines -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale_linters#ansible#ansible_lint#GetExecutable(buffer),
|
||||
\ '%e --version',
|
||||
\ {buffer, version -> ale_linters#ansible#ansible_lint#Handle(
|
||||
\ buffer,
|
||||
\ l:version,
|
||||
\ lines)},
|
||||
\ )},
|
||||
\})
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
" Author: Leo <thinkabit.ukim@gmail.com>
|
||||
" Description: apkbuild-lint from atools linter for APKBUILDs
|
||||
|
||||
call ale#Set('apkbuild_apkbuild_lint_executable', 'apkbuild-lint')
|
||||
|
||||
call ale#linter#Define('apkbuild', {
|
||||
\ 'name': 'apkbuild_lint',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable': {b -> ale#Var(b, 'apkbuild_apkbuild_lint_executable')},
|
||||
\ 'command': '%e %t',
|
||||
\ 'callback': 'ale#handlers#atools#Handle',
|
||||
\})
|
|
@ -0,0 +1,12 @@
|
|||
" Author: Leo <thinkabit.ukim@gmail.com>
|
||||
" Description: secfixes-check from atools linter for APKBUILDs
|
||||
|
||||
call ale#Set('apkbuild_secfixes_check_executable', 'secfixes-check')
|
||||
|
||||
call ale#linter#Define('apkbuild', {
|
||||
\ 'name': 'secfixes_check',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable': {b -> ale#Var(b, 'apkbuild_secfixes_check_executable')},
|
||||
\ 'command': '%e %t',
|
||||
\ 'callback': 'ale#handlers#atools#Handle',
|
||||
\})
|
|
@ -5,15 +5,13 @@ call ale#Set('c_cppcheck_executable', 'cppcheck')
|
|||
call ale#Set('c_cppcheck_options', '--enable=style')
|
||||
|
||||
function! ale_linters#c#cppcheck#GetCommand(buffer) abort
|
||||
let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer)
|
||||
let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer)
|
||||
let l:buffer_path_include = empty(l:compile_commands_option)
|
||||
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer)
|
||||
\ : ''
|
||||
let l:template = ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
|
||||
let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
|
||||
|
||||
return l:cd_command
|
||||
\ . '%e -q --language=c'
|
||||
return '%e -q --language=c'
|
||||
\ . l:template
|
||||
\ . ale#Pad(l:compile_commands_option)
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'c_cppcheck_options'))
|
||||
|
@ -25,6 +23,7 @@ call ale#linter#Define('c', {
|
|||
\ 'name': 'cppcheck',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'executable': {b -> ale#Var(b, 'c_cppcheck_executable')},
|
||||
\ 'cwd': function('ale#handlers#cppcheck#GetCwd'),
|
||||
\ 'command': function('ale_linters#c#cppcheck#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
|
||||
\})
|
||||
|
|
|
@ -29,6 +29,7 @@ endfunction
|
|||
|
||||
call ale#linter#Define('cloudformation', {
|
||||
\ 'name': 'cloudformation',
|
||||
\ 'aliases': ['cfn-lint'],
|
||||
\ 'executable': 'cfn-lint',
|
||||
\ 'command': 'cfn-lint --template %t --format parseable',
|
||||
\ 'callback': 'ale_linters#cloudformation#cfn_python_lint#Handle',
|
||||
|
|
|
@ -23,12 +23,14 @@ function! ale_linters#cpp#clangtidy#GetCommand(buffer, output) abort
|
|||
let l:options = ale#Var(a:buffer, 'cpp_clangtidy_options')
|
||||
let l:cflags = ale#c#GetCFlags(a:buffer, a:output)
|
||||
let l:options .= !empty(l:options) ? ale#Pad(l:cflags) : l:cflags
|
||||
endif
|
||||
|
||||
" Tell clang-tidy a .h header with a C++ filetype in Vim is a C++ file.
|
||||
" Tell clang-tidy a .h header with a C++ filetype in Vim is a C++ file
|
||||
" only when compile-commands.json file is not there. Adding these
|
||||
" flags makes clang-tidy completely ignore compile commmands.
|
||||
if expand('#' . a:buffer) =~# '\.h$'
|
||||
let l:options .= !empty(l:options) ? ' -x c++' : '-x c++'
|
||||
endif
|
||||
endif
|
||||
|
||||
" Get the options to pass directly to clang-tidy
|
||||
let l:extra_options = ale#Var(a:buffer, 'cpp_clangtidy_extra_options')
|
||||
|
|
|
@ -5,15 +5,13 @@ call ale#Set('cpp_cppcheck_executable', 'cppcheck')
|
|||
call ale#Set('cpp_cppcheck_options', '--enable=style')
|
||||
|
||||
function! ale_linters#cpp#cppcheck#GetCommand(buffer) abort
|
||||
let l:cd_command = ale#handlers#cppcheck#GetCdCommand(a:buffer)
|
||||
let l:compile_commands_option = ale#handlers#cppcheck#GetCompileCommandsOptions(a:buffer)
|
||||
let l:buffer_path_include = empty(l:compile_commands_option)
|
||||
\ ? ale#handlers#cppcheck#GetBufferPathIncludeOptions(a:buffer)
|
||||
\ : ''
|
||||
let l:template = ' --template=''{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}'''
|
||||
let l:template = ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
|
||||
|
||||
return l:cd_command
|
||||
\ . '%e -q --language=c++'
|
||||
return '%e -q --language=c++'
|
||||
\ . l:template
|
||||
\ . ale#Pad(l:compile_commands_option)
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'cpp_cppcheck_options'))
|
||||
|
@ -25,6 +23,7 @@ call ale#linter#Define('cpp', {
|
|||
\ 'name': 'cppcheck',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'executable': {b -> ale#Var(b, 'cpp_cppcheck_executable')},
|
||||
\ 'cwd': function('ale#handlers#cppcheck#GetCwd'),
|
||||
\ 'command': function('ale_linters#cpp#cppcheck#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#cppcheck#HandleCppCheckFormat',
|
||||
\})
|
||||
|
|
|
@ -3,14 +3,10 @@ call ale#Set('cs_csc_source', '')
|
|||
call ale#Set('cs_csc_assembly_path', [])
|
||||
call ale#Set('cs_csc_assemblies', [])
|
||||
|
||||
function! s:GetWorkingDirectory(buffer) abort
|
||||
let l:working_directory = ale#Var(a:buffer, 'cs_csc_source')
|
||||
function! ale_linters#cs#csc#GetCwd(buffer) abort
|
||||
let l:cwd = ale#Var(a:buffer, 'cs_csc_source')
|
||||
|
||||
if !empty(l:working_directory)
|
||||
return l:working_directory
|
||||
endif
|
||||
|
||||
return expand('#' . a:buffer . ':p:h')
|
||||
return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#cs#csc#GetCommand(buffer) abort
|
||||
|
@ -34,8 +30,7 @@ function! ale_linters#cs#csc#GetCommand(buffer) abort
|
|||
|
||||
" The code is compiled as a module and the output is redirected to a
|
||||
" temporary file.
|
||||
return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
|
||||
\ . 'csc /unsafe'
|
||||
return 'csc /unsafe'
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'cs_csc_options'))
|
||||
\ . ale#Pad(l:lib_option)
|
||||
\ . ale#Pad(l:r_option)
|
||||
|
@ -57,8 +52,7 @@ function! ale_linters#cs#csc#Handle(buffer, lines) abort
|
|||
\ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$',
|
||||
\]
|
||||
let l:output = []
|
||||
|
||||
let l:dir = s:GetWorkingDirectory(a:buffer)
|
||||
let l:dir = ale_linters#cs#csc#GetCwd(a:buffer)
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:patterns)
|
||||
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS'
|
||||
|
@ -89,6 +83,7 @@ call ale#linter#Define('cs',{
|
|||
\ 'name': 'csc',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable': 'csc',
|
||||
\ 'cwd': function('ale_linters#cs#csc#GetCwd'),
|
||||
\ 'command': function('ale_linters#cs#csc#GetCommand'),
|
||||
\ 'callback': 'ale_linters#cs#csc#Handle',
|
||||
\ 'lint_file': 1
|
||||
|
|
|
@ -3,14 +3,10 @@ call ale#Set('cs_mcsc_source', '')
|
|||
call ale#Set('cs_mcsc_assembly_path', [])
|
||||
call ale#Set('cs_mcsc_assemblies', [])
|
||||
|
||||
function! s:GetWorkingDirectory(buffer) abort
|
||||
let l:working_directory = ale#Var(a:buffer, 'cs_mcsc_source')
|
||||
function! ale_linters#cs#mcsc#GetCwd(buffer) abort
|
||||
let l:cwd = ale#Var(a:buffer, 'cs_mcsc_source')
|
||||
|
||||
if !empty(l:working_directory)
|
||||
return l:working_directory
|
||||
endif
|
||||
|
||||
return expand('#' . a:buffer . ':p:h')
|
||||
return !empty(l:cwd) ? l:cwd : expand('#' . a:buffer . ':p:h')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#cs#mcsc#GetCommand(buffer) abort
|
||||
|
@ -34,8 +30,7 @@ function! ale_linters#cs#mcsc#GetCommand(buffer) abort
|
|||
|
||||
" The code is compiled as a module and the output is redirected to a
|
||||
" temporary file.
|
||||
return ale#path#CdString(s:GetWorkingDirectory(a:buffer))
|
||||
\ . 'mcs -unsafe'
|
||||
return 'mcs -unsafe'
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'cs_mcsc_options'))
|
||||
\ . ale#Pad(l:lib_option)
|
||||
\ . ale#Pad(l:r_option)
|
||||
|
@ -58,7 +53,7 @@ function! ale_linters#cs#mcsc#Handle(buffer, lines) abort
|
|||
\]
|
||||
let l:output = []
|
||||
|
||||
let l:dir = s:GetWorkingDirectory(a:buffer)
|
||||
let l:dir = ale_linters#cs#mcsc#GetCwd(a:buffer)
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:patterns)
|
||||
if len(l:match) > 6 && strlen(l:match[5]) > 2 && l:match[5][:1] is? 'CS'
|
||||
|
@ -89,6 +84,7 @@ call ale#linter#Define('cs',{
|
|||
\ 'name': 'mcsc',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'mcs',
|
||||
\ 'cwd': function('ale_linters#cs#mcsc#GetCwd'),
|
||||
\ 'command': function('ale_linters#cs#mcsc#GetCommand'),
|
||||
\ 'callback': 'ale_linters#cs#mcsc#Handle',
|
||||
\ 'lint_file': 1
|
||||
|
|
23
sources_non_forked/ale/ale_linters/cuda/clangd.vim
Normal file
23
sources_non_forked/ale/ale_linters/cuda/clangd.vim
Normal file
|
@ -0,0 +1,23 @@
|
|||
" Author: Tommy Chiang <ty1208chiang@gmail.com>
|
||||
" Description: Clangd language server for CUDA (modified from Andrey
|
||||
" Melentyev's implementation for C++)
|
||||
|
||||
call ale#Set('cuda_clangd_executable', 'clangd')
|
||||
call ale#Set('cuda_clangd_options', '')
|
||||
call ale#Set('c_build_dir', '')
|
||||
|
||||
function! ale_linters#cuda#clangd#GetCommand(buffer) abort
|
||||
let l:build_dir = ale#c#GetBuildDirectory(a:buffer)
|
||||
|
||||
return '%e'
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'cuda_clangd_options'))
|
||||
\ . (!empty(l:build_dir) ? ' -compile-commands-dir=' . ale#Escape(l:build_dir) : '')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('cuda', {
|
||||
\ 'name': 'clangd',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#Var(b, 'cuda_clangd_executable')},
|
||||
\ 'command': function('ale_linters#cuda#clangd#GetCommand'),
|
||||
\ 'project_root': function('ale#c#FindProjectRoot'),
|
||||
\})
|
|
@ -1,64 +1,106 @@
|
|||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: "dmd for D files"
|
||||
|
||||
function! ale_linters#d#dmd#GetDUBCommand(buffer) abort
|
||||
function! s:GetDUBCommand(buffer) abort
|
||||
" If we can't run dub, then skip this command.
|
||||
if !executable('dub')
|
||||
if executable('dub')
|
||||
" Returning an empty string skips to the DMD command.
|
||||
return ''
|
||||
endif
|
||||
let l:config = ale#d#FindDUBConfig(a:buffer)
|
||||
|
||||
let l:dub_file = ale#d#FindDUBConfig(a:buffer)
|
||||
|
||||
if empty(l:dub_file)
|
||||
return ''
|
||||
endif
|
||||
|
||||
" To support older dub versions, we just change the directory to
|
||||
" the directory where we found the dub config, and then run `dub describe`
|
||||
" To support older dub versions, we just change the directory to the
|
||||
" directory where we found the dub config, and then run `dub describe`
|
||||
" from that directory.
|
||||
return 'cd ' . ale#Escape(fnamemodify(l:dub_file, ':h'))
|
||||
\ . ' && dub describe --import-paths'
|
||||
if !empty(l:config)
|
||||
return [fnamemodify(l:config, ':h'), 'dub describe --data-list
|
||||
\ --data=import-paths
|
||||
\ --data=string-import-paths
|
||||
\ --data=versions
|
||||
\ --data=debug-versions
|
||||
\']
|
||||
endif
|
||||
endif
|
||||
|
||||
return ['', '']
|
||||
endfunction
|
||||
|
||||
function! ale_linters#d#dmd#RunDUBCommand(buffer) abort
|
||||
let l:command = ale_linters#d#dmd#GetDUBCommand(a:buffer)
|
||||
let [l:cwd, l:command] = s:GetDUBCommand(a:buffer)
|
||||
|
||||
if empty(l:command)
|
||||
" If we can't run DUB, just run DMD.
|
||||
return ale_linters#d#dmd#DMDCommand(a:buffer, [], {})
|
||||
endif
|
||||
|
||||
return ale#command#Run(a:buffer, l:command, function('ale_linters#d#dmd#DMDCommand'))
|
||||
return ale#command#Run(
|
||||
\ a:buffer,
|
||||
\ l:command,
|
||||
\ function('ale_linters#d#dmd#DMDCommand'),
|
||||
\ {'cwd': l:cwd},
|
||||
\)
|
||||
endfunction
|
||||
|
||||
function! ale_linters#d#dmd#DMDCommand(buffer, dub_output, meta) abort
|
||||
let l:import_list = []
|
||||
let l:str_import_list = []
|
||||
let l:versions_list = []
|
||||
let l:deb_versions_list = []
|
||||
let l:list_ind = 1
|
||||
let l:seen_line = 0
|
||||
|
||||
" Build a list of import paths generated from DUB, if available.
|
||||
" Build a list of options generated from DUB, if available.
|
||||
" DUB output each path or version on a single line.
|
||||
" Each list is separated by a blank line.
|
||||
" Empty list are represented by a blank line (followed and/or
|
||||
" preceded by a separation blank line)
|
||||
for l:line in a:dub_output
|
||||
" line still has end of line char on windows
|
||||
let l:line = substitute(l:line, '[\r\n]*$', '', '')
|
||||
|
||||
if !empty(l:line)
|
||||
" The arguments must be '-Ifilename', not '-I filename'
|
||||
if l:list_ind == 1
|
||||
call add(l:import_list, '-I' . ale#Escape(l:line))
|
||||
elseif l:list_ind == 2
|
||||
call add(l:str_import_list, '-J' . ale#Escape(l:line))
|
||||
elseif l:list_ind == 3
|
||||
call add(l:versions_list, '-version=' . ale#Escape(l:line))
|
||||
elseif l:list_ind == 4
|
||||
call add(l:deb_versions_list, '-debug=' . ale#Escape(l:line))
|
||||
endif
|
||||
|
||||
let l:seen_line = 1
|
||||
elseif !l:seen_line
|
||||
" if list is empty must skip one empty line
|
||||
let l:seen_line = 1
|
||||
else
|
||||
let l:seen_line = 0
|
||||
let l:list_ind += 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
return 'dmd '. join(l:import_list) . ' -o- -wi -vcolumns -c %t'
|
||||
return 'dmd ' . join(l:import_list) . ' ' .
|
||||
\ join(l:str_import_list) . ' ' .
|
||||
\ join(l:versions_list) . ' ' .
|
||||
\ join(l:deb_versions_list) . ' -o- -wi -vcolumns -c %t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#d#dmd#Handle(buffer, lines) abort
|
||||
" Matches patterns lines like the following:
|
||||
" /tmp/tmp.qclsa7qLP7/file.d(1): Error: function declaration without return type. (Note that constructors are always named 'this')
|
||||
" /tmp/tmp.G1L5xIizvB.d(8,8): Error: module weak_reference is in file 'dstruct/weak_reference.d' which cannot be read
|
||||
let l:pattern = '^[^(]\+(\([0-9]\+\)\,\?\([0-9]*\)): \([^:]\+\): \(.\+\)'
|
||||
let l:pattern = '\v^(\f+)\((\d+)(,(\d+))?\): (\w+): (.+)$'
|
||||
let l:output = []
|
||||
let l:dir = expand('#' . a:buffer . ':p:h')
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
" If dmd was invoked with relative path, match[1] is relative, otherwise it is absolute.
|
||||
" As we invoke dmd with the buffer path (in /tmp), this will generally be absolute already
|
||||
let l:fname = ale#path#GetAbsPath(l:dir, l:match[1])
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1],
|
||||
\ 'col': l:match[2],
|
||||
\ 'type': l:match[3] is# 'Warning' ? 'W' : 'E',
|
||||
\ 'text': l:match[4],
|
||||
\ 'filename': l:fname,
|
||||
\ 'lnum': l:match[2],
|
||||
\ 'col': l:match[4],
|
||||
\ 'type': l:match[5] is# 'Warning' || l:match[5] is# 'Deprecation' ? 'W' : 'E',
|
||||
\ 'text': l:match[6],
|
||||
\})
|
||||
endfor
|
||||
|
||||
|
|
|
@ -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],
|
||||
|
@ -14,13 +14,28 @@ function! ale_linters#dafny#dafny#Handle(buffer, lines) abort
|
|||
\ })
|
||||
endfor
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, '\v(.*)\((\d+),(\d+)\): (Verification of .{-} timed out after \d+ seconds)')
|
||||
call add(l:output, {
|
||||
\ 'filename': l:match[1],
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\ 'type': 'E',
|
||||
\ })
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#dafny#dafny#GetCommand(buffer) abort
|
||||
return printf('dafny %%s /compile:0 /timeLimit:%d', ale#Var(a:buffer, 'dafny_dafny_timelimit'))
|
||||
endfunction
|
||||
|
||||
call ale#Set('dafny_dafny_timelimit', 10)
|
||||
call ale#linter#Define('dafny', {
|
||||
\ 'name': 'dafny',
|
||||
\ 'executable': 'dafny',
|
||||
\ 'command': 'dafny %s /compile:0',
|
||||
\ 'command': function('ale_linters#dafny#dafny#GetCommand'),
|
||||
\ 'callback': 'ale_linters#dafny#dafny#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\ })
|
||||
|
|
29
sources_non_forked/ale/ale_linters/dart/analysis_server.vim
Normal file
29
sources_non_forked/ale/ale_linters/dart/analysis_server.vim
Normal file
|
@ -0,0 +1,29 @@
|
|||
" Author: Nelson Yeung <nelsyeung@gmail.com>
|
||||
" Description: Check Dart files with dart analysis server LSP
|
||||
|
||||
call ale#Set('dart_analysis_server_executable', 'dart')
|
||||
|
||||
function! ale_linters#dart#analysis_server#GetProjectRoot(buffer) abort
|
||||
" Note: pub only looks for pubspec.yaml, there's no point in adding
|
||||
" support for pubspec.yml
|
||||
let l:pubspec = ale#path#FindNearestFile(a:buffer, 'pubspec.yaml')
|
||||
|
||||
return !empty(l:pubspec) ? fnamemodify(l:pubspec, ':h:h') : '.'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#dart#analysis_server#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'dart_analysis_server_executable')
|
||||
let l:dart = resolve(exepath(l:executable))
|
||||
|
||||
return '%e '
|
||||
\ . fnamemodify(l:dart, ':h') . '/snapshots/analysis_server.dart.snapshot'
|
||||
\ . ' --lsp'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('dart', {
|
||||
\ 'name': 'analysis_server',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#Var(b, 'dart_analysis_server_executable')},
|
||||
\ 'command': function('ale_linters#dart#analysis_server#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#dart#analysis_server#GetProjectRoot'),
|
||||
\})
|
|
@ -0,0 +1,31 @@
|
|||
call ale#Set('desktop_desktop_file_validate_options', '')
|
||||
|
||||
" Example matches for pattern:
|
||||
"
|
||||
" foo.desktop: warning: key "TerminalOptions" in group ...
|
||||
" foo.desktop: error: action "new-private-window" is defined, ...
|
||||
let s:pattern = '\v^(.+): ([a-z]+): (.+)$'
|
||||
|
||||
function! ale_linters#desktop#desktop_file_validate#Handle(buffer, lines) abort
|
||||
" The error format doesn't specify lines, so we can just put all of the
|
||||
" errors on line 1.
|
||||
return ale#util#MapMatches(a:lines, s:pattern, {match -> {
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 1,
|
||||
\ 'type': match[2] is? 'error' ? 'E' : 'W',
|
||||
\ 'text': match[3],
|
||||
\}})
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('desktop', {
|
||||
\ 'name': 'desktop_file_validate',
|
||||
\ 'aliases': ['desktop-file-validate'],
|
||||
\ 'executable': 'desktop-file-validate',
|
||||
\ 'command': {b ->
|
||||
\ '%e'
|
||||
\ . ale#Pad(ale#Var(b, 'desktop_desktop_file_validate_options'))
|
||||
\ . ' %t'
|
||||
\ },
|
||||
\ 'callback': 'ale_linters#desktop#desktop_file_validate#Handle',
|
||||
\ 'output_stream': 'both',
|
||||
\})
|
|
@ -9,7 +9,7 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
|
|||
"
|
||||
" /dev/stdin:19 DL3001 Pipe chain should start with a raw value.
|
||||
" /dev/stdin:19:3 unexpected thing
|
||||
let l:pattern = '\v^/dev/stdin:(\d+):?(\d+)? ((DL|SC)(\d+) )?(.+)$'
|
||||
let l:pattern = '\v^%(/dev/stdin|-):(\d+):?(\d+)? ((DL|SC)(\d+) )?((.+)?: )?(.+)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
|
@ -24,9 +24,19 @@ function! ale_linters#dockerfile#hadolint#Handle(buffer, lines) abort
|
|||
let l:colnum = l:match[2] + 0
|
||||
endif
|
||||
|
||||
" Shellcheck knows a 'style' severity - pin it to info level as well.
|
||||
if l:match[7] is# 'style'
|
||||
let l:type = 'I'
|
||||
elseif l:match[7] is# 'info'
|
||||
let l:type = 'I'
|
||||
elseif l:match[7] is# 'warning'
|
||||
let l:type = 'W'
|
||||
let l:text = l:match[6]
|
||||
let l:detail = l:match[6]
|
||||
else
|
||||
let l:type = 'E'
|
||||
endif
|
||||
|
||||
let l:text = l:match[8]
|
||||
let l:detail = l:match[8]
|
||||
let l:domain = 'https://github.com/hadolint/hadolint/wiki/'
|
||||
|
||||
if l:match[4] is# 'SC'
|
||||
|
@ -82,12 +92,15 @@ endfunction
|
|||
|
||||
function! ale_linters#dockerfile#hadolint#GetCommand(buffer) abort
|
||||
let l:command = ale_linters#dockerfile#hadolint#GetExecutable(a:buffer)
|
||||
let l:opts = '--no-color -'
|
||||
|
||||
if l:command is# 'docker'
|
||||
return 'docker run --rm -i ' . ale#Var(a:buffer, 'dockerfile_hadolint_docker_image')
|
||||
return printf('docker run --rm -i %s hadolint %s',
|
||||
\ ale#Var(a:buffer, 'dockerfile_hadolint_docker_image'),
|
||||
\ l:opts)
|
||||
endif
|
||||
|
||||
return 'hadolint -'
|
||||
return 'hadolint ' . l:opts
|
||||
endfunction
|
||||
|
||||
|
||||
|
|
|
@ -45,19 +45,27 @@ function! ale_linters#elixir#credo#GetMode() abort
|
|||
endif
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elixir#credo#GetCommand(buffer) abort
|
||||
let l:project_root = ale#handlers#elixir#FindMixUmbrellaRoot(a:buffer)
|
||||
let l:mode = ale_linters#elixir#credo#GetMode()
|
||||
function! ale_linters#elixir#credo#GetConfigFile() abort
|
||||
let l:config_file = get(g:, 'ale_elixir_credo_config_file', '')
|
||||
|
||||
return ale#path#CdString(l:project_root)
|
||||
\ . 'mix help credo && '
|
||||
if empty(l:config_file)
|
||||
return ''
|
||||
endif
|
||||
|
||||
return ' --config-file ' . l:config_file
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elixir#credo#GetCommand(buffer) abort
|
||||
return 'mix help credo && '
|
||||
\ . 'mix credo ' . ale_linters#elixir#credo#GetMode()
|
||||
\ . ale_linters#elixir#credo#GetConfigFile()
|
||||
\ . ' --format=flycheck --read-from-stdin %s'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('elixir', {
|
||||
\ 'name': 'credo',
|
||||
\ 'executable': 'mix',
|
||||
\ 'cwd': function('ale#handlers#elixir#FindMixUmbrellaRoot'),
|
||||
\ 'command': function('ale_linters#elixir#credo#GetCommand'),
|
||||
\ 'callback': 'ale_linters#elixir#credo#Handle',
|
||||
\})
|
||||
|
|
|
@ -25,17 +25,10 @@ function! ale_linters#elixir#dialyxir#Handle(buffer, lines) abort
|
|||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elixir#dialyxir#GetCommand(buffer) abort
|
||||
let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer)
|
||||
|
||||
return ale#path#CdString(l:project_root)
|
||||
\ . ' mix help dialyzer && mix dialyzer'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('elixir', {
|
||||
\ 'name': 'dialyxir',
|
||||
\ 'executable': 'mix',
|
||||
\ 'command': function('ale_linters#elixir#dialyxir#GetCommand'),
|
||||
\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'),
|
||||
\ 'command': 'mix help dialyzer && mix dialyzer',
|
||||
\ 'callback': 'ale_linters#elixir#dialyxir#Handle',
|
||||
\})
|
||||
|
||||
|
|
|
@ -29,17 +29,11 @@ function! ale_linters#elixir#dogma#Handle(buffer, lines) abort
|
|||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elixir#dogma#GetCommand(buffer) abort
|
||||
let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer)
|
||||
|
||||
return ale#path#CdString(l:project_root)
|
||||
\ . ' mix help dogma && mix dogma %s --format=flycheck'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('elixir', {
|
||||
\ 'name': 'dogma',
|
||||
\ 'executable': 'mix',
|
||||
\ 'command': function('ale_linters#elixir#dogma#GetCommand'),
|
||||
\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'),
|
||||
\ 'command': 'mix help dogma && mix dogma %s --format=flycheck',
|
||||
\ 'lint_file': 1,
|
||||
\ 'callback': 'ale_linters#elixir#dogma#Handle',
|
||||
\})
|
||||
|
|
|
@ -30,22 +30,15 @@ function! ale_linters#elixir#mix#Handle(buffer, lines) abort
|
|||
endfunction
|
||||
|
||||
function! ale_linters#elixir#mix#GetCommand(buffer) abort
|
||||
let l:project_root = ale#handlers#elixir#FindMixProjectRoot(a:buffer)
|
||||
|
||||
let l:temp_dir = ale#command#CreateDirectory(a:buffer)
|
||||
|
||||
let l:mix_build_path = has('win32')
|
||||
\ ? 'set MIX_BUILD_PATH=' . ale#Escape(l:temp_dir) . ' &&'
|
||||
\ : 'MIX_BUILD_PATH=' . ale#Escape(l:temp_dir)
|
||||
|
||||
return ale#path#CdString(l:project_root)
|
||||
\ . l:mix_build_path
|
||||
\ . ' mix compile %s'
|
||||
return ale#Env('MIX_BUILD_PATH', l:temp_dir) . 'mix compile %s'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('elixir', {
|
||||
\ 'name': 'mix',
|
||||
\ 'executable': 'mix',
|
||||
\ 'cwd': function('ale#handlers#elixir#FindMixProjectRoot'),
|
||||
\ 'command': function('ale_linters#elixir#mix#GetCommand'),
|
||||
\ 'callback': 'ale_linters#elixir#mix#Handle',
|
||||
\ 'lint_file': 1,
|
||||
|
|
|
@ -186,20 +186,19 @@ function! ale_linters#elm#make#IsTest(buffer) abort
|
|||
endif
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elm#make#GetCwd(buffer) abort
|
||||
let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer)
|
||||
|
||||
return !empty(l:root_dir) ? l:root_dir : ''
|
||||
endfunction
|
||||
|
||||
" Return the command to execute the linter in the projects directory.
|
||||
" If it doesn't, then this will fail when imports are needed.
|
||||
function! ale_linters#elm#make#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#elm#make#GetExecutable(a:buffer)
|
||||
let l:root_dir = ale_linters#elm#make#GetRootDir(a:buffer)
|
||||
let l:is_v19 = ale_linters#elm#make#IsVersionGte19(a:buffer)
|
||||
let l:is_using_elm_test = l:executable =~# 'elm-test$'
|
||||
|
||||
if empty(l:root_dir)
|
||||
let l:dir_set_cmd = ''
|
||||
else
|
||||
let l:dir_set_cmd = 'cd ' . ale#Escape(l:root_dir) . ' && '
|
||||
endif
|
||||
|
||||
" elm-test needs to know the path of elm-make if elm isn't installed globally.
|
||||
" https://github.com/rtfeldman/node-test-runner/blob/57728f10668f2d2ab3179e7e3208bcfa9a1f19aa/README.md#--compiler
|
||||
if l:is_v19 && l:is_using_elm_test
|
||||
|
@ -213,7 +212,9 @@ function! ale_linters#elm#make#GetCommand(buffer) abort
|
|||
" a sort of flag to tell the compiler not to generate an output file,
|
||||
" which is why this is hard coded here.
|
||||
" Source: https://github.com/elm-lang/elm-compiler/blob/19d5a769b30ec0b2fc4475985abb4cd94cd1d6c3/builder/src/Generate/Output.hs#L253
|
||||
return l:dir_set_cmd . '%e make --report=json --output=/dev/null' . l:elm_test_compiler_flag . '%t'
|
||||
return '%e make --report=json --output=/dev/null'
|
||||
\ . l:elm_test_compiler_flag
|
||||
\ . '%t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#elm#make#GetExecutable(buffer) abort
|
||||
|
@ -235,6 +236,7 @@ call ale#linter#Define('elm', {
|
|||
\ 'name': 'make',
|
||||
\ 'executable': function('ale_linters#elm#make#GetExecutable'),
|
||||
\ 'output_stream': 'both',
|
||||
\ 'cwd': function('ale_linters#elm#make#GetCwd'),
|
||||
\ 'command': function('ale_linters#elm#make#GetCommand'),
|
||||
\ 'callback': 'ale_linters#elm#make#Handle'
|
||||
\})
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
|
||||
let g:ale_erlang_dialyzer_executable =
|
||||
\ get(g:, 'ale_erlang_dialyzer_executable', 'dialyzer')
|
||||
let g:ale_erlang_dialyzer_options =
|
||||
\ get(g:, 'ale_erlang_dialyzer_options', '-Wunmatched_returns'
|
||||
\ . ' -Werror_handling'
|
||||
\ . ' -Wrace_conditions'
|
||||
\ . ' -Wunderspecs')
|
||||
let g:ale_erlang_dialyzer_plt_file =
|
||||
\ get(g:, 'ale_erlang_dialyzer_plt_file', '')
|
||||
let g:ale_erlang_dialyzer_rebar3_profile =
|
||||
|
@ -47,13 +52,12 @@ function! ale_linters#erlang#dialyzer#GetExecutable(buffer) abort
|
|||
endfunction
|
||||
|
||||
function! ale_linters#erlang#dialyzer#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'erlang_dialyzer_options')
|
||||
|
||||
let l:command = ale#Escape(ale_linters#erlang#dialyzer#GetExecutable(a:buffer))
|
||||
\ . ' -n'
|
||||
\ . ' --plt ' . ale#Escape(ale_linters#erlang#dialyzer#GetPlt(a:buffer))
|
||||
\ . ' -Wunmatched_returns'
|
||||
\ . ' -Werror_handling'
|
||||
\ . ' -Wrace_conditions'
|
||||
\ . ' -Wunderspecs'
|
||||
\ . ' ' . l:options
|
||||
\ . ' %s'
|
||||
|
||||
return l:command
|
||||
|
|
|
@ -1,14 +1,22 @@
|
|||
" Author: Magnus Ottenklinger - https://github.com/evnu
|
||||
|
||||
let g:ale_erlang_erlc_executable = get(g:, 'ale_erlang_erlc_executable', 'erlc')
|
||||
let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '')
|
||||
|
||||
function! ale_linters#erlang#erlc#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'erlang_erlc_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#erlang#erlc#GetCommand(buffer) abort
|
||||
let l:output_file = ale#util#Tempname()
|
||||
call ale#command#ManageFile(a:buffer, l:output_file)
|
||||
|
||||
return 'erlc -o ' . ale#Escape(l:output_file)
|
||||
let l:command = ale#Escape(ale_linters#erlang#erlc#GetExecutable(a:buffer))
|
||||
\ . ' -o ' . ale#Escape(l:output_file)
|
||||
\ . ' ' . ale#Var(a:buffer, 'erlang_erlc_options')
|
||||
\ . ' %t'
|
||||
|
||||
return l:command
|
||||
endfunction
|
||||
|
||||
function! ale_linters#erlang#erlc#Handle(buffer, lines) abort
|
||||
|
@ -90,7 +98,7 @@ endfunction
|
|||
|
||||
call ale#linter#Define('erlang', {
|
||||
\ 'name': 'erlc',
|
||||
\ 'executable': 'erlc',
|
||||
\ 'executable': function('ale_linters#erlang#erlc#GetExecutable'),
|
||||
\ 'command': function('ale_linters#erlang#erlc#GetCommand'),
|
||||
\ 'callback': 'ale_linters#erlang#erlc#Handle',
|
||||
\})
|
||||
|
|
|
@ -10,8 +10,7 @@ function! ale_linters#go#gobuild#GetCommand(buffer) abort
|
|||
let l:options = ale#Var(a:buffer, 'go_gobuild_options')
|
||||
|
||||
" Run go test in local directory with relative path
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
return ale#go#EnvString(a:buffer)
|
||||
\ . ale#Var(a:buffer, 'go_go_executable') . ' test'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -c -o /dev/null ./'
|
||||
|
@ -50,6 +49,7 @@ call ale#linter#Define('go', {
|
|||
\ 'name': 'gobuild',
|
||||
\ 'aliases': ['go build'],
|
||||
\ 'executable': {b -> ale#Var(b, 'go_go_executable')},
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#go#gobuild#GetCommand'),
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale_linters#go#gobuild#Handler',
|
||||
|
|
|
@ -12,14 +12,12 @@ function! ale_linters#go#golangci_lint#GetCommand(buffer) abort
|
|||
|
||||
|
||||
if l:lint_package
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
return ale#go#EnvString(a:buffer)
|
||||
\ . '%e run '
|
||||
\ . l:options
|
||||
endif
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
return ale#go#EnvString(a:buffer)
|
||||
\ . '%e run '
|
||||
\ . ale#Escape(l:filename)
|
||||
\ . ' ' . l:options
|
||||
|
@ -53,6 +51,7 @@ endfunction
|
|||
call ale#linter#Define('go', {
|
||||
\ 'name': 'golangci-lint',
|
||||
\ 'executable': {b -> ale#Var(b, 'go_golangci_lint_executable')},
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#go#golangci_lint#GetCommand'),
|
||||
\ 'callback': 'ale_linters#go#golangci_lint#Handler',
|
||||
\ 'lint_file': 1,
|
||||
|
|
|
@ -13,14 +13,12 @@ function! ale_linters#go#gometalinter#GetCommand(buffer) abort
|
|||
" BufferCdString is used so that we can be sure the paths output from gometalinter can
|
||||
" be calculated to absolute paths in the Handler
|
||||
if l:lint_package
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
return ale#go#EnvString(a:buffer)
|
||||
\ . '%e'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
|
||||
endif
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
return ale#go#EnvString(a:buffer)
|
||||
\ . '%e'
|
||||
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(l:filename))
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
|
||||
|
@ -53,6 +51,7 @@ endfunction
|
|||
call ale#linter#Define('go', {
|
||||
\ 'name': 'gometalinter',
|
||||
\ 'executable': {b -> ale#Var(b, 'go_gometalinter_executable')},
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#go#gometalinter#GetCommand'),
|
||||
\ 'callback': 'ale_linters#go#gometalinter#Handler',
|
||||
\ 'lint_file': 1,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
call ale#Set('go_gopls_executable', 'gopls')
|
||||
call ale#Set('go_gopls_options', '--mode stdio')
|
||||
call ale#Set('go_gopls_init_options', {})
|
||||
|
||||
function! ale_linters#go#gopls#GetCommand(buffer) abort
|
||||
return ale#go#EnvString(a:buffer)
|
||||
|
@ -31,4 +32,5 @@ call ale#linter#Define('go', {
|
|||
\ 'executable': {b -> ale#Var(b, 'go_gopls_executable')},
|
||||
\ 'command': function('ale_linters#go#gopls#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#go#gopls#FindProjectRoot'),
|
||||
\ 'initialization_options': {b -> ale#Var(b, 'go_gopls_init_options')},
|
||||
\})
|
||||
|
|
|
@ -1,15 +1,11 @@
|
|||
" Author: Ben Reedy <https://github.com/breed808>
|
||||
" Description: gosimple for Go files
|
||||
|
||||
function! ale_linters#go#gosimple#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer) . ' '
|
||||
\ . ale#go#EnvString(a:buffer) . 'gosimple .'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'gosimple',
|
||||
\ 'executable': 'gosimple',
|
||||
\ 'command': function('ale_linters#go#gosimple#GetCommand'),
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': {b -> ale#go#EnvString(b) . 'gosimple .'},
|
||||
\ 'callback': 'ale#handlers#go#Handler',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'lint_file': 1,
|
||||
|
|
|
@ -1,19 +1,23 @@
|
|||
" Author: Jelte Fennema <github-public@jeltef.nl>
|
||||
" Description: gotype for Go files
|
||||
|
||||
function! ale_linters#go#gotype#GetCommand(buffer) abort
|
||||
function! ale_linters#go#gotype#GetExecutable(buffer) abort
|
||||
if expand('#' . a:buffer . ':p') =~# '_test\.go$'
|
||||
return ''
|
||||
endif
|
||||
|
||||
return ale#path#BufferCdString(a:buffer) . ' '
|
||||
\ . ale#go#EnvString(a:buffer) . 'gotype -e .'
|
||||
return 'gotype'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#go#gotype#GetCommand(buffer) abort
|
||||
return ale#go#EnvString(a:buffer) . 'gotype -e .'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'gotype',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'gotype',
|
||||
\ 'executable': function('ale_linters#go#gotype#GetExecutable'),
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#go#gotype#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#go#Handler',
|
||||
\ 'lint_file': 1,
|
||||
|
|
|
@ -10,8 +10,7 @@ call ale#Set('go_govet_options', '')
|
|||
function! ale_linters#go#govet#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'go_govet_options')
|
||||
|
||||
return ale#path#BufferCdString(a:buffer) . ' '
|
||||
\ . ale#go#EnvString(a:buffer)
|
||||
return ale#go#EnvString(a:buffer)
|
||||
\ . ale#Var(a:buffer, 'go_go_executable') . ' vet '
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' .'
|
||||
|
@ -22,6 +21,7 @@ call ale#linter#Define('go', {
|
|||
\ 'aliases': ['go vet'],
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': {b -> ale#Var(b, 'go_go_executable')},
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#go#govet#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#go#Handler',
|
||||
\ 'lint_file': 1,
|
||||
|
|
|
@ -5,28 +5,24 @@ call ale#Set('go_staticcheck_options', '')
|
|||
call ale#Set('go_staticcheck_lint_package', 0)
|
||||
|
||||
function! ale_linters#go#staticcheck#GetCommand(buffer) abort
|
||||
let l:filename = expand('#' . a:buffer . ':t')
|
||||
let l:options = ale#Var(a:buffer, 'go_staticcheck_options')
|
||||
let l:lint_package = ale#Var(a:buffer, 'go_staticcheck_lint_package')
|
||||
let l:env = ale#go#EnvString(a:buffer)
|
||||
|
||||
" BufferCdString is used so that we can be sure the paths output from
|
||||
" staticcheck can be calculated to absolute paths in the Handler
|
||||
if l:lint_package
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . l:env . 'staticcheck'
|
||||
return l:env . 'staticcheck'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '') . ' .'
|
||||
endif
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . l:env . 'staticcheck'
|
||||
return l:env . 'staticcheck'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' ' . ale#Escape(l:filename)
|
||||
\ . ' %s:t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'staticcheck',
|
||||
\ 'executable': 'staticcheck',
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#go#staticcheck#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#go#Handler',
|
||||
\ 'output_stream': 'both',
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
call ale#linter#Define('graphql', {
|
||||
\ 'name': 'eslint',
|
||||
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
|
||||
\ 'cwd': function('ale#handlers#eslint#GetCwd'),
|
||||
\ 'command': function('ale#handlers#eslint#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#eslint#HandleJSON',
|
||||
\})
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
" Author: Michiel Westerbeek <happylinks@gmail.com>
|
||||
" Description: Linter for GraphQL Schemas
|
||||
|
||||
function! ale_linters#graphql#gqlint#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'gqlint'
|
||||
\ . ' --reporter=simple %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('graphql', {
|
||||
\ 'name': 'gqlint',
|
||||
\ 'executable': 'gqlint',
|
||||
\ 'command': function('ale_linters#graphql#gqlint#GetCommand'),
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': 'gqlint --reporter=simple %t',
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsWarning',
|
||||
\})
|
||||
|
|
|
@ -4,8 +4,7 @@
|
|||
call ale#Set('haskell_cabal_ghc_options', '-fno-code -v0')
|
||||
|
||||
function! ale_linters#haskell#cabal_ghc#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'cabal exec -- ghc '
|
||||
return 'cabal exec -- ghc '
|
||||
\ . ale#Var(a:buffer, 'haskell_cabal_ghc_options')
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
@ -15,6 +14,7 @@ call ale#linter#Define('haskell', {
|
|||
\ 'aliases': ['cabal-ghc'],
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'cabal',
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#haskell#cabal_ghc#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||
\})
|
||||
|
|
63
sources_non_forked/ale/ale_linters/haskell/hls.vim
Normal file
63
sources_non_forked/ale/ale_linters/haskell/hls.vim
Normal file
|
@ -0,0 +1,63 @@
|
|||
" Author: Yen3 <yen3rc@gmail.com>
|
||||
" Description: A language server for haskell
|
||||
" The file is based on hie.vim (author: Luxed
|
||||
" <devildead13@gmail.com>). It search more project root files.
|
||||
"
|
||||
call ale#Set('haskell_hls_executable', 'haskell-language-server-wrapper')
|
||||
|
||||
function! ale_linters#haskell#hls#FindRootFile(buffer) abort
|
||||
let l:serach_root_files = [
|
||||
\ 'stack.yaml',
|
||||
\ 'cabal.project',
|
||||
\ 'package.yaml',
|
||||
\ 'hie.yaml'
|
||||
\ ]
|
||||
|
||||
for l:path in ale#path#Upwards(expand('#' . a:buffer . ':p:h'))
|
||||
for l:root_file in l:serach_root_files
|
||||
if filereadable(l:path . l:root_file)
|
||||
return l:path
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#haskell#hls#GetProjectRoot(buffer) abort
|
||||
" Search for the project file first
|
||||
let l:project_file = ale_linters#haskell#hls#FindRootFile(a:buffer)
|
||||
|
||||
" If it's empty, search for the cabal file
|
||||
if empty(l:project_file)
|
||||
" Search all of the paths except for the root filesystem path.
|
||||
let l:paths = join(
|
||||
\ ale#path#Upwards(expand('#' . a:buffer . ':p:h'))[:-2],
|
||||
\ ','
|
||||
\)
|
||||
let l:project_file = globpath(l:paths, '*.cabal')
|
||||
endif
|
||||
|
||||
" If we still can't find one, use the current file.
|
||||
if empty(l:project_file)
|
||||
let l:project_file = expand('#' . a:buffer . ':p')
|
||||
endif
|
||||
|
||||
return fnamemodify(l:project_file, ':h')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#haskell#hls#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'haskell_hls_executable')
|
||||
|
||||
return ale#handlers#haskell_stack#EscapeExecutable(l:executable,
|
||||
\ 'haskell-language-server-wrapper')
|
||||
\ . ' --lsp'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('haskell', {
|
||||
\ 'name': 'hls',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'command': function('ale_linters#haskell#hls#GetCommand'),
|
||||
\ 'executable': {b -> ale#Var(b, 'haskell_hls_executable')},
|
||||
\ 'project_root': function('ale_linters#haskell#hls#GetProjectRoot'),
|
||||
\})
|
|
@ -4,8 +4,7 @@
|
|||
call ale#Set('haskell_stack_ghc_options', '-fno-code -v0')
|
||||
|
||||
function! ale_linters#haskell#stack_ghc#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#handlers#haskell#GetStackExecutable(a:buffer)
|
||||
return ale#handlers#haskell#GetStackExecutable(a:buffer)
|
||||
\ . ' ghc -- '
|
||||
\ . ale#Var(a:buffer, 'haskell_stack_ghc_options')
|
||||
\ . ' %t'
|
||||
|
@ -16,6 +15,7 @@ call ale#linter#Define('haskell', {
|
|||
\ 'aliases': ['stack-ghc'],
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': function('ale#handlers#haskell#GetStackExecutable'),
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#haskell#stack_ghc#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#haskell#HandleGHCFormat',
|
||||
\})
|
||||
|
|
52
sources_non_forked/ale/ale_linters/html/angular.vim
Normal file
52
sources_non_forked/ale/ale_linters/html/angular.vim
Normal file
|
@ -0,0 +1,52 @@
|
|||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: tsserver integration for ALE
|
||||
|
||||
call ale#Set('html_angular_executable', 'ngserver')
|
||||
call ale#Set('html_angular_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale_linters#html#angular#GetProjectRoot(buffer) abort
|
||||
return ale#path#Dirname(
|
||||
\ ale#path#FindNearestDirectory(a:buffer, 'node_modules')
|
||||
\)
|
||||
endfunction
|
||||
|
||||
function! ale_linters#html#angular#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'html_angular', [
|
||||
\ 'node_modules/@angular/language-server/bin/ngserver',
|
||||
\ 'node_modules/@angular/language-server/index.js',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#html#angular#GetCommand(buffer) abort
|
||||
let l:language_service_dir = ale#path#Simplify(
|
||||
\ ale#path#FindNearestDirectory(
|
||||
\ a:buffer,
|
||||
\ 'node_modules/@angular/language-service'
|
||||
\ )
|
||||
\)
|
||||
|
||||
if empty(l:language_service_dir)
|
||||
return ''
|
||||
endif
|
||||
|
||||
let l:language_service_dir = fnamemodify(l:language_service_dir, ':h')
|
||||
let l:typescript_dir = ale#path#Simplify(
|
||||
\ fnamemodify(l:language_service_dir, ':h:h')
|
||||
\ . '/typescript'
|
||||
\)
|
||||
let l:executable = ale_linters#html#angular#GetExecutable(a:buffer)
|
||||
|
||||
return ale#node#Executable(a:buffer, l:executable)
|
||||
\ . ' --ngProbeLocations ' . ale#Escape(l:language_service_dir)
|
||||
\ . ' --tsProbeLocations ' . ale#Escape(l:typescript_dir)
|
||||
\ . ' --stdio'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('html', {
|
||||
\ 'name': 'angular',
|
||||
\ 'aliases': ['angular-language-server'],
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': function('ale_linters#html#angular#GetExecutable'),
|
||||
\ 'command': function('ale_linters#html#angular#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#html#angular#GetProjectRoot'),
|
||||
\})
|
33
sources_non_forked/ale/ale_linters/inko/inko.vim
Normal file
33
sources_non_forked/ale/ale_linters/inko/inko.vim
Normal file
|
@ -0,0 +1,33 @@
|
|||
" Author: Yorick Peterse <yorick@yorickpeterse.com>
|
||||
" Description: linting of Inko source code using the Inko compiler
|
||||
|
||||
call ale#Set('inko_inko_executable', 'inko')
|
||||
|
||||
function! ale_linters#inko#inko#GetCommand(buffer) abort
|
||||
let l:include = ''
|
||||
|
||||
" Include the tests source directory, but only for test files.
|
||||
if expand('#' . a:buffer . ':p') =~? '\vtests[/\\]test[/\\]'
|
||||
let l:test_dir = ale#path#FindNearestDirectory(a:buffer, 'tests')
|
||||
|
||||
if isdirectory(l:test_dir)
|
||||
let l:include = '--include ' . ale#Escape(l:test_dir)
|
||||
endif
|
||||
endif
|
||||
|
||||
" We use %s instead of %t so the compiler determines the correct module
|
||||
" names for the file being edited. Not doing so may lead to errors in
|
||||
" certain cases.
|
||||
return '%e build --check --format=json'
|
||||
\ . ale#Pad(l:include)
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('inko', {
|
||||
\ 'name': 'inko',
|
||||
\ 'executable': {b -> ale#Var(b, 'inko_inko_executable')},
|
||||
\ 'command': function('ale_linters#inko#inko#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#inko#Handle',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'lint_file': 1
|
||||
\})
|
|
@ -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, {
|
||||
|
|
|
@ -29,28 +29,28 @@ function! ale_linters#java#eclipselsp#JarPath(buffer) abort
|
|||
endif
|
||||
|
||||
" Search jar file within repository path when manually built using mvn
|
||||
let l:files = globpath(l:path, '**/'.l:platform.'/**/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_*\.jar', 1, 1)
|
||||
|
||||
if len(l:files) >= 1
|
||||
return l:files[0]
|
||||
endif
|
||||
|
||||
" Search jar file within VSCode extensions folder.
|
||||
let l:files = globpath(l:path, '**/'.l:platform.'/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_*\.jar', 1, 1)
|
||||
|
||||
if len(l:files) >= 1
|
||||
return l:files[0]
|
||||
endif
|
||||
|
||||
" Search jar file within unzipped tar.gz file
|
||||
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, 'plugins/org.eclipse.equinox.launcher_*\.jar', 1, 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)
|
||||
let l:files = globpath('/usr/share/java/jdtls/plugins', 'org.eclipse.equinox.launcher_*\.jar', 1, 1)
|
||||
|
||||
if len(l:files) >= 1
|
||||
return l:files[0]
|
||||
|
|
|
@ -9,16 +9,16 @@ call ale#Set('java_javac_classpath', '')
|
|||
call ale#Set('java_javac_sourcepath', '')
|
||||
|
||||
function! ale_linters#java#javac#RunWithImportPaths(buffer) abort
|
||||
let l:command = ale#maven#BuildClasspathCommand(a:buffer)
|
||||
let [l:cwd, l:command] = ale#maven#BuildClasspathCommand(a:buffer)
|
||||
|
||||
" Try to use Gradle if Maven isn't available.
|
||||
if empty(l:command)
|
||||
let l:command = ale#gradle#BuildClasspathCommand(a:buffer)
|
||||
let [l:cwd, l:command] = ale#gradle#BuildClasspathCommand(a:buffer)
|
||||
endif
|
||||
|
||||
" Try to use Ant if Gradle and Maven aren't available
|
||||
if empty(l:command)
|
||||
let l:command = ale#ant#BuildClasspathCommand(a:buffer)
|
||||
let [l:cwd, l:command] = ale#ant#BuildClasspathCommand(a:buffer)
|
||||
endif
|
||||
|
||||
if empty(l:command)
|
||||
|
@ -28,7 +28,8 @@ function! ale_linters#java#javac#RunWithImportPaths(buffer) abort
|
|||
return ale#command#Run(
|
||||
\ a:buffer,
|
||||
\ l:command,
|
||||
\ function('ale_linters#java#javac#GetCommand')
|
||||
\ function('ale_linters#java#javac#GetCommand'),
|
||||
\ {'cwd': l:cwd},
|
||||
\)
|
||||
endfunction
|
||||
|
||||
|
@ -110,8 +111,7 @@ function! ale_linters#java#javac#GetCommand(buffer, import_paths, meta) abort
|
|||
|
||||
" Always run javac from the directory the file is in, so we can resolve
|
||||
" relative paths correctly.
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . '%e -Xlint'
|
||||
return '%e -Xlint'
|
||||
\ . ale#Pad(l:cp_option)
|
||||
\ . ale#Pad(l:sp_option)
|
||||
\ . ' -d ' . ale#Escape(l:class_file_directory)
|
||||
|
@ -154,6 +154,7 @@ endfunction
|
|||
call ale#linter#Define('java', {
|
||||
\ 'name': 'javac',
|
||||
\ 'executable': {b -> ale#Var(b, 'java_javac_executable')},
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#java#javac#RunWithImportPaths'),
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale_linters#java#javac#Handle',
|
||||
|
|
|
@ -5,6 +5,7 @@ call ale#linter#Define('javascript', {
|
|||
\ 'name': 'eslint',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
|
||||
\ 'cwd': function('ale#handlers#eslint#GetCwd'),
|
||||
\ 'command': function('ale#handlers#eslint#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#eslint#HandleJSON',
|
||||
\})
|
||||
|
|
|
@ -1,26 +1,9 @@
|
|||
" Author: Daniel Lupu <lupu.daniel.f@gmail.com>
|
||||
" Description: xo for JavaScript files
|
||||
|
||||
call ale#Set('javascript_xo_executable', 'xo')
|
||||
call ale#Set('javascript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('javascript_xo_options', '')
|
||||
|
||||
function! ale_linters#javascript#xo#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'javascript_xo', [
|
||||
\ 'node_modules/.bin/xo',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#javascript#xo#GetCommand(buffer) abort
|
||||
return ale#Escape(ale_linters#javascript#xo#GetExecutable(a:buffer))
|
||||
\ . ' ' . ale#Var(a:buffer, 'javascript_xo_options')
|
||||
\ . ' --reporter json --stdin --stdin-filename %s'
|
||||
endfunction
|
||||
|
||||
" xo uses eslint and the output format is the same
|
||||
call ale#linter#Define('javascript', {
|
||||
\ 'name': 'xo',
|
||||
\ 'executable': function('ale_linters#javascript#xo#GetExecutable'),
|
||||
\ 'command': function('ale_linters#javascript#xo#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#eslint#HandleJSON',
|
||||
\ 'executable': function('ale#handlers#xo#GetExecutable'),
|
||||
\ 'command': function('ale#handlers#xo#GetLintCommand'),
|
||||
\ 'callback': 'ale#handlers#xo#HandleJSON',
|
||||
\})
|
||||
|
|
24
sources_non_forked/ale/ale_linters/json/jq.vim
Normal file
24
sources_non_forked/ale/ale_linters/json/jq.vim
Normal file
|
@ -0,0 +1,24 @@
|
|||
" Author: jD91mZM2 <me@krake.one>
|
||||
call ale#Set('json_jq_executable', 'jq')
|
||||
call ale#Set('json_jq_options', '')
|
||||
call ale#Set('json_jq_filters', '.')
|
||||
|
||||
" Matches patterns like the following:
|
||||
" parse error: Expected another key-value pair at line 4, column 3
|
||||
let s:pattern = '^parse error: \(.\+\) at line \(\d\+\), column \(\d\+\)$'
|
||||
|
||||
function! ale_linters#json#jq#Handle(buffer, lines) abort
|
||||
return ale#util#MapMatches(a:lines, s:pattern, {match -> {
|
||||
\ 'text': match[1],
|
||||
\ 'lnum': match[2] + 0,
|
||||
\ 'col': match[3] + 0,
|
||||
\}})
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('json', {
|
||||
\ 'name': 'jq',
|
||||
\ 'executable': {b -> ale#Var(b, 'json_jq_executable')},
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'command': '%e',
|
||||
\ 'callback': 'ale_linters#json#jq#Handle',
|
||||
\})
|
14
sources_non_forked/ale/ale_linters/json/spectral.vim
Normal file
14
sources_non_forked/ale/ale_linters/json/spectral.vim
Normal file
|
@ -0,0 +1,14 @@
|
|||
" Author: t2h5 <https://github.com/t2h5>
|
||||
" Description: Integration of Stoplight Spectral CLI with ALE.
|
||||
|
||||
call ale#Set('json_spectral_executable', 'spectral')
|
||||
call ale#Set('json_spectral_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
call ale#linter#Define('json', {
|
||||
\ 'name': 'spectral',
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'json_spectral', [
|
||||
\ 'node_modules/.bin/spectral',
|
||||
\ ])},
|
||||
\ 'command': '%e lint --ignore-unknown-format -q -f text %t',
|
||||
\ 'callback': 'ale#handlers#spectral#HandleSpectralOutput'
|
||||
\})
|
|
@ -6,9 +6,9 @@ call ale#Set('julia_executable', 'julia')
|
|||
|
||||
function! ale_linters#julia#languageserver#GetCommand(buffer) abort
|
||||
let l:julia_executable = ale#Var(a:buffer, 'julia_executable')
|
||||
let l:cmd_string = 'using LanguageServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, false); server.runlinter = true; run(server);'
|
||||
let l:cmd_string = 'using LanguageServer; using Pkg; import StaticLint; import SymbolServer; server = LanguageServer.LanguageServerInstance(isdefined(Base, :stdin) ? stdin : STDIN, isdefined(Base, :stdout) ? stdout : STDOUT, dirname(Pkg.Types.Context().env.project_file)); server.runlinter = true; run(server);'
|
||||
|
||||
return ale#Escape(l:julia_executable) . ' --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string)
|
||||
return ale#Escape(l:julia_executable) . ' --project=@. --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string)
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('julia', {
|
||||
|
|
|
@ -15,20 +15,15 @@ function! ale_linters#kotlin#kotlinc#RunWithImportPaths(buffer) abort
|
|||
let l:command = ''
|
||||
|
||||
" exec maven/gradle only if classpath is not set
|
||||
if ale#Var(a:buffer, 'kotlin_kotlinc_classpath') isnot# ''
|
||||
if !empty(ale#Var(a:buffer, 'kotlin_kotlinc_classpath'))
|
||||
return ale_linters#kotlin#kotlinc#GetCommand(a:buffer, [], {})
|
||||
endif
|
||||
|
||||
let l:pom_path = ale#path#FindNearestFile(a:buffer, 'pom.xml')
|
||||
|
||||
if !empty(l:pom_path) && executable('mvn')
|
||||
let l:command = ale#path#CdString(fnamemodify(l:pom_path, ':h'))
|
||||
\ . 'mvn dependency:build-classpath'
|
||||
endif
|
||||
let [l:cwd, l:command] = ale#maven#BuildClasspathCommand(a:buffer)
|
||||
|
||||
" Try to use Gradle if Maven isn't available.
|
||||
if empty(l:command)
|
||||
let l:command = ale#gradle#BuildClasspathCommand(a:buffer)
|
||||
let [l:cwd, l:command] = ale#gradle#BuildClasspathCommand(a:buffer)
|
||||
endif
|
||||
|
||||
if empty(l:command)
|
||||
|
@ -38,7 +33,8 @@ function! ale_linters#kotlin#kotlinc#RunWithImportPaths(buffer) abort
|
|||
return ale#command#Run(
|
||||
\ a:buffer,
|
||||
\ l:command,
|
||||
\ function('ale_linters#kotlin#kotlinc#GetCommand')
|
||||
\ function('ale_linters#kotlin#kotlinc#GetCommand'),
|
||||
\ {'cwd': l:cwd},
|
||||
\)
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
" Author: chew-z https://github.com/chew-z
|
||||
" Description: vale for Markdown files
|
||||
|
||||
call ale#Set('markdown_vale_executable', 'vale')
|
||||
call ale#Set('markdown_vale_input_file', '%t')
|
||||
call ale#Set('markdown_vale_options', '')
|
||||
|
||||
function! ale_linters#markdown#vale#GetCommand(buffer) abort
|
||||
let l:executable = ale#Var(a:buffer, 'markdown_vale_executable')
|
||||
let l:input_file = ale#Var(a:buffer, 'markdown_vale_input_file')
|
||||
|
||||
" Defaults to `vale --output=JSON %t`
|
||||
return ale#Escape(l:executable)
|
||||
\ . ' --output=JSON '
|
||||
\ . ale#Var(a:buffer, 'markdown_vale_options')
|
||||
\ . ' ' . l:input_file
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('markdown', {
|
||||
\ 'name': 'vale',
|
||||
\ 'executable': 'vale',
|
||||
\ 'command': 'vale --output=JSON %t',
|
||||
\ 'executable': {b -> ale#Var(b, 'markdown_vale_executable')},
|
||||
\ 'command': function('ale_linters#markdown#vale#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#vale#Handle',
|
||||
\})
|
||||
|
|
|
@ -5,12 +5,9 @@ call ale#Set('mercury_mmc_executable', 'mmc')
|
|||
call ale#Set('mercury_mmc_options', '--make --output-compile-error-lines 100')
|
||||
|
||||
function! ale_linters#mercury#mmc#GetCommand(buffer) abort
|
||||
let l:module_name = expand('#' . a:buffer . ':t:r')
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . '%e --errorcheck-only '
|
||||
return '%e --errorcheck-only '
|
||||
\ . ale#Var(a:buffer, 'mercury_mmc_options')
|
||||
\ . ' ' . l:module_name
|
||||
\ . ' %s:t:r'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#mercury#mmc#Handle(buffer, lines) abort
|
||||
|
@ -34,6 +31,7 @@ call ale#linter#Define('mercury', {
|
|||
\ 'name': 'mmc',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': {b -> ale#Var(b, 'mercury_mmc_executable')},
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#mercury#mmc#GetCommand'),
|
||||
\ 'callback': 'ale_linters#mercury#mmc#Handle',
|
||||
\ 'lint_file': 1,
|
||||
|
|
|
@ -1,18 +1,51 @@
|
|||
" Author: Alistair Bill <@alibabzo>
|
||||
" Author: Maximilian Bosch <maximilian@mbosch.me>
|
||||
" Description: nix-instantiate linter for nix files
|
||||
|
||||
function! ale_linters#nix#nix#Command(buffer, output, meta) abort
|
||||
let l:version = a:output[0][22:]
|
||||
|
||||
if l:version =~# '^\(2.4\|3\).*'
|
||||
return 'nix-instantiate --log-format internal-json --parse -'
|
||||
else
|
||||
return 'nix-instantiate --parse -'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale_linters#nix#nix#Handle(buffer, lines) abort
|
||||
let l:pattern = '^\(.\+\): \(.\+\), at .*:\(\d\+\):\(\d\+\)$'
|
||||
let l:output = []
|
||||
|
||||
if empty(a:lines)
|
||||
return l:output
|
||||
endif
|
||||
|
||||
if a:lines[0] =~# '^@nix .*'
|
||||
for l:line in a:lines
|
||||
if l:line =~# '^@nix .*'
|
||||
let l:result = json_decode(strpart(l:line, 4))
|
||||
|
||||
if has_key(l:result, 'column')
|
||||
call add(l:output, {
|
||||
\ 'type': 'E',
|
||||
\ 'lnum': l:result.line,
|
||||
\ 'col': l:result.column,
|
||||
\ 'text': l:result.raw_msg
|
||||
\})
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
else
|
||||
let l:pattern = '^\(.\+\): \(.\+\) at .*:\(\d\+\):\(\d\+\)$'
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[3] + 0,
|
||||
\ 'col': l:match[4] + 0,
|
||||
\ 'text': l:match[1] . ': ' . l:match[2],
|
||||
\ 'text': l:match[1] . ': ' . substitute(l:match[2], ',$', '', ''),
|
||||
\ 'type': l:match[1] =~# '^error' ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
endif
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
@ -21,6 +54,10 @@ call ale#linter#Define('nix', {
|
|||
\ 'name': 'nix',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'nix-instantiate',
|
||||
\ 'command': 'nix-instantiate --parse -',
|
||||
\ 'command': {buffer -> ale#command#Run(
|
||||
\ buffer,
|
||||
\ 'nix-instantiate --version',
|
||||
\ function('ale_linters#nix#nix#Command')
|
||||
\ )},
|
||||
\ 'callback': 'ale_linters#nix#nix#Handle',
|
||||
\})
|
||||
|
|
16
sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim
Normal file
16
sources_non_forked/ale/ale_linters/nix/rnix_lsp.vim
Normal file
|
@ -0,0 +1,16 @@
|
|||
" Author: jD91mZM2 <me@krake.one>
|
||||
" Description: rnix-lsp language client
|
||||
|
||||
function! ale_linters#nix#rnix_lsp#GetProjectRoot(buffer) abort
|
||||
" rnix-lsp does not yet use the project root, so getting it right is not
|
||||
" important
|
||||
return fnamemodify(a:buffer, ':h')
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('nix', {
|
||||
\ 'name': 'rnix_lsp',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': 'rnix-lsp',
|
||||
\ 'command': '%e',
|
||||
\ 'project_root': function('ale_linters#nix#rnix_lsp#GetProjectRoot'),
|
||||
\})
|
13
sources_non_forked/ale/ale_linters/ocaml/ocamllsp.vim
Normal file
13
sources_non_forked/ale/ale_linters/ocaml/ocamllsp.vim
Normal file
|
@ -0,0 +1,13 @@
|
|||
" Author: Risto Stevcev <me@risto.codes>
|
||||
" Description: The official language server for OCaml
|
||||
|
||||
call ale#Set('ocaml_ocamllsp_use_opam', 1)
|
||||
|
||||
call ale#linter#Define('ocaml', {
|
||||
\ 'name': 'ocamllsp',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': function('ale#handlers#ocamllsp#GetExecutable'),
|
||||
\ 'command': function('ale#handlers#ocamllsp#GetCommand'),
|
||||
\ 'language': function('ale#handlers#ocamllsp#GetLanguage'),
|
||||
\ 'project_root': function('ale#handlers#ocamllsp#GetProjectRoot'),
|
||||
\})
|
58
sources_non_forked/ale/ale_linters/openapi/ibm_validator.vim
Normal file
58
sources_non_forked/ale/ale_linters/openapi/ibm_validator.vim
Normal file
|
@ -0,0 +1,58 @@
|
|||
" Author: Horacio Sanson <hsanson@gmail.com>
|
||||
|
||||
call ale#Set('openapi_ibm_validator_executable', 'lint-openapi')
|
||||
call ale#Set('openapi_ibm_validator_options', '')
|
||||
|
||||
function! ale_linters#openapi#ibm_validator#GetCommand(buffer) abort
|
||||
return '%e' . ale#Pad(ale#Var(a:buffer, 'openapi_ibm_validator_options'))
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#openapi#ibm_validator#Handle(buffer, lines) abort
|
||||
let l:output = []
|
||||
let l:type = 'E'
|
||||
let l:message = ''
|
||||
let l:nr = -1
|
||||
|
||||
for l:line in a:lines
|
||||
let l:match = matchlist(l:line, '^errors$')
|
||||
|
||||
if !empty(l:match)
|
||||
let l:type = 'E'
|
||||
endif
|
||||
|
||||
let l:match = matchlist(l:line, '^warnings$')
|
||||
|
||||
if !empty(l:match)
|
||||
let l:type = 'W'
|
||||
endif
|
||||
|
||||
let l:match = matchlist(l:line, '^ *Message : *\(.\+\)$')
|
||||
|
||||
if !empty(l:match)
|
||||
let l:message = l:match[1]
|
||||
endif
|
||||
|
||||
let l:match = matchlist(l:line, '^ *Line *: *\(\d\+\)$')
|
||||
|
||||
if !empty(l:match)
|
||||
let l:nr = l:match[1]
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:nr + 0,
|
||||
\ 'col': 0,
|
||||
\ 'text': l:message,
|
||||
\ 'type': l:type,
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('openapi', {
|
||||
\ 'name': 'ibm_validator',
|
||||
\ 'executable': {b -> ale#Var(b, 'openapi_ibm_validator_executable')},
|
||||
\ 'command': function('ale_linters#openapi#ibm_validator#GetCommand'),
|
||||
\ 'callback': 'ale_linters#openapi#ibm_validator#Handle',
|
||||
\})
|
9
sources_non_forked/ale/ale_linters/openapi/yamllint.vim
Normal file
9
sources_non_forked/ale/ale_linters/openapi/yamllint.vim
Normal file
|
@ -0,0 +1,9 @@
|
|||
call ale#Set('yaml_yamllint_executable', 'yamllint')
|
||||
call ale#Set('yaml_yamllint_options', '')
|
||||
|
||||
call ale#linter#Define('openapi', {
|
||||
\ 'name': 'yamllint',
|
||||
\ 'executable': {b -> ale#Var(b, 'yaml_yamllint_executable')},
|
||||
\ 'command': function('ale#handlers#yamllint#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#yamllint#Handle',
|
||||
\})
|
|
@ -88,7 +88,7 @@ function! ale_linters#perl6#perl6#Handle(buffer, lines) abort
|
|||
|
||||
try
|
||||
let l:json = json_decode(join(a:lines, ''))
|
||||
catch /E474/
|
||||
catch /E474\|E491/
|
||||
call add(l:output, {
|
||||
\ 'lnum': '1',
|
||||
\ 'text': 'Received output in the default Perl6 error format. See :ALEDetail for details',
|
||||
|
|
|
@ -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', {
|
||||
|
|
|
@ -39,7 +39,7 @@ function! ale_linters#php#phan#Handle(buffer, lines) abort
|
|||
let l:pattern = '^Phan error: \(\w\+\): \(.\+\) in \(.\+\) on line \(\d\+\)$'
|
||||
else
|
||||
" /path/to/some-filename.php:18 ERRORTYPE message
|
||||
let l:pattern = '^.*:\(\d\+\)\s\(\w\+\)\s\(.\+\)$'
|
||||
let l:pattern = '^\(.*\):\(\d\+\)\s\(\w\+\)\s\(.\+\)$'
|
||||
endif
|
||||
|
||||
let l:output = []
|
||||
|
@ -49,13 +49,15 @@ function! ale_linters#php#phan#Handle(buffer, lines) abort
|
|||
let l:dict = {
|
||||
\ 'lnum': l:match[4] + 0,
|
||||
\ 'text': l:match[2],
|
||||
\ 'filename': l:match[3],
|
||||
\ 'type': 'W',
|
||||
\}
|
||||
else
|
||||
let l:dict = {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'text': l:match[3],
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\ 'type': 'W',
|
||||
\ 'filename': l:match[1],
|
||||
\}
|
||||
endif
|
||||
|
||||
|
|
|
@ -13,8 +13,7 @@ function! ale_linters#php#phpcs#GetCommand(buffer) abort
|
|||
\ ? '--standard=' . ale#Escape(l:standard)
|
||||
\ : ''
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . '%e -s --report=emacs --stdin-path=%s'
|
||||
return '%e -s --report=emacs --stdin-path=%s'
|
||||
\ . ale#Pad(l:standard_option)
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'php_phpcs_options'))
|
||||
endfunction
|
||||
|
@ -49,6 +48,7 @@ call ale#linter#Define('php', {
|
|||
\ 'vendor/bin/phpcs',
|
||||
\ 'phpcs'
|
||||
\ ])},
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#php#phpcs#GetCommand'),
|
||||
\ 'callback': 'ale_linters#php#phpcs#Handle',
|
||||
\})
|
||||
|
|
|
@ -35,10 +35,11 @@ function! s:Subst(format, vars) abort
|
|||
endfunction
|
||||
|
||||
function! ale_linters#prolog#swipl#Handle(buffer, lines) abort
|
||||
let l:pattern = '\v^(ERROR|Warning)+%(:\s*[^:]+:(\d+)%(:(\d+))?)?:\s*(.*)$'
|
||||
let l:output = []
|
||||
let l:i = 0
|
||||
|
||||
let l:pattern = '\v^(ERROR|Warning)+%(:\s*[^:]+:(\d+)%(:(\d+))?)?:\s*(.*)$'
|
||||
|
||||
while l:i < len(a:lines)
|
||||
let l:match = matchlist(a:lines[l:i], l:pattern)
|
||||
|
||||
|
@ -72,8 +73,17 @@ function! s:GetErrMsg(i, lines, text) abort
|
|||
let l:i = a:i + 1
|
||||
let l:text = []
|
||||
|
||||
while l:i < len(a:lines) && a:lines[l:i] =~# '^\s'
|
||||
call add(l:text, s:Trim(a:lines[l:i]))
|
||||
let l:pattern = '\v^(ERROR|Warning)?:?(.*)$'
|
||||
|
||||
while l:i < len(a:lines)
|
||||
let l:match = matchlist(a:lines[l:i], l:pattern)
|
||||
|
||||
if empty(l:match) || empty(l:match[2])
|
||||
let l:i += 1
|
||||
break
|
||||
endif
|
||||
|
||||
call add(l:text, s:Trim(l:match[2]))
|
||||
let l:i += 1
|
||||
endwhile
|
||||
|
||||
|
|
24
sources_non_forked/ale/ale_linters/proto/protolint.vim
Normal file
24
sources_non_forked/ale/ale_linters/proto/protolint.vim
Normal file
|
@ -0,0 +1,24 @@
|
|||
" Author: Yohei Yoshimuta <yoheimuta@gmail.com>
|
||||
" Description: run the protolint for Protocol Buffer files
|
||||
|
||||
call ale#Set('proto_protolint_executable', 'protolint')
|
||||
call ale#Set('proto_protolint_config', '')
|
||||
|
||||
function! ale_linters#proto#protolint#GetCommand(buffer) abort
|
||||
let l:config = ale#Var(a:buffer, 'proto_protolint_config')
|
||||
|
||||
return '%e lint'
|
||||
\ . (!empty(l:config) ? ' -config_path=' . ale#Escape(l:config) : '')
|
||||
\ . ' -reporter=unix'
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('proto', {
|
||||
\ 'name': 'protolint',
|
||||
\ 'lint_file': 1,
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': {b -> ale#Var(b, 'proto_protolint_executable')},
|
||||
\ 'command': function('ale_linters#proto#protolint#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#unix#HandleAsError',
|
||||
\})
|
||||
|
|
@ -38,30 +38,28 @@ function! ale_linters#python#flake8#RunWithVersionCheck(buffer) abort
|
|||
\)
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#flake8#GetCdString(buffer) abort
|
||||
function! ale_linters#python#flake8#GetCwd(buffer) abort
|
||||
let l:change_directory = ale#Var(a:buffer, 'python_flake8_change_directory')
|
||||
let l:cd_string = ''
|
||||
let l:cwd = ''
|
||||
|
||||
if l:change_directory is# 'project'
|
||||
let l:project_root = ale#python#FindProjectRootIni(a:buffer)
|
||||
|
||||
if !empty(l:project_root)
|
||||
let l:cd_string = ale#path#CdString(l:project_root)
|
||||
let l:cwd = l:project_root
|
||||
endif
|
||||
endif
|
||||
|
||||
if (l:change_directory is# 'project' && empty(l:cd_string))
|
||||
if (l:change_directory is# 'project' && empty(l:cwd))
|
||||
\|| l:change_directory is# 1
|
||||
\|| l:change_directory is# 'file'
|
||||
let l:cd_string = ale#path#BufferCdString(a:buffer)
|
||||
let l:cwd = '%s:h'
|
||||
endif
|
||||
|
||||
return l:cd_string
|
||||
return l:cwd
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#flake8#GetCommand(buffer, version) abort
|
||||
let l:cd_string = ale_linters#python#flake8#GetCdString(a:buffer)
|
||||
|
||||
let l:executable = ale_linters#python#flake8#GetExecutable(a:buffer)
|
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv$'
|
||||
|
@ -76,8 +74,7 @@ function! ale_linters#python#flake8#GetCommand(buffer, version) abort
|
|||
|
||||
let l:options = ale#Var(a:buffer, 'python_flake8_options')
|
||||
|
||||
return l:cd_string
|
||||
\ . ale#Escape(l:executable) . l:exec_args
|
||||
return ale#Escape(l:executable) . l:exec_args
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' --format=default'
|
||||
\ . l:display_name_args . ' -'
|
||||
|
@ -161,6 +158,7 @@ endfunction
|
|||
call ale#linter#Define('python', {
|
||||
\ 'name': 'flake8',
|
||||
\ 'executable': function('ale_linters#python#flake8#GetExecutable'),
|
||||
\ 'cwd': function('ale_linters#python#flake8#GetCwd'),
|
||||
\ 'command': function('ale_linters#python#flake8#RunWithVersionCheck'),
|
||||
\ 'callback': 'ale_linters#python#flake8#Handle',
|
||||
\})
|
||||
|
|
|
@ -18,7 +18,7 @@ function! ale_linters#python#mypy#GetExecutable(buffer) abort
|
|||
endfunction
|
||||
|
||||
" The directory to change to before running mypy
|
||||
function! s:GetDir(buffer) abort
|
||||
function! ale_linters#python#mypy#GetCwd(buffer) abort
|
||||
" If we find a directory with "mypy.ini" in it use that,
|
||||
" else try and find the "python project" root, or failing
|
||||
" that, run from the same folder as the current file
|
||||
|
@ -36,24 +36,19 @@ function! s:GetDir(buffer) abort
|
|||
endfunction
|
||||
|
||||
function! ale_linters#python#mypy#GetCommand(buffer) abort
|
||||
let l:dir = s:GetDir(a:buffer)
|
||||
let l:executable = ale_linters#python#mypy#GetExecutable(a:buffer)
|
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv$'
|
||||
\ ? ' run mypy'
|
||||
\ : ''
|
||||
|
||||
" We have to always switch to an explicit directory for a command so
|
||||
" we can know with certainty the base path for the 'filename' keys below.
|
||||
return ale#path#CdString(l:dir)
|
||||
\ . ale#Escape(l:executable) . l:exec_args
|
||||
\ . ' --show-column-numbers '
|
||||
\ . ale#Var(a:buffer, 'python_mypy_options')
|
||||
return '%e' . l:exec_args
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'python_mypy_options'))
|
||||
\ . ' --show-column-numbers'
|
||||
\ . ' --shadow-file %s %t %s'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#mypy#Handle(buffer, lines) abort
|
||||
let l:dir = s:GetDir(a:buffer)
|
||||
let l:dir = ale_linters#python#mypy#GetCwd(a:buffer)
|
||||
" Look for lines like the following:
|
||||
"
|
||||
" file.py:4: error: No library stub file for module 'django.db'
|
||||
|
@ -95,6 +90,7 @@ endfunction
|
|||
call ale#linter#Define('python', {
|
||||
\ 'name': 'mypy',
|
||||
\ 'executable': function('ale_linters#python#mypy#GetExecutable'),
|
||||
\ 'cwd': function('ale_linters#python#mypy#GetCwd'),
|
||||
\ 'command': function('ale_linters#python#mypy#GetCommand'),
|
||||
\ 'callback': 'ale_linters#python#mypy#Handle',
|
||||
\ 'output_stream': 'both'
|
||||
|
|
|
@ -21,8 +21,7 @@ function! ale_linters#python#pydocstyle#GetCommand(buffer) abort
|
|||
\ ? ' run pydocstyle'
|
||||
\ : ''
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(l:executable) . l:exec_args
|
||||
return ale#Escape(l:executable) . l:exec_args
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'python_pydocstyle_options'))
|
||||
\ . ' %s:t'
|
||||
endfunction
|
||||
|
@ -66,6 +65,7 @@ endfunction
|
|||
call ale#linter#Define('python', {
|
||||
\ 'name': 'pydocstyle',
|
||||
\ 'executable': function('ale_linters#python#pydocstyle#GetExecutable'),
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#python#pydocstyle#GetCommand'),
|
||||
\ 'callback': 'ale_linters#python#pydocstyle#Handle',
|
||||
\})
|
||||
|
|
|
@ -16,19 +16,20 @@ function! ale_linters#python#pylama#GetExecutable(buffer) abort
|
|||
return ale#python#FindExecutable(a:buffer, 'python_pylama', ['pylama'])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#pylama#GetCommand(buffer) abort
|
||||
let l:cd_string = ''
|
||||
|
||||
function! ale_linters#python#pylama#GetCwd(buffer) abort
|
||||
if ale#Var(a:buffer, 'python_pylama_change_directory')
|
||||
" Pylama loads its configuration from the current directory only, and
|
||||
" applies file masks using paths relative to the current directory.
|
||||
" Run from project root, if found, otherwise buffer dir.
|
||||
let l:project_root = ale#python#FindProjectRoot(a:buffer)
|
||||
let l:cd_string = l:project_root isnot# ''
|
||||
\ ? ale#path#CdString(l:project_root)
|
||||
\ : ale#path#BufferCdString(a:buffer)
|
||||
|
||||
return !empty(l:project_root) ? l:project_root : '%s:h'
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#pylama#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#python#pylama#GetExecutable(a:buffer)
|
||||
let l:exec_args = l:executable =~? 'pipenv$'
|
||||
\ ? ' run pylama'
|
||||
|
@ -37,8 +38,7 @@ function! ale_linters#python#pylama#GetCommand(buffer) abort
|
|||
" Note: Using %t to lint changes would be preferable, but many pylama
|
||||
" checks use surrounding paths (e.g. C0103 module name, E0402 relative
|
||||
" import beyond top, etc.). Neither is ideal.
|
||||
return l:cd_string
|
||||
\ . ale#Escape(l:executable) . l:exec_args
|
||||
return ale#Escape(l:executable) . l:exec_args
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'python_pylama_options'))
|
||||
\ . ' %s'
|
||||
endfunction
|
||||
|
@ -86,6 +86,7 @@ endfunction
|
|||
call ale#linter#Define('python', {
|
||||
\ 'name': 'pylama',
|
||||
\ 'executable': function('ale_linters#python#pylama#GetExecutable'),
|
||||
\ 'cwd': function('ale_linters#python#pylama#GetCwd'),
|
||||
\ 'command': function('ale_linters#python#pylama#GetCommand'),
|
||||
\ 'callback': 'ale_linters#python#pylama#Handle',
|
||||
\ 'lint_file': 1,
|
||||
|
|
|
@ -17,27 +17,26 @@ function! ale_linters#python#pylint#GetExecutable(buffer) abort
|
|||
return ale#python#FindExecutable(a:buffer, 'python_pylint', ['pylint'])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#pylint#GetCommand(buffer, version) abort
|
||||
let l:cd_string = ''
|
||||
|
||||
function! ale_linters#python#pylint#GetCwd(buffer) abort
|
||||
if ale#Var(a:buffer, 'python_pylint_change_directory')
|
||||
" pylint only checks for pylintrc in the packages above its current
|
||||
" directory before falling back to user and global pylintrc.
|
||||
" Run from project root, if found, otherwise buffer dir.
|
||||
let l:project_root = ale#python#FindProjectRoot(a:buffer)
|
||||
let l:cd_string = l:project_root isnot# ''
|
||||
\ ? ale#path#CdString(l:project_root)
|
||||
\ : ale#path#BufferCdString(a:buffer)
|
||||
|
||||
return !empty(l:project_root) ? l:project_root : '%s:h'
|
||||
endif
|
||||
|
||||
let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer)
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#pylint#GetCommand(buffer, version) abort
|
||||
let l:executable = ale_linters#python#pylint#GetExecutable(a:buffer)
|
||||
let l:exec_args = l:executable =~? 'pipenv$'
|
||||
\ ? ' run pylint'
|
||||
\ : ''
|
||||
|
||||
return l:cd_string
|
||||
\ . ale#Escape(l:executable) . l:exec_args
|
||||
return ale#Escape(l:executable) . l:exec_args
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'python_pylint_options'))
|
||||
\ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n'
|
||||
\ . (ale#semver#GTE(a:version, [2, 4, 0]) ? ' --from-stdin' : '')
|
||||
|
@ -104,6 +103,7 @@ call ale#linter#Define('python', {
|
|||
\ '%e --version',
|
||||
\ {buffer, version -> !ale#semver#GTE(version, [2, 4, 0])},
|
||||
\ )},
|
||||
\ 'cwd': function('ale_linters#python#pylint#GetCwd'),
|
||||
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale#Var(buffer, 'python_pylint_executable'),
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
" Description: A language server for Python
|
||||
|
||||
call ale#Set('python_pyls_executable', 'pyls')
|
||||
call ale#Set('python_pyls_options', '')
|
||||
call ale#Set('python_pyls_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('python_pyls_auto_pipenv', 0)
|
||||
call ale#Set('python_pyls_config', {})
|
||||
|
@ -22,7 +23,7 @@ function! ale_linters#python#pyls#GetCommand(buffer) abort
|
|||
\ ? ' run pyls'
|
||||
\ : ''
|
||||
|
||||
return ale#Escape(l:executable) . l:exec_args
|
||||
return ale#Escape(l:executable) . l:exec_args . ale#Pad(ale#Var(a:buffer, 'python_pyls_options'))
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('python', {
|
||||
|
|
|
@ -6,7 +6,6 @@ call ale#Set('python_vulture_options', '')
|
|||
call ale#Set('python_vulture_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('python_vulture_change_directory', 1)
|
||||
|
||||
|
||||
" The directory to change to before running vulture
|
||||
function! s:GetDir(buffer) abort
|
||||
let l:project_root = ale#python#FindProjectRoot(a:buffer)
|
||||
|
@ -16,29 +15,28 @@ function! s:GetDir(buffer) abort
|
|||
\ : expand('#' . a:buffer . ':p:h')
|
||||
endfunction
|
||||
|
||||
|
||||
function! ale_linters#python#vulture#GetExecutable(buffer) abort
|
||||
return ale#python#FindExecutable(a:buffer, 'python_vulture', ['vulture'])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#vulture#GetCwd(buffer) abort
|
||||
if !ale#Var(a:buffer, 'python_vulture_change_directory')
|
||||
return ''
|
||||
endif
|
||||
|
||||
return s:GetDir(a:buffer)
|
||||
endfunction
|
||||
|
||||
function! ale_linters#python#vulture#GetCommand(buffer) abort
|
||||
let l:change_dir = ale#Var(a:buffer, 'python_vulture_change_directory')
|
||||
\ ? ale#path#CdString(s:GetDir(a:buffer))
|
||||
\ : ''
|
||||
|
||||
let l:executable = ale_linters#python#vulture#GetExecutable(a:buffer)
|
||||
|
||||
let l:exec_args = l:executable =~? 'pipenv$'
|
||||
\ ? ' run vulture'
|
||||
\ : ''
|
||||
|
||||
let l:lint_dest = ale#Var(a:buffer, 'python_vulture_change_directory')
|
||||
\ ? ' .'
|
||||
\ : ' %s'
|
||||
|
||||
return l:change_dir
|
||||
\ . ale#Escape(l:executable) . l:exec_args
|
||||
return ale#Escape(l:executable) . l:exec_args
|
||||
\ . ' '
|
||||
\ . ale#Var(a:buffer, 'python_vulture_options')
|
||||
\ . l:lint_dest
|
||||
|
@ -74,6 +72,7 @@ endfunction
|
|||
call ale#linter#Define('python', {
|
||||
\ 'name': 'vulture',
|
||||
\ 'executable': function('ale_linters#python#vulture#GetExecutable'),
|
||||
\ 'cwd': function('ale_linters#python#vulture#GetCwd'),
|
||||
\ 'command': function('ale_linters#python#vulture#GetCommand'),
|
||||
\ 'callback': 'ale_linters#python#vulture#Handle',
|
||||
\ 'lint_file': 1,
|
||||
|
|
|
@ -21,14 +21,13 @@ function! ale_linters#r#lintr#GetCommand(buffer) abort
|
|||
let l:cmd_string = 'suppressPackageStartupMessages(library(lintr));'
|
||||
\ . l:lint_cmd
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'Rscript --vanilla -e '
|
||||
\ . ale#Escape(l:cmd_string) . ' %t'
|
||||
return 'Rscript --vanilla -e ' . ale#Escape(l:cmd_string) . ' %t'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('r', {
|
||||
\ 'name': 'lintr',
|
||||
\ 'executable': 'Rscript',
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#r#lintr#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#gcc#HandleGCCFormat',
|
||||
\ 'output_stream': 'both',
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
" Author: John Nduli https://github.com/jnduli
|
||||
" Description: Rstcheck for reStructuredText files
|
||||
"
|
||||
|
||||
function! ale_linters#rst#rstcheck#Handle(buffer, lines) abort
|
||||
" matches: 'bad_rst.rst:1: (SEVERE/4) Title overline & underline
|
||||
|
@ -22,17 +21,11 @@ function! ale_linters#rst#rstcheck#Handle(buffer, lines) abort
|
|||
return l:output
|
||||
endfunction
|
||||
|
||||
function! ale_linters#rst#rstcheck#GetCommand(buffer) abort
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'rstcheck'
|
||||
\ . ' %t'
|
||||
endfunction
|
||||
|
||||
|
||||
call ale#linter#Define('rst', {
|
||||
\ 'name': 'rstcheck',
|
||||
\ 'executable': 'rstcheck',
|
||||
\ 'command': function('ale_linters#rst#rstcheck#GetCommand'),
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': 'rstcheck %t',
|
||||
\ 'callback': 'ale_linters#rst#rstcheck#Handle',
|
||||
\ 'output_stream': 'both',
|
||||
\})
|
||||
|
|
|
@ -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', {
|
||||
|
|
|
@ -17,7 +17,7 @@ endfunction
|
|||
call ale#linter#Define('rust', {
|
||||
\ 'name': 'analyzer',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'lsp_config': {b -> ale#Var(b, 'rust_analyzer_config')},
|
||||
\ 'initialization_options': {b -> ale#Var(b, 'rust_analyzer_config')},
|
||||
\ 'executable': {b -> ale#Var(b, 'rust_analyzer_executable')},
|
||||
\ 'command': function('ale_linters#rust#analyzer#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#rust#analyzer#GetProjectRoot'),
|
||||
|
|
|
@ -23,6 +23,19 @@ function! ale_linters#rust#cargo#GetCargoExecutable(bufnr) abort
|
|||
endif
|
||||
endfunction
|
||||
|
||||
function! ale_linters#rust#cargo#GetCwd(buffer) abort
|
||||
if ale#Var(a:buffer, 'rust_cargo_avoid_whole_workspace')
|
||||
let l:nearest_cargo = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')
|
||||
let l:nearest_cargo_dir = fnamemodify(l:nearest_cargo, ':h')
|
||||
|
||||
if l:nearest_cargo_dir isnot# '.'
|
||||
return l:nearest_cargo_dir
|
||||
endif
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#rust#cargo#GetCommand(buffer, version) abort
|
||||
let l:use_check = ale#Var(a:buffer, 'rust_cargo_use_check')
|
||||
\ && ale#semver#GTE(a:version, [0, 17, 0])
|
||||
|
@ -42,18 +55,6 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort
|
|||
let l:include_features = ' --features ' . ale#Escape(l:include_features)
|
||||
endif
|
||||
|
||||
let l:avoid_whole_workspace = ale#Var(a:buffer, 'rust_cargo_avoid_whole_workspace')
|
||||
let l:nearest_cargo_prefix = ''
|
||||
|
||||
if l:avoid_whole_workspace
|
||||
let l:nearest_cargo = ale#path#FindNearestFile(a:buffer, 'Cargo.toml')
|
||||
let l:nearest_cargo_dir = fnamemodify(l:nearest_cargo, ':h')
|
||||
|
||||
if l:nearest_cargo_dir isnot# '.'
|
||||
let l:nearest_cargo_prefix = 'cd '. ale#Escape(l:nearest_cargo_dir) .' && '
|
||||
endif
|
||||
endif
|
||||
|
||||
let l:default_feature_behavior = ale#Var(a:buffer, 'rust_cargo_default_feature_behavior')
|
||||
|
||||
if l:default_feature_behavior is# 'all'
|
||||
|
@ -81,7 +82,7 @@ function! ale_linters#rust#cargo#GetCommand(buffer, version) abort
|
|||
endif
|
||||
endif
|
||||
|
||||
return l:nearest_cargo_prefix . 'cargo '
|
||||
return 'cargo '
|
||||
\ . l:subcommand
|
||||
\ . (l:use_all_targets ? ' --all-targets' : '')
|
||||
\ . (l:use_examples ? ' --examples' : '')
|
||||
|
@ -96,6 +97,7 @@ endfunction
|
|||
call ale#linter#Define('rust', {
|
||||
\ 'name': 'cargo',
|
||||
\ 'executable': function('ale_linters#rust#cargo#GetCargoExecutable'),
|
||||
\ 'cwd': function('ale_linters#rust#cargo#GetCwd'),
|
||||
\ 'command': {buffer -> ale#semver#RunWithVersionCheck(
|
||||
\ buffer,
|
||||
\ ale_linters#rust#cargo#GetCargoExecutable(buffer),
|
||||
|
|
33
sources_non_forked/ale/ale_linters/salt/salt_lint.vim
Normal file
33
sources_non_forked/ale/ale_linters/salt/salt_lint.vim
Normal file
|
@ -0,0 +1,33 @@
|
|||
" 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',
|
||||
\ 'aliases': ['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'
|
||||
\})
|
|
@ -1,29 +1,12 @@
|
|||
" Author: Franco Victorio - https://github.com/fvictorio
|
||||
" Authors: Franco Victorio - https://github.com/fvictorio, Henrique Barcelos
|
||||
" https://github.com/hbarcelos
|
||||
" Description: Report errors in Solidity code with solhint
|
||||
|
||||
function! ale_linters#solidity#solhint#Handle(buffer, lines) abort
|
||||
" Matches patterns like the following:
|
||||
" /path/to/file/file.sol: line 1, col 10, Error - 'addOne' is defined but never used. (no-unused-vars)
|
||||
let l:pattern = '\v^[^:]+: line (\d+), col (\d+), (Error|Warning) - (.*) \((.*)\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:isError = l:match[3] is? 'error'
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\ 'code': l:match[5],
|
||||
\ 'type': l:isError ? 'E' : 'W',
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('solidity', {
|
||||
\ 'name': 'solhint',
|
||||
\ 'executable': 'solhint',
|
||||
\ 'command': 'solhint --formatter compact %t',
|
||||
\ 'callback': 'ale_linters#solidity#solhint#Handle',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'executable': function('ale#handlers#solhint#GetExecutable'),
|
||||
\ 'cwd': function('ale#handlers#solhint#GetCwd'),
|
||||
\ 'command': function('ale#handlers#solhint#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#solhint#Handle',
|
||||
\})
|
||||
|
|
21
sources_non_forked/ale/ale_linters/svelte/svelteserver.vim
Normal file
21
sources_non_forked/ale/ale_linters/svelte/svelteserver.vim
Normal file
|
@ -0,0 +1,21 @@
|
|||
" Author: Joakim Repomaa <joakim@repomaa.com>
|
||||
" Description: Svelte Language Server integration for ALE
|
||||
|
||||
call ale#Set('svelte_svelteserver_executable', 'svelteserver')
|
||||
call ale#Set('svelte_svelteserver_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
function! ale_linters#svelte#svelteserver#GetProjectRoot(buffer) abort
|
||||
let l:package_path = ale#path#FindNearestFile(a:buffer, 'package.json')
|
||||
|
||||
return !empty(l:package_path) ? fnamemodify(l:package_path, ':h') : ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('svelte', {
|
||||
\ 'name': 'svelteserver',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'svelte_svelteserver', [
|
||||
\ 'node_modules/.bin/svelteserver',
|
||||
\ ])},
|
||||
\ 'command': '%e --stdio',
|
||||
\ 'project_root': function('ale_linters#svelte#svelteserver#GetProjectRoot'),
|
||||
\})
|
|
@ -0,0 +1,43 @@
|
|||
" Authors: Klaas Pieter Annema <https://github.com/klaaspieter>, bosr <bosr@bosr.cc>
|
||||
" Description: Support for swift-format https://github.com/apple/swift-format
|
||||
|
||||
function! ale_linters#swift#appleswiftformat#GetLinterCommand(buffer) abort
|
||||
let l:command_args = ale#swift#GetAppleSwiftFormatCommand(a:buffer) . ' lint %t'
|
||||
let l:config_args = ale#swift#GetAppleSwiftFormatConfigArgs(a:buffer)
|
||||
|
||||
if l:config_args isnot# ''
|
||||
let l:command_args = l:command_args . ' ' . l:config_args
|
||||
endif
|
||||
|
||||
return l:command_args
|
||||
endfunction
|
||||
|
||||
function! ale_linters#swift#appleswiftformat#Handle(buffer, lines) abort
|
||||
" Matches the typical output of swift-format, that is lines of the following pattern:
|
||||
"
|
||||
" Sources/main.swift:4:21: warning: [DoNotUseSemicolons] remove ';' and move the next statement to the new line
|
||||
" Sources/main.swift:3:12: warning: [Spacing] remove 1 space
|
||||
let l:pattern = '\v^.*:(\d+):(\d+): (\S+): \[(\S+)\] (.*)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
|
||||
\ 'code': l:match[4],
|
||||
\ 'text': l:match[5],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('swift', {
|
||||
\ 'name': 'apple-swift-format',
|
||||
\ 'executable': function('ale#swift#GetAppleSwiftFormatExecutable'),
|
||||
\ 'command': function('ale_linters#swift#appleswiftformat#GetLinterCommand'),
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'language': 'swift',
|
||||
\ 'callback': 'ale_linters#swift#appleswiftformat#Handle'
|
||||
\})
|
|
@ -1,62 +0,0 @@
|
|||
" Author: Klaas Pieter Annema <https://github.com/klaaspieter>
|
||||
" Description: Support for swift-format https://github.com/apple/swift-format
|
||||
|
||||
let s:default_executable = 'swift-format'
|
||||
call ale#Set('swift_swiftformat_executable', s:default_executable)
|
||||
|
||||
function! ale_linters#swift#swiftformat#UseSwift(buffer) abort
|
||||
let l:swift_config = ale#path#FindNearestFile(a:buffer, 'Package.swift')
|
||||
let l:executable = ale#Var(a:buffer, 'swift_swiftformat_executable')
|
||||
|
||||
return !empty(l:swift_config) && l:executable is# s:default_executable
|
||||
endfunction
|
||||
|
||||
function! ale_linters#swift#swiftformat#GetExecutable(buffer) abort
|
||||
if ale_linters#swift#swiftformat#UseSwift(a:buffer)
|
||||
return 'swift'
|
||||
endif
|
||||
|
||||
return ale#Var(a:buffer, 'swift_swiftformat_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#swift#swiftformat#GetCommand(buffer) abort
|
||||
let l:executable = ale_linters#swift#swiftformat#GetExecutable(a:buffer)
|
||||
let l:args = '--mode lint %t'
|
||||
|
||||
if ale_linters#swift#swiftformat#UseSwift(a:buffer)
|
||||
let l:args = 'run swift-format' . ' ' . l:args
|
||||
endif
|
||||
|
||||
return ale#Escape(l:executable) . ' ' . l:args
|
||||
endfunction
|
||||
|
||||
function! ale_linters#swift#swiftformat#Handle(buffer, lines) abort
|
||||
" Matches lines of the following pattern:
|
||||
"
|
||||
" Sources/main.swift:4:21: warning: [DoNotUseSemicolons]: remove ';' and move the next statement to the new line
|
||||
" Sources/main.swift:3:12: warning: [Spacing]: remove 1 space
|
||||
let l:pattern = '\v^.*:(\d+):(\d+): (\S+) \[(\S+)\]: (.*)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
|
||||
\ 'code': l:match[4],
|
||||
\ 'text': l:match[5],
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
|
||||
call ale#linter#Define('swift', {
|
||||
\ 'name': 'swift-format',
|
||||
\ 'executable': function('ale_linters#swift#swiftformat#GetExecutable'),
|
||||
\ 'command': function('ale_linters#swift#swiftformat#GetCommand'),
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'language': 'swift',
|
||||
\ 'callback': 'ale_linters#swift#swiftformat#Handle'
|
||||
\})
|
|
@ -0,0 +1,18 @@
|
|||
function! ale_linters#systemd#systemd_analyze#Handle(buffer, lines) abort
|
||||
return ale#util#MapMatches(a:lines, '\v(.+):([0-9]+): (.+)', {match -> {
|
||||
\ 'lnum': str2nr(match[2]),
|
||||
\ 'col': 1,
|
||||
\ 'type': 'W',
|
||||
\ 'text': match[3],
|
||||
\}})
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('systemd', {
|
||||
\ 'name': 'systemd_analyze',
|
||||
\ 'aliases': ['systemd-analyze'],
|
||||
\ 'executable': 'systemd-analyze',
|
||||
\ 'command': 'SYSTEMD_LOG_COLOR=0 %e --user verify %s',
|
||||
\ 'callback': 'ale_linters#systemd#systemd_analyze#Handle',
|
||||
\ 'output_stream': 'both',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
|
@ -9,30 +9,44 @@ endfunction
|
|||
|
||||
function! ale_linters#terraform#terraform#GetCommand(buffer) abort
|
||||
return ale#Escape(ale_linters#terraform#terraform#GetExecutable(a:buffer))
|
||||
\ . ' fmt -no-color --check=true -'
|
||||
\ . ' validate -no-color -json '
|
||||
endfunction
|
||||
|
||||
function! ale_linters#terraform#terraform#GetType(severity) abort
|
||||
if a:severity is? 'warning'
|
||||
return 'W'
|
||||
endif
|
||||
|
||||
return 'E'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#terraform#terraform#GetDetail(error) abort
|
||||
return get(a:error, 'detail', get(a:error, 'summary', ''))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#terraform#terraform#Handle(buffer, lines) abort
|
||||
let l:head = '^Error running fmt: In <standard input>: '
|
||||
let l:output = []
|
||||
let l:patterns = [
|
||||
\ l:head.'At \(\d\+\):\(\d\+\): \(.*\)$',
|
||||
\ l:head.'\(.*\)$'
|
||||
\]
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:patterns)
|
||||
if len(l:match[2]) > 0
|
||||
let l:errors = ale#util#FuzzyJSONDecode(a:lines, {'diagnostics': []})
|
||||
let l:dir = expand('#' . a:buffer . ':p:h')
|
||||
let l:file = expand('#' . a:buffer . ':p')
|
||||
|
||||
for l:error in l:errors['diagnostics']
|
||||
if has_key(l:error, 'range')
|
||||
call add(l:output, {
|
||||
\ 'lnum': str2nr(l:match[1]),
|
||||
\ 'col': str2nr(l:match[2]),
|
||||
\ 'text': l:match[3],
|
||||
\ 'type': 'E',
|
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:error['range']['filename']),
|
||||
\ 'lnum': l:error['range']['start']['line'],
|
||||
\ 'col': l:error['range']['start']['column'],
|
||||
\ 'text': ale_linters#terraform#terraform#GetDetail(l:error),
|
||||
\ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']),
|
||||
\})
|
||||
else
|
||||
call add(l:output, {
|
||||
\ 'lnum': line('$'),
|
||||
\ 'text': l:match[1],
|
||||
\ 'type': 'E',
|
||||
\ 'filename': l:file,
|
||||
\ 'lnum': 0,
|
||||
\ 'col': 0,
|
||||
\ 'text': ale_linters#terraform#terraform#GetDetail(l:error),
|
||||
\ 'type': ale_linters#terraform#terraform#GetType(l:error['severity']),
|
||||
\})
|
||||
endif
|
||||
endfor
|
||||
|
@ -42,7 +56,7 @@ endfunction
|
|||
|
||||
call ale#linter#Define('terraform', {
|
||||
\ 'name': 'terraform',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable': function('ale_linters#terraform#terraform#GetExecutable'),
|
||||
\ 'command': function('ale_linters#terraform#terraform#GetCommand'),
|
||||
\ 'callback': 'ale_linters#terraform#terraform#Handle',
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
" Author: Horacio Sanson <hsanson@gmail.com>
|
||||
" Description: terraform-ls integration for ALE (cf. https://github.com/hashicorp/terraform-ls)
|
||||
|
||||
call ale#Set('terraform_terraform_executable', 'terraform')
|
||||
call ale#Set('terraform_ls_executable', 'terraform-ls')
|
||||
call ale#Set('terraform_ls_options', '')
|
||||
|
||||
function! ale_linters#terraform#terraform_ls#GetTerraformExecutable(buffer) abort
|
||||
let l:terraform_executable = ale#Var(a:buffer, 'terraform_terraform_executable')
|
||||
|
||||
if(ale#path#IsAbsolute(l:terraform_executable))
|
||||
return '-tf-exec ' . l:terraform_executable
|
||||
endif
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#terraform#terraform_ls#GetCommand(buffer) abort
|
||||
return '%e'
|
||||
\ . ale#Pad('serve')
|
||||
\ . ale#Pad(ale_linters#terraform#terraform_ls#GetTerraformExecutable(a:buffer))
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'terraform_ls_options'))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#terraform#terraform_ls#GetProjectRoot(buffer) abort
|
||||
let l:tf_dir = ale#path#FindNearestDirectory(a:buffer, '.terraform')
|
||||
|
||||
return !empty(l:tf_dir) ? fnamemodify(l:tf_dir, ':h:h') : ''
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('terraform', {
|
||||
\ 'name': 'terraform_ls',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': {b -> ale#Var(b, 'terraform_ls_executable')},
|
||||
\ 'command': function('ale_linters#terraform#terraform_ls#GetCommand'),
|
||||
\ 'project_root': function('ale_linters#terraform#terraform_ls#GetProjectRoot'),
|
||||
\ 'language': 'terraform',
|
||||
\})
|
|
@ -1,11 +1,14 @@
|
|||
" Author: Ricardo Liang <ricardoliang@gmail.com>
|
||||
" Author: ourigen <ourigen [at] pm.me>
|
||||
" Description: Texlab language server (Rust rewrite)
|
||||
|
||||
call ale#Set('tex_texlab_executable', 'texlab')
|
||||
call ale#Set('tex_texlab_options', '')
|
||||
|
||||
function! ale_linters#tex#texlab#GetProjectRoot(buffer) abort
|
||||
return ''
|
||||
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
|
||||
|
||||
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : ''
|
||||
endfunction
|
||||
|
||||
function! ale_linters#tex#texlab#GetCommand(buffer) abort
|
||||
|
|
25
sources_non_forked/ale/ale_linters/typescript/deno.vim
Normal file
25
sources_non_forked/ale/ale_linters/typescript/deno.vim
Normal file
|
@ -0,0 +1,25 @@
|
|||
" Author: Mohammed Chelouti - https://github.com/motato1
|
||||
" Description: Deno lsp linter for TypeScript files.
|
||||
|
||||
call ale#linter#Define('typescript', {
|
||||
\ 'name': 'deno',
|
||||
\ 'lsp': 'stdio',
|
||||
\ 'executable': function('ale#handlers#deno#GetExecutable'),
|
||||
\ 'command': '%e lsp',
|
||||
\ 'project_root': function('ale#handlers#deno#GetProjectRoot'),
|
||||
\ 'initialization_options': function('ale_linters#typescript#deno#GetInitializationOptions'),
|
||||
\})
|
||||
|
||||
function! ale_linters#typescript#deno#GetInitializationOptions(buffer) abort
|
||||
let l:options = {
|
||||
\ 'enable': v:true,
|
||||
\ 'lint': v:true,
|
||||
\ 'unstable': v:false,
|
||||
\ }
|
||||
|
||||
if ale#Var(a:buffer, 'deno_unstable')
|
||||
let l:options.unstable = v:true
|
||||
endif
|
||||
|
||||
return l:options
|
||||
endfunction
|
|
@ -4,6 +4,7 @@
|
|||
call ale#linter#Define('typescript', {
|
||||
\ 'name': 'eslint',
|
||||
\ 'executable': function('ale#handlers#eslint#GetExecutable'),
|
||||
\ 'cwd': function('ale#handlers#eslint#GetCwd'),
|
||||
\ 'command': function('ale#handlers#eslint#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#eslint#HandleJSON',
|
||||
\})
|
||||
|
|
|
@ -59,8 +59,7 @@ function! ale_linters#typescript#tslint#GetCommand(buffer) abort
|
|||
\ ? ' -r ' . ale#Escape(l:tslint_rules_dir)
|
||||
\ : ''
|
||||
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer))
|
||||
return ale#Escape(ale#handlers#tslint#GetExecutable(a:buffer))
|
||||
\ . ' --format json'
|
||||
\ . l:tslint_config_option
|
||||
\ . l:tslint_rules_option
|
||||
|
@ -70,6 +69,7 @@ endfunction
|
|||
call ale#linter#Define('typescript', {
|
||||
\ 'name': 'tslint',
|
||||
\ 'executable': function('ale#handlers#tslint#GetExecutable'),
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': function('ale_linters#typescript#tslint#GetCommand'),
|
||||
\ 'callback': 'ale_linters#typescript#tslint#Handle',
|
||||
\})
|
||||
|
|
|
@ -1,23 +1,6 @@
|
|||
call ale#Set('typescript_xo_executable', 'xo')
|
||||
call ale#Set('typescript_xo_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
call ale#Set('typescript_xo_options', '')
|
||||
|
||||
function! ale_linters#typescript#xo#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'typescript_xo', [
|
||||
\ 'node_modules/.bin/xo',
|
||||
\])
|
||||
endfunction
|
||||
|
||||
function! ale_linters#typescript#xo#GetCommand(buffer) abort
|
||||
return ale#Escape(ale_linters#typescript#xo#GetExecutable(a:buffer))
|
||||
\ . ale#Pad(ale#Var(a:buffer, 'typescript_xo_options'))
|
||||
\ . ' --reporter json --stdin --stdin-filename %s'
|
||||
endfunction
|
||||
|
||||
" xo uses eslint and the output format is the same
|
||||
call ale#linter#Define('typescript', {
|
||||
\ 'name': 'xo',
|
||||
\ 'executable': function('ale_linters#typescript#xo#GetExecutable'),
|
||||
\ 'command': function('ale_linters#typescript#xo#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#eslint#HandleJSON',
|
||||
\ 'executable': function('ale#handlers#xo#GetExecutable'),
|
||||
\ 'command': function('ale#handlers#xo#GetLintCommand'),
|
||||
\ 'callback': 'ale#handlers#xo#HandleJSON',
|
||||
\})
|
||||
|
|
82
sources_non_forked/ale/ale_linters/v/v.vim
Normal file
82
sources_non_forked/ale/ale_linters/v/v.vim
Normal file
|
@ -0,0 +1,82 @@
|
|||
" Author: fiatjaf <fiatjaf@alhur.es>
|
||||
" Description: v build for V files
|
||||
|
||||
call ale#Set('v_v_executable', 'v')
|
||||
call ale#Set('v_v_options', '')
|
||||
|
||||
function! ale_linters#v#v#GetCommand(buffer) abort
|
||||
let l:options = ale#Var(a:buffer, 'v_v_options')
|
||||
|
||||
" Run v in local directory with relative path
|
||||
let l:command = ale#Var(a:buffer, 'v_v_executable')
|
||||
\ . ale#Pad(l:options)
|
||||
\ . ' .' . ' -o /tmp/vim-ale-v'
|
||||
|
||||
return l:command
|
||||
endfunction
|
||||
|
||||
function! ale_linters#v#v#Handler(buffer, lines) abort
|
||||
let l:dir = expand('#' . a:buffer . ':p:h')
|
||||
let l:output = []
|
||||
|
||||
" Matches patterns like the following:
|
||||
"
|
||||
" ./const.v:4:3: warning: const names cannot contain uppercase letters, use snake_case instead
|
||||
" 2 |
|
||||
" 3 | const (
|
||||
" 4 | BUTTON_TEXT = 'OK'
|
||||
" | ~~~~~~~~~~~
|
||||
" 5 | )
|
||||
" ./main.v:4:8: warning: module 'os' is imported but never used
|
||||
" 2 |
|
||||
" 3 | import ui
|
||||
" 4 | import os
|
||||
" | ~~
|
||||
" 5 |
|
||||
" 6 | const (
|
||||
" ./main.v:20:10: error: undefined ident: `win_widt`
|
||||
" 18 | mut app := &App{}
|
||||
" 19 | app.window = ui.window({
|
||||
" 20 | width: win_widt
|
||||
" | ~~~~~~~~
|
||||
" 21 | height: win_height
|
||||
" 22 | title: 'Counter'
|
||||
let l:current = {}
|
||||
|
||||
for l:line in a:lines
|
||||
" matches basic error description
|
||||
let l:match = matchlist(l:line,
|
||||
\ '\([^:]\+\):\([^:]\+\):\([^:]\+\): \([^:]\+\): \(.*\)')
|
||||
|
||||
if !empty(l:match)
|
||||
let l:current = {
|
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]),
|
||||
\ 'lnum': l:match[2] + 0,
|
||||
\ 'col': l:match[3] + 0,
|
||||
\ 'text': l:match[5],
|
||||
\ 'type': l:match[4] is# 'error' ? 'E' : 'W',
|
||||
\}
|
||||
call add(l:output, l:current)
|
||||
continue
|
||||
endif
|
||||
|
||||
" try to get information about the ending column
|
||||
let l:tildematch = matchstr(l:line, '\~\+')
|
||||
|
||||
if !empty(l:tildematch)
|
||||
let l:current['end_col'] = l:current['col'] + len(l:tildematch)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('v', {
|
||||
\ 'name': 'v',
|
||||
\ 'aliases': [],
|
||||
\ 'executable': {b -> ale#Var(b, 'v_v_executable')},
|
||||
\ 'command': function('ale_linters#v#v#GetCommand'),
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale_linters#v#v#Handler',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
66
sources_non_forked/ale/ale_linters/vala/vala_lint.vim
Normal file
66
sources_non_forked/ale/ale_linters/vala/vala_lint.vim
Normal file
|
@ -0,0 +1,66 @@
|
|||
" Author: Atsuya Takagi <asoftonight@gmail.com>
|
||||
" Description: A linter for Vala using Vala-Lint.
|
||||
|
||||
call ale#Set('vala_vala_lint_config_filename', 'vala-lint.conf')
|
||||
call ale#Set('vala_vala_lint_executable', 'io.elementary.vala-lint')
|
||||
|
||||
function! ale_linters#vala#vala_lint#GetExecutable(buffer) abort
|
||||
return ale#Var(a:buffer, 'vala_vala_lint_executable')
|
||||
endfunction
|
||||
|
||||
function! ale_linters#vala#vala_lint#GetCommand(buffer) abort
|
||||
let l:command = ale_linters#vala#vala_lint#GetExecutable(a:buffer)
|
||||
|
||||
let l:config_filename = ale#Var(a:buffer, 'vala_vala_lint_config_filename')
|
||||
let l:config_path = ale#path#FindNearestFile(a:buffer, l:config_filename)
|
||||
|
||||
if !empty(l:config_path)
|
||||
let l:command .= ' -c ' . l:config_path
|
||||
endif
|
||||
|
||||
return l:command . ' %s'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#vala#vala_lint#Handle(buffer, lines) abort
|
||||
let l:pattern = '^\s*\(\d\+\)\.\(\d\+\)\s\+\(error\|warn\)\s\+\(.\+\)\s\([A-Za-z0-9_\-]\+\)'
|
||||
let l:output = []
|
||||
|
||||
for l:line in a:lines
|
||||
" remove color escape sequences since vala-lint doesn't support
|
||||
" output without colors
|
||||
let l:cleaned_line = substitute(l:line, '\e\[[0-9;]\+[mK]', '', 'g')
|
||||
let l:match = matchlist(l:cleaned_line, l:pattern)
|
||||
|
||||
if len(l:match) == 0
|
||||
continue
|
||||
endif
|
||||
|
||||
let l:refined_type = l:match[3] is# 'warn' ? 'W' : 'E'
|
||||
let l:cleaned_text = substitute(l:match[4], '^\s*\(.\{-}\)\s*$', '\1', '')
|
||||
|
||||
let l:lnum = l:match[1] + 0
|
||||
let l:column = l:match[2] + 0
|
||||
let l:type = l:refined_type
|
||||
let l:text = l:cleaned_text
|
||||
let l:code = l:match[5]
|
||||
|
||||
call add(l:output, {
|
||||
\ 'lnum': l:lnum,
|
||||
\ 'col': l:column,
|
||||
\ 'text': l:text,
|
||||
\ 'type': l:type,
|
||||
\ 'code': l:code,
|
||||
\})
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('vala', {
|
||||
\ 'name': 'vala_lint',
|
||||
\ 'output_stream': 'stdout',
|
||||
\ 'executable': function('ale_linters#vala#vala_lint#GetExecutable'),
|
||||
\ 'command': function('ale_linters#vala#vala_lint#GetCommand'),
|
||||
\ 'callback': 'ale_linters#vala#vala_lint#Handle',
|
||||
\ 'lint_file': 1,
|
||||
\})
|
|
@ -7,16 +7,11 @@ if !exists('g:ale_verilog_verilator_options')
|
|||
endif
|
||||
|
||||
function! ale_linters#verilog#verilator#GetCommand(buffer) abort
|
||||
let l:filename = ale#util#Tempname() . '_verilator_linted.v'
|
||||
|
||||
" Create a special filename, so we can detect it in the handler.
|
||||
call ale#command#ManageFile(a:buffer, l:filename)
|
||||
let l:lines = getbufline(a:buffer, 1, '$')
|
||||
call ale#util#Writefile(a:buffer, l:lines, l:filename)
|
||||
|
||||
" the path to the current file is systematically added to the search path
|
||||
return 'verilator --lint-only -Wall -Wno-DECLFILENAME '
|
||||
\ . '-I%s:h '
|
||||
\ . ale#Var(a:buffer, 'verilog_verilator_options') .' '
|
||||
\ . ale#Escape(l:filename)
|
||||
\ . '%t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
|
||||
|
@ -34,7 +29,7 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
|
|||
"
|
||||
" to stay compatible with old versions of the tool, the column number is
|
||||
" optional in the researched pattern
|
||||
let l:pattern = '^%\(Warning\|Error\)[^:]*:\([^:]\+\):\(\d\+\):\(\d\+\)\?:\? \(.\+\)$'
|
||||
let l:pattern = '^%\(Warning\|Error\)[^:]*:\s*\([^:]\+\):\(\d\+\):\(\d\+\)\?:\? \(.\+\)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
|
@ -42,17 +37,14 @@ function! ale_linters#verilog#verilator#Handle(buffer, lines) abort
|
|||
\ 'lnum': str2nr(l:match[3]),
|
||||
\ 'text': l:match[5],
|
||||
\ 'type': l:match[1] is# 'Error' ? 'E' : 'W',
|
||||
\ 'filename': l:match[2],
|
||||
\}
|
||||
|
||||
if !empty(l:match[4])
|
||||
let l:item.col = str2nr(l:match[4])
|
||||
endif
|
||||
|
||||
let l:file = l:match[2]
|
||||
|
||||
if l:file =~# '_verilator_linted.v'
|
||||
call add(l:output, l:item)
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
|
|
|
@ -22,16 +22,20 @@ function! s:GetALEProjectDir(buffer) abort
|
|||
return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable)))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort
|
||||
let l:dir = s:GetALEProjectDir(a:buffer)
|
||||
function! ale_linters#vim#ale_custom_linting_rules#GetCwd(buffer) abort
|
||||
let l:executable = ale_linters#vim#ale_custom_linting_rules#GetExecutable(a:buffer)
|
||||
|
||||
return ale#path#Dirname(ale#path#Dirname(ale#path#Dirname(l:executable)))
|
||||
endfunction
|
||||
|
||||
function! ale_linters#vim#ale_custom_linting_rules#GetCommand(buffer) abort
|
||||
let l:temp_dir = ale#command#CreateDirectory(a:buffer)
|
||||
let l:temp_file = l:temp_dir . '/example.vim'
|
||||
|
||||
let l:lines = getbufline(a:buffer, 1, '$')
|
||||
call ale#util#Writefile(a:buffer, l:lines, l:temp_file)
|
||||
|
||||
return ale#path#CdString(l:dir) . '%e ' . ale#Escape(l:temp_dir)
|
||||
return '%e ' . ale#Escape(l:temp_dir)
|
||||
endfunction
|
||||
|
||||
function! ale_linters#vim#ale_custom_linting_rules#Handle(buffer, lines) abort
|
||||
|
@ -59,6 +63,7 @@ endfunction
|
|||
call ale#linter#Define('vim', {
|
||||
\ 'name': 'ale_custom_linting_rules',
|
||||
\ 'executable': function('ale_linters#vim#ale_custom_linting_rules#GetExecutable'),
|
||||
\ 'cwd': function('ale_linters#vim#ale_custom_linting_rules#GetCwd'),
|
||||
\ 'command': function('ale_linters#vim#ale_custom_linting_rules#GetCommand'),
|
||||
\ 'callback': 'ale_linters#vim#ale_custom_linting_rules#Handle',
|
||||
\ 'read_buffer': 0,
|
||||
|
|
14
sources_non_forked/ale/ale_linters/yaml/spectral.vim
Normal file
14
sources_non_forked/ale/ale_linters/yaml/spectral.vim
Normal file
|
@ -0,0 +1,14 @@
|
|||
" Author: t2h5 <https://github.com/t2h5>
|
||||
" Description: Integration of Stoplight Spectral CLI with ALE.
|
||||
|
||||
call ale#Set('yaml_spectral_executable', 'spectral')
|
||||
call ale#Set('yaml_spectral_use_global', get(g:, 'ale_use_global_executables', 0))
|
||||
|
||||
call ale#linter#Define('yaml', {
|
||||
\ 'name': 'spectral',
|
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'yaml_spectral', [
|
||||
\ 'node_modules/.bin/spectral',
|
||||
\ ])},
|
||||
\ 'command': '%e lint --ignore-unknown-format -q -f text %t',
|
||||
\ 'callback': 'ale#handlers#spectral#HandleSpectralOutput'
|
||||
\})
|
|
@ -3,48 +3,9 @@
|
|||
call ale#Set('yaml_yamllint_executable', 'yamllint')
|
||||
call ale#Set('yaml_yamllint_options', '')
|
||||
|
||||
function! ale_linters#yaml#yamllint#GetCommand(buffer) abort
|
||||
return '%e' . ale#Pad(ale#Var(a:buffer, 'yaml_yamllint_options'))
|
||||
\ . ' -f parsable %t'
|
||||
endfunction
|
||||
|
||||
function! ale_linters#yaml#yamllint#Handle(buffer, lines) abort
|
||||
" Matches patterns line the following:
|
||||
" something.yaml:1:1: [warning] missing document start "---" (document-start)
|
||||
" something.yml:2:1: [error] syntax error: expected the node content, but found '<stream end>'
|
||||
let l:pattern = '\v^.*:(\d+):(\d+): \[(error|warning)\] (.+)$'
|
||||
let l:output = []
|
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern)
|
||||
let l:item = {
|
||||
\ 'lnum': l:match[1] + 0,
|
||||
\ 'col': l:match[2] + 0,
|
||||
\ 'text': l:match[4],
|
||||
\ 'type': l:match[3] is# 'error' ? 'E' : 'W',
|
||||
\}
|
||||
|
||||
let l:code_match = matchlist(l:item.text, '\v^(.+) \(([^)]+)\)$')
|
||||
|
||||
if !empty(l:code_match)
|
||||
if l:code_match[2] is# 'trailing-spaces'
|
||||
\&& !ale#Var(a:buffer, 'warn_about_trailing_whitespace')
|
||||
" Skip warnings for trailing whitespace if the option is off.
|
||||
continue
|
||||
endif
|
||||
|
||||
let l:item.text = l:code_match[1]
|
||||
let l:item.code = l:code_match[2]
|
||||
endif
|
||||
|
||||
call add(l:output, l:item)
|
||||
endfor
|
||||
|
||||
return l:output
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('yaml', {
|
||||
\ 'name': 'yamllint',
|
||||
\ 'executable': {b -> ale#Var(b, 'yaml_yamllint_executable')},
|
||||
\ 'command': function('ale_linters#yaml#yamllint#GetCommand'),
|
||||
\ 'callback': 'ale_linters#yaml#yamllint#Handle',
|
||||
\ 'command': function('ale#handlers#yamllint#GetCommand'),
|
||||
\ 'callback': 'ale#handlers#yamllint#Handle',
|
||||
\})
|
||||
|
|
|
@ -157,7 +157,7 @@ function! ale#Queue(delay, ...) abort
|
|||
endif
|
||||
endfunction
|
||||
|
||||
let s:current_ale_version = [3, 0, 0]
|
||||
let s:current_ale_version = [3, 1, 0]
|
||||
|
||||
" A function used to check for ALE features in files outside of the project.
|
||||
function! ale#Has(feature) abort
|
||||
|
|
|
@ -23,19 +23,23 @@ function! ale#ant#FindExecutable(buffer) abort
|
|||
return ''
|
||||
endfunction
|
||||
|
||||
" Given a buffer number, build a command to print the classpath of the root
|
||||
" project. Returns an empty string if cannot build the command.
|
||||
" Given a buffer number, get a working directory and command to print the
|
||||
" classpath of the root project.
|
||||
"
|
||||
" Returns an empty string for the command if Ant is not detected.
|
||||
function! ale#ant#BuildClasspathCommand(buffer) abort
|
||||
let l:executable = ale#ant#FindExecutable(a:buffer)
|
||||
|
||||
if !empty(l:executable)
|
||||
let l:project_root = ale#ant#FindProjectRoot(a:buffer)
|
||||
|
||||
if !empty(l:executable) && !empty(l:project_root)
|
||||
return ale#path#CdString(l:project_root)
|
||||
\ . ale#Escape(l:executable)
|
||||
\ . ' classpath'
|
||||
\ . ' -S'
|
||||
\ . ' -q'
|
||||
if !empty(l:project_root)
|
||||
return [
|
||||
\ l:project_root,
|
||||
\ ale#Escape(l:executable) .' classpath -S -q'
|
||||
\]
|
||||
endif
|
||||
endif
|
||||
|
||||
return ''
|
||||
return ['', '']
|
||||
endfunction
|
||||
|
|
|
@ -52,6 +52,36 @@ function! s:ProcessDeferredCommands(initial_result) abort
|
|||
return l:command
|
||||
endfunction
|
||||
|
||||
function! s:ProcessDeferredCwds(initial_command, initial_cwd) abort
|
||||
let l:result = a:initial_command
|
||||
let l:last_cwd = v:null
|
||||
let l:command_index = 0
|
||||
let l:cwd_list = []
|
||||
|
||||
while ale#command#IsDeferred(l:result)
|
||||
call add(l:cwd_list, l:result.cwd)
|
||||
|
||||
if get(g:, 'ale_run_synchronously_emulate_commands')
|
||||
" Don't run commands, but simulate the results.
|
||||
let l:Callback = g:ale_run_synchronously_callbacks[0]
|
||||
let l:output = get(s:command_output, l:command_index, [])
|
||||
call l:Callback(0, l:output)
|
||||
unlet g:ale_run_synchronously_callbacks
|
||||
|
||||
let l:command_index += 1
|
||||
else
|
||||
" Run the commands in the shell, synchronously.
|
||||
call ale#test#FlushJobs()
|
||||
endif
|
||||
|
||||
let l:result = l:result.value
|
||||
endwhile
|
||||
|
||||
call add(l:cwd_list, a:initial_cwd is v:null ? l:last_cwd : a:initial_cwd)
|
||||
|
||||
return l:cwd_list
|
||||
endfunction
|
||||
|
||||
" Load the currently loaded linter for a test case, and check that the command
|
||||
" matches the given string.
|
||||
function! ale#assert#Linter(expected_executable, expected_command) abort
|
||||
|
@ -85,6 +115,38 @@ function! ale#assert#Linter(expected_executable, expected_command) abort
|
|||
\ [l:executable, l:command]
|
||||
endfunction
|
||||
|
||||
function! ale#assert#LinterCwd(expected_cwd) abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:linter = s:GetLinter()
|
||||
|
||||
let l:initial_cwd = ale#linter#GetCwd(l:buffer, l:linter)
|
||||
call ale#command#SetCwd(l:buffer, l:initial_cwd)
|
||||
|
||||
let l:cwd = s:ProcessDeferredCwds(
|
||||
\ ale#linter#GetCommand(l:buffer, l:linter),
|
||||
\ l:initial_cwd,
|
||||
\)
|
||||
|
||||
call ale#command#ResetCwd(l:buffer)
|
||||
|
||||
if type(a:expected_cwd) isnot v:t_list
|
||||
let l:cwd = l:cwd[-1]
|
||||
endif
|
||||
|
||||
AssertEqual a:expected_cwd, l:cwd
|
||||
endfunction
|
||||
|
||||
function! ale#assert#FixerCwd(expected_cwd) abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:cwd = s:ProcessDeferredCwds(s:FixerFunction(l:buffer), v:null)
|
||||
|
||||
if type(a:expected_cwd) isnot v:t_list
|
||||
let l:cwd = l:cwd[-1]
|
||||
endif
|
||||
|
||||
AssertEqual a:expected_cwd, l:cwd
|
||||
endfunction
|
||||
|
||||
function! ale#assert#Fixer(expected_result) abort
|
||||
let l:buffer = bufnr('')
|
||||
let l:result = s:ProcessDeferredCommands(s:FixerFunction(l:buffer))
|
||||
|
@ -107,8 +169,21 @@ function! ale#assert#LinterNotExecuted() abort
|
|||
let l:buffer = bufnr('')
|
||||
let l:linter = s:GetLinter()
|
||||
let l:executable = ale#linter#GetExecutable(l:buffer, l:linter)
|
||||
let l:executed = 1
|
||||
|
||||
Assert empty(l:executable), "The linter will be executed when it shouldn't be"
|
||||
if !empty(l:executable)
|
||||
let l:command = ale#linter#GetCommand(l:buffer, l:linter)
|
||||
|
||||
if type(l:command) is v:t_list
|
||||
let l:command = l:command[-1]
|
||||
endif
|
||||
|
||||
let l:executed = !empty(l:command)
|
||||
else
|
||||
let l:executed = 0
|
||||
endif
|
||||
|
||||
Assert !l:executed, "The linter will be executed when it shouldn't be"
|
||||
endfunction
|
||||
|
||||
function! ale#assert#LSPOptions(expected_options) abort
|
||||
|
@ -153,6 +228,7 @@ endfunction
|
|||
|
||||
function! ale#assert#SetUpLinterTestCommands() abort
|
||||
command! -nargs=+ GivenCommandOutput :call ale#assert#GivenCommandOutput(<args>)
|
||||
command! -nargs=+ AssertLinterCwd :call ale#assert#LinterCwd(<args>)
|
||||
command! -nargs=+ AssertLinter :call ale#assert#Linter(<args>)
|
||||
command! -nargs=0 AssertLinterNotExecuted :call ale#assert#LinterNotExecuted()
|
||||
command! -nargs=+ AssertLSPOptions :call ale#assert#LSPOptions(<args>)
|
||||
|
@ -164,10 +240,35 @@ endfunction
|
|||
|
||||
function! ale#assert#SetUpFixerTestCommands() abort
|
||||
command! -nargs=+ GivenCommandOutput :call ale#assert#GivenCommandOutput(<args>)
|
||||
command! -nargs=+ AssertFixerCwd :call ale#assert#FixerCwd(<args>)
|
||||
command! -nargs=+ AssertFixer :call ale#assert#Fixer(<args>)
|
||||
command! -nargs=0 AssertFixerNotExecuted :call ale#assert#FixerNotExecuted()
|
||||
endfunction
|
||||
|
||||
function! ale#assert#ResetVariables(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
|
||||
|
||||
let l:option_suffix = get(a:000, 0, a:name)
|
||||
let l:prefix = 'ale_' . a:filetype . '_'
|
||||
\ . substitute(l:option_suffix, '-', '_', 'g')
|
||||
let l:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix'
|
||||
|
||||
" Save and clear linter variables.
|
||||
" We'll load the runtime file to reset them to defaults.
|
||||
for l:key in filter(keys(g:), l:filter_expr)
|
||||
execute 'Save g:' . l:key
|
||||
unlet g:[l:key]
|
||||
endfor
|
||||
|
||||
for l:key in filter(keys(b:), l:filter_expr)
|
||||
unlet b:[l:key]
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" A dummy function for making sure this module is loaded.
|
||||
function! ale#assert#SetUpLinterTest(filetype, name) abort
|
||||
" Set up a marker so ALE doesn't create real random temporary filenames.
|
||||
|
@ -177,35 +278,22 @@ function! ale#assert#SetUpLinterTest(filetype, name) abort
|
|||
call ale#linter#Reset()
|
||||
call ale#linter#PreventLoading(a:filetype)
|
||||
|
||||
let l:prefix = 'ale_' . a:filetype . '_' . a:name
|
||||
let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix'
|
||||
Save g:ale_root
|
||||
let g:ale_root = {}
|
||||
|
||||
Save g:ale_lsp_root
|
||||
let g:ale_lsp_root = {}
|
||||
Save b:ale_root
|
||||
unlet! b:ale_root
|
||||
|
||||
Save b:ale_lsp_root
|
||||
unlet! b:ale_lsp_root
|
||||
call ale#assert#ResetVariables(a:filetype, a:name)
|
||||
|
||||
Save g:ale_c_build_dir
|
||||
unlet! g:ale_c_build_dir
|
||||
|
||||
" Save and clear linter variables.
|
||||
" We'll load the runtime file to reset them to defaults.
|
||||
for l:key in filter(keys(g:), b:filter_expr)
|
||||
execute 'Save g:' . l:key
|
||||
unlet g:[l:key]
|
||||
endfor
|
||||
|
||||
unlet! b:ale_c_build_dir
|
||||
|
||||
for l:key in filter(keys(b:), b:filter_expr)
|
||||
unlet b:[l:key]
|
||||
endfor
|
||||
|
||||
execute 'runtime ale_linters/' . a:filetype . '/' . a:name . '.vim'
|
||||
|
||||
if !exists('g:dir')
|
||||
call ale#test#SetDirectory('/testplugin/test/command_callback')
|
||||
call ale#test#SetDirectory('/testplugin/test/linter')
|
||||
endif
|
||||
|
||||
call ale#assert#SetUpLinterTestCommands()
|
||||
|
@ -226,6 +314,10 @@ function! ale#assert#TearDownLinterTest() abort
|
|||
delcommand GivenCommandOutput
|
||||
endif
|
||||
|
||||
if exists(':AssertLinterCwd')
|
||||
delcommand AssertLinterCwd
|
||||
endif
|
||||
|
||||
if exists(':AssertLinter')
|
||||
delcommand AssertLinter
|
||||
endif
|
||||
|
@ -281,18 +373,7 @@ function! ale#assert#SetUpFixerTest(filetype, name, ...) abort
|
|||
let s:FixerFunction = function(l:function_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)
|
||||
execute 'Save g:' . l:key
|
||||
unlet g:[l:key]
|
||||
endfor
|
||||
|
||||
for l:key in filter(keys(b:), b:filter_expr)
|
||||
unlet b:[l:key]
|
||||
endfor
|
||||
call ale#assert#ResetVariables(a:filetype, a:name, l:option_suffix)
|
||||
|
||||
execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim'
|
||||
|
||||
|
@ -329,6 +410,10 @@ function! ale#assert#TearDownFixerTest() abort
|
|||
delcommand GivenCommandOutput
|
||||
endif
|
||||
|
||||
if exists(':AssertFixerCwd')
|
||||
delcommand AssertFixerCwd
|
||||
endif
|
||||
|
||||
if exists(':AssertFixer')
|
||||
delcommand AssertFixer
|
||||
endif
|
||||
|
|
|
@ -152,6 +152,7 @@ function! ale#c#ParseCFlags(path_prefix, should_quote, raw_arguments) abort
|
|||
\ || stridx(l:option, '-idirafter') == 0
|
||||
\ || stridx(l:option, '-iframework') == 0
|
||||
\ || stridx(l:option, '-include') == 0
|
||||
\ || stridx(l:option, '-imacros') == 0
|
||||
if stridx(l:option, '-I') == 0 && l:option isnot# '-I'
|
||||
let l:arg = join(split(l:option, '\zs')[2:], '')
|
||||
let l:option = '-I'
|
||||
|
@ -490,7 +491,7 @@ function! ale#c#GetCFlags(buffer, output) abort
|
|||
endif
|
||||
endif
|
||||
|
||||
if s:CanParseMakefile(a:buffer) && !empty(a:output) && !empty(l:cflags)
|
||||
if empty(l:cflags) && s:CanParseMakefile(a:buffer) && !empty(a:output)
|
||||
let l:cflags = ale#c#ParseCFlagsFromMakeOutput(a:buffer, a:output)
|
||||
endif
|
||||
|
||||
|
@ -505,19 +506,25 @@ function! ale#c#GetMakeCommand(buffer) abort
|
|||
if s:CanParseMakefile(a:buffer)
|
||||
let l:path = ale#path#FindNearestFile(a:buffer, 'Makefile')
|
||||
|
||||
if empty(l:path)
|
||||
let l:path = ale#path#FindNearestFile(a:buffer, 'GNUmakefile')
|
||||
endif
|
||||
|
||||
if !empty(l:path)
|
||||
let l:always_make = ale#Var(a:buffer, 'c_always_make')
|
||||
|
||||
return ale#path#CdString(fnamemodify(l:path, ':h'))
|
||||
\ . 'make -n' . (l:always_make ? ' --always-make' : '')
|
||||
return [
|
||||
\ fnamemodify(l:path, ':h'),
|
||||
\ 'make -n' . (l:always_make ? ' --always-make' : ''),
|
||||
\]
|
||||
endif
|
||||
endif
|
||||
|
||||
return ''
|
||||
return ['', '']
|
||||
endfunction
|
||||
|
||||
function! ale#c#RunMakeCommand(buffer, Callback) abort
|
||||
let l:command = ale#c#GetMakeCommand(a:buffer)
|
||||
let [l:cwd, l:command] = ale#c#GetMakeCommand(a:buffer)
|
||||
|
||||
if empty(l:command)
|
||||
return a:Callback(a:buffer, [])
|
||||
|
@ -527,6 +534,7 @@ function! ale#c#RunMakeCommand(buffer, Callback) abort
|
|||
\ a:buffer,
|
||||
\ l:command,
|
||||
\ {b, output -> a:Callback(a:buffer, output)},
|
||||
\ {'cwd': l:cwd},
|
||||
\)
|
||||
endfunction
|
||||
|
||||
|
|
|
@ -71,6 +71,11 @@ function! ale#code_action#ApplyChanges(filename, changes, should_save) abort
|
|||
|
||||
if l:buffer > 0
|
||||
let l:lines = getbufline(l:buffer, 1, '$')
|
||||
|
||||
" Add empty line if there's trailing newline, like readfile() does.
|
||||
if getbufvar(l:buffer, '&eol')
|
||||
let l:lines += ['']
|
||||
endif
|
||||
else
|
||||
let l:lines = readfile(a:filename, 'b')
|
||||
endif
|
||||
|
@ -89,62 +94,82 @@ function! ale#code_action#ApplyChanges(filename, changes, should_save) abort
|
|||
let l:end_column = l:code_edit.end.offset
|
||||
let l:text = l:code_edit.newText
|
||||
|
||||
" Adjust the ends according to previous edits.
|
||||
if l:end_line > len(l:lines)
|
||||
let l:end_line_len = 0
|
||||
else
|
||||
let l:end_line_len = len(l:lines[l:end_line - 1])
|
||||
endif
|
||||
|
||||
let l:insertions = split(l:text, '\n', 1)
|
||||
|
||||
if l:line is 1
|
||||
" Same logic as for column below. Vimscript's slice [:-1] will not
|
||||
" be an empty list.
|
||||
let l:start = []
|
||||
else
|
||||
let l:start = l:lines[: l:line - 2]
|
||||
" Fix invalid columns
|
||||
let l:column = l:column > 0 ? l:column : 1
|
||||
let l:end_column = l:end_column > 0 ? l:end_column : 1
|
||||
|
||||
" Clamp start to BOF
|
||||
if l:line < 1
|
||||
let [l:line, l:column] = [1, 1]
|
||||
endif
|
||||
|
||||
" Special case when text must be added after new line
|
||||
if l:column > len(l:lines[l:line - 1])
|
||||
call extend(l:start, [l:lines[l:line - 1]])
|
||||
let l:column = 1
|
||||
" Clamp start to EOF
|
||||
if l:line > len(l:lines) || l:line == len(l:lines) && l:column > len(l:lines[-1]) + 1
|
||||
let [l:line, l:column] = [len(l:lines), len(l:lines[-1]) + 1]
|
||||
" Special case when start is after EOL
|
||||
elseif l:line < len(l:lines) && l:column > len(l:lines[l:line - 1]) + 1
|
||||
let [l:line, l:column] = [l:line + 1, 1]
|
||||
endif
|
||||
|
||||
if l:column is 1
|
||||
" We need to handle column 1 specially, because we can't slice an
|
||||
" empty string ending on index 0.
|
||||
let l:middle = [l:insertions[0]]
|
||||
else
|
||||
let l:middle = [l:lines[l:line - 1][: l:column - 2] . l:insertions[0]]
|
||||
" Adjust end: clamp if invalid and/or adjust if we moved start
|
||||
if l:end_line < l:line || l:end_line == l:line && l:end_column < l:column
|
||||
let [l:end_line, l:end_column] = [l:line, l:column]
|
||||
endif
|
||||
|
||||
call extend(l:middle, l:insertions[1:])
|
||||
" Clamp end to EOF
|
||||
if l:end_line > len(l:lines) || l:end_line == len(l:lines) && l:end_column > len(l:lines[-1]) + 1
|
||||
let [l:end_line, l:end_column] = [len(l:lines), len(l:lines[-1]) + 1]
|
||||
" Special case when end is after EOL
|
||||
elseif l:end_line < len(l:lines) && l:end_column > len(l:lines[l:end_line - 1]) + 1
|
||||
let [l:end_line, l:end_column] = [l:end_line + 1, 1]
|
||||
endif
|
||||
|
||||
if l:end_line <= len(l:lines)
|
||||
" Only extend the last line if end_line is within the range of
|
||||
" lines.
|
||||
" Careful, [:-1] is not an empty list
|
||||
let l:start = l:line is 1 ? [] : l:lines[: l:line - 2]
|
||||
let l:middle = l:column is 1 ? [''] : [l:lines[l:line - 1][: l:column - 2]]
|
||||
|
||||
let l:middle[-1] .= l:insertions[0]
|
||||
let l:middle += l:insertions[1:]
|
||||
let l:middle[-1] .= l:lines[l:end_line - 1][l:end_column - 1 :]
|
||||
endif
|
||||
|
||||
let l:end_line_len = len(l:lines[l:end_line - 1])
|
||||
let l:lines_before_change = len(l:lines)
|
||||
let l:lines = l:start + l:middle + l:lines[l:end_line :]
|
||||
|
||||
let l:current_line_offset = len(l:lines) - l:lines_before_change
|
||||
let l:column_offset = len(l:middle[-1]) - l:end_line_len
|
||||
|
||||
" Keep cursor where it was (if outside of changes) or move it after
|
||||
" the changed text (if inside), but don't touch it when the change
|
||||
" spans the entire buffer, in which case we have no clue and it's
|
||||
" better to not do anything.
|
||||
if l:line isnot 1 || l:column isnot 1
|
||||
\|| l:end_line < l:lines_before_change
|
||||
\|| l:end_line == l:lines_before_change && l:end_column <= l:end_line_len
|
||||
let l:pos = s:UpdateCursor(l:pos,
|
||||
\ [l:line, l:column],
|
||||
\ [l:end_line, l:end_column],
|
||||
\ [l:current_line_offset, l:column_offset])
|
||||
endif
|
||||
endfor
|
||||
|
||||
if l:lines[-1] is# ''
|
||||
if l:buffer > 0
|
||||
" Make sure ale#util#{Writefile,SetBufferContents} add trailing
|
||||
" newline if and only if it should be added.
|
||||
if l:lines[-1] is# '' && getbufvar(l:buffer, '&eol')
|
||||
call remove(l:lines, -1)
|
||||
else
|
||||
call setbufvar(l:buffer, '&eol', 0)
|
||||
endif
|
||||
elseif exists('+fixeol') && &fixeol && l:lines[-1] is# ''
|
||||
" Not in buffer, ale#util#Writefile can't check &eol and always adds
|
||||
" newline if &fixeol: remove to prevent double trailing newline.
|
||||
call remove(l:lines, -1)
|
||||
endif
|
||||
|
||||
if a:should_save
|
||||
if a:should_save || l:buffer < 0
|
||||
call ale#util#Writefile(l:buffer, l:lines, a:filename)
|
||||
else
|
||||
call ale#util#SetBufferContents(l:buffer, l:lines)
|
||||
|
@ -222,6 +247,10 @@ function! s:UpdateCursor(cursor, start, end, offset) abort
|
|||
endfunction
|
||||
|
||||
function! ale#code_action#GetChanges(workspace_edit) abort
|
||||
if a:workspace_edit is v:null
|
||||
return {}
|
||||
endif
|
||||
|
||||
let l:changes = {}
|
||||
|
||||
if has_key(a:workspace_edit, 'changes') && !empty(a:workspace_edit.changes)
|
||||
|
|
|
@ -261,7 +261,10 @@ function! ale#codefix#HandleLSPResponse(conn_id, response) abort
|
|||
|
||||
" Send the results to the menu callback, if set.
|
||||
if l:MenuCallback isnot v:null
|
||||
call l:MenuCallback(map(copy(l:result), '[''lsp'', v:val]'))
|
||||
call l:MenuCallback(
|
||||
\ l:data,
|
||||
\ map(copy(l:result), '[''lsp'', v:val]')
|
||||
\)
|
||||
|
||||
return
|
||||
endif
|
||||
|
|
|
@ -7,6 +7,9 @@ if !exists('s:buffer_data')
|
|||
let s:buffer_data = {}
|
||||
endif
|
||||
|
||||
" The regular expression used for formatting filenames with modifiers.
|
||||
let s:path_format_regex = '\v\%s(%(:h|:t|:r|:e)*)'
|
||||
|
||||
" Used to get the data in tests.
|
||||
function! ale#command#GetData() abort
|
||||
return deepcopy(s:buffer_data)
|
||||
|
@ -26,6 +29,19 @@ function! ale#command#InitData(buffer) abort
|
|||
endif
|
||||
endfunction
|
||||
|
||||
" Set the cwd for commands that are about to run.
|
||||
" Used internally.
|
||||
function! ale#command#SetCwd(buffer, cwd) abort
|
||||
call ale#command#InitData(a:buffer)
|
||||
let s:buffer_data[a:buffer].cwd = a:cwd
|
||||
endfunction
|
||||
|
||||
function! ale#command#ResetCwd(buffer) abort
|
||||
if has_key(s:buffer_data, a:buffer)
|
||||
let s:buffer_data[a:buffer].cwd = v:null
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#command#ManageFile(buffer, file) abort
|
||||
call ale#command#InitData(a:buffer)
|
||||
call add(s:buffer_data[a:buffer].file_list, a:file)
|
||||
|
@ -151,6 +167,24 @@ function! s:FormatFilename(filename, mappings, modifiers) abort
|
|||
return ale#Escape(l:filename)
|
||||
endfunction
|
||||
|
||||
" Produce a command prefix to check to a particular directory for a command.
|
||||
" %s format markers with filename-modifiers can be used as the directory, and
|
||||
" will be returned verbatim for formatting in paths relative to files.
|
||||
function! ale#command#CdString(directory) abort
|
||||
let l:match = matchstrpos(a:directory, s:path_format_regex)
|
||||
" Do not escape the directory here if it's a valid format string.
|
||||
" This allows us to use sequences like %s:h, %s:h:h, etc.
|
||||
let l:directory = l:match[1:] == [0, len(a:directory)]
|
||||
\ ? a:directory
|
||||
\ : ale#Escape(a:directory)
|
||||
|
||||
if has('win32')
|
||||
return 'cd /d ' . l:directory . ' && '
|
||||
endif
|
||||
|
||||
return 'cd ' . l:directory . ' && '
|
||||
endfunction
|
||||
|
||||
" Given a command string, replace every...
|
||||
" %s -> with the current filename
|
||||
" %t -> with the name of an unused file in a temporary directory
|
||||
|
@ -161,11 +195,16 @@ function! ale#command#FormatCommand(
|
|||
\ command,
|
||||
\ pipe_file_if_needed,
|
||||
\ input,
|
||||
\ cwd,
|
||||
\ mappings,
|
||||
\) abort
|
||||
let l:temporary_file = ''
|
||||
let l:command = a:command
|
||||
|
||||
if !empty(a:cwd)
|
||||
let l:command = ale#command#CdString(a:cwd) . l:command
|
||||
endif
|
||||
|
||||
" First replace all uses of %%, used for literal percent characters,
|
||||
" with an ugly string.
|
||||
let l:command = substitute(l:command, '%%', '<<PERCENTS>>', 'g')
|
||||
|
@ -181,7 +220,7 @@ function! ale#command#FormatCommand(
|
|||
let l:filename = fnamemodify(bufname(a:buffer), ':p')
|
||||
let l:command = substitute(
|
||||
\ l:command,
|
||||
\ '\v\%s(%(:h|:t|:r|:e)*)',
|
||||
\ s:path_format_regex,
|
||||
\ '\=s:FormatFilename(l:filename, a:mappings, submatch(1))',
|
||||
\ 'g'
|
||||
\)
|
||||
|
@ -279,9 +318,16 @@ function! s:ExitCallback(buffer, line_list, Callback, data) abort
|
|||
let l:result = a:data.result
|
||||
let l:result.value = l:value
|
||||
|
||||
" Set the default cwd for this buffer in this call stack.
|
||||
call ale#command#SetCwd(a:buffer, l:result.cwd)
|
||||
|
||||
try
|
||||
if get(l:result, 'result_callback', v:null) isnot v:null
|
||||
call call(l:result.result_callback, [l:value])
|
||||
endif
|
||||
finally
|
||||
call ale#command#ResetCwd(a:buffer)
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
function! ale#command#Run(buffer, command, Callback, ...) abort
|
||||
|
@ -293,6 +339,13 @@ function! ale#command#Run(buffer, command, Callback, ...) abort
|
|||
|
||||
let l:output_stream = get(l:options, 'output_stream', 'stdout')
|
||||
let l:line_list = []
|
||||
let l:cwd = get(l:options, 'cwd', v:null)
|
||||
|
||||
if l:cwd is v:null
|
||||
" Default the working directory to whatever it was for the last
|
||||
" command run in the chain.
|
||||
let l:cwd = get(get(s:buffer_data, a:buffer, {}), 'cwd', v:null)
|
||||
endif
|
||||
|
||||
let [l:temporary_file, l:command, l:file_created] = ale#command#FormatCommand(
|
||||
\ a:buffer,
|
||||
|
@ -300,6 +353,7 @@ function! ale#command#Run(buffer, command, Callback, ...) abort
|
|||
\ a:command,
|
||||
\ get(l:options, 'read_buffer', 0),
|
||||
\ get(l:options, 'input', v:null),
|
||||
\ l:cwd,
|
||||
\ get(l:options, 'filename_mappings', []),
|
||||
\)
|
||||
let l:command = ale#job#PrepareCommand(a:buffer, l:command)
|
||||
|
@ -366,10 +420,14 @@ function! ale#command#Run(buffer, command, Callback, ...) abort
|
|||
" The `_deferred_job_id` is used for both checking the type of object, and
|
||||
" for checking the job ID and status.
|
||||
"
|
||||
" The cwd is kept and used as the default value for the next command in
|
||||
" the chain.
|
||||
"
|
||||
" The original command here is used in tests.
|
||||
let l:result = {
|
||||
\ '_deferred_job_id': l:job_id,
|
||||
\ 'executable': get(l:options, 'executable', ''),
|
||||
\ 'cwd': l:cwd,
|
||||
\ 'command': a:command,
|
||||
\}
|
||||
|
||||
|
|
|
@ -614,6 +614,8 @@ function! ale#completion#ParseLSPCompletions(response) abort
|
|||
\ 'kind': ale#completion#GetCompletionSymbols(get(l:item, 'kind', '')),
|
||||
\ 'icase': 1,
|
||||
\ 'menu': l:detail,
|
||||
\ 'dup': get(l:info, 'additional_edits_only', 0)
|
||||
\ || g:ale_completion_autoimport,
|
||||
\ 'info': (type(l:doc) is v:t_string ? l:doc : ''),
|
||||
\}
|
||||
" This flag is used to tell if this completion came from ALE or not.
|
||||
|
|
|
@ -9,7 +9,6 @@ let g:ale_echo_delay = get(g:, 'ale_echo_delay', 10)
|
|||
let g:ale_echo_msg_format = get(g:, 'ale_echo_msg_format', '%code: %%s')
|
||||
|
||||
let s:cursor_timer = -1
|
||||
let s:last_pos = [0, 0, 0]
|
||||
|
||||
function! ale#cursor#TruncatedEcho(original_message) abort
|
||||
let l:message = a:original_message
|
||||
|
@ -118,14 +117,18 @@ function! ale#cursor#EchoCursorWarningWithDelay() abort
|
|||
|
||||
let l:pos = getpos('.')[0:2]
|
||||
|
||||
if !exists('w:last_pos')
|
||||
let w:last_pos = [0, 0, 0]
|
||||
endif
|
||||
|
||||
" Check the current buffer, line, and column number against the last
|
||||
" recorded position. If the position has actually changed, *then*
|
||||
" we should echo something. Otherwise we can end up doing processing
|
||||
" the echo message far too frequently.
|
||||
if l:pos != s:last_pos
|
||||
if l:pos != w:last_pos
|
||||
let l:delay = ale#Var(l:buffer, 'echo_delay')
|
||||
|
||||
let s:last_pos = l:pos
|
||||
let w:last_pos = l:pos
|
||||
let s:cursor_timer = timer_start(
|
||||
\ l:delay,
|
||||
\ function('ale#cursor#EchoCursorWarning')
|
||||
|
@ -139,12 +142,17 @@ function! s:ShowCursorDetailForItem(loc, options) abort
|
|||
let s:last_detailed_line = line('.')
|
||||
let l:message = get(a:loc, 'detail', a:loc.text)
|
||||
let l:lines = split(l:message, "\n")
|
||||
|
||||
if g:ale_floating_preview || g:ale_detail_to_floating_preview
|
||||
call ale#floating_preview#Show(l:lines)
|
||||
else
|
||||
call ale#preview#Show(l:lines, {'stay_here': l:stay_here})
|
||||
|
||||
" Clear the echo message if we manually displayed details.
|
||||
if !l:stay_here
|
||||
execute 'echo'
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#cursor#ShowCursorDetail() abort
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue