mingw: Incompatible with mingw64
What did you do? (required: The issue will be closed when not provided)
Ran plugin with mingw64 (git bash for windows). I believe this problem likely would affect msys2 as well.
What did you expect to happen?
What happened instead?
When opening a file paths are not properly formed in plugin. I get a message like:
vim-go: failed to load view for file:///C:/c/path/to/my/project: invalid workspace folder path: The system cannot find the path specified.; check that the casing of the configured workspace folder path agrees with the casing reported by the operating system
Looked into the code a little bit, has('Win32') is used by the IsWin function in util.vim. This returns 0 for msys2/mingw64. has('Win32unix') returns 1 as does has('unix').
Also, GoInstallBinaries did not work without explicitly setting GOBIN variable as GOPATH/bin (not sure if this is related or not, I no longer have the error messages, but they complained about GOBIN).
Configuration (MUST fill this out):
vim-go version:
4d6962d8
vimrc you used to reproduce:
vimrc
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"call vundle#begin('~/some/path/here')
Plugin 'VundleVim/Vundle.vim'
Plugin 'heavenshell/vim-pydocstring'
Plugin 'wannesm/wmgraphviz.vim'
Plugin 'vim-scripts/reload.vim'
Plugin 'vim-scripts/vim-misc'
Plugin 'romainl/Apprentice'
Plugin 'iamcco/markdown-preview.nvim'
Plugin 'fatih/vim-go'
call vundle#end() " required
filetype plugin indent on " required
"filetype plugin on
colorscheme default
if &diff
colorscheme molokai
endif
:set tabstop=4
:set shiftwidth=4
:set softtabstop=4
:set expandtab
:set autoindent
augroup myvimrchooks
au!
autocmd bufwritepost .vimrc source ~/.vimrc
augroup END
filetype plugin on
autocmd FileType yaml setlocal shiftwidth=2 tabstop=2 softtabstop=2
nmap <silent> <c-p> <Plug>(pydocstring)
nnoremap <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
Vim version (first three lines from :version):
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Nov 22 2021 19:31:05)
Included patches: 1-3582
Compiled by <https://www.msys2.org/>
Go version (go version):
go version go1.19 windows/amd64
Go environment
go env Output:
set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\bmccord\AppData\Local\go-build set GOENV=C:\Users\bmccord\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\bmccord\go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:/Users/bmccord/go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=C:\Program Files\Go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.19 set GCCGO=gccgo set GOAMD64=v1 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=NUL set GOWORK= set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\bmccord\AppData\Local\Temp\go-build3966281748=/tmp/go-build -gno-record-gcc-switches
gopls version
gopls version Output:
golang.org/x/tools/gopls v0.9.4
golang.org/x/tools/[email protected] h1:YhHOxVi++ILnY+QnH9FGtRKZZrunSaR7OW8/dCp7bBk=
Vim-go is unlikely to support mingw64 explicitly; I don't have a Windows machine to test with, and arguably one would be better off using Vim built for Windows than trying to use one built specifically for mingw64.
I think the error message you're seeing is actually coming from gopls and is merely being surfaced by vim-go. I'm not sure if there's anything that vim-go can do about this. I wonder if this would resolve itself if you configured your environment to use the mingw64 version of Go and then rebuilt the binaries that vim-go needs using :GoUpdateBinaries.
mingw64 doesn't provide golang package because it is the same windows version. Last time I tried to figure out root cause it was a problem with a path notations: / vs \. But using same binaries from shell itself worked fine.
Yes, the problems is paths, but the systems ability to understand a path will depend on how it was compiled. In this case, it looks like gopls was compiled outside of mingw, but is being used inside of mingw. Running vim in mingw and executing :GoUpdateBinaries gopls may resolve this.
Yes, the problems is paths, but the systems ability to understand a path will depend on how it was compiled. In this case, it looks like
goplswas compiled outside of mingw, but is being used inside of mingw. Running vim in mingw and executing:GoUpdateBinaries goplsmay resolve this.
Nope. Same error as at issue description.
I'm not sure how to solve this. The problem is the the path has /C:/c where it should just be /c. I think this may be a consequence of effectively trying to use a binaries in the mingw context that are compiled without using mingw, but I'm not sure, and I don't have a way to test.
It may be related to the Go version that's being used, or something else. Until we can find a solution, I'd recommend not using mingw's Vim on Windows with vim-go.
Maybe we can get to the bottom of this. Here's what I need:
- execute
let g:go_debug=['lsp']and reproduce the problem. I need the contents of the__GOLSP_LOG__window. - What does
:echo expand('%:p:h')output for you? - What does
:echo expand('%:p')output for you? - What does
:echo resolve('%:p:h)output for you? - What does
:cd expand('%:p:h) | !go env GOMODoutput for you?
I'd recommend not using mingw's Vim on Windows with vim-go.
Idea is to use vim within a shell. So, I'm not using vim-go :D
execute ..
File: D:\main.go
let g:go_debug=['lsp']
===== sent =====
Content-Length: 227
{"method":"textDocument/didChange","jsonrpc":"2.0","params":{"contentChanges":[{"text":"package main\n\nimport \"fmt\"\n\nfunc main() {\n\tfmt.Println(\"vim-go\")\n}\n"}],"textDocument":{"uri":"file:///d/main.go","version":5}}}
echo expand('%:p:h')
/d
echo expand('%:p')
/d/main.go
echo resolve('%:p:h); mistake in the command, do You wantecho resolve(expand('%:p:h'))? Here it is
/d
cd expand('%:p:h') | !go env GOMOD
E344: Can't find directory "expand('/d')" in cdpath
E472: Command failed
Press ENTER or type command to continue
Hey sorry I haven't been active in this thread--I actually forgot I posted this issue. I ended up using VS Code for the golang development I needed to do and am not actively using golang at this time so I don't have much to offer in terms of debugging unfortunately