repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

neovim: java lsp resurrection of the jdtls full mode

e7458103b35963cdce6f187a975adf4a8ff2b9fb

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (2)

neovim/lua/bugabinga/java.lua

Modified
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]
15 - end
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]
15 + end
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()
30 - local runtimes = {}
29 + local find_runtimes = function()
30 + local runtimes = {}
32 - table.insert(runtimes, {
33 - name = 'JavaSE-24',
34 - path = jdtls_jre_path,
35 - sources = vim.fs.joinpath(jdtls_jre_path, 'lib', 'src.zip'),
36 - default = true,
37 - })
32 + table.insert(runtimes, {
33 + name = 'JavaSE-25',
34 + path = jdtls_jre_path,
35 + sources = vim.fs.joinpath(jdtls_jre_path, 'lib', 'src.zip'),
36 + default = true,
37 + })
39 - if (project_local_settings.jdtls.runtimes) then
40 - return table.deep_extend('force', runtimes, project_local_settings.jdlts.runtimes)
41 - else
42 - return runtimes
43 - end
44 - end
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'
49 - else
50 - jdlts_config_dir = vim.fn.has 'win32' and 'config_win' or 'config_linux'
51 - end
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)
41 + else
42 + return runtimes
43 + end
44 + end
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'
49 + else
50 + jdlts_config_dir = vim.fn.has 'win32' and 'config_win' or 'config_linux'
51 + end
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')
56 - local cmd = {
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',
62 - '-Xmx8G',
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,
71 - }
56 + local cmd = {
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',
62 + '-Xmx8G',
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,
71 + }
73 - if syntax_server_mode then
74 - table.insert(cmd, 2, '-Dsyntaxserver=true')
75 - end
73 + if syntax_server_mode then
74 + table.insert(cmd, 2, '-Dsyntaxserver=true')
75 + end
77 - local runtimes = find_runtimes()
78 - local config = {
79 - name = syntax_server_mode and 'jdtls_ss' or 'jdtls',
80 - cmd = cmd,
81 - root_dir = root_dir,
82 - settings = {
83 - java = {
84 - autobuild = { enabled = true },
85 - cleanup = {
86 - actionsOnSave = {
87 - 'qualifyMembers',
88 - 'qualifyStaticMembers',
89 - 'addOverride',
90 - 'addDeprecated',
91 - 'stringConcatToTextBlock',
92 - 'invertEquals',
93 - 'addFinalModifier',
94 - 'instanceofPatternMatch',
95 - 'switchExpression',
96 - },
97 - },
98 - codeGeneration = {
99 - generateComments = false,
100 - hashCodeEquals = { useJava7Objects = true },
101 - toString = {
102 - template = '${object.className}{${member.name()}=${member.value()}, ${otherMembers}}',
103 - },
104 - useBlocks = true,
105 - },
106 - codeAction = { sortMembers = { avoidVolatileChanges = true } },
107 - completion = {
108 - enabled = 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.*',
123 - },
124 - filteredTypes = {
125 - -- Swing and AWT
126 - 'javax.swing.*',
127 - 'java.awt.*',
128 - -- CORBA
129 - 'org.omg.*',
130 - -- Applet
131 - 'java.applet.*',
132 - -- Legacy JAF
133 - 'javax.activation.*',
134 - -- Legacy Security
135 - 'java.security.acl.*',
136 - 'javax.security.auth.callback.*',
137 - -- Legacy XML/SOAP
138 - 'javax.xml.soap.*',
139 - 'javax.xml.rpc.*',
140 - -- RMI
141 - 'java.rmi.*',
142 - -- Legacy Collections
143 - 'java.util.Vector',
144 - 'java.util.Hashtable',
145 - 'java.util.Stack',
146 - 'java.util.Dictionary',
147 - -- Deprecated Classes
148 - 'java.util.Date',
149 - 'java.util.Calendar',
150 - 'java.util.Observable',
151 - 'java.util.Observer',
152 - -- Niche Packages
153 - 'javax.annotation.*',
154 - 'javax.jws.*',
155 - 'java.beans.*',
156 - 'javax.management.*',
157 - },
158 - guessMethodArguments = false,
159 - importOrder = {
160 - 'net',
161 - 'de',
162 - 'org',
163 - 'com',
164 - 'javax',
165 - 'java',
166 - },
167 - matchCase = 'FIRSTLETTER',
168 - maxResults = 5,
169 - overwrite = true,
170 - postfix = { enabled = true },
171 - },
172 - configuration = {
173 - runtimes = runtimes,
174 - updateBuildConfiguration = 'interactive',
175 - },
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 },
184 - import = {
185 - maven = { enabled = true },
186 - gradle = {
187 - enabled = true,
188 - annotationProcessing = true,
189 - wrapper = { enabled = true },
190 - },
191 - exclusions = {
192 - '**/output/**',
193 - '**/target/**',
194 - '**/node_modules/**',
195 - '**/.metadata/**',
196 - '**/archetype-resources/**',
197 - '**/META-INF/maven/**',
198 - },
199 - },
200 - inlayHints = { parameterNames = { enabled = 'all' } },
201 - jdt = {
202 - ls = {
203 - androidSupport = false,
204 - lombokSupport = false,
205 - protofBufSupport = true,
206 - },
207 - },
208 - maven = { notCoveredPluginExecutionSeverity = 'error' },
209 - maxConcurrentBuilds = 16,
210 - project = {
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,
216 - },
217 - referencesCodeLens = { enabled = true },
218 - references = {
219 - includeAccessors = true,
220 - includeDecompiledSources = true,
221 - },
222 - rename = { enabled = true },
223 - saveActions = { origanizeImports = true },
224 - selectionRange = { enabled = true },
225 - settings = {
226 - url = compiler_options_path,
227 - },
228 - signatureHelp = { enabled = true },
229 - sources = {
230 - organizeImports = {
231 - starThreshold = 9999,
232 - staticStarThreshold = 9999,
233 - },
234 - },
235 - symbols = { includeSourceMethodDeclarations = true },
236 - trace = { server = dbg.get() and 'verbose' or 'off' },
237 - edit = { validateAllOpenBuffersOnChanges = false },
238 - },
239 - },
240 - handlers = {
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)
245 - end
246 - end,
248 - },
249 - }
250 - return config
77 + local runtimes = find_runtimes()
78 + local config = {
79 + name = syntax_server_mode and 'jdtls_ss' or 'jdtls',
80 + cmd = cmd,
81 + root_dir = root_dir,
82 + settings = {
83 + java = {
84 + autobuild = { enabled = true },
85 + cleanup = {
86 + actionsOnSave = {
87 + 'qualifyMembers',
88 + 'qualifyStaticMembers',
89 + 'addOverride',
90 + 'addDeprecated',
91 + 'stringConcatToTextBlock',
92 + 'invertEquals',
93 + 'addFinalModifier',
94 + 'instanceofPatternMatch',
95 + 'switchExpression',
96 + },
97 + },
98 + codeGeneration = {
99 + generateComments = false,
100 + hashCodeEquals = { useJava7Objects = true },
101 + toString = {
102 + template = '${object.className}{${member.name()}=${member.value()}, ${otherMembers}}',
103 + },
104 + useBlocks = true,
105 + },
106 + codeAction = { sortMembers = { avoidVolatileChanges = true } },
107 + completion = {
108 + enabled = 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.*',
123 + },
124 + filteredTypes = {
125 + -- Swing and AWT
126 + 'javax.swing.*',
127 + 'java.awt.*',
128 + -- CORBA
129 + 'org.omg.*',
130 + -- Applet
131 + 'java.applet.*',
132 + -- Legacy JAF
133 + 'javax.activation.*',
134 + -- Legacy Security
135 + 'java.security.acl.*',
136 + 'javax.security.auth.callback.*',
137 + -- Legacy XML/SOAP
138 + 'javax.xml.soap.*',
139 + 'javax.xml.rpc.*',
140 + -- RMI
141 + 'java.rmi.*',
142 + -- Legacy Collections
143 + 'java.util.Vector',
144 + 'java.util.Hashtable',
145 + 'java.util.Stack',
146 + 'java.util.Dictionary',
147 + -- Deprecated Classes
148 + 'java.util.Date',
149 + 'java.util.Calendar',
150 + 'java.util.Observable',
151 + 'java.util.Observer',
152 + -- Niche Packages
153 + 'javax.annotation.*',
154 + 'javax.jws.*',
155 + 'java.beans.*',
156 + 'javax.management.*',
157 + },
158 + guessMethodArguments = false,
159 + importOrder = {
160 + 'net',
161 + 'de',
162 + 'org',
163 + 'com',
164 + 'javax',
165 + 'java',
166 + },
167 + matchCase = 'FIRSTLETTER',
168 + maxResults = 5,
169 + overwrite = true,
170 + postfix = { enabled = true },
171 + },
172 + configuration = {
173 + runtimes = runtimes,
174 + updateBuildConfiguration = 'interactive',
175 + },
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 },
184 + import = {
185 + maven = { enabled = true },
186 + gradle = {
187 + enabled = true,
188 + annotationProcessing = true,
189 + wrapper = { enabled = true },
190 + },
191 + exclusions = {
192 + '**/output/**',
193 + '**/target/**',
194 + '**/node_modules/**',
195 + '**/.metadata/**',
196 + '**/archetype-resources/**',
197 + '**/META-INF/maven/**',
198 + },
199 + },
200 + inlayHints = { parameterNames = { enabled = 'all' } },
201 + jdt = {
202 + ls = {
203 + androidSupport = false,
204 + lombokSupport = false,
205 + protofBufSupport = true,
206 + },
207 + },
208 + maven = { notCoveredPluginExecutionSeverity = 'error' },
209 + maxConcurrentBuilds = 16,
210 + project = {
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,
216 + },
217 + referencesCodeLens = { enabled = true },
218 + references = {
219 + includeAccessors = true,
220 + includeDecompiledSources = true,
221 + },
222 + rename = { enabled = true },
223 + saveActions = { origanizeImports = true },
224 + selectionRange = { enabled = true },
225 + settings = {
226 + url = compiler_options_path,
227 + },
228 + signatureHelp = { enabled = true },
229 + sources = {
230 + organizeImports = {
231 + starThreshold = 9999,
232 + staticStarThreshold = 9999,
233 + },
234 + },
235 + symbols = { includeSourceMethodDeclarations = true },
236 + trace = { server = dbg.get() and 'verbose' or 'off' },
237 + edit = { validateAllOpenBuffersOnChanges = false },
238 + },
239 + },
240 + handlers = {
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)
245 + end
246 + end,
247 + },
249 + return config
253 252 auto 'start_jdtls' {
254 - pattern = 'java',
255 - events = 'FileType',
256 - description = 'Starts jdlts (with syntax mode initially)',
257 - command = function()
258 - local path = vim.api.nvim_buf_get_name(0)
259 - -- FIXME: often, jdtls_ss stays open...
260 - jdtls_ss_id = vim.lsp.start(create_config(true, path))
261 - -- puk 'jdtls'.start_or_attach(create_config(false, path))
262 - end,
253 + pattern = 'java',
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))
259 + --TODO: figure out a way to choose between ss and full mode on demand.
260 + -- using the full server in script files is annoying
261 + puk 'jdtls'.start_or_attach(create_config(false, path))
262 + end,

neovim/lua/bugabinga/notifications.lua

Modified
2 2 local puk = require 'std.puk'
3 3 local user_command = require 'std.user_command'
4 4 local notify = puk 'mini.notify'
6 -notify.setup {}
6 +notify.setup {
7 + lsp_progress = {
8 + enable = false
9 + }
7 11 vim.notify = notify.make_notify {
8 12 ERROR = { duration = 4242, hl_group = 'DiagnosticError' },
9 13 WARN = { duration = 3333, hl_group = 'DiagnosticWarn' },