ray-x / go.nvim

G'day Nvimer, Joyful Gopher: Discover the Feature-Rich Go Plugin for Neovim
MIT License
2.17k stars 126 forks source link

Gopls local property is not set when CWD doesn't contain go.mod #512

Open ffoebel opened 1 month ago

ffoebel commented 1 month ago

There's no upward search here: https://github.com/ray-x/go.nvim/blob/master/lua/go/gopls.lua#L288

I'm pretty sure go.mod discovery works fine in other cases, maybe there's a function to reuse?

For big repositories it's quite common (at least for me) to open nvim in a subdirectory to limit e.g. file search.

ray-x commented 1 month ago

You can re-write the function and pass the result to gopls config

lsp_cfg = {settings={gopls={['local'] = 'your_local_module_path', gofumpt = true }}}

But what does your preferred method look like? As I always set root-dir to either go.mod, go.work etc