mirror of
https://github.com/amix/vimrc
synced 2025-06-16 09:35:01 +08:00
Updated plugins
This commit is contained in:
@ -1,5 +1,20 @@
|
||||
function! s:gocodeCommand(cmd, args) abort
|
||||
let bin_path = go#path#CheckBinPath("gocode")
|
||||
let l:gocode_bin = "gocode"
|
||||
let l:gomod = go#util#gomod()
|
||||
if filereadable(l:gomod)
|
||||
" Save the file when in module mode so that go list can read the
|
||||
" imports. If the user doesn't have autowrite or autorwriteall enabled,
|
||||
" they'll need to write the file manually to get reliable results.
|
||||
" See https://github.com/fatih/vim-go/pull/1988#issuecomment-428576989.
|
||||
"
|
||||
" TODO(bc): don't save the file when in module mode once
|
||||
" golang.org/x/tools/go/packages has support for an overlay and it's used
|
||||
" by gocode.
|
||||
call go#cmd#autowrite()
|
||||
let l:gocode_bin = "gocode-gomod"
|
||||
endif
|
||||
|
||||
let bin_path = go#path#CheckBinPath(l:gocode_bin)
|
||||
if empty(bin_path)
|
||||
return []
|
||||
endif
|
||||
@ -18,6 +33,10 @@ function! s:gocodeCommand(cmd, args) abort
|
||||
let cmd = extend(cmd, ['-source'])
|
||||
endif
|
||||
|
||||
if go#config#GocodeUnimportedPackages()
|
||||
let cmd = extend(cmd, ['-unimported-packages'])
|
||||
endif
|
||||
|
||||
let cmd = extend(cmd, [a:cmd])
|
||||
let cmd = extend(cmd, a:args)
|
||||
|
||||
|
@ -135,6 +135,10 @@ function! go#config#SetGuruScope(scope) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! go#config#GocodeUnimportedPackages() abort
|
||||
return get(g:, 'go_gocode_unimported_packages', 0)
|
||||
endfunction
|
||||
|
||||
let s:sock_type = (has('win32') || has('win64')) ? 'tcp' : 'unix'
|
||||
function! go#config#GocodeSocketType() abort
|
||||
return get(g:, 'go_gocode_socket_type', s:sock_type)
|
||||
@ -420,6 +424,10 @@ function! go#config#HighlightVariableDeclarations() abort
|
||||
return get(g:, 'go_highlight_variable_declarations', 0)
|
||||
endfunction
|
||||
|
||||
function! go#config#HighlightDebug() abort
|
||||
return get(g:, 'go_highlight_debug', 1)
|
||||
endfunction
|
||||
|
||||
function! go#config#FoldEnable(...) abort
|
||||
if a:0 > 0
|
||||
return index(go#config#FoldEnable(), a:1) > -1
|
||||
|
@ -29,6 +29,11 @@ function! s:complete(job, exit_status, data) abort
|
||||
if has_key(s:state, 'job')
|
||||
call remove(s:state, 'job')
|
||||
endif
|
||||
|
||||
if has_key(s:state, 'ready')
|
||||
call remove(s:state, 'ready')
|
||||
endif
|
||||
|
||||
call s:clearState()
|
||||
if a:exit_status > 0
|
||||
call go#util#EchoError(s:state['message'])
|
||||
@ -66,7 +71,6 @@ function! s:call_jsonrpc(method, ...) abort
|
||||
let Cb = a:000[0]
|
||||
let args = a:000[1:]
|
||||
else
|
||||
let Cb = v:none
|
||||
let args = a:000
|
||||
endif
|
||||
let s:state['rpcid'] += 1
|
||||
@ -78,9 +82,26 @@ function! s:call_jsonrpc(method, ...) abort
|
||||
|
||||
try
|
||||
" Use callback
|
||||
if type(Cb) == v:t_func
|
||||
let s:ch = ch_open('127.0.0.1:8181', {'mode': 'nl', 'callback': Cb})
|
||||
call ch_sendraw(s:ch, req_json)
|
||||
if exists('l:Cb')
|
||||
if has('nvim')
|
||||
let state = {'callback': Cb}
|
||||
function! state.on_data(ch, msg, event) abort
|
||||
call self.state.callback(a:ch, a:msg)
|
||||
endfunction
|
||||
let l:ch = sockconnect('tcp', go#config#DebugAddress(), {'on_data': state.on_data, 'state': state})
|
||||
call chansend(l:ch, req_json)
|
||||
|
||||
if go#util#HasDebug('debugger-commands')
|
||||
let g:go_debug_commands = add(g:go_debug_commands, {
|
||||
\ 'request': req_json,
|
||||
\ 'response': Cb,
|
||||
\ })
|
||||
endif
|
||||
return
|
||||
endif
|
||||
|
||||
let l:ch = ch_open(go#config#DebugAddress(), {'mode': 'nl', 'callback': Cb})
|
||||
call ch_sendraw(l:ch, req_json)
|
||||
|
||||
if go#util#HasDebug('debugger-commands')
|
||||
let g:go_debug_commands = add(g:go_debug_commands, {
|
||||
@ -91,9 +112,23 @@ function! s:call_jsonrpc(method, ...) abort
|
||||
return
|
||||
endif
|
||||
|
||||
let ch = ch_open('127.0.0.1:8181', {'mode': 'nl', 'timeout': 20000})
|
||||
call ch_sendraw(ch, req_json)
|
||||
let resp_json = ch_readraw(ch)
|
||||
if has('nvim')
|
||||
let state = {'done': 0}
|
||||
function! state.on_data(ch, msg, event) abort
|
||||
let self.state.resp = a:msg
|
||||
let self.state.done = 1
|
||||
endfunction
|
||||
let l:ch = sockconnect('tcp', go#config#DebugAddress(), {'on_data': state.on_data, 'state': state})
|
||||
call chansend(l:ch, req_json)
|
||||
while state.done == 0
|
||||
sleep 50m
|
||||
endwhile
|
||||
let resp_json = state.resp
|
||||
else
|
||||
let ch = ch_open(go#config#DebugAddress(), {'mode': 'raw', 'timeout': 20000})
|
||||
call ch_sendraw(ch, req_json)
|
||||
let resp_json = ch_readraw(ch)
|
||||
endif
|
||||
|
||||
if go#util#HasDebug('debugger-commands')
|
||||
let g:go_debug_commands = add(g:go_debug_commands, {
|
||||
@ -115,7 +150,7 @@ endfunction
|
||||
" Update the location of the current breakpoint or line we're halted on based on
|
||||
" response from dlv.
|
||||
function! s:update_breakpoint(res) abort
|
||||
if type(a:res) ==# v:t_none
|
||||
if type(a:res) ==# type(v:null)
|
||||
return
|
||||
endif
|
||||
|
||||
@ -216,11 +251,17 @@ function! s:clearState() abort
|
||||
endfunction
|
||||
|
||||
function! s:stop() abort
|
||||
" TODO(bc): call Detach
|
||||
call go#job#Stop(s:state['job'])
|
||||
|
||||
call s:clearState()
|
||||
if has_key(s:state, 'job')
|
||||
call job_stop(s:state['job'])
|
||||
call remove(s:state, 'job')
|
||||
endif
|
||||
|
||||
if has_key(s:state, 'ready')
|
||||
call remove(s:state, 'ready')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! go#debug#Stop() abort
|
||||
@ -257,8 +298,10 @@ function! go#debug#Stop() abort
|
||||
silent! exe bufwinnr(bufnr('__GODEBUG_VARIABLES__')) 'wincmd c'
|
||||
silent! exe bufwinnr(bufnr('__GODEBUG_OUTPUT__')) 'wincmd c'
|
||||
|
||||
set noballooneval
|
||||
set balloonexpr=
|
||||
if has('balloon_eval')
|
||||
set noballooneval
|
||||
set balloonexpr=
|
||||
endif
|
||||
|
||||
augroup vim-go-debug
|
||||
autocmd!
|
||||
@ -453,8 +496,10 @@ function! s:start_cb(ch, json) abort
|
||||
nnoremap <silent> <Plug>(go-debug-stop) :<C-u>call go#debug#Stop()<CR>
|
||||
nnoremap <silent> <Plug>(go-debug-print) :<C-u>call go#debug#Print(expand('<cword>'))<CR>
|
||||
|
||||
set balloonexpr=go#debug#BalloonExpr()
|
||||
set ballooneval
|
||||
if has('balloon_eval')
|
||||
set balloonexpr=go#debug#BalloonExpr()
|
||||
set ballooneval
|
||||
endif
|
||||
|
||||
exe bufwinnr(oldbuf) 'wincmd w'
|
||||
|
||||
@ -470,20 +515,29 @@ function! s:start_cb(ch, json) abort
|
||||
endfunction
|
||||
|
||||
function! s:err_cb(ch, msg) abort
|
||||
if get(s:state, 'ready', 0) != 0
|
||||
call call('s:logger', ['ERR: ', a:ch, a:msg])
|
||||
return
|
||||
endif
|
||||
|
||||
call go#util#EchoError(a:msg)
|
||||
let s:state['message'] += [a:msg]
|
||||
endfunction
|
||||
|
||||
function! s:out_cb(ch, msg) abort
|
||||
if get(s:state, 'ready', 0) != 0
|
||||
call call('s:logger', ['OUT: ', a:ch, a:msg])
|
||||
return
|
||||
endif
|
||||
|
||||
call go#util#EchoProgress(a:msg)
|
||||
let s:state['message'] += [a:msg]
|
||||
|
||||
" TODO: why do this in this callback?
|
||||
if stridx(a:msg, go#config#DebugAddress()) != -1
|
||||
call ch_setoptions(a:ch, {
|
||||
\ 'out_cb': function('s:logger', ['OUT: ']),
|
||||
\ 'err_cb': function('s:logger', ['ERR: ']),
|
||||
\})
|
||||
" After this block executes, Delve will be running with all the
|
||||
" breakpoints setup, so this callback doesn't have to run again; just log
|
||||
" future messages.
|
||||
let s:state['ready'] = 1
|
||||
|
||||
" Tell dlv about the breakpoints that the user added before delve started.
|
||||
let l:breaks = copy(s:state.breakpoint)
|
||||
@ -501,17 +555,13 @@ endfunction
|
||||
function! go#debug#Start(is_test, ...) abort
|
||||
call go#cmd#autowrite()
|
||||
|
||||
if has('nvim')
|
||||
call go#util#EchoError('This feature only works in Vim for now; Neovim is not (yet) supported. Sorry :-(')
|
||||
return
|
||||
endif
|
||||
if !go#util#has_job()
|
||||
call go#util#EchoError('This feature requires Vim 8.0.0087 or newer with +job.')
|
||||
call go#util#EchoError('This feature requires either Vim 8.0.0087 or newer with +job or Neovim.')
|
||||
return
|
||||
endif
|
||||
|
||||
" It's already running.
|
||||
if has_key(s:state, 'job') && job_status(s:state['job']) == 'run'
|
||||
if has_key(s:state, 'job')
|
||||
return
|
||||
endif
|
||||
|
||||
@ -556,7 +606,7 @@ function! go#debug#Start(is_test, ...) abort
|
||||
\ '--output', tempname(),
|
||||
\ '--headless',
|
||||
\ '--api-version', '2',
|
||||
\ '--log', 'debugger',
|
||||
\ '--log', '--log-output', 'debugger,rpc',
|
||||
\ '--listen', go#config#DebugAddress(),
|
||||
\ '--accept-multiclient',
|
||||
\]
|
||||
@ -807,10 +857,7 @@ function! go#debug#Restart() abort
|
||||
call go#cmd#autowrite()
|
||||
|
||||
try
|
||||
call job_stop(s:state['job'])
|
||||
while has_key(s:state, 'job') && job_status(s:state['job']) is# 'run'
|
||||
sleep 50m
|
||||
endwhile
|
||||
call go#job#Stop(s:state['job'])
|
||||
|
||||
let l:breaks = s:state['breakpoint']
|
||||
let s:state = {
|
||||
@ -857,7 +904,7 @@ function! go#debug#Breakpoint(...) abort
|
||||
|
||||
try
|
||||
" Check if we already have a breakpoint for this line.
|
||||
let found = v:none
|
||||
let found = {}
|
||||
for k in keys(s:state.breakpoint)
|
||||
let bt = s:state.breakpoint[k]
|
||||
if bt.file == l:filename && bt.line == linenr
|
||||
@ -867,7 +914,7 @@ function! go#debug#Breakpoint(...) abort
|
||||
endfor
|
||||
|
||||
" Remove breakpoint.
|
||||
if type(found) == v:t_dict
|
||||
if type(found) == v:t_dict && !empty(found)
|
||||
call remove(s:state['breakpoint'], bt.id)
|
||||
exe 'sign unplace '. found.id .' file=' . found.file
|
||||
if s:isActive()
|
||||
|
@ -122,9 +122,12 @@ function! s:GodocView(newposition, position, content) abort
|
||||
setlocal nomodifiable
|
||||
sil normal! gg
|
||||
|
||||
" close easily with <esc> or enter
|
||||
" close easily with enter
|
||||
noremap <buffer> <silent> <CR> :<C-U>close<CR>
|
||||
noremap <buffer> <silent> <Esc> :<C-U>close<CR>
|
||||
" make sure any key that sends an escape as a prefix (e.g. the arrow keys)
|
||||
" don't cause the window to close.
|
||||
nnoremap <buffer> <silent> <Esc>[ <Esc>[
|
||||
endfunction
|
||||
|
||||
function! s:gogetdoc(json) abort
|
||||
|
95
sources_non_forked/vim-go/autoload/go/highlight_test.vim
Normal file
95
sources_non_forked/vim-go/autoload/go/highlight_test.vim
Normal file
@ -0,0 +1,95 @@
|
||||
function! Test_gomodVersion_highlight() abort
|
||||
try
|
||||
syntax on
|
||||
|
||||
let l:dir= gotest#write_file('gomodtest/go.mod', [
|
||||
\ 'module github.com/fatih/vim-go',
|
||||
\ '',
|
||||
\ '\x1frequire (',
|
||||
\ '\tversion/simple v1.0.0',
|
||||
\ '\tversion/pseudo/premajor v1.0.0-20060102150405-0123456789abcdef',
|
||||
\ '\tversion/pseudo/prerelease v1.0.0-prerelease.0.20060102150405-0123456789abcdef',
|
||||
\ '\tversion/pseudo/prepatch v1.0.1-0.20060102150405-0123456789abcdef',
|
||||
\ '\tversion/simple/incompatible v2.0.0+incompatible',
|
||||
\ '\tversion/pseudo/premajor/incompatible v2.0.0-20060102150405-0123456789abcdef+incompatible',
|
||||
\ '\tversion/pseudo/prerelease/incompatible v2.0.0-prerelease.0.20060102150405-0123456789abcdef+incompatible',
|
||||
\ '\tversion/pseudo/prepatch/incompatible v2.0.1-0.20060102150405-0123456789abcdef+incompatible',
|
||||
\ ')'])
|
||||
|
||||
let l:lineno = 4
|
||||
let l:lineclose = line('$')
|
||||
while l:lineno < l:lineclose
|
||||
let l:line = getline(l:lineno)
|
||||
let l:col = col([l:lineno, '$']) - 1
|
||||
let l:idx = len(l:line) - 1
|
||||
let l:from = stridx(l:line, ' ') + 1
|
||||
|
||||
while l:idx >= l:from
|
||||
call cursor(l:lineno, l:col)
|
||||
let l:synname = synIDattr(synID(l:lineno, l:col, 1), 'name')
|
||||
let l:errlen = len(v:errors)
|
||||
|
||||
call assert_equal('gomodVersion', l:synname, 'version on line ' . l:lineno)
|
||||
|
||||
" continue at the next line if there was an error at this column;
|
||||
" there's no need to test each column once an error is detected.
|
||||
if l:errlen < len(v:errors)
|
||||
break
|
||||
endif
|
||||
|
||||
let l:col -= 1
|
||||
let l:idx -= 1
|
||||
endwhile
|
||||
let l:lineno += 1
|
||||
endwhile
|
||||
finally
|
||||
call delete(l:dir, 'rf')
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
function! Test_gomodVersion_incompatible_highlight() abort
|
||||
try
|
||||
syntax on
|
||||
|
||||
let l:dir= gotest#write_file('gomodtest/go.mod', [
|
||||
\ 'module github.com/fatih/vim-go',
|
||||
\ '',
|
||||
\ '\x1frequire (',
|
||||
\ '\tversion/invalid/incompatible v1.0.0+incompatible',
|
||||
\ '\tversion/invalid/premajor/incompatible v1.0.0-20060102150405-0123456789abcdef+incompatible',
|
||||
\ '\tversion/invalid/prerelease/incompatible v1.0.0-prerelease.0.20060102150405-0123456789abcdef+incompatible',
|
||||
\ '\tversion/invalid/prepatch/incompatible v1.0.1-0.20060102150405-0123456789abcdef+incompatible',
|
||||
\ ')'])
|
||||
|
||||
let l:lineno = 4
|
||||
let l:lineclose = line('$')
|
||||
while l:lineno < l:lineclose
|
||||
let l:line = getline(l:lineno)
|
||||
let l:col = col([l:lineno, '$']) - 1
|
||||
let l:idx = len(l:line) - 1
|
||||
let l:from = stridx(l:line, '+')
|
||||
|
||||
while l:idx >= l:from
|
||||
call cursor(l:lineno, l:col)
|
||||
let l:synname = synIDattr(synID(l:lineno, l:col, 1), 'name')
|
||||
let l:errlen = len(v:errors)
|
||||
|
||||
call assert_notequal('gomodVersion', l:synname, 'version on line ' . l:lineno)
|
||||
|
||||
" continue at the next line if there was an error at this column;
|
||||
" there's no need to test each column once an error is detected.
|
||||
if l:errlen < len(v:errors)
|
||||
break
|
||||
endif
|
||||
|
||||
let l:col -= 1
|
||||
let l:idx -= 1
|
||||
endwhile
|
||||
let l:lineno += 1
|
||||
endwhile
|
||||
finally
|
||||
call delete(l:dir, 'rf')
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
" vim: sw=2 ts=2 et
|
@ -1,4 +1,7 @@
|
||||
func! Test_indent_raw_string() abort
|
||||
" The goRawString discovery requires that syntax be enabled.
|
||||
syntax on
|
||||
|
||||
try
|
||||
let l:dir= gotest#write_file('indent/indent.go', [
|
||||
\ 'package main',
|
||||
@ -17,6 +20,43 @@ func! Test_indent_raw_string() abort
|
||||
finally
|
||||
call delete(l:dir, 'rf')
|
||||
endtry
|
||||
endfunc
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
try
|
||||
let l:dir= gotest#write_file('indent/indent.go', [
|
||||
\ 'package main',
|
||||
\ '',
|
||||
\ 'import "fmt"',
|
||||
\ '',
|
||||
\ 'func main() {',
|
||||
\ "\t\x1fmsg := `",
|
||||
\ '`',
|
||||
\ '\tfmt.Println(msg)',
|
||||
\ '}'])
|
||||
|
||||
silent execute "normal o" . "not indented\<Esc>"
|
||||
let l:indent = indent(line('.'))
|
||||
call assert_equal(0, l:indent)
|
||||
finally
|
||||
call delete(l:dir, 'rf')
|
||||
endtry
|
||||
|
||||
try
|
||||
let l:dir= gotest#write_file('indent/indent.go', [
|
||||
\ 'package main',
|
||||
\ '',
|
||||
\ 'import "fmt"',
|
||||
\ '',
|
||||
\ 'func main() {',
|
||||
\ "\tconst msg = `",
|
||||
\ "\t\x1findented",
|
||||
\ '`',
|
||||
\ '\tfmt.Println(msg)',
|
||||
\ '}'])
|
||||
|
||||
silent execute "normal o" . "indented\<Esc>"
|
||||
let l:indent = indent(line('.'))
|
||||
call assert_equal(shiftwidth(), l:indent)
|
||||
finally
|
||||
call delete(l:dir, 'rf')
|
||||
endtry
|
||||
endfunc
|
||||
|
@ -293,6 +293,10 @@ function! go#job#Start(cmd, options)
|
||||
unlet l:options._start
|
||||
endif
|
||||
|
||||
if go#util#HasDebug('shell-commands')
|
||||
call go#util#EchoInfo('job command: ' . string(a:cmd))
|
||||
endif
|
||||
|
||||
if has('nvim')
|
||||
let l:input = []
|
||||
if has_key(a:options, 'in_io') && a:options.in_io ==# 'file' && !empty(a:options.in_name)
|
||||
@ -307,7 +311,12 @@ function! go#job#Start(cmd, options)
|
||||
call chanclose(job, 'stdin')
|
||||
endif
|
||||
else
|
||||
let job = job_start(a:cmd, l:options)
|
||||
let l:cmd = a:cmd
|
||||
if go#util#IsWin()
|
||||
let l:cmd = join(map(copy(a:cmd), function('s:winjobarg')), " ")
|
||||
endif
|
||||
|
||||
let job = job_start(l:cmd, l:options)
|
||||
endif
|
||||
|
||||
if !has_key(l:options, 'cwd')
|
||||
@ -501,4 +510,33 @@ function! s:neooptions(options)
|
||||
return l:options
|
||||
endfunction
|
||||
|
||||
function! go#job#Stop(job) abort
|
||||
if has('nvim')
|
||||
call jobstop(a:job)
|
||||
return
|
||||
endif
|
||||
|
||||
call job_stop(a:job)
|
||||
call go#job#Wait(a:job)
|
||||
return
|
||||
endfunction
|
||||
|
||||
function! go#job#Wait(job) abort
|
||||
if has('nvim')
|
||||
call jobwait(a:job)
|
||||
return
|
||||
endif
|
||||
|
||||
while job_status(a:job) is# 'run'
|
||||
sleep 50m
|
||||
endwhile
|
||||
endfunction
|
||||
|
||||
function! s:winjobarg(idx, val) abort
|
||||
if empty(a:val)
|
||||
return '""'
|
||||
endif
|
||||
return a:val
|
||||
endfunction
|
||||
|
||||
" vim: sw=2 ts=2 et
|
||||
|
@ -3,7 +3,7 @@ let s:go_major_version = ""
|
||||
function! go#mod#Format() abort
|
||||
" go mod only exists in `v1.11`
|
||||
if empty(s:go_major_version)
|
||||
let tokens = matchlist(go#util#System("go version"), '\d\+.\(\d\+\) ')
|
||||
let tokens = matchlist(go#util#System("go version"), '\d\+.\(\d\+\)\(\.\d\+\)\? ')
|
||||
let s:go_major_version = str2nr(tokens[1])
|
||||
endif
|
||||
|
||||
|
@ -54,11 +54,11 @@ function! go#statusline#Show() abort
|
||||
" only update highlight if status has changed.
|
||||
if status_text != s:last_status
|
||||
if status.state =~ "success" || status.state =~ "finished" || status.state =~ "pass"
|
||||
hi goStatusLineColor cterm=bold ctermbg=76 ctermfg=22
|
||||
hi goStatusLineColor cterm=bold ctermbg=76 ctermfg=22 guibg=#5fd700 guifg=#005f00
|
||||
elseif status.state =~ "started" || status.state =~ "analysing" || status.state =~ "compiling"
|
||||
hi goStatusLineColor cterm=bold ctermbg=208 ctermfg=88
|
||||
hi goStatusLineColor cterm=bold ctermbg=208 ctermfg=88 guibg=#ff8700 guifg=#870000
|
||||
elseif status.state =~ "failed"
|
||||
hi goStatusLineColor cterm=bold ctermbg=196 ctermfg=52
|
||||
hi goStatusLineColor cterm=bold ctermbg=196 ctermfg=52 guibg=#ff0000 guifg=#5f0000
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -127,6 +127,13 @@ function! go#util#gopath() abort
|
||||
return substitute(s:exec(['go', 'env', 'GOPATH'])[0], '\n', '', 'g')
|
||||
endfunction
|
||||
|
||||
" gomod returns 'go env GOMOD'. gomod changes depending on the folder. Don't
|
||||
" use go#util#env as it caches the value.
|
||||
function! go#util#gomod() abort
|
||||
return substitute(s:exec(['go', 'env', 'GOMOD'])[0], '\n', '', 'g')
|
||||
endfunction
|
||||
|
||||
|
||||
function! go#util#osarch() abort
|
||||
return go#util#env("goos") . '_' . go#util#env("goarch")
|
||||
endfunction
|
||||
@ -137,12 +144,13 @@ endfunction
|
||||
" so that we always use a standard POSIX-compatible Bourne shell (and not e.g.
|
||||
" csh, fish, etc.) See #988 and #1276.
|
||||
function! s:system(cmd, ...) abort
|
||||
" Preserve original shell and shellredir values
|
||||
" Preserve original shell, shellredir and shellcmdflag values
|
||||
let l:shell = &shell
|
||||
let l:shellredir = &shellredir
|
||||
let l:shellcmdflag = &shellcmdflag
|
||||
|
||||
if !go#util#IsWin() && executable('/bin/sh')
|
||||
set shell=/bin/sh shellredir=>%s\ 2>&1
|
||||
set shell=/bin/sh shellredir=>%s\ 2>&1 shellcmdflag=-c
|
||||
endif
|
||||
|
||||
try
|
||||
@ -151,6 +159,7 @@ function! s:system(cmd, ...) abort
|
||||
" Restore original values
|
||||
let &shell = l:shell
|
||||
let &shellredir = l:shellredir
|
||||
let &shellcmdflag = l:shellcmdflag
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
|
Reference in New Issue
Block a user