mirror of
https://github.com/amix/vimrc
synced 2025-06-16 01:25:00 +08:00
Updated vimrc
This commit is contained in:
@ -13,35 +13,43 @@ function! go#def#Jump(...)
|
||||
let arg = a:1
|
||||
endif
|
||||
|
||||
let bin_path = go#tool#BinPath(g:go_godef_bin)
|
||||
let bin_path = go#path#CheckBinPath(g:go_godef_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
endif
|
||||
|
||||
let command = bin_path . " -f=" . expand("%:p") . " -i " . shellescape(arg)
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
let command = bin_path . " -f=" . shellescape(expand("%:p")) . " -i " . shellescape(arg)
|
||||
|
||||
" get output of godef
|
||||
let out=system(command, join(getbufline(bufnr('%'), 1, '$'), LineEnding()))
|
||||
let out=system(command, join(getbufline(bufnr('%'), 1, '$'), go#util#LineEnding()))
|
||||
|
||||
" jump to it
|
||||
call s:godefJump(out, "")
|
||||
let $GOPATH = old_gopath
|
||||
endfunction
|
||||
|
||||
|
||||
function! go#def#JumpMode(mode)
|
||||
let arg = s:getOffset()
|
||||
|
||||
let bin_path = go#tool#BinPath(g:go_godef_bin)
|
||||
let bin_path = go#path#CheckBinPath(g:go_godef_bin)
|
||||
if empty(bin_path)
|
||||
return
|
||||
endif
|
||||
|
||||
let command = bin_path . " -f=" . expand("%:p") . " -i " . shellescape(arg)
|
||||
let old_gopath = $GOPATH
|
||||
let $GOPATH = go#path#Detect()
|
||||
|
||||
let command = bin_path . " -f=" . shellescape(expand("%:p")) . " -i " . shellescape(arg)
|
||||
|
||||
" get output of godef
|
||||
let out=system(command, join(getbufline(bufnr('%'), 1, '$'), LineEnding()))
|
||||
let out=system(command, join(getbufline(bufnr('%'), 1, '$'), go#util#LineEnding()))
|
||||
|
||||
call s:godefJump(out, a:mode)
|
||||
let $GOPATH = old_gopath
|
||||
endfunction
|
||||
|
||||
|
||||
@ -51,7 +59,7 @@ function! s:getOffset()
|
||||
let offs = line2byte(pos[0]) + pos[1] - 2
|
||||
else
|
||||
let c = pos[1]
|
||||
let buf = line('.') == 1 ? "" : (join(getline(1, pos[0] - 1), LineEnding()) . LineEnding())
|
||||
let buf = line('.') == 1 ? "" : (join(getline(1, pos[0] - 1), go#util#LineEnding()) . go#util#LineEnding())
|
||||
let buf .= c == 1 ? "" : getline(pos[0])[:c-2]
|
||||
let offs = len(iconv(buf, &encoding, "utf-8"))
|
||||
endif
|
||||
@ -66,7 +74,7 @@ function! s:godefJump(out, mode)
|
||||
let &errorformat = "%f:%l:%c"
|
||||
|
||||
if a:out =~ 'godef: '
|
||||
let out=substitute(a:out, LineEnding() . '$', '', '')
|
||||
let out=substitute(a:out, go#util#LineEnding() . '$', '', '')
|
||||
echom out
|
||||
else
|
||||
let parts = split(a:out, ':')
|
||||
|
Reference in New Issue
Block a user