Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings
nvim-java

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

LSP document symbols does not work#412

Unanswered
wpisarski asked this question inQ&A
Aug 9, 2025· 1 comments· 5 replies
Discussion options

Hi, I've recently switched fromnvim-jdtls tonvim-java (and from Telescope to FzfLua for better presentation) and for some reason LSP document symbols just does not work, FzfLua says[Fzf-lua] LSP: server does not support textDocument/documentSymbol. It did work withnvim-jdtls. Workspace symbols do work correctly, but I had to disablespring-boot-tools because this plugin's output is clearly meant to be used with some other tool and not FzfLua. Document symbols also work for other languages, for example Lua. Everything else I've tried so far (completions, debugging, running JUnits etc.) also works, just not document symbols. It's not a very big deal, but would be helpful when working in codebases with Java files going into thousands of lines.

I've tried some print debugging and found that:lua print(vim.lsp.get_clients({name="jdtls"})[1]:supports_method("textDocument/documentSymbol", 3)) printsfalse, but if I try:lua vim.print(vim.lsp.get_clients({name="jdtls"})[1]) it gives me this, which does not make sense for me:

...      documentSymbol = {        dynamicRegistration = false,        hierarchicalDocumentSymbolSupport = true,        symbolKind = {          valueSet = <10>{ 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 }        }      },...

My setup, some paths redacted. Neovim is installed via AppImage:

nvim --versionNVIM v0.11.2Build type: ReleaseLuaJIT 2.1.1741730670

OS default Java:

java --versionopenjdk 21.0.8 2025-07-15OpenJDK Runtime Environment (Red_Hat-21.0.8.0.9-1) (build 21.0.8+9)OpenJDK 64-Bit Server VM (Red_Hat-21.0.8.0.9-1) (build 21.0.8+9, mixed mode, sharing)

My lspconfig loaded with lazy.nvim, written from scratch from various guides, not a distribution:

return {        {"nvim-java/nvim-java",        },        {"mason-org/mason.nvim",lazy=false,config=function()require("mason").setup()end,        },        {"mason-org/mason-lspconfig.nvim",enabled=true,lazy=false,opts= {auto_install=true,                },        },        {"neovim/nvim-lspconfig",dependencies= {"saghen/blink.cmp"},lazy=false,config=function()vim.keymap.set("n","K",vim.lsp.buf.hover, {desc="LSP Hover"})vim.keymap.set("n","<leader>cd",vim.lsp.buf.definition, {desc="LSP definition"})vim.keymap.set("n","<leader>cf",vim.lsp.buf.references, {desc="LSP references"})vim.keymap.set({"n","v"},"<leader>ca",vim.lsp.buf.code_action, {desc="LSP code actions"})vim.keymap.set("n","<leader>cr",vim.lsp.buf.rename, {desc="LSP rename"})vim.keymap.set("n","<leader>ch",function ()vim.lsp.buf.typehierarchy("subtypes")end, {desc="LSP subtype hierarchy"})vim.keymap.set("n","<leader>cH",function ()vim.lsp.buf.typehierarchy("supertypes")end, {desc="LSP supertype hierarchy"})vim.keymap.set("n","<leader>ce","<cmd>lua vim.diagnostic.open_float()<CR>",                                {desc="Show diagnostic in floating windiw"}                        )localjava=require("java")java.setup(                                {java_debug_adapter= {enable=true,                                        },spring_boot_tools= {enable=false,                                        }                                })locallspconfig=require("lspconfig")lspconfig.jdtls.setup({})lspconfig.lua_ls.setup({settings= {Lua= {runtime= {version="LuaJIT",                                                },diagnostics= {globals= {"vim"},-- Add 'vim' to the list of globals to avoid undefined global errors                                                },workspace= {library= {vim.fn.expand("$VIMRUNTIME/lua"),vim.fn.stdpath("config").."/lua",-- Add any other paths where your Lua files are located                                                        },                                                },telemetry= {enable=false,                                                },                                        },                                },                        })end,        },        {"mfussenegger/nvim-jdtls",enabled=false,dependencies= {"nvim-dap"},        },        {"folke/lazydev.nvim",ft="lua",-- only load on lua filesopts= {library= {-- See the configuration section for more details-- Load luvit types when the `vim.uv` word is found                                {path="${3rd}/luv/library",words= {"vim%.uv"} },                        },                },        },}

Output of:LspInfo on any random Java code after everything is loaded and built:

