-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathexec-order-check.lua
More file actions
48 lines (40 loc) · 1.18 KB
/
exec-order-check.lua
File metadata and controls
48 lines (40 loc) · 1.18 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
48
local lspconfig = require('lspconfig')
local M = {}
lspconfig.util.on_setup = lspconfig.util.add_hook_before(
lspconfig.util.on_setup,
function(config)
if config.name == 'jdtls' then
vim.g.nvim_java_jdtls_setup_is_called = true
end
end
)
local message = 'Looks like require("lspconfig").jdtls.setup() is called before require("java").setup().'
.. '\nnvim-java will continue to setup but most features may not work as expected'
.. '\nThis might be due to old installation instructions.'
.. '\nPlease check the latest guide at https://github.com/nvim-java/nvim-java#hammer-how-to-install'
.. '\nIf you know what you are doing, you can disable the check from the config'
.. '\nhttps://github.com/nvim-java/nvim-java#wrench-configuration'
function M.is_valid()
if vim.g.nvim_java_jdtls_setup_is_called then
return {
success = false,
continue = true,
message = message,
}
end
local clients = vim.lsp.get_clients
and vim.lsp.get_clients({ name = 'jdtls' })
or vim.lsp.get_active_clients({ name = 'jdtls' })
if #clients > 0 then
return {
success = false,
continue = true,
message = message,
}
end
return {
success = true,
continue = true,
}
end
return M