mirror of https://github.com/amix/vimrc.git
parent
6711ae6453
commit
3aefdbd21a
@ -0,0 +1,95 @@ |
||||
call ale#Set('cs_csc_options', '') |
||||
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') |
||||
|
||||
if !empty(l:working_directory) |
||||
return l:working_directory |
||||
endif |
||||
|
||||
return expand('#' . a:buffer . ':p:h') |
||||
endfunction |
||||
|
||||
function! ale_linters#cs#csc#GetCommand(buffer) abort |
||||
" Pass assembly paths via the -lib: parameter. |
||||
let l:path_list = ale#Var(a:buffer, 'cs_csc_assembly_path') |
||||
|
||||
let l:lib_option = !empty(l:path_list) |
||||
\ ? '/lib:' . join(map(copy(l:path_list), 'ale#Escape(v:val)'), ',') |
||||
\ : '' |
||||
|
||||
" Pass paths to DLL files via the -r: parameter. |
||||
let l:assembly_list = ale#Var(a:buffer, 'cs_csc_assemblies') |
||||
|
||||
let l:r_option = !empty(l:assembly_list) |
||||
\ ? '/r:' . join(map(copy(l:assembly_list), 'ale#Escape(v:val)'), ',') |
||||
\ : '' |
||||
|
||||
" register temporary module target file with ale |
||||
" register temporary module target file with ALE. |
||||
let l:out = ale#command#CreateFile(a:buffer) |
||||
|
||||
" 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' |
||||
\ . ale#Pad(ale#Var(a:buffer, 'cs_csc_options')) |
||||
\ . ale#Pad(l:lib_option) |
||||
\ . ale#Pad(l:r_option) |
||||
\ . ' /out:' . l:out |
||||
\ . ' /t:module' |
||||
\ . ' /recurse:' . ale#Escape('*.cs') |
||||
endfunction |
||||
|
||||
function! ale_linters#cs#csc#Handle(buffer, lines) abort |
||||
" Look for lines like the following. |
||||
" |
||||
" Tests.cs(12,29): error CSXXXX: ; expected |
||||
" |
||||
" NOTE: pattern also captures file name as linter compiles all |
||||
" files within the source tree rooted at the specified source |
||||
" path and not just the file loaded in the buffer |
||||
let l:patterns = [ |
||||
\ '^\v(.+\.cs)\((\d+),(\d+)\)\:\s+([^ ]+)\s+([cC][sS][^ ]+):\s(.+)$', |
||||
\ '^\v([^ ]+)\s+([Cc][sS][^ ]+):\s+(.+)$', |
||||
\] |
||||
let l:output = [] |
||||
|
||||
let l:dir = s:GetWorkingDirectory(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' |
||||
call add(l:output, { |
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), |
||||
\ 'lnum': l:match[2] + 0, |
||||
\ 'col': l:match[3] + 0, |
||||
\ 'type': l:match[4] is# 'error' ? 'E' : 'W', |
||||
\ 'code': l:match[5], |
||||
\ 'text': l:match[6] , |
||||
\}) |
||||
elseif strlen(l:match[2]) > 2 && l:match[2][:1] is? 'CS' |
||||
call add(l:output, { |
||||
\ 'filename':'<csc>', |
||||
\ 'lnum': -1, |
||||
\ 'col': -1, |
||||
\ 'type': l:match[1] is# 'error' ? 'E' : 'W', |
||||
\ 'code': l:match[2], |
||||
\ 'text': l:match[3], |
||||
\}) |
||||
endif |
||||
endfor |
||||
|
||||
return l:output |
||||
endfunction |
||||
|
||||
call ale#linter#Define('cs',{ |
||||
\ 'name': 'csc', |
||||
\ 'output_stream': 'stdout', |
||||
\ 'executable': 'csc', |
||||
\ 'command': function('ale_linters#cs#csc#GetCommand'), |
||||
\ 'callback': 'ale_linters#cs#csc#Handle', |
||||
\ 'lint_file': 1 |
||||
\}) |
@ -0,0 +1,37 @@ |
||||
" Author: antew - https://github.com/antew |
||||
" Description: elm-language-server integration for elm (diagnostics, formatting, and more) |
||||
|
||||
call ale#Set('elm_ls_executable', 'elm-language-server') |
||||
call ale#Set('elm_ls_use_global', get(g:, 'ale_use_global_executables', 1)) |
||||
call ale#Set('elm_ls_elm_path', 'elm') |
||||
call ale#Set('elm_ls_elm_format_path', 'elm-format') |
||||
call ale#Set('elm_ls_elm_test_path', 'elm-test') |
||||
|
||||
function! elm_ls#GetRootDir(buffer) abort |
||||
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') |
||||
|
||||
return !empty(l:elm_json) ? fnamemodify(l:elm_json, ':p:h') : '' |
||||
endfunction |
||||
|
||||
function! elm_ls#GetOptions(buffer) abort |
||||
return { |
||||
\ 'runtime': 'node', |
||||
\ 'elmPath': ale#Var(a:buffer, 'elm_ls_elm_path'), |
||||
\ 'elmFormatPath': ale#Var(a:buffer, 'elm_ls_elm_format_path'), |
||||
\ 'elmTestPath': ale#Var(a:buffer, 'elm_ls_elm_test_path'), |
||||
\} |
||||
endfunction |
||||
|
||||
call ale#linter#Define('elm', { |
||||
\ 'name': 'elm_ls', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'elm_ls', [ |
||||
\ 'node_modules/.bin/elm-language-server', |
||||
\ 'node_modules/.bin/elm-lsp', |
||||
\ 'elm-lsp' |
||||
\ ])}, |
||||
\ 'command': '%e --stdio', |
||||
\ 'project_root': function('elm_ls#GetRootDir'), |
||||
\ 'language': 'elm', |
||||
\ 'initialization_options': function('elm_ls#GetOptions') |
||||
\}) |
@ -1,22 +0,0 @@ |
||||
" Author: antew - https://github.com/antew |
||||
" Description: LSP integration for elm, currently supports diagnostics (linting) |
||||
|
||||
call ale#Set('elm_lsp_executable', 'elm-lsp') |
||||
call ale#Set('elm_lsp_use_global', get(g:, 'ale_use_global_executables', 0)) |
||||
|
||||
function! elm_lsp#GetRootDir(buffer) abort |
||||
let l:elm_json = ale#path#FindNearestFile(a:buffer, 'elm.json') |
||||
|
||||
return !empty(l:elm_json) ? fnamemodify(l:elm_json, ':p:h') : '' |
||||
endfunction |
||||
|
||||
call ale#linter#Define('elm', { |
||||
\ 'name': 'elm_lsp', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable': {b -> ale#node#FindExecutable(b, 'elm_lsp', [ |
||||
\ 'node_modules/.bin/elm-lsp', |
||||
\ ])}, |
||||
\ 'command': '%e --stdio', |
||||
\ 'project_root': function('elm_lsp#GetRootDir'), |
||||
\ 'language': 'elm' |
||||
\}) |
@ -0,0 +1,93 @@ |
||||
" Author: Autoine Gagne - https://github.com/AntoineGagne |
||||
" Description: Define a checker that runs dialyzer on Erlang files. |
||||
|
||||
let g:ale_erlang_dialyzer_executable = |
||||
\ get(g:, 'ale_erlang_dialyzer_executable', 'dialyzer') |
||||
let g:ale_erlang_dialyzer_plt_file = |
||||
\ get(g:, 'ale_erlang_dialyzer_plt_file', '') |
||||
let g:ale_erlang_dialyzer_rebar3_profile = |
||||
\ get(g:, 'ale_erlang_dialyzer_rebar3_profile', 'default') |
||||
|
||||
function! ale_linters#erlang#dialyzer#GetRebar3Profile(buffer) abort |
||||
return ale#Var(a:buffer, 'erlang_dialyzer_rebar3_profile') |
||||
endfunction |
||||
|
||||
function! ale_linters#erlang#dialyzer#FindPlt(buffer) abort |
||||
let l:plt_file = '' |
||||
let l:rebar3_profile = ale_linters#erlang#dialyzer#GetRebar3Profile(a:buffer) |
||||
let l:plt_file_directory = ale#path#FindNearestDirectory(a:buffer, '_build' . l:rebar3_profile) |
||||
|
||||
if !empty(l:plt_file_directory) |
||||
let l:plt_file = split(globpath(l:plt_file_directory, '/*_plt'), '\n') |
||||
endif |
||||
|
||||
if !empty(l:plt_file) |
||||
return l:plt_file[0] |
||||
endif |
||||
|
||||
if !empty($REBAR_PLT_DIR) |
||||
return expand('$REBAR_PLT_DIR/dialyzer/plt') |
||||
endif |
||||
|
||||
return expand('$HOME/.dialyzer_plt') |
||||
endfunction |
||||
|
||||
function! ale_linters#erlang#dialyzer#GetPlt(buffer) abort |
||||
let l:plt_file = ale#Var(a:buffer, 'erlang_dialyzer_plt_file') |
||||
|
||||
if !empty(l:plt_file) |
||||
return l:plt_file |
||||
endif |
||||
|
||||
return ale_linters#erlang#dialyzer#FindPlt(a:buffer) |
||||
endfunction |
||||
|
||||
function! ale_linters#erlang#dialyzer#GetExecutable(buffer) abort |
||||
return ale#Var(a:buffer, 'erlang_dialyzer_executable') |
||||
endfunction |
||||
|
||||
function! ale_linters#erlang#dialyzer#GetCommand(buffer) abort |
||||
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' |
||||
\ . ' %s' |
||||
|
||||
return l:command |
||||
endfunction |
||||
|
||||
function! ale_linters#erlang#dialyzer#Handle(buffer, lines) abort |
||||
" Match patterns like the following: |
||||
" |
||||
" erl_tidy_prv_fmt.erl:3: Callback info about the provider behaviour is not available |
||||
let l:pattern = '^\S\+:\(\d\+\): \(.\+\)$' |
||||
let l:output = [] |
||||
|
||||
for l:line in a:lines |
||||
let l:match = matchlist(l:line, l:pattern) |
||||
|
||||
if len(l:match) != 0 |
||||
let l:code = l:match[2] |
||||
|
||||
call add(l:output, { |
||||
\ 'lnum': str2nr(l:match[1]), |
||||
\ 'lcol': 0, |
||||
\ 'text': l:code, |
||||
\ 'type': 'W' |
||||
\}) |
||||
endif |
||||
endfor |
||||
|
||||
return l:output |
||||
endfunction |
||||
|
||||
call ale#linter#Define('erlang', { |
||||
\ 'name': 'dialyzer', |
||||
\ 'executable': function('ale_linters#erlang#dialyzer#GetExecutable'), |
||||
\ 'command': function('ale_linters#erlang#dialyzer#GetCommand'), |
||||
\ 'callback': function('ale_linters#erlang#dialyzer#Handle'), |
||||
\ 'lint_file': 1 |
||||
\}) |
@ -1,10 +1,16 @@ |
||||
" Author: neersighted <bjorn@neersighted.com> |
||||
" Description: gofmt for Go files |
||||
|
||||
function! ale_linters#go#gofmt#GetCommand(buffer) abort |
||||
return ale#go#EnvString(a:buffer) |
||||
\ . '%e -e %t' |
||||
endfunction |
||||
|
||||
|
||||
call ale#linter#Define('go', { |
||||
\ 'name': 'gofmt', |
||||
\ 'output_stream': 'stderr', |
||||
\ 'executable': 'gofmt', |
||||
\ 'command': 'gofmt -e %t', |
||||
\ 'command': function('ale_linters#go#gofmt#GetCommand'), |
||||
\ 'callback': 'ale#handlers#unix#HandleAsError', |
||||
\}) |
||||
|
@ -0,0 +1,49 @@ |
||||
" Author: Drew Olson <drew@drewolson.org> |
||||
" Description: Integrate ALE with purescript-language-server. |
||||
|
||||
call ale#Set('purescript_ls_executable', 'purescript-language-server') |
||||
call ale#Set('purescript_ls_use_global', get(g:, 'ale_use_global_executables', 0)) |
||||
call ale#Set('purescript_ls_config', {}) |
||||
|
||||
function! ale_linters#purescript#ls#GetExecutable(buffer) abort |
||||
return ale#node#FindExecutable(a:buffer, 'purescript_ls', [ |
||||
\ 'node_modules/.bin/purescript-language-server', |
||||
\]) |
||||
endfunction |
||||
|
||||
function! ale_linters#purescript#ls#GetCommand(buffer) abort |
||||
let l:executable = ale_linters#purescript#ls#GetExecutable(a:buffer) |
||||
|
||||
return ale#Escape(l:executable) . ' --stdio' |
||||
endfunction |
||||
|
||||
function! ale_linters#purescript#ls#FindProjectRoot(buffer) abort |
||||
let l:config = ale#path#FindNearestFile(a:buffer, 'bower.json') |
||||
|
||||
if !empty(l:config) |
||||
return fnamemodify(l:config, ':h') |
||||
endif |
||||
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, 'psc-package.json') |
||||
|
||||
if !empty(l:config) |
||||
return fnamemodify(l:config, ':h') |
||||
endif |
||||
|
||||
let l:config = ale#path#FindNearestFile(a:buffer, 'spago.dhall') |
||||
|
||||
if !empty(l:config) |
||||
return fnamemodify(l:config, ':h') |
||||
endif |
||||
|
||||
return '' |
||||
endfunction |
||||
|
||||