nvimdev / nvimdev/lspsaga.nvim

lspsga function "lsp_finder<CR>"

Open
#1,484 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Lua
Stars
3.8k
Forks
308
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

when i use lspsga function "lsp_finder" the ERR"Error executing Lua callback: ...e/pack/packer/start/lspsaga.nvim/lua/lspsaga/command.lua:80: attemp
t to call a nil value
stack traceback:
...e/pack/packer/start/lspsaga.nvim/lua/lspsaga/command.lua:80: in function 'load_command'
...m/site/pack/packer/start/lspsaga.nvim/plugin/lspsaga.lua:8: in function <...m/site/pack/p
acker/start/lspsaga.nvim/plugin/lspsaga.lua:7>
Press ENTER or type command to continue"
WechatIMG309

Steps to reproduce

when i use rn to rename my function i can't use enter to rename
below is my lspconfig.lua

-- import lspconfig plugin safely
local lspconfig_status, lspconfig = pcall(require, "lspconfig")
if not lspconfig_status then
return
end

-- import cmp-nvim-lsp plugin safely
local cmp_nvim_lsp_status, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
if not cmp_nvim_lsp_status then
return
end

-- import typescript plugin safely
local typescript_setup, typescript = pcall(require, "typescript")
if not typescript_setup then
return
end

local keymap = vim.keymap -- for conciseness

-- enable keybinds only for when lsp server available
local on_attach = function(client, bufnr)
-- keybind options
local opts = { noremap = true, silent = true, buffer = bufnr }

-- set keybinds
keymap.set("n", "gf", "Lspsaga lsp_finder", opts) -- show definition, references
keymap.set("n", "gD", "lua vim.lsp.buf.declaration()", opts) -- got to declaration
keymap.set("n", "gd", "Lspsaga peek_definition", opts) -- see definition and make edits in window
keymap.set("n", "gi", "lua vim.lsp.buf.implementation()", opts) -- go to implementation
keymap.set("n", "ca", "Lspsaga code_action", opts) -- see available code actions
keymap.set("n", "rn", "Lspsaga rename", opts) -- smart rename
keymap.set("n", "D", "Lspsaga show_line_diagnostics", opts) -- show diagnostics for line
keymap.set("n", "d", "Lspsaga show_cursor_diagnostics", opts) -- show diagnostics for cursor
keymap.set("n", "[d", "Lspsaga diagnostic_jump_prev", opts) -- jump to previous diagnostic in buffer
keymap.set("n", "]d", "Lspsaga diagnostic_jump_next", opts) -- jump to next diagnostic in buffer
keymap.set("n", "K", "Lspsaga hover_doc", opts) -- show documentation for what is under cursor
keymap.set("n", "o", "LSoutlineToggle", opts) -- see outline on right hand side

-- typescript specific keymaps (e.g. rename file and update imports)
if client.name == "tsserver" then
keymap.set("n", "rf", ":TypescriptRenameFile") -- rename file and update imports
keymap.set("n", "oi", ":TypescriptOrganizeImports") -- organize imports (not in youtube nvim video)
keymap.set("n", "ru", ":TypescriptRemoveUnused") -- remove unused variables (not in youtube nvim video)
end
end

-- used to enable autocompletion (assign to every lsp server config)
local capabilities = cmp_nvim_lsp.default_capabilities()

-- Change the Diagnostic symbols in the sign column (gutter)
-- (not in youtube nvim video)
local signs = { Error = " ", Warn = " ", Hint = "ﴞ ", Info = " " }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end

-- configure html server
lspconfig["html"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

-- configure typescript server with plugin
typescript.setup({
server = {
capabilities = capabilities,
on_attach = on_attach,
},
})

-- configure css server
lspconfig["cssls"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

-- configure tailwindcss server
lspconfig["tailwindcss"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

-- configure emmet language server
lspconfig["emmet_ls"].setup({
capabilities = capabilities,
on_attach = on_attach,
filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "svelte" },
})

-- configure lua server (with special settings)
lspconfig["lua_ls"].setup({
capabilities = capabilities,
on_attach = on_attach,
settings = { -- custom settings for lua
Lua = {
-- make the language server recognize "vim" global
diagnostics = {
globals = { "vim" },
},
workspace = {
-- make language server aware of runtime files
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
},
},
})

-- configure Python server
lspconfig["pyright"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

-- configure Golang server
lspconfig["gopls"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

-- configure C/C++ server
lspconfig["clangd"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

-- configure Vue server
lspconfig["vuels"].setup({
capabilities = capabilities,
on_attach = on_attach,
})

my lspsaga.lua

--
print("Loading Lspsaga configuration...")

local saga_status, saga = pcall(require, "lspsaga")
if not saga_status then
print("Failed to load Lspsaga")
return
end

saga.setup({
-- keybinds for navigation in lspsaga window
scroll_preview = { scroll_down = "", scroll_up = "" },
-- use enter to open file with definition preview
definition = {
edit = "",
},
ui = {
colors = {
normal_bg = "#022746",
},
},
})

print("Lspsaga configuration loaded successfully")

Expected behavior

fix it

Neovim version (nvim -v)

0.10.1

lspsaga commit

commit

Terminal name/version

iterm2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the error with the Lspsaga lsp_finder<CR> mapping and inspect lua/lspsaga/command.lua at line 80, along with the loading path in plugin/lspsaga.lua. Clarify whether the target is the lsp_finder callback error or the reported rename behavior, then verify that the selected operation completes without the nil-value error.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua, neovim
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.