@@ -140,6 +140,8 @@ vim.opt.rtp:prepend(lazypath)
140140-- To update plugins you can run
141141-- :Lazy update
142142--
143+ -- See HACK below...
144+ jdtls_already_ran = false
143145-- NOTE: Here is where you install your plugins.
144146require (' lazy' ).setup ({
145147
@@ -438,6 +440,7 @@ require('lazy').setup({
438440 { ' williamboman/mason.nvim' , config = true }, -- NOTE: Must be loaded before dependants
439441 ' williamboman/mason-lspconfig.nvim' ,
440442 ' WhoIsSethDaniel/mason-tool-installer.nvim' ,
443+ ' nvim-java/nvim-java' ,
441444
442445 -- Useful status updates for LSP.
443446 -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
@@ -508,7 +511,7 @@ require('lazy').setup({
508511
509512 -- Fuzzy find all the symbols in your current document.
510513 -- Symbols are things like variables, functions, types, etc.
511- map (' <leader>ds' , require (' telescope.builtin' ).lsp_document_symbols , ' [D]ocument [S]ymbols' )
514+ map (' <leader>ds' , require (' telescope.builtin' ).treesitter , ' [D]ocument [S]ymbols' )
512515
513516 -- Fuzzy find all the symbols in your current workspace.
514517 -- Similar to document symbols, except searches over your entire project.
@@ -639,6 +642,161 @@ require('lazy').setup({
639642 server .capabilities = vim .tbl_deep_extend (' force' , {}, capabilities , server .capabilities or {})
640643 require (' lspconfig' )[server_name ].setup (server )
641644 end ,
645+ jdtls = function ()
646+ -- HACK: Don't know why this gets called more than once
647+ if jdtls_already_ran then
648+ return
649+ end
650+ jdtls_already_ran = true
651+ require (' java' ).setup {
652+ -- Your custom jdtls settings goes here
653+ -- Do not automatically install JDK 17
654+ -- From: https://github.com/nvim-java/nvim-java/wiki/Q-&-A#no_entry-disable-openjdk-17-auto-installation
655+ jdk = {
656+ auto_install = false ,
657+ },
658+ init_options = {
659+ documentSymbol = {
660+ dynamicRegistration = false ,
661+ hierarchicalDocumentSymbolSupport = true ,
662+ labelSupport = true ,
663+ symbolKind = {
664+ valueSet = {
665+ 1 ,
666+ 2 ,
667+ 3 ,
668+ 4 ,
669+ 5 ,
670+ 6 ,
671+ 7 ,
672+ 8 ,
673+ 9 ,
674+ 10 ,
675+ 11 ,
676+ 12 ,
677+ 13 ,
678+ 14 ,
679+ 15 ,
680+ 16 ,
681+ 17 ,
682+ 18 ,
683+ 19 ,
684+ 20 ,
685+ 21 ,
686+ 22 ,
687+ 23 ,
688+ 24 ,
689+ 25 ,
690+ 26 ,
691+ 27 ,
692+ 28 ,
693+ 29 ,
694+ 30 ,
695+ 31 ,
696+ },
697+ tagSupport = {
698+ valueSet = {},
699+ },
700+ },
701+ },
702+ },
703+
704+ -- NOTE: custom java settings
705+ -- https://github.com/ray-x/lsp_signature.nvim/issues/97
706+ -- all options:
707+ -- https://github.com/mfussenegger/nvim-jdtls
708+ -- https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
709+ single_file_support = true ,
710+ settings = {
711+ java = {
712+ autobuild = { enabled = false },
713+ server = { launchMode = ' Hybrid' },
714+ eclipse = {
715+ downloadSources = true ,
716+ },
717+ maven = {
718+ downloadSources = true ,
719+ },
720+ import = {
721+ gradle = {
722+ enabled = true ,
723+ },
724+ maven = {
725+ enabled = true ,
726+ },
727+ exclusions = {
728+ ' **/node_modules/**' ,
729+ ' **/.metadata/**' ,
730+ ' **/archetype-resources/**' ,
731+ ' **/META-INF/maven/**' ,
732+ ' /**/test/**' ,
733+ },
734+ },
735+ -- configuration = {
736+ -- runtimes = {
737+ -- {
738+ -- name = 'JavaSE-1.8',
739+ -- path = '~/.sdkman/candidates/java/8.0.402-tem',
740+ -- },
741+ -- {
742+ -- name = 'JavaSE-11',
743+ -- path = '~/.sdkman/candidates/java/11.0.22-tem',
744+ -- },
745+ -- {
746+ -- name = 'JavaSE-17',
747+ -- path = '~/.sdkman/candidates/java/17.0.10-tem',
748+ -- },
749+ -- {
750+ -- name = 'JavaSE-21',
751+ -- path = '~/.sdkman/candidates/java/21.0.3-tem',
752+ -- },
753+ -- },
754+ -- },
755+ references = {
756+ includeDecompiledSources = true ,
757+ },
758+ implementationsCodeLens = {
759+ enabled = false ,
760+ },
761+ referenceCodeLens = {
762+ enabled = false ,
763+ },
764+ -- https://github.com/eclipse-jdtls/eclipse.jdt.ls/issues/2948
765+ inlayHints = {
766+ parameterNames = {
767+ --- @type " none" | " literals" | " all"
768+ enabled = ' all' ,
769+ },
770+ },
771+ signatureHelp = {
772+ enabled = true ,
773+ description = {
774+ enabled = true ,
775+ },
776+ },
777+ symbols = {
778+ includeSourceMethodDeclarations = true ,
779+ },
780+ -- https://stackoverflow.com/questions/74844019/neovim-setting-up-jdtls-with-lsp-zero-mason
781+ rename = { enabled = true },
782+
783+ contentProvider = {
784+ preferred = ' fernflower' ,
785+ },
786+ sources = {
787+ organizeImports = {
788+ starThreshold = 9999 ,
789+ staticStarThreshold = 9999 ,
790+ },
791+ },
792+ },
793+ redhat = { telemetry = { enabled = false } },
794+ },
795+
796+ }
797+
798+ require (' lspconfig' ).jdtls .setup { }
799+ end ,
642800 },
643801 }
644802 end ,
@@ -905,6 +1063,7 @@ require('lazy').setup({
9051063 -- Uncomment any of the lines below to enable them (you will need to restart nvim).
9061064 --
9071065 -- require 'kickstart.plugins.debug',
1066+ require ' kickstart.plugins.debug' ,
9081067 -- require 'kickstart.plugins.indent_line',
9091068 -- require 'kickstart.plugins.lint',
9101069 -- require 'kickstart.plugins.autopairs',
@@ -1156,10 +1315,11 @@ local on_attach = function(_, bufnr)
11561315 nmap (' gr' , require (' telescope.builtin' ).lsp_references , ' [G]oto [R]eferences' )
11571316 nmap (' gI' , require (' telescope.builtin' ).lsp_implementations , ' [G]oto [I]mplementation' )
11581317 nmap (' <leader>D' , vim .lsp .buf .type_definition , ' Type [D]efinition' )
1159- -- Just show classes and functions
1160- nmap (' <leader>ds' , function ()
1161- require (' telescope.builtin' ).lsp_document_symbols { ignore_symbols = { ' variable' , ' constant' } }
1162- end , ' [D]ocument [S]ymbols' )
1318+
1319+ -- HACK: I can't get lsp_document_symbols to work for jdtls for some reason...
1320+ -- nmap('<leader>ds', function()
1321+ -- require('telescope.builtin').lsp_document_symbols { ignore_symbols = { 'variable', 'constant' } }
1322+ -- end, '[D]ocument [S]ymbols')
11631323 nmap (' <leader>ws' , require (' telescope.builtin' ).lsp_dynamic_workspace_symbols , ' [W]orkspace [S]ymbols' )
11641324
11651325 -- See `:help K` for why this keymap
@@ -1212,7 +1372,6 @@ local servers = {
12121372 bashls = {},
12131373 groovyls = {},
12141374 intelephense = {},
1215- jdtls = {},
12161375 jsonls = {},
12171376 lua_ls = {
12181377 Lua = {
0 commit comments