mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated plugins
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
" Description: go build for Go files
|
||||
" inspired by work from dzhou121 <dzhou121@gmail.com>
|
||||
|
||||
call ale#Set('go_go_executable', 'go')
|
||||
call ale#Set('go_gobuild_options', '')
|
||||
|
||||
function! ale_linters#go#gobuild#GetCommand(buffer) abort
|
||||
@ -10,7 +11,7 @@ function! ale_linters#go#gobuild#GetCommand(buffer) abort
|
||||
|
||||
" Run go test in local directory with relative path
|
||||
return ale#path#BufferCdString(a:buffer)
|
||||
\ . 'go test'
|
||||
\ . ale#Var(a:buffer, 'go_go_executable') . ' test'
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' -c -o /dev/null ./'
|
||||
endfunction
|
||||
@ -21,7 +22,6 @@ function! ale_linters#go#gobuild#GetMatches(lines) abort
|
||||
" file.go:27: missing argument for Printf("%s"): format reads arg 2, have only 1 args
|
||||
" file.go:53:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
|
||||
" file.go:5:2: expected declaration, found 'STRING' "log"
|
||||
|
||||
" go test returns relative paths so use tail of filename as part of pattern matcher
|
||||
let l:pattern = '\v^([a-zA-Z]?:?[^:]+):(\d+):?(\d+)?:? (.+)$'
|
||||
|
||||
@ -48,7 +48,7 @@ endfunction
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'gobuild',
|
||||
\ 'aliases': ['go build'],
|
||||
\ 'executable': 'go',
|
||||
\ 'executable_callback': ale#VarFunc('go_go_executable'),
|
||||
\ 'command_callback': 'ale_linters#go#gobuild#GetCommand',
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'callback': 'ale_linters#go#gobuild#Handler',
|
||||
|
56
sources_non_forked/ale/ale_linters/go/golangci_lint.vim
Normal file
56
sources_non_forked/ale/ale_linters/go/golangci_lint.vim
Normal file
@ -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,
|
||||
\})
|
@ -4,19 +4,23 @@
|
||||
" Author: John Eikenberry <jae@zhar.net>
|
||||
" Description: updated to work with go1.10
|
||||
|
||||
call ale#Set('go_go_executable', 'go')
|
||||
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) . ' go vet .'
|
||||
|
||||
return ale#path#BufferCdString(a:buffer) . ' '
|
||||
\ . ale#Var(a:buffer, 'go_go_executable') . ' vet '
|
||||
\ . (!empty(l:options) ? ' ' . l:options : '')
|
||||
\ . ' .'
|
||||
endfunction
|
||||
|
||||
call ale#linter#Define('go', {
|
||||
\ 'name': 'govet',
|
||||
\ 'aliases': ['go vet'],
|
||||
\ 'output_stream': 'stderr',
|
||||
\ 'executable': 'go',
|
||||
\ 'executable_callback': ale#VarFunc('go_go_executable'),
|
||||
\ 'command_callback': 'ale_linters#go#govet#GetCommand',
|
||||
\ 'callback': 'ale#handlers#go#Handler',
|
||||
\ 'lint_file': 1,
|
||||
|
28
sources_non_forked/ale/ale_linters/go/langserver.vim
Normal file
28
sources_non_forked/ale/ale_linters/go/langserver.vim
Normal file
@ -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',
|
||||
\})
|
Reference in New Issue
Block a user