mirror of https://github.com/amix/vimrc.git
parent
6bd9eda8c3
commit
a6b64938eb
@ -0,0 +1,56 @@ |
||||
" Author: Sascha Grunert <mail@saschagrunert.de> |
||||
" Description: Adds support of golangci-lint |
||||
|
||||
call ale#Set('go_golangci_lint_options', '--enable-all') |
||||
call ale#Set('go_golangci_lint_executable', 'golangci-lint') |
||||
call ale#Set('go_golangci_lint_package', 0) |
||||
|
||||
function! ale_linters#go#golangci_lint#GetCommand(buffer) abort |
||||
let l:filename = expand('#' . a:buffer . ':t') |
||||
let l:options = ale#Var(a:buffer, 'go_golangci_lint_options') |
||||
let l:lint_package = ale#Var(a:buffer, 'go_golangci_lint_package') |
||||
|
||||
if l:lint_package |
||||
return ale#path#BufferCdString(a:buffer) |
||||
\ . '%e run ' |
||||
\ . l:options |
||||
endif |
||||
|
||||
return ale#path#BufferCdString(a:buffer) |
||||
\ . '%e run ' |
||||
\ . ale#Escape(l:filename) |
||||
\ . ' ' . l:options |
||||
endfunction |
||||
|
||||
function! ale_linters#go#golangci_lint#GetMatches(lines) abort |
||||
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:?:?:?\s\*?(.+)$' |
||||
|
||||
return ale#util#GetMatches(a:lines, l:pattern) |
||||
endfunction |
||||
|
||||
function! ale_linters#go#golangci_lint#Handler(buffer, lines) abort |
||||
let l:dir = expand('#' . a:buffer . ':p:h') |
||||
let l:output = [] |
||||
|
||||
for l:match in ale_linters#go#golangci_lint#GetMatches(a:lines) |
||||
" l:match[1] will already be an absolute path, output from |
||||
" golangci_lint |
||||
call add(l:output, { |
||||
\ 'filename': ale#path#GetAbsPath(l:dir, l:match[1]), |
||||
\ 'lnum': l:match[2] + 0, |
||||
\ 'col': l:match[3] + 0, |
||||
\ 'type': 'E', |
||||
\ 'text': l:match[4], |
||||
\}) |
||||
endfor |
||||
|
||||
return l:output |
||||
endfunction |
||||
|
||||
call ale#linter#Define('go', { |
||||
\ 'name': 'golangci-lint', |
||||
\ 'executable_callback': ale#VarFunc('go_golangci_lint_executable'), |
||||
\ 'command_callback': 'ale_linters#go#golangci_lint#GetCommand', |
||||
\ 'callback': 'ale_linters#go#golangci_lint#Handler', |
||||
\ 'lint_file': 1, |
||||
\}) |
@ -0,0 +1,28 @@ |
||||
" Author: Horacio Sanson <https://github.com/hsanson> |
||||
" Description: Support for go-langserver https://github.com/sourcegraph/go-langserver |
||||
|
||||
call ale#Set('go_langserver_executable', 'go-langserver') |
||||
call ale#Set('go_langserver_options', '') |
||||
|
||||
function! ale_linters#go#langserver#GetCommand(buffer) abort |
||||
let l:executable = [ale#Escape(ale#Var(a:buffer, 'go_langserver_executable'))] |
||||
let l:options = ale#Var(a:buffer, 'go_langserver_options') |
||||
let l:options = substitute(l:options, '-gocodecompletion', '', 'g') |
||||
let l:options = filter(split(l:options, ' '), 'empty(v:val) != 1') |
||||
|
||||
if(ale#Var(a:buffer, 'completion_enabled') == 1) |
||||
call add(l:options, '-gocodecompletion') |
||||
endif |
||||
|
||||
let l:options = uniq(sort(l:options)) |
||||
|
||||
return join(extend(l:executable, l:options), ' ') |
||||
endfunction |
||||
|
||||
call ale#linter#Define('go', { |
||||
\ 'name': 'golangserver', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable_callback': ale#VarFunc('go_langserver_executable'), |
||||
\ 'command_callback': 'ale_linters#go#langserver#GetCommand', |
||||
\ 'project_root_callback': 'ale#go#FindProjectRoot', |
||||
\}) |
@ -0,0 +1,23 @@ |
||||
" Author: Horacio Sanson <https://github.com/hsanson> |
||||
" Description: Support for the Java language server https://github.com/georgewfraser/vscode-javac |
||||
|
||||
call ale#Set('java_javalsp_jar', 'javacs.jar') |
||||
|
||||
function! ale_linters#java#javalsp#Executable(buffer) abort |
||||
return 'java' |
||||
endfunction |
||||
|
||||
function! ale_linters#java#javalsp#Command(buffer) abort |
||||
let l:jar = ale#Var(a:buffer, 'java_javalsp_jar') |
||||
|
||||
return ale#Escape('java -cp ' . l:jar . ' -Xverify:none org.javacs.Main') |
||||
endfunction |
||||
|
||||
call ale#linter#Define('java', { |
||||
\ 'name': 'javalsp', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable_callback': 'ale_linters#java#javalsp#Executable', |
||||
\ 'command_callback': 'ale_linters#java#javalsp#Command', |
||||
\ 'language': 'java', |
||||
\ 'project_root_callback': 'ale#java#FindProjectRoot', |
||||
\}) |
@ -0,0 +1,21 @@ |
||||
" Author: Bartolomeo Stellato <bartolomeo.stellato@gmail.com> |
||||
" Description: A language server for Julia |
||||
|
||||
" Set julia executable variable |
||||
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);' |
||||
|
||||
return ale#Escape(l:julia_executable) . ' --startup-file=no --history-file=no -e ' . ale#Escape(l:cmd_string) |
||||
endfunction |
||||
|
||||
call ale#linter#Define('julia', { |
||||
\ 'name': 'languageserver', |
||||
\ 'lsp': 'stdio', |
||||
\ 'executable_callback': ale#VarFunc('julia_executable'), |
||||
\ 'command_callback': 'ale_linters#julia#languageserver#GetCommand', |
||||
\ 'language': 'julia', |
||||
\ 'project_root_callback': 'ale#julia#FindProjectRoot', |
||||
\}) |
@ -0,0 +1,20 @@ |
||||
" Author: Horacio Sanson - https://github.com/hsanson |
||||
" Description: Solargraph Language Server https://solargraph.org/ |
||||
" |
||||
" Author: Devon Meunier <devon.meunier@gmail.com> |
||||
" Description: updated to use stdio |
||||
|
||||
call ale#Set('ruby_solargraph_executable', 'solargraph') |
||||
|
||||
function! ale_linters#ruby#solargraph#GetCommand(buffer) abort |
||||
return '%e' . ale#Pad('stdio') |
||||
endfunction |
||||
|
||||
call ale#linter#Define('ruby', { |
||||
\ 'name': 'solargraph', |
||||
\ 'lsp': 'stdio', |
||||
\ 'language': 'ruby', |
||||
\ 'executable_callback': ale#VarFunc('ruby_solargraph_executable'), |
||||
\ 'command_callback': 'ale_linters#ruby#solargraph#GetCommand', |
||||
\ 'project_root_callback': 'ale#ruby#FindProjectRoot', |
||||
\}) |
@ -0,0 +1,31 @@ |
||||
" Author: ophirr33 <coghlan.ty@gmail.com> |
||||
" Description: TCP lsp client for sbt Server |
||||
|
||||
call ale#Set('scala_sbtserver_address', '127.0.0.1:4273') |
||||
call ale#Set('scala_sbtserver_project_root', '') |
||||
|
||||
function! ale_linters#scala#sbtserver#GetProjectRoot(buffer) abort |
||||
let l:project_root = ale#Var(a:buffer, 'scala_sbtserver_project_root') |
||||
|
||||
if l:project_root is? '' |
||||
let l:project_root = ale#path#FindNearestFile(a:buffer, 'build.sbt') |
||||
|
||||
return !empty(l:project_root) ? fnamemodify(l:project_root, ':h') : '' |
||||
endif |
||||
|
||||
return l:project_root |
||||
endfunction |
||||
|
||||
function! ale_linters#scala#sbtserver#GetAddress(buffer) abort |
||||
let l:address = ale#Var(a:buffer, 'scala_sbtserver_address') |
||||
|
||||
return l:address |
||||
endfunction |
||||
|
||||
call ale#linter#Define('scala', { |
||||
\ 'name': 'sbtserver', |
||||
\ 'lsp': 'socket', |
||||
\ 'address_callback': 'ale_linters#scala#sbtserver#GetAddress', |
||||
\ 'language': 'scala', |
||||
\ 'project_root_callback': 'ale_linters#scala#sbtserver#GetProjectRoot', |
||||
\}) |