vim-go icon indicating copy to clipboard operation
vim-go copied to clipboard

mingw: Add platform checking of GoDocBrowser for Cygwin on windows

Open rwxguo opened this issue 2 years ago • 6 comments

  • When using Cygwin/MSYS2 on windows, the :GoDocBrowser cannot popup the browser correctly.
    • Added has('win32unix') for platform compatibility.
  • Also resolved vim screen mess up after using :silent with external command
    • refer to :h :silent
    • https://vi.stackexchange.com/questions/2809/silent-makes-my-vim-go-blank

rwxguo avatar Dec 15 '23 09:12 rwxguo

Thank you

bhcleek avatar Dec 15 '23 16:12 bhcleek

welcome, happy holiday !

rwxguo avatar Dec 19 '23 06:12 rwxguo

@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_...

rwxguo avatar Dec 24 '23 06:12 rwxguo

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

rwxguo avatar Dec 24 '23 06:12 rwxguo

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.

bhcleek avatar Dec 24 '23 07:12 bhcleek

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)

rwxguo avatar Dec 25 '23 13:12 rwxguo