Skip to content

Commit

Permalink
feat(nvim): update Java LSP settings for better support
Browse files Browse the repository at this point in the history
- Added custom Java settings for improved LSP support.
- Enabled single file support.
- Updated import exclusions and content provider preferences.
- Enabled Gradle and Maven import settings.
- Included source method declarations in symbols.
- Enabled rename functionality.

References:
- ray-x/lsp_signature.nvim#97
- https://github.com/mfussenegger/nvim-jdtls
- https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
- https://stackoverflow.com/questions/74844019/neovim-setting-up-jdtls-with-lsp-zero-mason
  • Loading branch information
gipo355 committed Sep 1, 2024
1 parent 295f356 commit 14988da
Showing 1 changed file with 90 additions and 59 deletions.
149 changes: 90 additions & 59 deletions lua/user/plugins/lsp/lspconfig/lspconfig.lua
Original file line number Diff line number Diff line change
Expand Up @@ -190,65 +190,96 @@ return {
-- -- client.server_capabilities.documentSymbolProvider =
-- -- false
-- end,
-- settings = {
-- java = {
-- server = { launchMode = 'Hybrid' },
-- eclipse = {
-- downloadSources = true,
-- },
-- maven = {
-- downloadSources = true,
-- },
-- -- configuration = {
-- -- runtimes = {
-- -- {
-- -- name = 'JavaSE-1.8',
-- -- path = '~/.sdkman/candidates/java/8.0.402-tem',
-- -- },
-- -- {
-- -- name = 'JavaSE-11',
-- -- path = '~/.sdkman/candidates/java/11.0.22-tem',
-- -- },
-- -- {
-- -- name = 'JavaSE-17',
-- -- path = '~/.sdkman/candidates/java/17.0.10-tem',
-- -- },
-- -- {
-- -- name = 'JavaSE-21',
-- -- path = '~/.sdkman/candidates/java/21.0.3-tem',
-- -- },
-- -- },
-- -- },
-- references = {
-- includeDecompiledSources = true,
-- },
-- implementationsCodeLens = {
-- enabled = false,
-- },
-- referenceCodeLens = {
-- enabled = false,
-- },
-- inlayHints = {
-- parameterNames = {
-- -- enabled = 'none',
-- enabled = 'all',
-- },
-- },
-- signatureHelp = {
-- enabled = true,
-- description = {
-- enabled = true,
-- },
-- },
-- sources = {
-- organizeImports = {
-- starThreshold = 9999,
-- staticStarThreshold = 9999,
-- },
-- },
-- },
-- redhat = { telemetry = { enabled = false } },
-- },

-- NOTE: custom java settings
-- https://github.com/ray-x/lsp_signature.nvim/issues/97
-- all options:
-- https://github.com/mfussenegger/nvim-jdtls
-- https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
single_file_support = true,
settings = {
java = {
server = { launchMode = 'Hybrid' },
eclipse = {
downloadSources = true,
},
maven = {
downloadSources = true,
},
import = {
gradle = {
enabled = true,
},
maven = {
enabled = true,
},
exclusions = {
'**/node_modules/**',
'**/.metadata/**',
'**/archetype-resources/**',
'**/META-INF/maven/**',
'/**/test/**',
},
},
-- configuration = {
-- runtimes = {
-- {
-- name = 'JavaSE-1.8',
-- path = '~/.sdkman/candidates/java/8.0.402-tem',
-- },
-- {
-- name = 'JavaSE-11',
-- path = '~/.sdkman/candidates/java/11.0.22-tem',
-- },
-- {
-- name = 'JavaSE-17',
-- path = '~/.sdkman/candidates/java/17.0.10-tem',
-- },
-- {
-- name = 'JavaSE-21',
-- path = '~/.sdkman/candidates/java/21.0.3-tem',
-- },
-- },
-- },
references = {
includeDecompiledSources = true,
},
implementationsCodeLens = {
enabled = false,
},
referenceCodeLens = {
enabled = false,
},
inlayHints = {
parameterNames = {
---@type "none" | "literals" | "all"
enabled = 'all',
},
},
signatureHelp = {
enabled = true,
description = {
enabled = true,
},
},
symbols = {
includeSourceMethodDeclarations = true,
},
-- https://stackoverflow.com/questions/74844019/neovim-setting-up-jdtls-with-lsp-zero-mason
rename = { enabled = true },

contentProvider = {
preferred = 'fernflower',
},
sources = {
organizeImports = {
starThreshold = 9999,
staticStarThreshold = 9999,
},
},
},
redhat = { telemetry = { enabled = false } },
},
})
end,
},
Expand Down

0 comments on commit 14988da

Please sign in to comment.