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

BUG: failed to open document symbols with pylsp [attempt to index local ‘range’ (a nil value)] #1085

Open
3 tasks done
ideless opened this issue Aug 6, 2023 · 5 comments · May be fixed by #1644
Open
3 tasks done
Labels
bug Something isn't working

Comments

@ideless
Copy link

ideless commented Aug 6, 2023

Did you check docs and existing issues?

  • I have read all the docs.
  • I have searched the existing issues.
  • I have searched the existing discussions.

Neovim Version (nvim -v)

0.9.0

Operating System / Version

Ubuntu 20.04.6 LTS

Describe the Bug

Failed to open document_symbols when using pylsp.
There is no problem with other lsp servers (at least lua_ls, tsserver) though. I’m not sure if it is a bug of neo-tree or pylsp.

Screenshots, Traceback

Error message:

Error executing vim.schedule lua callback: .../neo-tree/sources/document_symbols/lib/symbols_utils.lua:43: attempt to inde
x local 'range' (a nil value)
stack traceback:
        .../neo-tree/sources/document_symbols/lib/symbols_utils.lua:43: in function 'parse_range'
        .../neo-tree/sources/document_symbols/lib/symbols_utils.lua:111: in function 'parse_resp'
        .../neo-tree/sources/document_symbols/lib/symbols_utils.lua:149: in function 'on_lsp_resp'
        .../neo-tree/sources/document_symbols/lib/symbols_utils.lua:200: in function 'callback'
        ...vim/squashfs-root/usr/share/nvim/runtime/lua/vim/lsp.lua:2021: in function 'handler'
        ...vim/squashfs-root/usr/share/nvim/runtime/lua/vim/lsp.lua:1394: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

Steps to Reproduce

  1. install pylsp by mason
  2. open a python script
  3. open document symbols and see the error

Expected Behavior

document symbols should be opened

Your Configuration

local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs { "config", "data", "state", "cache" } do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system {
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  }
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "neovim/nvim-lspconfig",
  {
    "williamboman/mason.nvim",
    opts = {},
  },
  {
    "williamboman/mason-lspconfig",
    dependencies = {
      "williamboman/mason.nvim",
      "neovim/nvim-lspconfig",
    },
    opts = {
      ensure_installed = { "pylsp" },
    },
    config = function(_, opts)
      local mason_lsp = require("mason-lspconfig")

      mason_lsp.setup(opts)

      mason_lsp.setup_handlers {
        function(server_name) -- default handler
          require("lspconfig")[server_name].setup {}
        end,
      }
    end,
  },
  {
    "nvim-neo-tree/neo-tree.nvim",
    branch = "v3.x",
    dependencies = {
      "nvim-lua/plenary.nvim",
      "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended
      "MunifTanjim/nui.nvim",
    },
    opts = {
      sources = {
        "filesystem",
        "buffers",
        "git_status",
        "document_symbols",
      },
    },
  },
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})
@ideless ideless added the bug Something isn't working label Aug 6, 2023
@AadityaRavindran
Copy link

I see the same issue with pylsp but not with clangd

@miki725
Copy link

miki725 commented Oct 12, 2023

can confirm its happening for me for pylsp as well but not for gopls for example

@miki725
Copy link

miki725 commented Oct 12, 2023

also interesting that pyright it works ok. just pylsp is causing issues. does that mean its a bug in the LSP itself? or neo-tree is not handling some response correctly?

seeing this in :LspLog:

[ERROR][2023-10-12 16:36:29] .../vim/lsp/rpc.lua:734	"rpc"	"/root/.local/bin/pylsp"	"stderr"	"2023-10-12 16:36:29,563 EDT - WARNING - pylsp_jsonrpc.endpoint - Received cancel notification for unknown message id 8\n"
[ERROR][2023-10-12 16:36:33] .../vim/lsp/rpc.lua:734	"rpc"	"/root/.local/bin/pylsp"	"stderr"	"2023-10-12 16:36:33,376 EDT - WARNING - pylsp_jsonrpc.endpoint - Received cancel notification for unknown message id 10\n"
[ERROR][2023-10-12 16:36:35] .../vim/lsp/rpc.lua:734	"rpc"	"/root/.local/bin/pylsp"	"stderr"	"2023-10-12 16:36:35,679 EDT - WARNING - pylsp_jsonrpc.endpoint - Received cancel notification for unknown message id 11\n"
[ERROR][2023-10-12 16:36:37] .../vim/lsp/rpc.lua:734	"rpc"	"/root/.local/bin/pylsp"	"stderr"	"2023-10-12 16:36:37,233 EDT - WARNING - pylsp_jsonrpc.endpoint - Received cancel notification for unknown message id 14\n"

although not sure what that means

@bak1an
Copy link

bak1an commented Aug 5, 2024

I see the same issue with solargraph (ruby lsp) but not with gopls and not with rust-analyzer.

@juanlopez4691
Copy link

Same happens with Intelephense LSP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants