Skip to content

Commit 66f7c03

Browse files
author
Jose Alvarez
committed
fix(rpc): check config.cmd before indexing
1 parent 5142728 commit 66f7c03

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lua/null-ls/rpc.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ M.setup = function()
5454
local rpc_start = rpc.start
5555
rpc.start = function(cmd, cmd_args, dispatchers, ...)
5656
local config = require("lspconfig.configs")["null-ls"]
57-
if config and cmd == config.cmd[1] then
57+
if config and config.cmd and cmd == config.cmd[1] then
5858
return M.start(dispatchers)
5959
end
6060
return rpc_start(cmd, cmd_args, dispatchers, ...)

test/spec/rpc_spec.lua

+5-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ describe("rpc", function()
3434
end)
3535

3636
it("should call rpc.start override if config exists and command matches", function()
37-
require("lspconfig")["null-ls"] = { cmd = { "nvim" } }
37+
local configs = require("lspconfig.configs")
38+
configs["null-ls"] = {
39+
default_config = { name = "null-ls", cmd = { "nvim" } },
40+
}
41+
require("lspconfig")["null-ls"].setup({})
3842
rpc.setup()
3943

4044
require("vim.lsp.rpc").start("nvim", "args", "dispatchers", "other_args")

0 commit comments

Comments
 (0)