GithubHelp home page GithubHelp logo

attemp to compare string with nil about go.nvim HOT 4 CLOSED

ray-x avatar ray-x commented on July 16, 2024
attemp to compare string with nil

from go.nvim.

Comments (4)

WaveYourHands avatar WaveYourHands commented on July 16, 2024 1

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/[email protected] 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/[email protected] 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)

from go.nvim.

ray-x avatar ray-x commented on July 16, 2024

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.

from go.nvim.

WaveYourHands avatar WaveYourHands commented on July 16, 2024

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/[email protected] 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

from go.nvim.

ray-x avatar ray-x commented on July 16, 2024

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!

from go.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.