nvimdev / lspsaga.nvim

improve neovim lsp experience
MIT License
3.46k stars 288 forks source link

lspsaga/finder.lua:59: attempt to index a nil value and lspsaga/finder.lua:112: attempt to concatenate field 'param' (a nil value) when use lua language server #309

Closed milanglacier closed 2 years ago

milanglacier commented 2 years ago

when use lua language server with lsp_finder, get the following error:

Error executing vim.schedule lua callback: ...site/pack/packer/opt/lspsaga.nvim/lua/lspsaga/finder.lua:59: attempt to index a nil value
stack traceback:
        ...site/pack/packer/opt/lspsaga.nvim/lua/lspsaga/finder.lua:59: in function 'callback'
        ...w/Cellar/neovim/0.7.2/share/nvim/runtime/lua/vim/lsp.lua:1535: in function 'handler'
        ...w/Cellar/neovim/0.7.2/share/nvim/runtime/lua/vim/lsp.lua:1025: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

but the finder float window can show normally (i.e it firstly throws this error, and then displays the finder window, and the functionality of the finder works well)

And if use the lsp_finder for the first time in this nvim session, will also get the following error:

Error executing Lua callback: ...site/pack/packer/opt/lspsaga.nvim/lua/lspsaga/finder.lua:112: attempt to concatenate field 'param' (a nil value)
stack traceback:
        ...site/pack/packer/opt/lspsaga.nvim/lua/lspsaga/finder.lua:112: in function 'create_finder_contents'
        ...site/pack/packer/opt/lspsaga.nvim/lua/lspsaga/finder.lua:99: in function 'lsp_finder_request'
        ...site/pack/packer/opt/lspsaga.nvim/lua/lspsaga/finder.lua:473: in function <...site/pack/packer/opt/lspsaga.nvim/lua/lspsaga/finder.lua:470>
        ...ite/pack/packer/opt/lspsaga.nvim/lua/lspsaga/command.lua:36: in function 'load_command'
        ...vim/site/pack/packer/opt/lspsaga.nvim/plugin/lspsaga.lua:56: in function <...vim/site/pack/packer/opt/lspsaga.nvim/plugin/lspsaga.lua:55>

but this 112 error only occurs once. And for the next time I call lsp_finder in this session, this error will not occur, but 59 error always occurs.

example test file:

(test.lua)

```lua vim.cmd [[packadd! telescope.nvim]] vim.cmd [[packadd! telescope-fzf-native.nvim]] vim.cmd [[packadd! telescope-ui-select.nvim]] vim.cmd [[packadd! project.nvim]] vim.cmd [[packadd! nvim-notify]] local telescope = require 'telescope' telescope.setup { pickers = { find_files = { find_command = { 'rg', '--files', '--iglob', '!.git', '--hidden' }, }, keymaps = { modes = { 'n', 'i', 'c', 'x', 'v', 'o', '', '!' }, }, }, defaults = { mappings = { i = { [''] = 'select_horizontal', [''] = 'preview_scrolling_up', [''] = 'preview_scrolling_down', [''] = 'which_key', }, n = { ['t'] = 'select_tab', ['s'] = 'select_horizontal', ['v'] = 'select_vertical', [''] = 'preview_scrolling_up', [''] = 'preview_scrolling_down', ['K'] = require('telescope.actions').toggle_selection + require('telescope.actions').move_selection_worse, ['J'] = require('telescope.actions').toggle_selection + require('telescope.actions').move_selection_better, }, }, layout_strategy = 'vertical', layout_config = { vertical = { preview_cutoff = 30, }, }, cache_picker = { num_pickers = 2, limit_entries = 100 }, -- wrap_results = true, }, extensions = { ['ui-select'] = { require('telescope.themes').get_dropdown {}, }, }, } require('telescope').load_extension 'fzf' require('telescope').load_extension 'notify' require('telescope').load_extension 'projects' require('telescope').load_extension 'ui-select' local opts = { noremap = true } local opts_desc = function(desc) return { noremap = true, desc = desc, } end local keymap = vim.api.nvim_set_keymap keymap('n', 'ff', 'Telescope find_files', opts) keymap('n', 'fg', 'Telescope live_grep', opts) keymap('n', 'fb', 'Telescope buffers', opts) keymap('n', 'fh', 'Telescope help_tags', opts) keymap('n', 'fk', 'Telescope keymaps', opts) keymap('n', 'fc', 'Telescope commands', opts) keymap('n', 'fC', 'Telescope command_history', opts) keymap('n', 'fs', 'Telescope lsp_document_symbols', opts) keymap('n', 'fr', 'Telescope registers', opts) keymap('n', 'fj', 'Telescope jumplist', opts) keymap('n', 'fo', 'Telescope oldfiles', opts) keymap('n', 'fT', 'Telescope treesitter', opts) keymap('n', 'ft', 'Telescope tags', opts) keymap('n', 'fm', 'Telescope marks', opts) keymap('n', 'F', 'Telescope builtin include_extensions=true', opts_desc 'Telescope extensions') keymap('n', 'fe', 'Telescope builtin include_extensions=true', opts_desc 'Telescope extensions') keymap('n', '', 'Telescope commands', opts_desc 'Telescope extensions') ``` put the cursor at function `opts_desc` and get the error as I described.

example config file:

require('lspconfig').sumneko_lua.setup {}
-- the minimal setup function will still throw the error

    local saga = require 'lspsaga'
    saga.init_lsp_saga {
        max_preview_lines = 100,
    }

nvim -v

NVIM v0.7.2
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by brew@HMBRW-A-001-M1-004.local

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.7.2/share/nvim"

Run :checkhealth for more info
glepnir commented 2 years ago

because the get self.param in an async request. if server return response slowly when we render contents the self.param is nil. use sync function can resolve it . but I found it will make finder slow..so I am thinking..

leoatchina commented 2 years ago

because the get self.param in an async request. if server return response slowly when we render contents the self.param is nil. use sync function can resolve it . but I found it will make finder slow..so I am thinking..

I think you can give a WARN when got nil.

glepnir commented 2 years ago

use sync now, there has a solution when i finished symbolbar feature