-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add gometalinter #312
add gometalinter #312
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
let s:SplitChar = has('unix') ? ':' : ':' | ||
|
||
let g:ale_linters#go#gometalinter#args = get(g:, 'ale_linters#go#gometalinter#args', [ | ||
\ '--fast', | ||
\ '--tests', | ||
\ ]) | ||
|
||
function! s:Args() abort | ||
return join(map(copy(g:ale_linters#go#gometalinter#args), 'shellescape(v:val)'), ' ') | ||
endfunction | ||
|
||
function! ale_linters#go#gometalinter#GetCommand(buffer, copy_output) abort | ||
let l:tempdir = a:copy_output[0] | ||
let l:importpath = ale_linters#go#gobuild#PackageImportPath(a:buffer) | ||
let l:gopaths = [ l:tempdir ] | ||
call extend(l:gopaths, split(g:ale_linters#go#gobuild#go_env.GOPATH, s:SplitChar)) | ||
|
||
return 'GOPATH=' . shellescape(join(l:gopaths, s:SplitChar)) . ' gometalinter ' . s:Args() . ' ' . shellescape(l:tempdir . '/src/' . l:importpath) | ||
endfunction | ||
|
||
let s:path_pattern = '[a-zA-Z]\?\\\?:\?[[:alnum:]/\.\-_]\+' | ||
let s:handler_pattern = '^\(' . s:path_pattern . '\):\(\d\+\):\?\(\d\+\)\?:\?\([a-zA-Z]\+\): \(.\+\)$' | ||
|
||
function! ale_linters#go#gometalinter#Handler(buffer, lines) abort | ||
let l:output = [] | ||
|
||
for l:line in a:lines | ||
let l:match = matchlist(l:line, s:handler_pattern) | ||
|
||
if len(l:match) == 0 | ||
continue | ||
endif | ||
|
||
let l:buffer = ale_linters#go#gobuild#FindBuffer(l:match[1]) | ||
|
||
if l:buffer == -1 | ||
continue | ||
endif | ||
|
||
if !get(g:, 'ale_experimental_multibuffer', 0) && l:buffer != a:buffer | ||
" strip lines from other buffers | ||
continue | ||
endif | ||
|
||
call add(l:output, { | ||
\ 'bufnr': l:buffer, | ||
\ 'lnum': l:match[2] + 0, | ||
\ 'vcol': 0, | ||
\ 'col': l:match[3] + 0, | ||
\ 'text': l:match[5], | ||
\ 'type': toupper(l:match[4][0]), | ||
\ 'nr': -1, | ||
\}) | ||
endfor | ||
|
||
return l:output | ||
endfunction | ||
|
||
call ale#linter#Define('go', { | ||
\ 'name': 'gometalinter', | ||
\ 'executable': 'gometalinter', | ||
\ 'command_chain': [ | ||
\ {'callback': 'ale_linters#go#gobuild#GoEnv', 'output_stream': 'stdout'}, | ||
\ {'callback': 'ale_linters#go#gobuild#GoList', 'output_stream': 'stdout'}, | ||
\ {'callback': 'ale_linters#go#gobuild#CopyFiles', 'output_stream': 'stdout'}, | ||
\ {'callback': 'ale_linters#go#gobuild#WriteBuffers', 'output_stream': 'stdout'}, | ||
\ {'callback': 'ale_linters#go#gometalinter#GetCommand', 'output_stream': 'stdout'}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be an idea to move functions shared between two linter definitions into the
If anyone ever changes the way linters are loaded so only the list of enabled linters are loaded, which has tried before, then this code will break when only this linter is enabled for |
||
\ ], | ||
\ 'callback': 'ale_linters#go#gometalinter#Handler', | ||
\}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could perhaps start implementing this flag in the function which fixes problems with the loclist items. If the flag isn't on, you could automatically remove items for other buffers in that function.