Skip to content

Commit b07ce47

Browse files
author
Jose Alvarez
authored
Merge pull request #382 from kylo252/fix-lspconfig-compat
fix(lspconfig): update the setup workflow
2 parents 0387477 + 533a876 commit b07ce47

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

lua/null-ls/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ M.config = function(user_config)
2828
end
2929

3030
c.setup(user_config or {})
31-
require("null-ls.rpc").setup()
3231
require("null-ls.lspconfig").setup()
32+
require("null-ls.rpc").setup()
3333
require("null-ls.handlers").setup()
3434

3535
vim.cmd("command! NullLsInfo lua require('null-ls').null_ls_info()")

lua/null-ls/lspconfig.lua

+5-4
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ function M.setup()
4848
autostart = false,
4949
}
5050

51-
require("lspconfig/configs")["null-ls"] = {
51+
local configs = require("lspconfig.configs")
52+
configs["null-ls"] = {
5253
default_config = default_config,
5354
}
5455
end
5556

5657
-- after registering a new source, try attaching to existing buffers and refresh diagnostics
5758
function M.on_register_source(source)
58-
if not require("lspconfig")["null-ls"] then
59+
if not require("lspconfig.configs")["null-ls"] then
5960
return
6061
end
6162

@@ -78,7 +79,7 @@ end
7879

7980
-- refresh filetypes after modifying registered sources
8081
function M.on_register_sources()
81-
local config = require("lspconfig")["null-ls"]
82+
local config = require("lspconfig.configs")["null-ls"]
8283
if not config then
8384
return
8485
end
@@ -87,7 +88,7 @@ function M.on_register_sources()
8788
end
8889

8990
function M.try_add(bufnr)
90-
local config = require("lspconfig")["null-ls"]
91+
local config = require("lspconfig.configs")["null-ls"]
9192
if not config and config.manager then
9293
return
9394
end

lua/null-ls/rpc.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ M.setup = function()
5353

5454
local rpc_start = rpc.start
5555
rpc.start = function(cmd, cmd_args, dispatchers, ...)
56-
local config = require("lspconfig")["null-ls"]
56+
local config = require("lspconfig.configs")["null-ls"]
5757
if config and cmd == config.cmd[1] then
5858
return M.start(dispatchers)
5959
end

test/spec/lspconfig_spec.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("lspconfig", function()
2121

2222
describe("setup", function()
2323
it("should set up default config", function()
24-
local null_ls_config = require("lspconfig/configs")["null-ls"]
24+
local null_ls_config = require("lspconfig.configs")["null-ls"]
2525
assert.truthy(null_ls_config)
2626

2727
local default_config = null_ls_config.document_config.default_config
@@ -37,7 +37,7 @@ describe("lspconfig", function()
3737
it("should return root dir", function()
3838
local cwd = vim.fn.getcwd()
3939

40-
local root_dir = require("lspconfig/configs")["null-ls"].document_config.default_config.root_dir
40+
local root_dir = require("lspconfig.configs")["null-ls"].document_config.default_config.root_dir
4141

4242
assert.equals(root_dir(cwd), cwd)
4343
end)

0 commit comments

Comments
 (0)