-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathsettings.lua
More file actions
47 lines (38 loc) · 1.36 KB
/
settings.lua
File metadata and controls
47 lines (38 loc) · 1.36 KB
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
37
38
39
40
41
42
43
44
45
46
47
local lsp_utils = require('java-core.utils.lsp')
local JdtlsClient = require('java-core.ls.clients.jdtls-client')
local conf_utils = require('java.utils.config')
local notify = require('java-core.utils.notify')
local ui = require('java.ui.utils')
local runner = require('async.runner')
local get_error_handler = require('java-core.utils.error_handler')
local M = {}
function M.change_runtime()
local client = lsp_utils.get_jdtls()
---@type RuntimeOption[]
local runtimes = conf_utils.get_property_from_conf(client.config, 'settings.java.configuration.runtimes', {})
if #runtimes < 1 then
notify.error(
'No configured runtimes available'
.. '\nRefer following link for instructions define available runtimes'
.. '\nhttps://github.com/nvim-java/nvim-java?tab=readme-ov-file#clamp-how-to-use-jdk-xx-version'
)
return
end
local jdtls = JdtlsClient(client)
runner(function()
local sel_runtime = ui.select('Select Runtime', runtimes, function(runtime)
return runtime.name .. '::' .. runtime.path
end)
for _, runtime in ipairs(client.config.settings.java.configuration.runtimes) do
if sel_runtime.path == runtime.path then
runtime.default = true
else
runtime.default = nil
end
end
jdtls:workspace_did_change_configuration(client.config.settings)
end)
.catch(get_error_handler('Changing runtime failed'))
.run()
end
return M