Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attemp to compare string with nil #81

Closed
WaveYourHands opened this issue Jan 31, 2022 · 4 comments
Closed

attemp to compare string with nil #81

WaveYourHands opened this issue Jan 31, 2022 · 4 comments

Comments

@WaveYourHands
Copy link

nil

-- go.nvim setup copy from https://github.com/ray-x/go.nvim#sample-vimrc

require('go').setup({
  goimport = 'gopls', -- if set to 'gopls' will use golsp format
  gofmt = 'gopls', -- if set to gopls will use golsp format
  max_line_len = 120,
  tag_transform = false,
  test_dir = '',
  comment_placeholder = '',
  lsp_cfg = false, -- false: use your own lspconfig
  lsp_gofumpt = true, -- true: set default gofmt in gopls format to gofumpt
  lsp_on_attach = true, -- use on_attach from go.nvim
  dap_debug = true,
})
-- lsp-installer setup

...

    elseif server.name == "gopls" then
      -- require'go.lsp' : attemp to compare string with nil ?????
      local go_lsp_opts = require'go.lsp'.config() -- config() return the go.nvim gopls setup
      go_lsp_opts = vim.tbl_deep_extend("force", go_lsp_opts, opts)
      server:setup(go_lsp_opts)

...
gopls version
golang.org/x/tools/gopls master
    golang.org/x/tools/gopls@v0.7.5 h1:8Az52YwcFXTWPvrRomns1C0N+zlgTyyPKWvRazO9GG8=
@ray-x
Copy link
Owner

ray-x commented Jan 31, 2022

If you are using lsp-installer you need to export the PATH
check this: https://github.com/ray-x/go.nvim#integrate-with-nvim-lsp-installer
And also make sure you are using the latest version.

@WaveYourHands
Copy link
Author

another error:

"E730: using List as a String"

If you are using lsp-installer you need to export the PATH

echo $PATH
/Users/xxx/.local/share/nvim/lsp_servers/go:
/Users/xxx/.cargo/bin:
/usr/local/Caskroom/miniconda/base/envs/py39/bin:
/usr/local/Caskroom/miniconda/base/condabin:
/Users/xxx/.nvm/versions/node/v16.13.2/bin:
/Users/xxx/.jenv/shims:
/Users/xxx/.jenv/bin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/Users/xxx/go/bin 
gopls version
golang.org/x/tools/gopls v0.7.5
    golang.org/x/tools/gopls@v0.7.5 h1:8Az52YwcFXTWPvrRomns1C0N+zlgTyyPKWvRazO9GG8=
-- copy from https://github.com/ray-x/go.nvim#integrate-with-nvim-lsp-installer
local path = require 'nvim-lsp-installer.path'
local install_root_dir = path.concat { vim.fn.stdpath 'data', 'lsp_servers' }

require('go').setup {
  gopls_cmd        = { install_root_dir .. '/go/gopls' },
  filstruct              = 'gopls',
  dap_debug        = true,
  dap_debug_gui = true,
}
-- lsp-installer setup
...

    elseif server.name == "gopls" then
      -- require'go.lsp' 
      local go_lsp_opts = require'go.lsp'.config() -- config() return the go.nvim gopls setup
      go_lsp_opts = vim.tbl_deep_extend("force", go_lsp_opts, opts)
      server:setup(go_lsp_opts)

...
git log --oneline
f599a5e (HEAD -> master, origin/master, origin/HEAD) gopls cmd fallback
ce29866 lsp installer path setup for version check
180e44a (grafted) handle nil

ray-x added a commit that referenced this issue Jan 31, 2022
@ray-x
Copy link
Owner

ray-x commented Jan 31, 2022

I pushed another version to fix this issue.
I am not a lsp-installer user. If you still seeing issues, please add a minimum vimrc for me to reproduce. Thanks!

@WaveYourHands
Copy link
Author

WaveYourHands commented Feb 1, 2022

It looks ok now
Thanks!!!!!!

I am not a lsp-installer user. If you still seeing issues, please add a minimum vimrc for me to reproduce.

structure

# ~/.config/nvim/
.
├── ...
├── init.lua
├── lua
│   ├── ...
│   ├── go-setup.lua
│   ├── lsp-setup.lua
│   └── ...
└── ...

A

version

Available prior to this version

problem

  • attemp to compare string with nil

gopls

(py39) xxx@xxx: ~  $ echo $PATH
/Users/xxx/.cargo/bin:
/usr/local/Caskroom/miniconda/base/envs/py39/bin:
/usr/local/Caskroom/miniconda/base/condabin:
/Users/xxx/.nvm/versions/node/v16.13.2/bin:
/Users/xxx/.jenv/shims:
/Users/xxx/.jenv/bin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/Users/xxx/go/bin   (gopls)
(py39) xxx@xxx: ~  $ gopls version
golang.org/x/tools/gopls master    👈 (that time : master??? not v0.7.5)
    golang.org/x/tools/gopls@v0.7.5 h1:8Az52YwcFXTWPvrRomns1C0N+zlgTyyPKWvRazO9GG8=
local v = vim.fn.system("gopls version"):match("%s+v([%d%.]+)%s+")
print(v) -- nil

structure

init.lua

require 'go-setup'
require 'lsp-setup'

go-setup.lua

require('go').setup({
  goimport            = 'gopls', -- if set to 'gopls' will use golsp format
  gofmt               = 'gopls', -- if set to gopls will use golsp format
  max_line_len        = 120,
  tag_transform       = false,
  test_dir            = '',
  comment_placeholder = '',
  lsp_cfg             = false, -- false: use your own lspconfig
  lsp_gofumpt         = true, -- true: set default gofmt in gopls format to gofumpt
  lsp_on_attach       = true, -- use on_attach from go.nvim
  dap_debug           = true,
})

lsp-setup.lua

local lsp_installer = require 'nvim-lsp-installer'

lsp_installer.on_server_ready(function(server)
  local opts = {
    on_attach    = on_attach,
    capabilities = capabilities,
  }

  if language_servers[server.name] then
    if server.name == ... then
        -- config
        -- ...
      server:attach_buffers()
    elseif server.name == "gopls" then
      local go_lsp_opts = require'go.lsp'.config() -- config() return the go.nvim gopls setup
      go_lsp_opts = vim.tbl_deep_extend("force", go_lsp_opts, opts)
      server:setup(go_lsp_opts)
    else
        -- config
        -- ...
      server:setup(opts)
    end
  end

end)

B

version

problem

  • "E730: using List as a String"

gopls

(py39) xxx@xxx: ~  $ echo $PATH
/Users/xxx/.local/share/nvim/lsp_servers/go:   (gopls)
/Users/xxx/.cargo/bin:
/usr/local/Caskroom/miniconda/base/envs/py39/bin:
/usr/local/Caskroom/miniconda/base/condabin:
/Users/xxx/.nvm/versions/node/v16.13.2/bin:
/Users/xxx/.jenv/shims:
/Users/xxx/.jenv/bin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/Users/xxx/go/bin   (gopls)
(py39) xxx@xxx: ~  $ gopls version
golang.org/x/tools/gopls v0.7.5
    golang.org/x/tools/gopls@v0.7.5 h1:8Az52YwcFXTWPvrRomns1C0N+zlgTyyPKWvRazO9GG8=

structure

init.lua

require 'go-setup'
require 'lsp-setup'

go-setup.lua

local path = require 'nvim-lsp-installer.path'
local install_root_dir = path.concat { vim.fn.stdpath 'data', 'lsp_servers' }

require('go').setup {
  gopls_cmd        = { install_root_dir .. '/go/gopls' },
  filstruct        = 'gopls',
  dap_debug        = true,
  dap_debug_gui    = true,
}

lsp-setup.lua

local lsp_installer = require 'nvim-lsp-installer'

lsp_installer.on_server_ready(function(server)
  local opts = {
    on_attach    = on_attach,
    capabilities = capabilities,
  }

  if language_servers[server.name] then
    if server.name == ... then
        -- config
        -- ...
      server:attach_buffers()
    elseif server.name == "gopls" then
      local go_lsp_opts = require'go.lsp'.config() -- config() return the go.nvim gopls setup
      go_lsp_opts = vim.tbl_deep_extend("force", go_lsp_opts, opts)
      server:setup(go_lsp_opts)
    else
        -- config
        -- ...
      server:setup(opts)
    end
  end

end)

@ray-x ray-x closed this as completed Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants