From e6a48de652fd64820583c245eede0b242b6eb2bb Mon Sep 17 00:00:00 2001 From: rwxguo <10892928+rwxguo@users.noreply.github.com> Date: Sun, 24 Dec 2023 14:17:16 +0800 Subject: [PATCH] add cygwin detection (include cygwin, msys2 and gitbash) --- autoload/go/config.vim | 2 +- autoload/go/util.vim | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/autoload/go/config.vim b/autoload/go/config.vim index ef699a0593..91f16ff32c 100644 --- a/autoload/go/config.vim +++ b/autoload/go/config.vim @@ -100,7 +100,7 @@ function! go#config#SnippetEngine() abort endfunction function! go#config#PlayBrowserCommand() abort - if go#util#IsWin() || system('uname') =~ 'MINGW' || system('uname') =~ 'CYGWIN' + if go#util#IsWin() || go#util#IsCygwin() let go_play_browser_command = '!start rundll32 url.dll,FileProtocolHandler %URL%' elseif go#util#IsMac() let go_play_browser_command = 'open %URL%' diff --git a/autoload/go/util.vim b/autoload/go/util.vim index 89b72733d4..3846a4664d 100644 --- a/autoload/go/util.vim +++ b/autoload/go/util.vim @@ -49,6 +49,17 @@ function! go#util#IsMac() abort \ go#util#Exec(['uname'])[0] =~? '^darwin' endfunction +" IsCygwin returns 1 if current OS is Cygwin/MSYS2/GitBash, 0 otherwise +function! go#util#IsCygwin() + return !has('win32') && + \ has('win32unix') && + \ ( + \ system('uname') =~ 'CYGWIN' || + \ system('uname') =~ 'MINGW' || + \ system('uname') =~ 'MSYS' + \ ) +endfunction + " Checks if using: " 1) Windows system, " 2) And has cygpath executable,