-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava.lua
98 lines (85 loc) · 3.56 KB
/
java.lua
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
-- See `:help vim.lsp.start_client` for an overview of the supported `config` options.
local path_to_lsp = '/Users/fatty_ray/.local/share/lsp/jdtls/'
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
local workspace_dir = '/Users/fatty_ray/java_projects/workspace/' .. project_name
local bundles = {
vim.fn.glob("/Users/fatty_ray/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-*.jar",
1)
}
print(bundles)
print(vim.split(vim.fn.glob("/Users/fatty_ray/vscode-java-test/server/*.jar", 1), "\n"))
vim.list_extend(bundles, vim.split(vim.fn.glob("/Users/fatty_ray/vscode-java-test/server/*.jar", 1), "\n"))
local config = {
-- The command that starts the language server
-- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
cmd = {
-- 💀
'java', -- or '/path/to/java17_or_newer/bin/java'
-- depends on if `java` is in your $PATH env variable and if it points to the right version.
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
'-Dosgi.bundles.defaultStartLevel=4',
'-Declipse.product=org.eclipse.jdt.ls.core.product',
'-Dlog.protocol=true',
'-Dlog.level=ALL',
'-Xmx1g',
'--add-modules=ALL-SYSTEM',
'--add-opens', 'java.base/java.util=ALL-UNNAMED',
'--add-opens', 'java.base/java.lang=ALL-UNNAMED',
-- 💀
'-jar', path_to_lsp .. '/plugins/org.eclipse.equinox.launcher_1.6.500.v20230622-2056.jar',
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
-- Must point to the Change this to
-- eclipse.jdt.ls installation the actual version
-- 💀
'-configuration', path_to_lsp .. '/config_mac',
-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^
-- Must point to the Change to one of `linux`, `win` or `mac`
-- eclipse.jdt.ls installation Depending on your system.
-- 💀
-- See `data directory configuration` section in the README
'-data', workspace_dir
},
-- 💀
-- This is the default if not provided, you can remove it. Or adjust as needed.
-- One dedicated LSP server & client will be started per unique root_dir
root_dir = require('jdtls.setup').find_root({ '.git', 'pom.xml', 'mvnw', 'gradlew' }),
-- Here you can configure eclipse.jdt.ls specific settings
-- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
-- for a list of options
settings = {
java = {
maven = {
downloadSources = true,
},
implementationsCodeLens = {
enabled = true,
},
referencesCodeLens = {
enabled = true,
},
references = {
includeDecompiledSources = true,
},
format = {
enabled = true,
settings = {
url = vim.fn.stdpath "config" .. "/resources/intellij-java-google-style.xml",
profile = "GoogleStyle",
},
},
}
},
-- Language server `initializationOptions`
-- You need to extend the `bundles` with paths to jar files
-- if you want to use additional eclipse.jdt.ls plugins.
--
-- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation
--
-- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this
init_options = {
bundles = bundles
},
}
-- This starts a new client & server,
-- or attaches to an existing client & server depending on the `root_dir
require('jdtls').start_or_attach(config)