Comments (8)
Have you saved the file to disk?
from vim-go.
Yes.
from vim-go.
đ¤ I'm not sure what would cause that then. I followed your instructions to replicate and don't see any errors.
Can you execute :let g:go_debug=['lsp']
and try jumping to the definition? I'd like to see the full contents of the __GOLSP_LOG__
window.
from vim-go.
Sure:
===== sent =====
Content-Length: 166
{"method":"textDocument/definition","jsonrpc":"2.0","id":3,"params":{"textDocument":{"uri":"file:///home/tyler/go-test/main.go"},"position":{"character":5,"line":5}}}
===== received =====
Content-Length: 119
{"jsonrpc":"2.0","error":{"code":0,"message":"no package metadata for file file:///home/tyler/go-test/main.go"},"id":3}
^ That's from me opening main.go
and typing gd
on top of Println
from vim-go.
The only things that come to mind are case sensitivity of the file system or that your main.go hasn't been persisted to disk.
from vim-go.
Hmm yeah. The weird thing is that I have many other projects (which I cloned from Github) on my machine that vim-go is working perfectly for, but for some reason when I try to start a new project it gives this error. I don't know what is different about my configuration that is causing gopls to complain.
from vim-go.
OK so it appears that running :GoUpdateBinaries
has fixed the issue. I'm not sure the root cause, but I'm good to go now. Thank you for you taking the time to help me debug.
from vim-go.
EDIT: found the solution by deleting the vendor
folder. The project is already using Go modules đ
Facing the same issue here. Sadly, :GoUpdateBinaries
didn't work for me
What did you do? (required: The issue will be closed when not provided)
I've been using vim-go for many other projects, and they all work fine except for one, which I started working on yesterday. When I open any Go project file, and then hit gd
to go to the origin, the same issue happens.
It's worth mentioning that this project is using the vendor approach for its dependencies, while all the others don't. Also, ctags
works as expected, so that's what I'm using till a solution is found đ
What did you expect to happen?
The reference under the cursor would follow its source file.
What happened instead?
Got the output below:
vim-go: no package metadata for file file:///home/devdrops/work/company/area/project/package1/package2/file.go
I can't print the file name exactly because of copyrights (it's a private project).
Configuration (MUST fill this out):
vim-go version:
https://github.com/fatih/vim-go/releases/tag/v1.28
vimrc
you used to reproduce:
vimrc
" ##################################
" # VIM SETTINGS
" #
" # REFERENCES:
" # https://github.com/mhinz/vim-galore/blob/master/static/minimal-vimrc.vim
" # http://ivanbrennan.nyc/blog/2014/01/16/rigging-vims-netrw/
" # http://www.drchip.org/astronaut/vim/index.html#NETRW
" # https://www.cs.clemson.edu/course/cpsc102/links/vimrc
" # http://ellengummesson.com/blog/2014/02/22/make-vim-really-behave-like-netrw/
" # https://gist.github.com/danidiaz/37a69305e2ed3319bfff9631175c5d0f
" # https://github.com/sickill/vim-monokai
" # https://jovicailic.org/mastering-vim-quickly/
" # https://medium.com/vim-drops/javascript-folding-on-vim-119c70d2e872
" # https://vimways.org/2018/from-vimrc-to-vim/
" # https://github.com/amix/vimrc/blob/master/vimrcs/basic.vim
" # https://html.developreference.com/article/22757209/Forcing+vimdiff+to+wrap+lines%3F
" # https://remram44.github.io/regex-cheatsheet/regex.html
" # https://cheatography.com/fievel/cheat-sheets/vim-regexp/
" # http://www.softpanorama.org/Editors/Vimorama/vim_regular_expressions.shtml
" # https://vimtricks.com/p/highlight-syntax-inside-markdown/
" # https://vim.fandom.com/wiki/256_colors_in_vim
" # https://vimtricks.com/p/vim-search-ignore-case
" # https://cs.opensource.google/go/x/tools/+/refs/tags/gopls/v0.14.2:gopls/doc/vim.md
" #
" ##################################
" :::::::::: Vim General Settings ::::::::::
syntax enable " File syntax.
set nocompatible " Vim exclusive.
set autoindent " Vim auto indentation.
set ttyfast " Indicates a fast terminal connection.
set tabstop=2 " Tabs with 2 intervals.
set expandtab " Tabs replaced by spaces.
set shiftwidth=2 " Indentation with 2 intervals.
set softtabstop=2 " Indentation with 2 intervals.
set shiftround " Round indent to shiftwidth value.
set laststatus=2 " Last window status.
set display=lastline " Display the whole line instead of wrap with @.
set showmode " Already defined on Vim. Display current mode.
set incsearch " Highlight pattern on search while typing.
set hlsearch " Highlight all matches on search.
set wrapscan " Searches wrap around the end of the file.
set splitbelow " Puts the new splitted window below the current one.
set splitright " Puts the new splitted window right the current one.
set cursorline " Highlight the screen line of the cursor.
set report=0 " Reports number of lines changed. 0 stands for always.
set synmaxcol=0 " Maximum column to search for syntax items. Default: 3000. 0 removes the limit.
set number " Line number.
set relativenumber " Relative line number.
set wildmode=longest,list,full " Navigation method.
set wildmenu " Navigation through files/folders.
set wildignorecase " Case insensitive autocompletion for files and folders.
set ignorecase " Makes pattern matching case-insensitive.
set smartcase " Overrides ignorecase if your pattern contains mixed case.
set tabpagemax=100 " Number of tabs when using `vim -p` (default is 10).
set showtabline=2 " Tab display. 0: never; 1: only with 2 or more tabs; 2: always.
set foldcolumn=1 " Columns when folding.
set foldlevelstart=99 " Folding mode when opening files. 99 keeps all folds open.
set keywordprg=google " Execute `google` when hit K. Requires `bins/google` file from this repository.
set autoread " Vim will automatically read all changes made outside Vim.
set ruler " Display current line and column numbers, as `live, column`.
set title " Enables title
" Modify title format
set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:~:.:h\")})%)%(\ %a%)
filetype plugin on
filetype indent on
set nobackup " No backup files.
set nowritebackup " No backup write files.
set nowb " Don't write backup files.
set noswapfile " No swap files.
set noundofile " Deactivate file backup.
set t_Co=256 " Enable 256 colors.
set foldmethod=indent " Set which method is used for folding:
" - manual
" - indent
" - expr
" - marker
" - syntax (default)
" - diff
" See :h foldmethod
packadd! dracula
colorscheme dracula " Define the current color theme.
" Set highlight syntax on code written inside markdown blocks
let g:markdown_fenced_languages =
\ [
\ 'conf', 'css', 'cucumber', 'dockerfile', 'go', 'java', 'javascript',
\ 'json', 'kotlin', 'make', 'nginx', 'php', 'terraform', 'text', 'toml',
\ 'xml', 'yaml', 'html', 'bash', 'sh', 'vim'
\ ]
" Tabs
hi TabLine cterm=NONE ctermfg=Gray ctermbg=238
hi TabLineSel cterm=bold,italic ctermfg=123
hi TabLineFill cterm=NONE ctermbg=16
" :::::::::: Netrw Settings ::::::::::
let g:netrw_banner=0 " Netrw banner.
" 0 - Suppress.
" 1 - Display (default).
let g:netrw_liststyle=3 " Folder/file list style.
" 0 - Thin.
" 1 - Long.
" 2 - Wide.
" 3 - Tree.
let g:netrw_altv=1 " Control right/left splitting.
" 0 - Horizontal.
" 1 - Vertical.
let g:netrw_preview=1 " Control horizontal vs vertical splitting.
" 0 - Preview horizontal.
" 1 - Preview vertical.
let g:netrw_winsize=80 " Open the preview with 80% of the screen.
let g:netrw_special_syntax=1 " Special syntax for a given list of file
" types.
" 0 - Disabled.
" 1 - Enabled.
let g:netrw_fastbrowse=2 " Directory browsing.
" 0 - Slow.
" 1 - Medium (default).
" 2 - Fast.
" Do not display files and folders in the list.
let g:netrw_list_hide='^.git/$,.jpg$,.jpeg$,.png$,.svg,.ico,.gif$,.cache$,.woff2$'
let g:netrw_ignorenetrc=1 " .netrc file usage.
" 0 - Load.
" 1 - Ignore.
let g:netrw_browse_split=3 " Set how to display splitted files:
" 0 - Default.
" 1 - Horizontal split.
" 2 - Vertical split.
" 3 - New tab/window.
let g:netrw_hide=1 " File display mode:
" 0 - Show all.
" 1 - Show not hidden (default).
" 2 - Show only hidden.
let g:netrw_sort_by='name' " Display sort:
" 'name' - Alphabetically (default).
" 'time' - Modification time.
" 'size' - Size.
" 'exten' - Extension.
let g:netrw_sort_direction='normal' " Sort orientation:
" 'normal' - A to Z (default).
" 'reverse' - Z to A.
let g:netrw_sort_options='i' " Sort options.
" 'i' means 'case insensitive'.
" Time format for strftime().
let g:netrw_timefmt=' %a %Y-%m-%d %I:%M:%S %p'
let g:netrw_use_noswf=0 " Netrw creation of swap files for browser
" buffers:
" 1 - Enabled (default).
" 0 - Disabled.
let g:netrw_keepdir=1 " Current browser directory
" 1 - (default) keep current directory immune from the browsing directory.
" 0 - keep the current directory the same as the browsing directory.
let g:netrw_localcopycmd='cp-r' " Netrw's command to copy folders. Default: 'cp'
let g:netrw_localcopydircmd='cp -r' " Netrw's command to copy folders. Default: 'cp'
let g:netrw_localmkdir='mkdir -p'
let g:netrw_use_errorwindow=2
let g:netrw_sizestyle='H' " Changes how file size is displayed using qf.
" b - (default) Byte size
" h - Human friendly, base 1000
" H - Human friendly, base 1024
" :::::::::: vimdiff Settings ::::::::::
" Set line wrap when using vimdiff.
au VimEnter * if &diff | execute 'windo set wrap' | endif
if &diff
" vimdiff syntax highlight: added line.
hi DiffAdd ctermfg=Black ctermbg=LightGreen
" vimdiff syntax highlight: changed line.
hi DiffChange ctermfg=Black ctermbg=Yellow
" vimdiff syntax highlight: deleted line.
hi DiffDelete ctermfg=Black ctermbg=LightRed
" vimdiff syntax highlight: changed text within a changed line.
hi DiffText ctermfg=Black ctermbg=LightBlue
endif
" :::::::::: gitcommit Settings ::::::::::
hi diffAdded cterm=bold ctermfg=LightGreen ctermbg=Black
hi diffRemoved cterm=bold ctermfg=DarkRed ctermbg=Black
hi diffNewFile cterm=bold ctermfg=DarkBlue ctermbg=Black
hi diffFile cterm=bold ctermfg=LightBlue ctermbg=Black
hi gitcommitDiff cterm=NONE ctermfg=240
" :::::::::: vim-go Settings ::::::::::
" Debug
let g:go_debug_windows = {
\ 'vars': 'rightbelow 60vnew',
\ 'stack': 'rightbelow 10new',
\ 'out': 'botright 5new',
\ }
let g:go_debug_preserve_layout = 1
" gopls
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
Vim version (first three lines from :version
):
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Oct 16 2023 18:15:38)
Included patches: 1-579, 1969, 580-1854, 1857, 1855-1857, 1331, 1858, 1858-1859, 1873, 1860-1969, 1992, 1970-1992, 2010, 1993-3995, 4563, 4646, 4774, 4895, 4899, 4901, 4919,
213, 1840, 1846-1847
Modified by [email protected]
Compiled by [email protected]
Go version (go version
):
go version go1.21.1 linux/amd64
Go environment
go env
Output:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/devdrops/.cache/go-build'
GOENV='/home/devdrops/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/devdrops/.asdf/installs/golang/1.21.1/packages/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/devdrops/.asdf/installs/golang/1.21.1/packages'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/devdrops/.asdf/installs/golang/1.21.1/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/devdrops/.asdf/installs/golang/1.21.1/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3465231527=/tmp/go-build -gno-record-gcc-switches'
gopls version
gopls version
Output:
golang.org/x/tools/gopls v0.14.2 golang.org/x/tools/[email protected] h1:sIw6vjZiuQ9S7s0auUUkHlWgsCkKZFWDHmrge8LYsnc=
from vim-go.
Related Issues (20)
- mingw: GoDef (and various other commands) don't work, potentially due to pathing issue HOT 7
- Vim jumps to end of file on save HOT 2
- GoSameIds end position miscalculated for identifiers at the end of line
- GoExtract sends incorrect location to LSP HOT 1
- Error detected while processing Buf WritePre HOT 1
- Error detected while processing function <SNR>129_debugasync: E117 Unknown function: state ... HOT 1
- Typecheck errors when calling a function in another go file in the same package. HOT 9
- Godef has been Invalid in code with "import C" HOT 4
- Merged #3617 breaks UltiSnips placeholder mechanism HOT 3
- Cannot install or make it work with NeoVim gives error E492: Not an editor command :GoDef HOT 2
- Auto imports not working HOT 1
- Error in identifier/syntax prevents autocommands to be executed HOT 7
- Support quoting arguments to :GoImpl HOT 3
- Development: `make lint` always fails using GNU grep 3.8 or later HOT 5
- Vim randomly stops when go_highlight_function_calls is on HOT 4
- Execution: GoFmt changes the Chinese at the end to <e4> HOT 2
- Startup time ~4 s on nvim, macos, even with empty init.lua HOT 1
- c-x c-o error HOT 8
- Running :GoDef or any other commands that require gopls fails without error HOT 9
- vim has defined a set of key positions that span the ages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â¤ī¸ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-go.