mingw: Add platform checking of GoDocBrowser for Cygwin on windows
- When using Cygwin/MSYS2 on windows, the
:GoDocBrowsercannot popup the browser correctly.- Added
has('win32unix')for platform compatibility.
- Added
- Also resolved vim screen mess up after using
:silentwith external command- refer to
:h :silent - https://vi.stackexchange.com/questions/2809/silent-makes-my-vim-go-blank
- refer to
Thank you
welcome, happy holiday !
@bhcleek Thank you for your guide and instruction. I added cygwin detection go#util#IsCygwin.
The reason using uname to check the platform is inspired by the maven-wrapper project, which is widely used in enterprise level java projects using SpringBoot etc.
Plus, I also leverage the vim built-in feature list has('win32unix') to make it more concise.
I have tested these factors on three major cygwin platforms, the result is for your reference:
| platform | has('win32') | has('win64') | has('win32unix') | uname |
|---|---|---|---|---|
| Cygwin | 0 | 0 | 1 | CYGWIN_... |
| GitBash (64bit) | 0 | 0 | 1 | MINGW64_... |
| MSYS2 - mingw32.exe | 0 | 0 | 1 | MINGW32_... |
| MSYS2 - mingw64.exe | 0 | 0 | 1 | MINGW64_... |
| MSYS2 - msys2.exe | 0 | 0 | 1 | MSYS_... |
By the way, I found there is a util function go#util#IsUsingCygwinShell which might not correct, because it uses go#util#IsWin, but based on my above testing result, go#util#IsWin always return 0 on all cygwin-like platform...
" Checks if using:
" 1) Windows system,
" 2) And has cygpath executable,
" 3) And uses *sh* as 'shell'
function! go#util#IsUsingCygwinShell()
return go#util#IsWin() && executable('cygpath') && &shell =~ '.*sh.*'
endfunction
The go#util#IsUsingCygwinShell is used in path.vim, for your information
Yes, go#util#IsUsingCygwinShell is for a different kind of use case than you've been working on. The last I checked, it is correct for the use case for which it is intended.
As CYGWIN uses cygstart instead of start, but MSYS2 and GitBash uses start, I made the cygwin checking as a seprated "elseif", and use rundll32 instead of start rundll32 or cygwin rundll32. (treat cygwin as a separated system, rather than a windows variation)