forked from nvim-java/nvim-java-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlsp.lua
More file actions
32 lines (24 loc) · 670 Bytes
/
lsp.lua
File metadata and controls
32 lines (24 loc) · 670 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local log = require('java-core.utils.log')
local List = require('java-core.utils.list')
local M = {}
---Returns the client by name of the language server
---@param name string name of the language server
---@return LspClient | nil
function M.find_client_by_name(name)
local clients = List:new(vim.lsp.get_active_clients())
return clients:find(function(client)
return client.name == name
end)
end
---Returns the jdtls client object
---@return LspClient
function M.get_jdtls_client()
local client = M.find_client_by_name('jdtls')
if not client then
local msg = 'No active jdtls client found'
log.error(msg)
error(msg)
end
return client
end
return M