ray-x / go.nvim

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

The plugin seems to be not loading when opening go files? #314

Closed qwexvf closed 1 year ago

qwexvf commented 1 year ago

Not sure when this happened but i released the plugin was not being loaded. I Also noticed that there was an error on :checkhealth

i can confirm that i have GOPATH configured with echo $PATH | grep "$GOPATH/bin"

my lazy config:

    -- Go
    {
        "ray-x/go.nvim",
        dependencies = { -- optional packages
            "ray-x/guihua.lua",
            "neovim/nvim-lspconfig",
            "nvim-treesitter/nvim-treesitter",
        },
        config = function()
            require("go").setup()
        end,
        event = { "CmdlineEnter" },
        ft = { "go", "gomod" },
        build = ":lua require(\"go.install\").update_all_sync()", -- if you need to install/update all binaries
    },

============================================================================== gitsigns: require("gitsigns.health").check()

============================================================================== go: require("go.health").check()

============================================================================== lazy: require("lazy.health").check()

lazy.nvim ~

============================================================================== nvim: require("nvim.health").check()

Configuration ~

Runtime ~

Performance ~

Remote Plugins ~

terminal ~

============================================================================== nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~

OS Info: { machine = "arm64", release = "22.3.0", sysname = "Darwin", version = "Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:35 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T8103" } ~

Parser/Features H L F I J

============================================================================== provider: health#provider#check

Clipboard (optional) ~

Python 3 provider (optional) ~

Python virtualenv ~

Ruby provider (optional) ~

Node.js provider (optional) ~

Perl provider (optional) ~

============================================================================== telescope: require("telescope.health").check()

Checking for required plugins ~

Checking external dependencies ~

===== Installed extensions ===== ~

Telescope Extension: file_browser ~

============================================================================== vim.lsp: require("vim.lsp.health").check()

vim.lsp: Active Clients ~

============================================================================== vim.treesitter: require("vim.treesitter.health").check()

ray-x commented 1 year ago

do you have packer installed as well?

qwexvf commented 1 year ago

@ray-x I do not have packer installed if you are asking because it says

im not sure why i have to i have a fresh installed macos and never installed packer .. ill do a quick research for packer paths and see if it changes anything

qwexvf commented 1 year ago

it turns out i had the plugin for packer installed still.... i just removed and did :lazy sync and the error of :checkhealth is gone.

Down below is my latest :checkhealth result:

==============================================================================
gitsigns: require("gitsigns.health").check()

- OK git version 2.40.0

==============================================================================
go: require("go.health").check()

Binaries ~
- go installed.
- Tool installed: mockgen
- Tool installed: golangci-lint
- Tool installed: gomvp
- Tool installed: gotestsum
- Tool installed: json-to-struct
- Tool installed: go-enum
- Tool installed: richgo
- Tool installed: impl
- Tool installed: fillswitch
- Tool installed: guru
- Tool installed: dlv
- Tool installed: callgraph
- Tool installed: iferr
- Tool installed: gotests
- Tool installed: gomodifytags
- Tool installed: goimports
- Tool installed: gorename
- Tool installed: gofumpt
- Tool installed: fillstruct
- Tool installed: gopls
- Tool installed: golines
- Tool installed: ginkgo
- Tool installed: govulncheck
- sed installed.
- curl installed.
- OK All binaries installed

Go Plugin Check ~
- OK lspconfig: plugin is installed
- OK nvim-treesitter: plugin is installed
- OK guihua: plugin is installed
- WARNING nvim-dap-virtual-text: not installed/loaded
- OK telescope: plugin is installed
- OK nvim-treesitter-go is installed
- WARNING nvim-dap-ui: not installed/loaded
- WARNING nvim-dap: not installed/loaded
- WARNING Not all plugin installed
- OK GOPATH is set
- OK GOROOT is set
- GOBIN is not set
- Not all enviroment variables set

==============================================================================
lazy: require("lazy.health").check()

lazy.nvim ~
- OK Git installed
- OK no existing packages found by other package managers
- OK packer_compiled.lua not found

==============================================================================
nvim: require("nvim.health").check()

Configuration ~
- OK no issues found

Runtime ~
- OK $VIMRUNTIME: /usr/local/share/nvim/runtime

Performance ~
- OK Build type: Release

Remote Plugins ~
- OK Up to date

terminal ~
- key_backspace (kbs) terminfo entry: `key_backspace=^H`
- key_dc (kdch1) terminfo entry: `key_dc=\E[3~`
- $COLORTERM="truecolor"

==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `node` found v19.7.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: Apple clang version 14.0.0 (clang-1400.0.29.202)
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "arm64",
  release = "22.3.0",
  sysname = "Darwin",
  version = "Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:35 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T8103"
} ~

Parser/Features         H L F I J
  - c                   ✓ ✓ ✓ ✓ ✓
  - go                  ✓ ✓ ✓ ✓ ✓
  - help                ✓ . . . ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - svelte              ✓ . ✓ ✓ ✓
  - typescript          ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ . ✓
  - vue                 ✓ . ✓ ✓ ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

==============================================================================
provider: health#provider#check

Clipboard (optional) ~
- OK Clipboard tool found: pbcopy

Python 3 provider (optional) ~
- WARNING No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
- WARNING Could not load Python 3:
  /opt/homebrew/bin/python3 does not have the "neovim" module.
  python3.10 not found in search path or not executable.
  python3.9 not found in search path or not executable.
  python3.8 not found in search path or not executable.
  python3.7 not found in search path or not executable.
  python not found in search path or not executable.
  - ADVICE:
    - See :help |provider-python| for more information.
    - You may disable this provider (and warning) by adding `let g:loaded_python3_provider = 0` to your init.vim
- Executable: Not found

Python virtualenv ~
- OK no $VIRTUAL_ENV

Ruby provider (optional) ~
- Ruby: ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin22]
- WARNING `neovim-ruby-host` not found.
  - ADVICE:
    - Run `gem install neovim` to ensure the neovim RubyGem is installed.
    - Run `gem environment` to ensure the gem bin directory is in $PATH.
    - If you are using rvm/rbenv/chruby, try "rehashing".
    - See :help |g:ruby_host_prog| for non-standard gem installations.
    - You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim

Node.js provider (optional) ~
- Node.js: v19.7.0
- WARNING Missing "neovim" npm (or yarn, pnpm) package.
  - ADVICE:
    - Run in shell: npm install -g neovim
    - Run in shell (if you use yarn): yarn global add neovim
    - Run in shell (if you use pnpm): pnpm install -g neovim
    - You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim

Perl provider (optional) ~
- WARNING "Neovim::Ext" cpan module is not installed
  - ADVICE:
    - See :help |provider-perl| for more information.
    - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim

==============================================================================
telescope: require("telescope.health").check()

Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies ~
- OK rg: found ripgrep 13.0.0 (rev af6b6c543b)
- OK fd: found fd 8.7.0

===== Installed extensions ===== ~

Telescope Extension: `file_browser` ~
- No healthcheck provided

==============================================================================
vim.lsp: require("vim.lsp.health").check()

- LSP log level : WARN
- Log path: /Users/qwexvf/.local/state/nvim/lsp.log
- Log size: 8212 KB

vim.lsp: Active Clients ~
- efm (id=1, root_dir=/Users/qwexvf/Documents)

==============================================================================
vim.treesitter: require("vim.treesitter.health").check()

- Nvim runtime ABI version: 14
- OK Parser: go         ABI: 14, path: /Users/qwexvf/.local/share/nvim/lazy/nvim-treesitter/parser/go.so
- OK Parser: javascript ABI: 14, path: /Users/qwexvf/.local/share/nvim/lazy/nvim-treesitter/parser/javascript.so
- OK Parser: lua        ABI: 13, path: /Users/qwexvf/.local/share/nvim/lazy/nvim-treesitter/parser/lua.so
- OK Parser: svelte     ABI: 13, path: /Users/qwexvf/.local/share/nvim/lazy/nvim-treesitter/parser/svelte.so
- OK Parser: typescript ABI: 14, path: /Users/qwexvf/.local/share/nvim/lazy/nvim-treesitter/parser/typescript.so
- OK Parser: vue        ABI: 13, path: /Users/qwexvf/.local/share/nvim/lazy/nvim-treesitter/parser/vue.so
- OK Parser: c          ABI: 13, path: /usr/local/lib/nvim/parser/c.so
- OK Parser: help       ABI: 14, path: /usr/local/lib/nvim/parser/help.so
- OK Parser: lua        ABI: 13, path: /usr/local/lib/nvim/parser/lua.so
- OK Parser: query      ABI: 14, path: /usr/local/lib/nvim/parser/query.so
- OK Parser: vim        ABI: 14, path: /usr/local/lib/nvim/parser/vim.so
qwexvf commented 1 year ago

Hmm, after setting $GOBIN to the correct path it still does not load the plugin 🤔

❯ echo $GOBIN
/Users/qwexvf/.local/share/rtx/installs/golang/1.20.2/bin

~
❯ ls /Users/qwexvf/.local/share/rtx/installs/golang/1.20.2/bin
callgraph  dlv  fillstruct  fillswitch  ginkgo  go-enum  gofumpt  goimports  golangci-lint  golines  gomodifytags  gomvp  gopls  gorename  gotests  gotestsum  govulncheck  guru  iferr  impl  json-to-struct  mockgen  richgo
ray-x commented 1 year ago

What is the symptom or errors? E.g. when you run GoBuild what are the error messages?

I suggest you start with a simple config, please check the playground folder of this plugin, I put an init.lua (with lazy.nvim) there: https://github.com/ray-x/go.nvim/blob/master/playground/init_lazy.lua

qwexvf commented 1 year ago

I didnt have any errors running :GoBuild it actually worked and the status on the right bottom corner also shows up.

And i tried your minimal config and the plugin loaded as expected 🤔 ill try to minimize my config and see what happens!

Thanks for the help btw really appreciate 🙇‍♂️

qwexvf commented 1 year ago

I found the problem which is kind of complicated but ill try explain as possible for in case of someone else happens to step into this.

i have configured lspconfig my self so i had to add lsp_cfg to the plugin configuration like below

require('go').setup{
  lsp_cfg = false
}

local cfg = require'go.lsp'.config() -- config() return the go.nvim gopls setup

require('lspconfig').gopls.setup(cfg)

Also i need a confirmation about line require('lspconfig').go.setup(cfg) which is in the document and im not familiar with mason but this is correct? cause for me it shows [lspconfig] Cannot access configuration for go. Ensure this server is listed inserver_configurations.mdor added as a custom server.

so i changed to require('lspconfig').gopls.setup(cfg) and it loaded and seems to be working.

ray-x commented 1 year ago

Ok, you are right, the documentation is not correct/accurate. I pushed an update for it.

qwexvf commented 1 year ago

Ok, you are right, the documentation is not correct/accurate. I pushed an update for it.

Thanks for the confirmation! it seems to be working as expected now with require('lspconfig').gopls.setup(cfg) Really cool plugin btw! Thanks!

SichangHe commented 7 months ago

This just bit me in the ass year later. This plugin is really not expecting the user to set up lspconfig elsewhere.

qwexvf commented 7 months ago

@SichangHe

This just bit me in the ass year later. This plugin is really not expecting the user to set up lspconfig elsewhere.

Could you you elaborate on your issue here?

I have working setup with go.nvim with my own lsp config.

SichangHe commented 7 months ago

Sure. The config in the README did not work, as in the Gopls LSP was not registered (I tried :LspInfo). (The Go… Vim commands were there).

I had to do this: https://github.com/SichangHe/.config/commit/43862b44020d2ca58474ff522ad90cd97007247a

Have to do with lspconfig behavior. I use mason-lspconfig to load it. Might be the reason.

qwexvf commented 7 months ago

@SichangHe If are using mason there's a docs section for it. https://github.com/ray-x/go.nvim?tab=readme-ov-file#integrate-with-mason-lspconfig

qwexvf commented 7 months ago

@ray-x just to confirm

{
  "ray-x/go.nvim",
  dependencies = {  -- optional packages
    "ray-x/guihua.lua",
    "neovim/nvim-lspconfig",
    "nvim-treesitter/nvim-treesitter",
  },
  config = function()
    require("go").setup()
  end,
  event = {"CmdlineEnter"},
  ft = {"go", 'gomod'},
  build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries
}

is this expected to run ? i thought lsp_cfg has to be true at least.

ray-x commented 7 months ago

lsp_cfg is defaulted to false If you need to start gopls using go.nvim's gopls config, you need to either set it to true or pass your gopls config to lsp_cfg.

SichangHe commented 7 months ago

lsp_cfg is defaulted to false

That explains. My bad. Didn't spot it in the README.

It is a bit weird to have it defaulted to false, though.