Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
rwxguo committed Dec 25, 2023
1 parent 085dd52 commit adc1751
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
11 changes: 7 additions & 4 deletions autoload/go/def.vim
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,15 @@ function! go#def#jump_to_declaration(out, mode, bin_name) abort

" strip line ending
let out = split(final_out, go#util#LineEnding())[0]

if go#util#IsWin()
let parts = split(out, '\(^[a-zA-Z]\)\@<!:')
elseif system('uname') =~ 'MINGW' || system('uname') =~ 'CYGWIN'
" remove comma from path before split. e.g. /c:/path to /c/path
if l:out[2:3] is# ':/'
let l:out = l:out[0:1] . l:out[3:]
elseif has('win32unix')
" remove comma in cygwin path e.g. '/c:/path'
if l:out[0:8] != '/cygdrive'
if l:out[2:3] is# ':/'
let l:out = l:out[0:1] . l:out[3:]
endif
endif
let parts = split(out, ':')
else
Expand Down
13 changes: 9 additions & 4 deletions autoload/go/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -617,12 +617,17 @@ function! s:definitionHandler(next, msg) abort dict
let l:msg = a:msg[0]

let l:msguri = go#path#FromURI(l:msg.uri)
" remove the comma in cygwin unix-like windwos path
" e.g. '/c:/path' to '/c/path'
if has('win32unix') && (system('uname') =~ 'MINGW' || system('uname') =~ 'CYGWIN')

if has('win32unix')
" remove comma in cygwin path e.g. '/c:/path'
if l:msguri[2:3] is# ':/'
let l:msguri = l:msguri[0:1] . l:msguri[3:]
endif

" add 'cygdrive' for CYGWIN rather than MSYS2/GitBash
if system('uname') =~ 'CYGWIN'
let l:msguri = '/cygdrive' . l:msguri
endif
endif

let l:line = s:lineinfile(l:msguri, l:msg.range.start.line+1)
Expand All @@ -631,7 +636,7 @@ function! s:definitionHandler(next, msg) abort dict
return
endif

let l:args = [[printf('%s:%d:%d: %s', go#path#FromURI(l:msg.uri), l:msg.range.start.line+1, go#lsp#lsp#PositionOf(l:line, l:msg.range.start.character), 'lsp does not supply a description')]]
let l:args = [[printf('%s:%d:%d: %s', l:msguri, l:msg.range.start.line+1, go#lsp#lsp#PositionOf(l:line, l:msg.range.start.character), 'lsp does not supply a description')]]
call call(a:next, l:args)
endfunction

Expand Down

0 comments on commit adc1751

Please sign in to comment.