Skip to content

Commit

Permalink
Merge pull request #1859 from bhcleek/more-build-tags
Browse files Browse the repository at this point in the history
add more build tag support
  • Loading branch information
bhcleek authored Jun 16, 2018
2 parents ea7d7c1 + 3760ef4 commit 155836d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
22 changes: 17 additions & 5 deletions autoload/go/cmd.vim
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@ endfunction

" Run runs the current file (and their dependencies if any) in a new terminal.
function! go#cmd#RunTerm(bang, mode, files) abort
let cmd = "go run "
let tags = go#config#BuildTags()
if len(tags) > 0
let cmd .= "-tags " . go#util#Shellescape(tags) . " "
endif

if empty(a:files)
let cmd = "go run ". go#util#Shelljoin(go#tool#Files())
let cmd .= go#util#Shelljoin(go#tool#Files())
else
let cmd = "go run ". go#util#Shelljoin(map(copy(a:files), "expand(v:val)"), 1)
let cmd .= go#util#Shelljoin(map(copy(a:files), "expand(v:val)"), 1)
endif
call go#term#newmode(a:bang, cmd, a:mode)
endfunction
Expand All @@ -138,8 +144,14 @@ function! go#cmd#Run(bang, ...) abort
" anything. Once this is implemented we're going to make :GoRun async
endif

let cmd = "go run "
let tags = go#config#BuildTags()
if len(tags) > 0
let cmd .= "-tags " . go#util#Shellescape(tags) . " "
endif

if go#util#IsWin()
exec '!go run ' . go#util#Shelljoin(go#tool#Files())
exec '!' . cmd . go#util#Shelljoin(go#tool#Files())
if v:shell_error
redraws! | echon "vim-go: [run] " | echohl ErrorMsg | echon "FAILED"| echohl None
else
Expand All @@ -152,9 +164,9 @@ function! go#cmd#Run(bang, ...) abort
" :make expands '%' and '#' wildcards, so they must also be escaped
let default_makeprg = &makeprg
if a:0 == 0
let &makeprg = 'go run ' . go#util#Shelljoin(go#tool#Files(), 1)
let &makeprg = cmd . go#util#Shelljoin(go#tool#Files(), 1)
else
let &makeprg = "go run " . go#util#Shelljoin(map(copy(a:000), "expand(v:val)"), 1)
let &makeprg = cmd . go#util#Shelljoin(map(copy(a:000), "expand(v:val)"), 1)
endif

let l:listtype = go#list#Type("GoRun")
Expand Down
10 changes: 5 additions & 5 deletions autoload/go/tool.vim
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function! go#tool#Files(...) abort
endif
endfor

let [l:out, l:err] = go#tool#ExecuteInDir(['go', 'list', '-f', l:combined])
let [l:out, l:err] = go#tool#ExecuteInDir(['go', 'list', '-tags', go#config#BuildTags(), '-f', l:combined])
return split(l:out, '\n')
endfunction

Expand All @@ -46,7 +46,7 @@ function! go#tool#Deps() abort
else
let format = "{{range $f := .Deps}}{{$f}}\n{{end}}"
endif
let [l:out, l:err] = go#tool#ExecuteInDir(['go', 'list', '-f', l:format])
let [l:out, l:err] = go#tool#ExecuteInDir(['go', 'list', '-tags', go#config#BuildTags(), '-f', l:format])
return split(l:out, '\n')
endfunction

Expand All @@ -57,14 +57,14 @@ function! go#tool#Imports() abort
else
let format = "{{range $f := .Imports}}{{$f}}{{printf \"\\n\"}}{{end}}"
endif
let [l:out, l:err] = go#tool#ExecuteInDir(['go', 'list', '-f', l:format])
let [l:out, l:err] = go#tool#ExecuteInDir(['go', 'list', '-tags', go#config#BuildTags(), '-f', l:format])
if l:err != 0
echo out
return imports
endif

for package_path in split(out, '\n')
let [l:out, l:err] = go#tool#ExecuteInDir(['go', 'list', '-f', '{{.Name}}', l:package_path])
let [l:out, l:err] = go#tool#ExecuteInDir(['go', 'list', '-tags', go#config#BuildTags(), '-f', '{{.Name}}', l:package_path])
if l:err != 0
echo out
return imports
Expand All @@ -88,7 +88,7 @@ function! go#tool#Info(auto) abort
endfunction

function! go#tool#PackageName() abort
let [l:out, l:err] = go#tool#ExecuteInDir(['go', 'list', '-f', '{{.Name}}'])
let [l:out, l:err] = go#tool#ExecuteInDir(['go', 'list', '-tags', go#config#BuildTags(), '-f', '{{.Name}}'])
if l:err != 0
return -1
endif
Expand Down

0 comments on commit 155836d

Please sign in to comment.