nvim-neo-tree / neo-tree.nvim

Neovim plugin to manage the file system and other tree like structures.
MIT License
3.63k stars 211 forks source link

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

Open ideless opened 1 year ago

ideless commented 1 year ago

Did you check docs and existing issues?

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",
})
AadityaRavindran commented 11 months ago

I see the same issue with pylsp but not with clangd

miki725 commented 11 months ago

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

miki725 commented 11 months ago

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 commented 1 month ago

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