jose-elias-alvarez / null-ls.nvim

Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
Other
3.64k stars 791 forks source link

PR #1073 leads to some breaking changes with nvim-lspconfig #1106

Closed Alex-Merrill closed 2 years ago

Alex-Merrill commented 2 years ago

FAQ

Issues

Neovim Version

v0.8.0-dev-1081-g907fc8ac3

Operating System

Linux - Fedora 36

Minimal config

-- this template is borrowed from nvim-lspconfig local on_windows = vim.loop.os_uname().version:match "Windows"

local function join_paths(...) local path_sep = on_windows and "\" or "/" local result = table.concat({ ... }, path_sep) return result end

vim.g.loaded_remote_plugins = "" vim.cmd [[set runtimepath=$VIMRUNTIME]]

local temp_dir = vim.loop.os_getenv "TEMP" or "/tmp"

vim.cmd("set packpath=" .. join_paths(temp_dir, "nvim", "site"))

local package_root = join_paths(temp_dir, "nvim", "site", "pack") local install_path = join_paths(package_root, "packer", "start", "packer.nvim") local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua")

local null_ls_config = function() local null_ls = require "null-ls" null_ls.setup { sources = { -- can use any formatter? Happens with go and lua at least null_ls.builtins.formatting.gofumpt, }, debug = true, } end

local function load_plugins() require("packer").startup { { "wbthomason/packer.nvim", { "jose-elias-alvarez/null-ls.nvim", requires = { "nvim-lua/plenary.nvim" }, config = null_ls_config, }, { "neovim/nvim-lspconfig", config = function() require("lspconfig").gopls.setup {} end, }, }, config = { package_root = package_root, compile_path = compile_path, }, } end

if vim.fn.isdirectory(install_path) == 0 then vim.fn.system { "git", "clone", "https://github.com/wbthomason/packer.nvim", install_path } load_plugins() require("packer").sync() else load_plugins() require("packer").sync() end

Steps to reproduce

Must have gopls installed and on path (or some other language server - and update minimal init accordingly) (tested with gopls/gofumpt and lua_language_server/stylua) Run nvim --clean -u minimal_init.lua Open a go file use :LspInfo

Expected behavior

Expect to see LspInfo popup showing attached clients - in this case gopls and null-ls

Actual behavior

getting error message:

Error executing Lua callback: ...packer/start/nvim-lspconfig/lua/lspconfig/ui/lspinf o.lua:18: bad argument #1 to 'pairs' (table expected, got function) stack traceback: [C]: in function 'pairs' ...packer/start/nvim-lspconfig/lua/lspconfig/ui/lspinfo.lua:18: in function 'trim_blankspace' ...packer/start/nvim-lspconfig/lua/lspconfig/ui/lspinfo.lua:31: in function 'remove_newlines' ...packer/start/nvim-lspconfig/lua/lspconfig/ui/lspinfo.lua:107: in function 'make_client_info' ...packer/start/nvim-lspconfig/lua/lspconfig/ui/lspinfo.lua:194: in function <...packer/start/nvim-lspconfig/lua/lspconfig/ui/lspinfo.lua:147> ...te/pack/packer/start/nvim-lspconfig/plugin/lspconfig.lua:64: in function <...te/pack/packer/start/nvim-lspconfig/plugin/lspconfig.lua:63>

This bug is mentioned here and its noted that rolling back to commit cdef04dfad2d1a6d76f596ac63600e7430baaabe fixes the error. I can confirm rolling back to this commit fixed the error for me.

Debug log

