mirror of https://github.com/amix/vimrc.git
parent
44dca49794
commit
d2d303593e
@ -0,0 +1,22 @@ |
||||
" Author: aurieh <me@aurieh.me> |
||||
" Description: A Language Server implementation for D |
||||
|
||||
call ale#Set('d_dls_executable', 'dls') |
||||
|
||||
function! ale_linters#d#dls#GetExecutable(buffer) abort |
||||
return ale#Var(a:buffer, 'd_dls_executable') |
||||
endfunction |
||||
|
||||
function! ale_linters#d#dls#FindProjectRoot(buffer) abort |
||||
" Note: this will return . if dub config is empty |
||||
" dls can run outside DUB projects just fine |
||||
return fnamemodify(ale#d#FindDUBConfig(a:buffer), ':h') |
||||
endfunction |
||||
|
||||
call ale#linter#Define('d', { |
||||
\ 'name': 'dls', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable_callback': 'ale_linters#d#dls#GetExecutable', |
||||
\ 'command_callback': 'ale_linters#d#dls#GetExecutable', |
||||
\ 'project_root_callback': 'ale_linters#d#dls#FindProjectRoot', |
||||
\}) |
@ -0,0 +1,61 @@ |
||||
" Author: Alexander Olofsson <alexander.olofsson@liu.se> |
||||
|
||||
call ale#Set('dockerfile_dockerfile_lint_executable', 'dockerfile_lint') |
||||
call ale#Set('dockerfile_dockerfile_lint_options', '') |
||||
|
||||
function! ale_linters#dockerfile#dockerfile_lint#GetType(type) abort |
||||
if a:type is? 'error' |
||||
return 'E' |
||||
elseif a:type is? 'warn' |
||||
return 'W' |
||||
endif |
||||
|
||||
return 'I' |
||||
endfunction |
||||
|
||||
function! ale_linters#dockerfile#dockerfile_lint#Handle(buffer, lines) abort |
||||
try |
||||
let l:data = json_decode(join(a:lines, '')) |
||||
catch |
||||
return [] |
||||
endtry |
||||
|
||||
if empty(l:data) |
||||
" Should never happen, but it's better to be on the safe side |
||||
return [] |
||||
endif |
||||
|
||||
let l:messages = [] |
||||
|
||||
for l:type in ['error', 'warn', 'info'] |
||||
for l:object in l:data[l:type]['data'] |
||||
let l:line = get(l:object, 'line', -1) |
||||
let l:message = l:object['message'] |
||||
|
||||
if get(l:object, 'description', 'None') isnot# 'None' |
||||
let l:message = l:message . '. ' . l:object['description'] |
||||
endif |
||||
|
||||
call add(l:messages, { |
||||
\ 'lnum': l:line, |
||||
\ 'text': l:message, |
||||
\ 'type': ale_linters#dockerfile#dockerfile_lint#GetType(l:type), |
||||
\}) |
||||
endfor |
||||
endfor |
||||
|
||||
return l:messages |
||||
endfunction |
||||
|
||||
function! ale_linters#dockerfile#dockerfile_lint#GetCommand(buffer) abort |
||||
return '%e' . ale#Pad(ale#Var(a:buffer, 'dockerfile_dockerfile_lint_options')) |
||||
\ . ' -p -j -f' |
||||
\ . ' %t' |
||||
endfunction |
||||
|
||||
call ale#linter#Define('dockerfile', { |
||||
\ 'name': 'dockerfile_lint', |
||||
\ 'executable_callback': ale#VarFunc('dockerfile_dockerfile_lint_executable'), |
||||
\ 'command_callback': 'ale_linters#dockerfile#dockerfile_lint#GetCommand', |
||||
\ 'callback': 'ale_linters#dockerfile#dockerfile_lint#Handle', |
||||
\}) |
@ -0,0 +1,19 @@ |
||||
" Author: Jon Parise <jon@indelible.org> |
||||
" Description: elixir-ls integration (https://github.com/JakeBecker/elixir-ls) |
||||
|
||||
call ale#Set('elixir_elixir_ls_release', 'elixir-ls') |
||||
|
||||
function! ale_linters#elixir#elixir_ls#GetExecutable(buffer) abort |
||||
let l:dir = ale#path#Simplify(ale#Var(a:buffer, 'elixir_elixir_ls_release')) |
||||
let l:cmd = ale#Has('win32') ? '\language_server.bat' : '/language_server.sh' |
||||
|
||||
return l:dir . l:cmd |
||||
endfunction |
||||
|
||||
call ale#linter#Define('elixir', { |
||||
\ 'name': 'elixir-ls', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable_callback': 'ale_linters#elixir#elixir_ls#GetExecutable', |
||||
\ 'command_callback': 'ale_linters#elixir#elixir_ls#GetExecutable', |
||||
\ 'project_root_callback': 'ale#handlers#elixir#FindMixProjectRoot', |
||||
\}) |
@ -0,0 +1,166 @@ |
||||
" Author:Travis Gibson <https://github.com/Garland-g> |
||||
" Description: This file adds support for checking perl6 syntax |
||||
|
||||
let g:ale_perl6_perl6_executable = |
||||
\ get(g:, 'ale_perl6_perl6_executable', 'perl6') |
||||
|
||||
let g:ale_perl6_perl6_options = |
||||
\ get(g:, 'ale_perl6_perl6_options', '-c -Ilib') |
||||
|
||||
let $PERL6_EXCEPTIONS_HANDLER = 'JSON' |
||||
|
||||
let $RAKUDO_ERROR_COLOR = 0 |
||||
|
||||
function! ale_linters#perl6#perl6#GetExecutable(buffer) abort |
||||
return ale#Var(a:buffer, 'perl6_perl6_executable') |
||||
endfunction |
||||
|
||||
function! ale_linters#perl6#perl6#GetCommand(buffer) abort |
||||
return ale_linters#perl6#perl6#GetExecutable(a:buffer) |
||||
\ . ' ' . ale#Var(a:buffer, 'perl6_perl6_options') |
||||
\ . ' %t' |
||||
endfunction |
||||
|
||||
function! ale_linters#perl6#perl6#ExtractError(dict, item, type, buffer) abort |
||||
let l:file = '' |
||||
let l:line = 1 |
||||
let l:column = '' |
||||
let l:text = '' |
||||
let l:pre = '' |
||||
let l:counter = 2 |
||||
let l:end_line = '' |
||||
let l:linepatternmessage = 'at\s\+line\s\+\(\d\+\)' |
||||
|
||||
if has_key(a:dict[a:item], 'filename') && !empty(a:dict[a:item]['filename']) |
||||
let l:file = a:dict[a:item]['filename'] |
||||
endif |
||||
|
||||
if has_key(a:dict[a:item], 'line') && !empty(a:dict[a:item]['line']) |
||||
let l:line = a:dict[a:item]['line'] |
||||
let l:counter -= 1 |
||||
endif |
||||
|
||||
if has_key(a:dict[a:item], 'column') && !empty(a:dict[a:item]['column']) |
||||
let l:column = a:dict[a:item]['column'] |
||||
endif |
||||
|
||||
if has_key(a:dict[a:item], 'message') && !empty(a:dict[a:item]['message']) |
||||
let l:text = substitute(a:dict[a:item]['message'], '\s*\n\s*', ' ', 'g') |
||||
let l:counter -= 1 |
||||
endif |
||||
|
||||
if has_key(a:dict[a:item], 'line-real') && !empty(a:dict[a:item]['line-real']) |
||||
let l:end_line = l:line |
||||
let l:line = a:dict[a:item]['line-real'] |
||||
endif |
||||
|
||||
for l:match in ale#util#GetMatches(l:text, l:linepatternmessage) |
||||
let l:line = l:match[1] |
||||
let l:counter -= 1 |
||||
endfor |
||||
|
||||
" Currently, filenames and line numbers are not always given in the error output |
||||
if l:counter < 2 |
||||
\&& ( ale#path#IsBufferPath(a:buffer, l:file) || l:file is# '' ) |
||||
return { |
||||
\ 'lnum': '' . l:line, |
||||
\ 'text': l:text, |
||||
\ 'type': a:type, |
||||
\ 'col': l:column, |
||||
\ 'end_lnum': l:end_line, |
||||
\ 'code': a:item, |
||||
\} |
||||
endif |
||||
|
||||
return '' |
||||
endfunction |
||||
|
||||
function! ale_linters#perl6#perl6#Handle(buffer, lines) abort |
||||
let l:output = [] |
||||
|
||||
if empty(a:lines) |
||||
return l:output |
||||
endif |
||||
|
||||
if a:lines[0] is# 'Syntax OK' |
||||
return l:output |
||||
endif |
||||
|
||||
try |
||||
let l:json = json_decode(join(a:lines, '')) |
||||
catch /E474/ |
||||
call add(l:output, { |
||||
\ 'lnum': '1', |
||||
\ 'text': 'Received output in the default Perl6 error format. See :ALEDetail for details', |
||||
\ 'detail': join(a:lines, "\n"), |
||||
\ 'type': 'W', |
||||
\ }) |
||||
|
||||
return l:output |
||||
endtry |
||||
|
||||
if type(l:json) is v:t_dict |
||||
for l:key in keys(l:json) |
||||
if has_key(l:json[l:key], 'sorrows') && |
||||
\ has_key(l:json[l:key], 'worries') |
||||
if !empty(l:json[l:key]['sorrows']) |
||||
for l:dictionary in get(l:json[l:key], 'sorrows') |
||||
for l:item in keys(l:dictionary) |
||||
let l:result = |
||||
\ ale_linters#perl6#perl6#ExtractError( |
||||
\ l:dictionary, |
||||
\ l:item, |
||||
\ 'E', |
||||
\ a:buffer, |
||||
\ ) |
||||
|
||||
if l:result isnot# '' |
||||
call add(l:output, l:result) |
||||
endif |
||||
endfor |
||||
endfor |
||||
endif |
||||
|
||||
if !empty(l:json[l:key]['worries']) |
||||
for l:dictionary in get(l:json[l:key], 'worries') |
||||
for l:item in keys(l:dictionary) |
||||
let l:result = |
||||
\ ale_linters#perl6#perl6#ExtractError( |
||||
\ l:dictionary, |
||||
\ l:item, |
||||
\ 'W', |
||||
\ a:buffer, |
||||
\ ) |
||||
|
||||
if l:result isnot# '' |
||||
call add(l:output, l:result) |
||||
endif |
||||
endfor |
||||
endfor |
||||
endif |
||||
else |
||||
let l:result = ale_linters#perl6#perl6#ExtractError( |
||||
\ l:json, |
||||
\ l:key, |
||||
\ 'E', |
||||
\ a:buffer, |
||||
\ ) |
||||
|
||||
if l:result isnot# '' |
||||
call add(l:output, l:result) |
||||
endif |
||||
endif |
||||
endfor |
||||
endif |
||||
|
||||
return l:output |
||||
endfunction |
||||
|
||||
call ale#linter#Define('perl6', { |
||||
\ 'name': 'perl6', |
||||
\ 'executable_callback': 'ale_linters#perl6#perl6#GetExecutable', |
||||
\ 'output_stream': 'both', |
||||
\ 'command_callback': 'ale_linters#perl6#perl6#GetCommand', |
||||
\ 'callback': 'ale_linters#perl6#perl6#Handle', |
||||
\}) |
||||
|
@ -1,28 +1,21 @@ |
||||
" Author: richard marmorstein <https://github.com/twitchard> |
||||
" Author: Matt Brown <https://github.com/muglug> |
||||
" Description: plugin for Psalm, static analyzer for PHP |
||||
|
||||
call ale#Set('php_psalm_executable', 'psalm') |
||||
call ale#Set('psalm_langserver_executable', 'psalm-language-server') |
||||
call ale#Set('psalm_langserver_use_global', get(g:, 'ale_use_global_executables', 0)) |
||||
|
||||
function! ale_linters#php#psalm#Handle(buffer, lines) abort |
||||
" Matches patterns like the following: |
||||
let l:pattern = '^.*:\(\d\+\):\(\d\+\):\(\w\+\) - \(.*\)$' |
||||
let l:output = [] |
||||
function! ale_linters#php#psalm#GetProjectRoot(buffer) abort |
||||
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git') |
||||
|
||||
for l:match in ale#util#GetMatches(a:lines, l:pattern) |
||||
call add(l:output, { |
||||
\ 'lnum': l:match[1] + 0, |
||||
\ 'text': l:match[4], |
||||
\ 'type': l:match[3][:0] is# 'e' ? 'E' : 'W', |
||||
\}) |
||||
endfor |
||||
|
||||
return l:output |
||||
return !empty(l:git_path) ? fnamemodify(l:git_path, ':h:h') : '' |
||||
endfunction |
||||
|
||||
call ale#linter#Define('php', { |
||||
\ 'name': 'psalm', |
||||
\ 'command': '%e --diff --output-format=emacs %s', |
||||
\ 'executable_callback': ale#VarFunc('php_psalm_executable'), |
||||
\ 'callback': 'ale_linters#php#psalm#Handle', |
||||
\ 'lint_file': 1, |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable_callback': ale#node#FindExecutableFunc('psalm_langserver', [ |
||||
\ 'vendor/bin/psalm-language-server', |
||||
\ ]), |
||||
\ 'command': '%e', |
||||
\ 'project_root_callback': 'ale_linters#php#psalm#GetProjectRoot', |
||||
\}) |
||||
|
@ -0,0 +1,100 @@ |
||||
" Author: Takuya Fujiwara <tyru.exe@gmail.com> |
||||
" Description: swipl syntax / semantic check for Prolog files |
||||
|
||||
call ale#Set('prolog_swipl_executable', 'swipl') |
||||
call ale#Set('prolog_swipl_load', 'current_prolog_flag(argv, [File]), load_files(File, [sandboxed(true)]), halt.') |
||||
call ale#Set('prolog_swipl_timeout', 3) |
||||
call ale#Set('prolog_swipl_alarm', 'alarm(%t, (%h), _, [])') |
||||
call ale#Set('prolog_swipl_alarm_handler', 'writeln(user_error, "ERROR: Exceeded %t seconds, Please change g:prolog_swipl_timeout to modify the limit."), halt(1)') |
||||
|
||||
function! ale_linters#prolog#swipl#GetCommand(buffer) abort |
||||
let l:goals = ale#Var(a:buffer, 'prolog_swipl_load') |
||||
let l:goals = l:goals =~# '^\s*$' ? 'halt' : l:goals |
||||
let l:timeout = ale#Var(a:buffer, 'prolog_swipl_timeout') + 0 |
||||
|
||||
if l:timeout > 0 |
||||
let l:goals = s:GetAlarm(a:buffer, l:timeout) . ', ' . l:goals |
||||
endif |
||||
|
||||
return '%e -g ' . ale#Escape(l:goals) . ' -- %s' |
||||
endfunction |
||||
|
||||
function! s:GetAlarm(buffer, timeout) abort |
||||
let l:handler = ale#Var(a:buffer, 'prolog_swipl_alarm_handler') |
||||
let l:handler = s:Subst(l:handler, {'t': a:timeout}) |
||||
let l:alarm = ale#Var(a:buffer, 'prolog_swipl_alarm') |
||||
let l:alarm = s:Subst(l:alarm, {'t': a:timeout, 'h': l:handler}) |
||||
|
||||
return l:alarm |
||||
endfunction |
||||
|
||||
function! s:Subst(format, vars) abort |
||||
let l:vars = extend(copy(a:vars), {'%': '%'}) |
||||
|
||||
return substitute(a:format, '%\(.\)', '\=get(l:vars, submatch(1), "")', 'g') |
||||
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 |
||||
|
||||
while l:i < len(a:lines) |
||||
let l:match = matchlist(a:lines[l:i], l:pattern) |
||||
|
||||
if empty(l:match) |
||||
let l:i += 1 |
||||
continue |
||||
endif |
||||
|
||||
let [l:i, l:text] = s:GetErrMsg(l:i, a:lines, l:match[4]) |
||||
let l:item = { |
||||
\ 'lnum': (l:match[2] + 0 ? l:match[2] + 0 : 1), |
||||
\ 'col': l:match[3] + 0, |
||||
\ 'text': l:text, |
||||
\ 'type': (l:match[1] is# 'ERROR' ? 'E' : 'W'), |
||||
\} |
||||
|
||||
if !s:Ignore(l:item) |
||||
call add(l:output, l:item) |
||||
endif |
||||
endwhile |
||||
|
||||
return l:output |
||||
endfunction |
||||
|
||||
" This returns [<next line number>, <error message string>] |
||||
function! s:GetErrMsg(i, lines, text) abort |
||||
if a:text !~# '^\s*$' |
||||
return [a:i + 1, a:text] |
||||
endif |
||||
|
||||
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:i += 1 |
||||
endwhile |
||||
|
||||
return [l:i, join(l:text, '. ')] |
||||
endfunction |
||||
|
||||
function! s:Trim(str) abort |
||||
return substitute(a:str, '\v^\s+|\s+$', '', 'g') |
||||
endfunction |
||||
|
||||
" Skip sandbox error which is caused by directives |
||||
" because what we want is syntactic or semantic check. |
||||
function! s:Ignore(item) abort |
||||
return a:item.type is# 'E' && |
||||
\ a:item.text =~# '\vNo permission to (call|directive|assert) sandboxed' |
||||
endfunction |
||||
|
||||
call ale#linter#Define('prolog', { |
||||
\ 'name': 'swipl', |
||||
\ 'output_stream': 'stderr', |
||||
\ 'executable_callback': ale#VarFunc('prolog_swipl_executable'), |
||||
\ 'command_callback': 'ale_linters#prolog#swipl#GetCommand', |
||||
\ 'callback': 'ale_linters#prolog#swipl#Handle', |
||||
\}) |
@ -0,0 +1,16 @@ |
||||
" Author: Auri <me@aurieh.me> |
||||
" Description: Functions for integrating with D linters. |
||||
|
||||
function! ale#d#FindDUBConfig(buffer) abort |
||||
" Find a DUB configuration file in ancestor paths. |
||||
" The most DUB-specific names will be tried first. |
||||
for l:possible_filename in ['dub.sdl', 'dub.json', 'package.json'] |
||||
let l:dub_file = ale#path#FindNearestFile(a:buffer, l:possible_filename) |
||||
|
||||
if !empty(l:dub_file) |
||||
return l:dub_file |
||||
endif |
||||
endfor |
||||
|
||||
return '' |
||||
endfunction |
@ -0,0 +1,17 @@ |
||||
" Author: dsifford <dereksifford@gmail.com> |
||||
" Description: Fixer for terraform and .hcl files |
||||
|
||||
call ale#Set('terraform_fmt_executable', 'terraform') |
||||
call ale#Set('terraform_fmt_options', '') |
||||
|
||||
function! ale#fixers#terraform#Fix(buffer) abort |
||||
let l:executable = ale#Var(a:buffer, 'terraform_fmt_executable') |
||||
let l:options = ale#Var(a:buffer, 'terraform_fmt_options') |
||||
|
||||
return { |
||||
\ 'command': ale#Escape(l:executable) |
||||
\ . ' fmt' |
||||
\ . (empty(l:options) ? '' : ' ' . l:options) |
||||
\ . ' -' |
||||
\} |
||||
endfunction |
@ -0,0 +1,13 @@ |
||||
" Author: Matteo Centenaro (bugant) - https://github.com/bugant |
||||
" |
||||
" Description: find the root directory for an elixir project that uses mix |
||||
|
||||
function! ale#handlers#elixir#FindMixProjectRoot(buffer) abort |
||||
let l:mix_file = ale#path#FindNearestFile(a:buffer, 'mix.exs') |
||||
|
||||
if !empty(l:mix_file) |
||||
return fnamemodify(l:mix_file, ':p:h') |
||||
endif |
||||
|
||||
return '.' |
||||
endfunction |