From 8315c0e3377921435af06a3182bdc0f1f0f222fc Mon Sep 17 00:00:00 2001 From: w0rp Date: Fri, 7 Jul 2017 00:10:30 +0100 Subject: Make the executable for gometalinter configurable --- ale_linters/go/gometalinter.vim | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'ale_linters') diff --git a/ale_linters/go/gometalinter.vim b/ale_linters/go/gometalinter.vim index 671b77cf..db7f7c11 100644 --- a/ale_linters/go/gometalinter.vim +++ b/ale_linters/go/gometalinter.vim @@ -1,16 +1,22 @@ " Author: Ben Reedy " Description: Adds support for the gometalinter suite for Go files -if !exists('g:ale_go_gometalinter_options') - let g:ale_go_gometalinter_options = '' -endif +call ale#Set('go_gometalinter_options', '') +call ale#Set('go_gometalinter_executable', 'gometalinter') + +function! ale_linters#go#gometalinter#GetExecutable(buffer) abort + return ale#Var(a:buffer, 'go_gometalinter_executable') +endfunction function! ale_linters#go#gometalinter#GetCommand(buffer) abort + let l:executable = ale_linters#go#gometalinter#GetExecutable(a:buffer) let l:filename = expand('#' . a:buffer . ':p') + let l:options = ale#Var(a:buffer, 'go_gometalinter_options') - return 'gometalinter --include=''^' . l:filename . '.*$'' ' - \ . ale#Var(a:buffer, 'go_gometalinter_options') - \ . ' ' . ale#Escape(fnamemodify(bufname(a:buffer), ':p:h')) + return ale#Escape(l:executable) + \ . ' --include=''^' . l:filename . '.*$''' + \ . (!empty(l:options) ? ' ' . l:options : '') + \ . ' ' . ale#Escape(fnamemodify(l:filename, ':h')) endfunction function! ale_linters#go#gometalinter#GetMatches(lines) abort @@ -36,7 +42,7 @@ endfunction call ale#linter#Define('go', { \ 'name': 'gometalinter', -\ 'executable': 'gometalinter', +\ 'executable_callback': 'ale_linters#go#gometalinter#GetExecutable', \ 'command_callback': 'ale_linters#go#gometalinter#GetCommand', \ 'callback': 'ale_linters#go#gometalinter#Handler', \ 'lint_file': 1, -- cgit v1.2.3