Skip to content

Commit a8bb5ad

Browse files
client: use vim.lsp.start (#245)
1 parent aa1620b commit a8bb5ad

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

doc/CONFIG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ local defaults = {
6464
```
6565

6666
null-ls allows configuring a subset of the options used by nvim-lspconfig's
67-
`setup` method (shared with `vim.lsp.start_client`), as described
67+
`setup` method (shared with `vim.lsp.start`), as described
6868
[here](https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D).
6969
If an option you want to use is missing, open an issue or PR.
7070

lua/null-ls/client.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ M.start_client = function(root_dir)
144144
}
145145

146146
log:trace("starting null-ls client")
147-
id = lsp.start_client(config)
147+
id = lsp.start(config)
148148

149149
if not id then
150150
log:error(string.format("failed to start null-ls client with config: %s", vim.inspect(config)))

test/spec/client_spec.lua

+15-15
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ describe("client", function()
2525
server_capabilities = {},
2626
}
2727
setmetatable(mock_client, vim.lsp.client)
28-
lsp.start_client.returns(mock_client_id)
28+
lsp.start.returns(mock_client_id)
2929
sources.get_filetypes.returns(mock_filetypes)
3030
end)
3131

3232
after_each(function()
33-
lsp.start_client:clear()
33+
lsp.start:clear()
3434
lsp.buf_attach_client:clear()
3535

3636
c.reset()
@@ -44,7 +44,7 @@ describe("client", function()
4444
local id = client.start_client("mock-root")
4545

4646
assert.equals(id, mock_client_id)
47-
local opts = lsp.start_client.calls[1].refs[1]
47+
local opts = lsp.start.calls[1].refs[1]
4848
assert.equals(opts.name, "null-ls")
4949
assert.equals(opts.root_dir, "mock-root")
5050
assert.equals(opts.cmd, require("null-ls.rpc").start)
@@ -60,7 +60,7 @@ describe("client", function()
6060
c._set({ on_init = on_init })
6161

6262
client.start_client("mock-file")
63-
lsp.start_client.calls[1].refs[1].on_init(mock_client, mock_initialize_result)
63+
lsp.start.calls[1].refs[1].on_init(mock_client, mock_initialize_result)
6464

6565
assert.stub(on_init).was_called_with(mock_client, mock_initialize_result)
6666
end)
@@ -69,9 +69,9 @@ describe("client", function()
6969
local on_exit
7070
before_each(function()
7171
client.start_client()
72-
lsp.start_client.calls[1].refs[1].on_init(mock_client)
72+
lsp.start.calls[1].refs[1].on_init(mock_client)
7373

74-
on_exit = lsp.start_client.calls[1].refs[1].on_exit
74+
on_exit = lsp.start.calls[1].refs[1].on_exit
7575
end)
7676

7777
it("should clear client and id", function()
@@ -95,7 +95,7 @@ describe("client", function()
9595
local on_init
9696
before_each(function()
9797
client.start_client()
98-
on_init = lsp.start_client.calls[1].refs[1].on_init
98+
on_init = lsp.start.calls[1].refs[1].on_init
9999
end)
100100

101101
it("should set client and override client.supports_method", function()
@@ -163,7 +163,7 @@ describe("client", function()
163163

164164
it("should clear client and id on exit", function()
165165
client.start_client()
166-
local opts = lsp.start_client.calls[1].refs[1]
166+
local opts = lsp.start.calls[1].refs[1]
167167
opts.on_init(mock_client)
168168

169169
opts.on_exit()
@@ -218,7 +218,7 @@ describe("client", function()
218218
c._set({ root_dir = root_dir })
219219

220220
client.try_add(mock_bufnr, function()
221-
local opts = lsp.start_client.calls[1].refs[1]
221+
local opts = lsp.start.calls[1].refs[1]
222222
assert.equals(opts.root_dir, vim.uv.cwd())
223223
end)
224224
end)
@@ -229,7 +229,7 @@ describe("client", function()
229229
c._set({ root_dir = root_dir })
230230

231231
client.try_add(mock_bufnr, function()
232-
local opts = lsp.start_client.calls[1].refs[1]
232+
local opts = lsp.start.calls[1].refs[1]
233233
assert.equals(opts.root_dir, "mock-root")
234234
end)
235235
end)
@@ -254,7 +254,7 @@ describe("client", function()
254254
end)
255255

256256
coroutine.yield()
257-
local opts = lsp.start_client.calls[1].refs[1]
257+
local opts = lsp.start.calls[1].refs[1]
258258
assert.equals(opts.root_dir, "mock-root")
259259
end)
260260

@@ -328,7 +328,7 @@ describe("client", function()
328328

329329
it("should call on_attach with client and bufnr if client", function()
330330
client.start_client()
331-
lsp.start_client.calls[1].refs[1].on_init(mock_client)
331+
lsp.start.calls[1].refs[1].on_init(mock_client)
332332

333333
client.setup_buffer(mock_bufnr)
334334

@@ -344,7 +344,7 @@ describe("client", function()
344344
local on_init
345345
before_each(function()
346346
client.start_client()
347-
on_init = lsp.start_client.calls[1].refs[1].on_init
347+
on_init = lsp.start.calls[1].refs[1].on_init
348348
end)
349349

350350
it("should do nothing if no client", function()
@@ -375,7 +375,7 @@ describe("client", function()
375375
local on_init
376376
before_each(function()
377377
client.start_client()
378-
on_init = lsp.start_client.calls[1].refs[1].on_init
378+
on_init = lsp.start.calls[1].refs[1].on_init
379379
end)
380380

381381
it("should return client handler if defined", function()
@@ -400,7 +400,7 @@ describe("client", function()
400400
describe("update_filetypes", function()
401401
before_each(function()
402402
client.start_client()
403-
lsp.start_client.calls[1].refs[1].on_init(mock_client)
403+
lsp.start.calls[1].refs[1].on_init(mock_client)
404404
end)
405405

406406
it("should update client filetypes", function()

0 commit comments

Comments
 (0)