mingw: Resolve path issue, make gopls work on CYGWIN/MSYS2/GitBash (:GoDoc
, :GoInfo
and :GoDef
)
#3612
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch can resolve the following issues:
The root cause is that
gopls
cannot identify the correct path sent fromvim-go
.When talking about cygwin, it generally means the
CYGWIN
,MSYS2
andGitBash
(main-stream system).Cygwin mixed the 2 path systems (Win & Unix) which benefit from two world, but also brought some problem. The path like
/c/mypath
is used to represent the corresponding windows pathc:\mypath
. However, when communicating withgopls
, the path becomes/c:/mypath
(please note there is a:
) which is neither cygwin path nor windows path. It is probably because the GitBash parse the path from/to thegopls
with a forward slash prefix/
. The problem is how to handle the comma properly.Another finding is that,
CYGWIN
path has a prefix/cygdrive
compare toMSYS2
/GitBash
. This should also be handled.Thus, the following matrix is showing the path compatibility:
CYGWIN
MSYS2
GitBash
Windows
c:\path
(\
and/
)c:\path
or"c:/path"
)/c/path
/cygdrive/c/path
/c:/path
I didn't modify the logic of
go#util#IsWin()
because it is called by many places in the program, to prevent other issues happen. Instead, I treated the Cygwin system as another system (Neither Windows, nor Unix).Vim provide a cygwin checking
has('win32unix')
and it should be enough. Refer to the bhcleek's reply. ForCYGWIN
specific checking, we can useuname
shell command.I have only tested
:GoDoc
,:GoInfo
and:GoDef
, which I think are the most popular functions for cygwin users.