forked from nvim-java/nvim-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlspconfig-setup-wrap.lua
More file actions
36 lines (27 loc) · 886 Bytes
/
lspconfig-setup-wrap.lua
File metadata and controls
36 lines (27 loc) · 886 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
33
34
35
36
local lspconfig = require('lspconfig')
local log = require('java.utils.log')
local server = require('java-core.ls.servers.jdtls')
local M = {}
---comment
---@param config java.Config
function M.setup(config)
log.info('wrap lspconfig.java.setup function to inject a custom java config')
---@type fun(config: LspSetupConfig)
local org_setup = lspconfig.jdtls.setup
lspconfig.jdtls.setup = function(user_config)
local jdtls_plugins = {}
if config.java_test.enable then
table.insert(jdtls_plugins, 'java-test')
end
if config.java_debug_adapter.enable then
table.insert(jdtls_plugins, 'java-debug-adapter')
end
local default_config = server.get_config({
root_markers = config.root_markers,
jdtls_plugins = jdtls_plugins,
use_mason_jdk = config.jdk.auto_install,
})
org_setup(vim.tbl_extend('force', default_config, user_config))
end
end
return M