Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mingw: Resolve path issue, make gopls work on CYGWIN/MSYS2/GitBash (:GoDoc, :GoInfo and :GoDef) #3612

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions autoload/go/def.vim
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ function! go#def#jump_to_declaration(out, mode, bin_name) abort
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'
if l:msguri[2:3] is# ':/'
rwxguo marked this conversation as resolved.
Show resolved Hide resolved
let l:out = l:out[0:1] . l:out[3:]
endif
let parts = split(out, ':')
else
let parts = split(out, ':')
endif
Expand Down
11 changes: 10 additions & 1 deletion autoload/go/lsp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,16 @@ function! s:definitionHandler(next, msg) abort dict
" gopls returns a []Location; just take the first one.
let l:msg = a:msg[0]

let l:line = s:lineinfile(go#path#FromURI(l:msg.uri), l:msg.range.start.line+1)
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 l:msguri[2:3] is# ':/'
let l:msguri = l:msguri[0:1] . l:msguri[3:]
endif
endif

let l:line = s:lineinfile(l:msguri, l:msg.range.start.line+1)
if l:line is -1
call go#util#Warn('could not find definition')
return
Expand Down
4 changes: 4 additions & 0 deletions autoload/go/path.vim
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ function! go#path#ToURI(path)
let l:absolute = 1
let l:prefix = '/' . l:path[0:1]
let l:path = l:path[2:]
elseif system('uname') =~ 'MINGW' || system('uname') =~ 'CYGWIN'
let l:absolute = 1
let l:prefix = l:path[0:1] . ':'
let l:path = l:path[2:3] is# ':/' ? l:path[3:] : l:path[2:]
endif

return substitute(
Expand Down
Loading