[TRACE Wed 14 Sep 2022 04:06:48 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:110: starting null-ls client [TRACE Wed 14 Sep 2022 04:06:48 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:123: received LSP request for method initialize [DEBUG Wed 14 Sep 2022 04:06:49 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:165: unable to notify client for method textDocument/didOpen (client not active): { textDocument = { uri = "file:///home/alex/Desktop/code/sudoku-tui/main.go" } } [TRACE Wed 14 Sep 2022 04:06:49 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method initialized [TRACE Wed 14 Sep 2022 04:06:49 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method textDocument/didOpen [TRACE Wed 14 Sep 2022 04:06:49 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN [DEBUG Wed 14 Sep 2022 04:06:49 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available [TRACE Wed 14 Sep 2022 04:08:09 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:123: received LSP request for method shutdown [TRACE Wed 14 Sep 2022 04:08:09 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method exit [TRACE Wed 14 Sep 2022 04:08:11 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:106: starting null-ls client [TRACE Wed 14 Sep 2022 04:08:11 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method initialize [DEBUG Wed 14 Sep 2022 04:08:11 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:161: unable to notify client for method textDocument/didOpen (client not active): { textDocument = { uri = "file:///home/alex/Desktop/code/sudoku-tui/main.go" } } [TRACE Wed 14 Sep 2022 04:08:11 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method initialized [TRACE Wed 14 Sep 2022 04:08:11 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method textDocument/didOpen [TRACE Wed 14 Sep 2022 04:08:11 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN [DEBUG Wed 14 Sep 2022 04:08:11 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available [TRACE Wed 14 Sep 2022 04:09:00 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method shutdown [TRACE Wed 14 Sep 2022 04:09:00 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method exit [TRACE Wed 14 Sep 2022 04:09:01 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:110: starting null-ls client [TRACE Wed 14 Sep 2022 04:09:01 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:123: received LSP request for method initialize [DEBUG Wed 14 Sep 2022 04:09:02 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:165: unable to notify client for method textDocument/didOpen (client not active): { textDocument = { uri = "file:///home/alex/Desktop/code/sudoku-tui/main.go" } } [TRACE Wed 14 Sep 2022 04:09:02 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method initialized [TRACE Wed 14 Sep 2022 04:09:02 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method textDocument/didOpen [TRACE Wed 14 Sep 2022 04:09:02 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN [DEBUG Wed 14 Sep 2022 04:09:02 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available [TRACE Wed 14 Sep 2022 04:13:05 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:123: received LSP request for method shutdown [TRACE Wed 14 Sep 2022 04:13:05 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method exit [TRACE Wed 14 Sep 2022 04:24:32 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:121: received LSP request for method shutdown [TRACE Wed 14 Sep 2022 04:24:32 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:146: received LSP notification for method exit [TRACE Wed 14 Sep 2022 04:25:10 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:110: starting null-ls client [TRACE Wed 14 Sep 2022 04:25:10 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:123: received LSP request for method initialize [DEBUG Wed 14 Sep 2022 04:25:11 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:165: unable to notify client for method textDocument/didOpen (client not active): { textDocument = { uri = "file:///home/alex/Desktop/code/sudoku-tui/main.go" } } [TRACE Wed 14 Sep 2022 04:25:11 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method initialized [TRACE Wed 14 Sep 2022 04:25:11 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method textDocument/didOpen [TRACE Wed 14 Sep 2022 04:25:11 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN [DEBUG Wed 14 Sep 2022 04:25:11 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available [TRACE Wed 14 Sep 2022 04:25:37 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:123: received LSP request for method shutdown [TRACE Wed 14 Sep 2022 04:25:37 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method exit [TRACE Wed 14 Sep 2022 04:25:41 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:110: starting null-ls client [TRACE Wed 14 Sep 2022 04:25:41 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:123: received LSP request for method initialize [DEBUG Wed 14 Sep 2022 04:25:42 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:165: unable to notify client for method textDocument/didOpen (client not active): { textDocument = { uri = "file:///home/alex/Desktop/code/sudoku-tui/main.go" } } [TRACE Wed 14 Sep 2022 04:25:42 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method initialized [TRACE Wed 14 Sep 2022 04:25:42 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method textDocument/didOpen [TRACE Wed 14 Sep 2022 04:25:42 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN [DEBUG Wed 14 Sep 2022 04:25:42 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available [TRACE Wed 14 Sep 2022 04:39:06 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:123: received LSP request for method shutdown [TRACE Wed 14 Sep 2022 04:39:06 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method exit [TRACE Wed 14 Sep 2022 04:39:08 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:110: starting null-ls client [TRACE Wed 14 Sep 2022 04:39:08 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:123: received LSP request for method initialize [DEBUG Wed 14 Sep 2022 04:39:08 AM EDT] ...te/pack/packer/start/null-ls.nvim/lua/null-ls/client.lua:165: unable to notify client for method textDocument/didOpen (client not active): { textDocument = { uri = "file:///home/alex/Desktop/code/sudoku-tui/main.go" } } [TRACE Wed 14 Sep 2022 04:39:08 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method initialized [TRACE Wed 14 Sep 2022 04:39:08 AM EDT] .../site/pack/packer/start/null-ls.nvim/lua/null-ls/rpc.lua:148: received LSP notification for method textDocument/didOpen [TRACE Wed 14 Sep 2022 04:39:08 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:21: running generators for method NULL_LS_DIAGNOSTICS_ON_OPEN [DEBUG Wed 14 Sep 2022 04:39:08 AM EDT] ...ack/packer/start/null-ls.nvim/lua/null-ls/generators.lua:24: no generators available

Help

Yes, but I don't know how to start. I would need guidance

Implementation help

I would need some guidance as to what this change is and why it was made/what the goal of it is (If this is actually the breaking change according to the above mentioned issue in nvim-lspconfig). Haven't really done any dev work with nvim before so would probably take a bit to get up and running but I'd be happy to help if this is a bug on Null-ls' end. Can't promise I could do it in a timely manner though.

Requirements

zeitchef commented 2 years ago

I came here to report a similar issue, though the error I'm getting is slightly different:

Screen Shot 2022-09-14 at 10 09 57

Not sure exactly if this is related.

rsdenijs commented 2 years ago

Experiencing same issue @zeitchef reported

Alex-Merrill commented 2 years ago

Pretty sure it has the same root cause, the client that’s created for null-ls has a cmd property that used to be a table and was changed to a function. Which is what your error is referring to I believe. Try to rollback null-ls to the commit I included in this issue for a temporary fix. @zeitchef @rsdenijs

jose-elias-alvarez commented 2 years ago

Rebuilding Neovim from HEAD (or updating from whatever source you are using to install Neovim 0.8, which is not yet released) will fix this issue.

Edit: this actually does not solve the nvim-lspconfig issue, which needs to be handled on their end. Setting cmd to a function is valid as of neovim/neovim#19916, so the :LspInfo window needs to handle that case.

Double edit: neovim/nvim-lspconfig#2141

Alex-Merrill commented 2 years ago

Thanks for clarifying. Appreciate your hard work on this plugin!

Jarmos-san commented 2 years ago

@jose-elias-alvarez I'm on the latest stable version of Neovim i.e v0.8.x & I still face this error (although it's not a deal-breaker tbh). Regardless, I've pinned the plugin to the specific commit @Alex-Merrill shared which seems to provide a temporary fix.

But, is there a possible fix in the works because as far as I can see, most of the linked PRs or issue threads discussing this concern is either merged or closed. So, what am I missing out here?

jose-elias-alvarez commented 2 years ago

@Jarmos-san If you're talking about the nvim-lspconfig window error, that was solved in https://github.com/neovim/nvim-lspconfig/issues/2141, so updating your plugins will take care of the issue.

If you're referring to other issues caused by the commit in question, take a look at other issues containing your error message. A lot of users were not properly cleaning up their runtime files and ended up with errors. If you're still having problems, please open another issue.