vim.lsp: Active Clients ~- null-ls (id: 2)  - Version: ? (no serverInfo.version response)  - Root directory: ~/redacted  - Command: <function @/home/username/.local/share/nvim/lazy/none-ls.nvim/lua/null-ls/rpc.lua:61>  - Settings: {}  - Attached buffers: 3- jdtls (id: 3)  - Version: ? (no serverInfo.version response)  - Root directory: ~/redacted  - Command: { "java", "-Declipse.application=org.eclipse.jdt.ls.core.id1", "-Dosgi.bundles.defaultStartLevel=4", "-Declipse.product=org.eclipse.jdt.ls.core.product", "-Dosgi.checkConfiguration=true", "-Dosgi.sharedConfiguration.area=/home/username/.local/share/nvim/mason/share/jdtls/config", "-Dosgi.sharedConfiguration.area.readOnly=true", "-Dosgi.configuration.cascaded=true", "-Xms1G", "--add-modules=ALL-SYSTEM", "--add-opens", "java.base/java.util=ALL-UNNAMED", "--add-opens", "java.base/java.lang=ALL-UNNAMED", "-javaagent:/home/username/.local/share/nvim/mason/share/lombok-nightly/lombok.jar", "-jar", "/home/username/.local/share/nvim/mason/share/jdtls/plugins/org.eclipse.equinox.launcher.jar", "-configuration", "/home/username/.cache/nvim/jdtls/config", "-data", "/home/username/.cache/nvim/jdtls/workspaces/_redacted" }  - Settings: vim.empty_dict()  - Attached buffers: 3vim.lsp: Enabled Configurations ~...- jdtls:  - capabilities: {      textDocument = {        completion = {          completionItem = {            commitCharactersSupport = false,            deprecatedSupport = true,            documentationFormat = { "markdown", "plaintext" },            insertReplaceSupport = true,            insertTextModeSupport = {              valueSet = { 1 }            },            labelDetailsSupport = true,            preselectSupport = false,            resolveSupport = {              properties = { "documentation", "detail", "additionalTextEdits", "command", "data" }            },            snippetSupport = true,            tagSupport = {              valueSet = { 1 }            }          },          completionList = {            itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }          },          contextSupport = true,          insertTextMode = 1        }      }    }  - cmd: { "jdtls", "-configuration", "/home/username/.cache/jdtls/config", "-data", "/home/username/.cache/jdtls/workspace" }  - filetypes: java  - handlers: {      ["language/status"] = <function 1>,      ["textDocument/codeAction"] = <function 2>,      ["textDocument/rename"] = <function 3>,      ["workspace/applyEdit"] = <function 4>    }  - init_options: {      jvm_args = {},      workspace = "/home/username/.cache/jdtls/workspace"    }  - root_markers: .git, build.gradle, build.gradle.kts, build.xml, pom.xml, settings.gradle, settings.gradle.kts...

Andftplugin/java.lua:

localjava=require("java")vim.keymap.set("n","<leader>ct",java.test.run_current_method, {desc="Java test method"})vim.keymap.set("n","<leader>cT",java.test.run_current_class, {desc="Java test class"})vim.keymap.set("n","<leader>dt",java.test.debug_current_method, {desc="Java debug method"})vim.keymap.set("n","<leader>dT",java.test.debug_current_class, {desc="Java debug class"})vim.keymap.set("n","<leader>cy",java.test.view_last_report, {desc="Java show test report"})vim.keymap.set("n","<leader>cl",java.runner.built_in.toggle_logs, {desc="Java toggle logs"})
You must be logged in to vote

Replies: 1 comment 5 replies

Comment options

Delete opts from Mason lspconfig line it causes it to setup jdtls before nvim-java and see#293 and#399

You must be logged in to vote
5 replies
@wpisarski
Comment options

Unfortunately that's not it. I did an experiment, tooknvim-java/starter-lazyvim starter config, disabledspring_boot_tools as it does provide document symbols, run Neovim with this config by substitutingXDG_CONFIG_DIR. Then I pointed Neovim at a random class with main method andvim.lsp.buf.document_symbol() still says that method is not supported. JDTLS is attached.

I will try debugging it further on a different machine, from scratch. And maybe I'll check different versions of Neovim, plugins or JDTLS.

@logrusx
Comment options

Unfortunately I don't have the possibility to look into this right now. I'm on the move and type from my phone.

@wpisarski
Comment options

No worries, I'm not expecting you to find the cause. I'll debug this myself and let you know when I find anything. I'm assuming the problem is somewhere in my config or environment.

@logrusx
Comment options

I'm at home now and have the time just to test if it works for me. It does. Both running:lua vim.lsp.buf.document_symbol() and:FzfLua lsp_document_symbols shows some symbols for me. Unfortunately I'm not that familiar with Neovim and LSP yet and cannot tell if those are the right symbols. Maybe I need to spawn an Eclipse IDE and see if they match, but can't do that right now.

Try the Kickstart starter, I think I used it recently. At least I'm sure it setup the language servers fine. Also my configuration is based on Kickstart, though not the nvim-java's kickstart starter. Nevertheless it follows the same conventions.

@logrusx
Comment options

Actually I found something. When I disabled spring boot tools then I too don't get document symbols. I get the message:

LSP: server does not support textDocument/documentSymbol

This might be missing implementation of the protocol on nvim-java's side, but I'm not (yet) familiar with that part of the code.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@wpisarski@logrusx

[8]ページ先頭

©2009-2025 Movatter.jp