9 9 local jdtls_ss_id
= nil 11 11 local create_config = function(syntax_server_mode, path)
12 - local data_path
= vim.fn.stdpath
'data' 13 - if type(data_path)
== 'table' then 14 - data_path
= data_path[
1]
16 - local home
= vim.fs.abspath
'~' 17 - local tools_path
= vim.fs.joinpath(home,
'Tools')
18 - local jdtls_jre_path
= vim.fs.find(
function(name)
return name:match
'graalvm%-community%-openjdk%-24.*' end,
19 - {
path = tools_path,
type =
'directory' })[
1]
20 - local jdtls_install_path
= vim.fs.find(
function(name)
return name:match
'jdt%-language%-server%-1%.47.*' end,
21 - {
path = tools_path,
type =
'directory' })[
1]
22 - local plugins_path
= vim.fs.joinpath(jdtls_install_path,
'plugins')
23 - local launcher_path
= vim.fs.find(
function(name)
return name:match
'org%.eclipse%.equinox%.launcher_.*' end,
24 - {
path = plugins_path,
type =
'file' })[
1]
12 + local data_path
= vim.fn.stdpath
'data' 13 + if type(data_path)
== 'table' then 14 + data_path
= data_path[
1]
16 + local home
= vim.fs.abspath
'~' 17 + local tools_path
= vim.fs.joinpath(home,
'Tools')
18 + local jdtls_jre_path
= vim.fs.find(
function(name)
return name:match
'graalvm%-community%-openjdk%-25.*' end,
19 + {
path = tools_path,
type =
'directory' })[
1]
20 + local jdtls_install_path
= vim.fs.find(
function(name)
return name:match
'jdt%-language%-server%-1%.49.*' end,
21 + {
path = tools_path,
type =
'directory' })[
1]
22 + local plugins_path
= vim.fs.joinpath(jdtls_install_path,
'plugins')
23 + local launcher_path
= vim.fs.find(
function(name)
return name:match
'org%.eclipse%.equinox%.launcher_.*' end,
24 + {
path = plugins_path,
type =
'file' })[
1]
26 - local project_local_settings
= localrc(
'.jdtls.lua',
'table')
or {}
27 - project_local_settings.jdtls
= project_local_settings.jdtls
or {}
26 + local project_local_settings
= localrc(
'.jdtls.lua',
'table')
or {}
27 + project_local_settings.jdtls
= project_local_settings.jdtls
or {}
29 - local find_runtimes = function()
29 + local find_runtimes = function()
32 - table.
insert(runtimes, {
34 - path = jdtls_jre_path,
35 - sources = vim.fs.joinpath(jdtls_jre_path,
'lib',
'src.zip'),
32 + table.
insert(runtimes, {
34 + path = jdtls_jre_path,
35 + sources = vim.fs.joinpath(jdtls_jre_path,
'lib',
'src.zip'),
39 - if (project_local_settings.jdtls.runtimes)
then 40 - return table.deep_extend(
'force', runtimes, project_local_settings.jdlts.runtimes)
45 - local root_dir
= project.find_java_project_root(path)
46 - local jdlts_config_dir
47 - if syntax_server_mode
then 48 - jdlts_config_dir
= vim.fn.has
'win32' and 'config_ss_win' or 'config_ss_linux' 50 - jdlts_config_dir
= vim.fn.has
'win32' and 'config_win' or 'config_linux' 52 - local config_dir
= vim.fs.joinpath(jdtls_install_path, jdlts_config_dir)
53 - local workspace_dir
= vim.fs.joinpath(data_path,
'jdtls-workspace', vim.fs.basename(root_dir))
54 - local compiler_options_path
= vim.fs.joinpath(home,
'.config',
'jdlts',
'compiler_options.properties')
39 + if (project_local_settings.jdtls.runtimes)
then 40 + return table.deep_extend(
'force', runtimes, project_local_settings.jdlts.runtimes)
45 + local root_dir
= project.find_java_project_root(path)
46 + local jdlts_config_dir
47 + if syntax_server_mode
then 48 + jdlts_config_dir
= vim.fn.has
'win32' and 'config_ss_win' or 'config_ss_linux' 50 + jdlts_config_dir
= vim.fn.has
'win32' and 'config_win' or 'config_linux' 52 + local config_dir
= vim.fs.joinpath(jdtls_install_path, jdlts_config_dir)
53 + local workspace_dir
= vim.fs.joinpath(data_path,
'jdtls-workspace', vim.fs.basename(root_dir))
54 + local compiler_options_path
= vim.fs.joinpath(home,
'.config',
'jdlts',
'compiler_options.properties')
57 - vim.fs.joinpath(jdtls_jre_path,
'bin',
'java'),
58 - '-Declipse.application=org.eclipse.jdt.ls.core.id1',
59 - '-Dosgi.bundles.defaultStartLevel=4',
60 - '-Declipse.product=org.eclipse.jdt.ls.core.product',
61 - '-Dlog.level=ERROR',
63 - '--add-modules=ALL-SYSTEM',
64 - '--add-opens',
'java.base/java.util=ALL-UNNAMED',
65 - '--add-opens',
'java.base/java.lang=ALL-UNNAMED',
66 - '--add-modules',
'jdk.incubator.vector',
67 - '--enable-native-access=ALL-UNNAMED',
68 - '-jar', launcher_path,
69 - '-configuration', config_dir,
70 - '-data', workspace_dir,
57 + vim.fs.joinpath(jdtls_jre_path,
'bin',
'java'),
58 + '-Declipse.application=org.eclipse.jdt.ls.core.id1',
59 + '-Dosgi.bundles.defaultStartLevel=4',
60 + '-Declipse.product=org.eclipse.jdt.ls.core.product',
61 + '-Dlog.level=ERROR',
63 + '--add-modules=ALL-SYSTEM',
64 + '--add-opens',
'java.base/java.util=ALL-UNNAMED',
65 + '--add-opens',
'java.base/java.lang=ALL-UNNAMED',
66 + '--add-modules',
'jdk.incubator.vector',
67 + '--enable-native-access=ALL-UNNAMED',
68 + '-jar', launcher_path,
69 + '-configuration', config_dir,
70 + '-data', workspace_dir,
73 - if syntax_server_mode
then 74 - table.
insert(cmd,
2,
'-Dsyntaxserver=true')
73 + if syntax_server_mode
then 74 + table.
insert(cmd,
2,
'-Dsyntaxserver=true')
77 - local runtimes
= find_runtimes()
79 - name = syntax_server_mode
and 'jdtls_ss' or 'jdtls',
81 - root_dir = root_dir,
84 - autobuild = {
enabled =
true },
88 - 'qualifyStaticMembers',
91 - 'stringConcatToTextBlock',
94 - 'instanceofPatternMatch',
99 - generateComments =
false,
100 - hashCodeEquals = {
useJava7Objects =
true },
102 - template =
'${object.className}{${member.name()}=${member.value()}, ${otherMembers}}',
106 - codeAction = {
sortMembers = {
avoidVolatileChanges =
true } },
109 - favortiteStaticMembers = {
110 - 'org.junit.Assert.*',
111 - 'org.junit.Assume.*',
112 - 'org.junit.jupiter.api.Assertions.*',
113 - 'org.junit.jupiter.api.Assumptions.*',
114 - 'org.junit.jupiter.api.DynamicContainer.*',
115 - 'org.junit.jupiter.api.DynamicTest.*',
116 - 'org.assertj.core.api.Assertions.*',
117 - 'org.assertj.core.api.Assumptions.*',
118 - 'java.util.Objects.requireNonNull',
119 - 'java.util.Objects.requireNonNullElse',
120 - 'java.time.temporal.ChronoUnit.*',
121 - 'java.lang.System.Logger',
122 - 'java.lang.System.Logger.Level.*',
133 - 'javax.activation.*',
135 - 'java.security.acl.*',
136 - 'javax.security.auth.callback.*',
138 - 'javax.xml.soap.*',
143 - 'java.util.Vector',
144 - 'java.util.Hashtable',
146 - 'java.util.Dictionary',
149 - 'java.util.Calendar',
150 - 'java.util.Observable',
151 - 'java.util.Observer',
153 - 'javax.annotation.*',
156 - 'javax.management.*',
158 - guessMethodArguments =
false,
167 - matchCase =
'FIRSTLETTER',
170 - postfix = {
enabled =
true },
173 - runtimes = runtimes,
174 - updateBuildConfiguration =
'interactive',
176 - contentProvider = {
preferred =
nil },
177 - eclipse = {
downloadSources =
true },
178 - errors = {
incompleteClassPath = {
severity =
'error' } },
179 - executeCommand = {
enabled =
true },
180 - foldingRange = {
enabled =
false },
181 - format = {
enabled =
true },
182 - home = jdtls_jre_path,
183 - implementationsCodeLens = {
enabled =
true },
185 - maven = {
enabled =
true },
188 - annotationProcessing =
true,
189 - wrapper = {
enabled =
true },
194 - '**/node_modules/**',
196 - '**/archetype-resources/**',
197 - '**/META-INF/maven/**',
200 - inlayHints = {
parameterNames = {
enabled =
'all' } },
203 - androidSupport =
false,
204 - lombokSupport =
false,
205 - protofBufSupport =
true,
208 - maven = {
notCoveredPluginExecutionSeverity =
'error' },
209 - maxConcurrentBuilds =
16,
211 - encoding =
'SETDEFAULT',
212 - outputPath = project_local_settings.jdtls.outputPath,
213 - referencedLibraries = project_local_settings.jdtls.referencedLibraries,
214 - resourceFilters = project_local_settings.jdtls.resourceFilters,
215 - sourcePaths = project_local_settings.jdtls.sourcePaths,
217 - referencesCodeLens = {
enabled =
true },
219 - includeAccessors =
true,
220 - includeDecompiledSources =
true,
222 - rename = {
enabled =
true },
223 - saveActions = {
origanizeImports =
true },
224 - selectionRange = {
enabled =
true },
226 - url = compiler_options_path,
228 - signatureHelp = {
enabled =
true },
230 - organizeImports = {
231 - starThreshold =
9999,
232 - staticStarThreshold =
9999,
235 - symbols = {
includeSourceMethodDeclarations =
true },
236 - trace = {
server = dbg.get()
and 'verbose' or 'off' },
237 - edit = {
validateAllOpenBuffersOnChanges =
false },
241 - [
'language/status'] =
function(_, status)
242 - if status.message
== 'ServiceReady' and jdtls_ss_id
~= nil then 243 - vim.notify(
'Stopping jdtls_ss: ' .. jdtls_ss_id)
244 - vim.lsp.stop_client(jdtls_ss_id,
true)
77 + local runtimes
= find_runtimes()
79 + name = syntax_server_mode
and 'jdtls_ss' or 'jdtls',
81 + root_dir = root_dir,
84 + autobuild = {
enabled =
true },
88 + 'qualifyStaticMembers',
91 + 'stringConcatToTextBlock',
94 + 'instanceofPatternMatch',
99 + generateComments =
false,
100 + hashCodeEquals = {
useJava7Objects =
true },
102 + template =
'${object.className}{${member.name()}=${member.value()}, ${otherMembers}}',
106 + codeAction = {
sortMembers = {
avoidVolatileChanges =
true } },
109 + favortiteStaticMembers = {
110 + 'org.junit.Assert.*',
111 + 'org.junit.Assume.*',
112 + 'org.junit.jupiter.api.Assertions.*',
113 + 'org.junit.jupiter.api.Assumptions.*',
114 + 'org.junit.jupiter.api.DynamicContainer.*',
115 + 'org.junit.jupiter.api.DynamicTest.*',
116 + 'org.assertj.core.api.Assertions.*',
117 + 'org.assertj.core.api.Assumptions.*',
118 + 'java.util.Objects.requireNonNull',
119 + 'java.util.Objects.requireNonNullElse',
120 + 'java.time.temporal.ChronoUnit.*',
121 + 'java.lang.System.Logger',
122 + 'java.lang.System.Logger.Level.*',
133 + 'javax.activation.*',
135 + 'java.security.acl.*',
136 + 'javax.security.auth.callback.*',
138 + 'javax.xml.soap.*',
143 + 'java.util.Vector',
144 + 'java.util.Hashtable',
146 + 'java.util.Dictionary',
149 + 'java.util.Calendar',
150 + 'java.util.Observable',
151 + 'java.util.Observer',
153 + 'javax.annotation.*',
156 + 'javax.management.*',
158 + guessMethodArguments =
false,
167 + matchCase =
'FIRSTLETTER',
170 + postfix = {
enabled =
true },
173 + runtimes = runtimes,
174 + updateBuildConfiguration =
'interactive',
176 + contentProvider = {
preferred =
nil },
177 + eclipse = {
downloadSources =
true },
178 + errors = {
incompleteClassPath = {
severity =
'error' } },
179 + executeCommand = {
enabled =
true },
180 + foldingRange = {
enabled =
false },
181 + format = {
enabled =
true },
182 + home = jdtls_jre_path,
183 + implementationsCodeLens = {
enabled =
true },
185 + maven = {
enabled =
true },
188 + annotationProcessing =
true,
189 + wrapper = {
enabled =
true },
194 + '**/node_modules/**',
196 + '**/archetype-resources/**',
197 + '**/META-INF/maven/**',
200 + inlayHints = {
parameterNames = {
enabled =
'all' } },
203 + androidSupport =
false,
204 + lombokSupport =
false,
205 + protofBufSupport =
true,
208 + maven = {
notCoveredPluginExecutionSeverity =
'error' },
209 + maxConcurrentBuilds =
16,
211 + encoding =
'SETDEFAULT',
212 + outputPath = project_local_settings.jdtls.outputPath,
213 + referencedLibraries = project_local_settings.jdtls.referencedLibraries,
214 + resourceFilters = project_local_settings.jdtls.resourceFilters,
215 + sourcePaths = project_local_settings.jdtls.sourcePaths,
217 + referencesCodeLens = {
enabled =
true },
219 + includeAccessors =
true,
220 + includeDecompiledSources =
true,
222 + rename = {
enabled =
true },
223 + saveActions = {
origanizeImports =
true },
224 + selectionRange = {
enabled =
true },
226 + url = compiler_options_path,
228 + signatureHelp = {
enabled =
true },
230 + organizeImports = {
231 + starThreshold =
9999,
232 + staticStarThreshold =
9999,
235 + symbols = {
includeSourceMethodDeclarations =
true },
236 + trace = {
server = dbg.get()
and 'verbose' or 'off' },
237 + edit = {
validateAllOpenBuffersOnChanges =
false },
241 + [
'language/status'] =
function(_, status)
242 + if status.message
== 'ServiceReady' and jdtls_ss_id
~= nil then 243 + vim.notify(
'Stopping jdtls_ss: ' .. jdtls_ss_id)
244 + vim.lsp.stop_client(jdtls_ss_id,
false)
253 252 auto
'start_jdtls' {
255 - events =
'FileType',
256 - description =
'Starts jdlts (with syntax mode initially)',
257 - command =
function()
258 - local path
= vim.api.nvim_buf_get_name(
0)
260 - jdtls_ss_id
= vim.lsp.start(create_config(
true, path))
254 + events =
'FileType',
255 + description =
'Starts jdlts (with syntax mode initially)',
256 + command =
function()
257 + local path
= vim.api.nvim_buf_get_name(
0)
258 + jdtls_ss_id
= vim.lsp.start(create_config(
true, path))
261 + puk
'jdtls'.start_or_attach(create_config(
false, path))