mfussenegger / nvim-jdtls

Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
GNU General Public License v3.0
1.09k stars 62 forks source link

Decompiled class name is strange #423

Closed SpicyChickenFLY closed 1 year ago

SpicyChickenFLY commented 1 year ago

LSP client configuration

local jdk8_path = '/usr/local/jdk17' local jdk17_path = '/usr/lib/jvm/java-17-openjdk' local jdtls_path = '/home/chow/.local/share/jdtls' local jdtls_cache_path = '/home/chow/.cache/jdtls'

local bundles = { vim.fn.glob("/home/chow/.local/share/java-debug/com.microsoft.java.debug.plugin/target/com.microsoft.java.debug.plugin-.jar", 1) } vim.list_extend(bundles, vim.split(vim.fn.glob("/usr/local/java-decompiler/server/.jar", 1), "\n"))

local config = { cmd = { jdk17_path .. '/bin/java', '-Declipse.application=org.eclipse.jdt.ls.core.id1', '-Dosgi.bundles.defaultStartLevel=4', '-Declipse.product=org.eclipse.jdt.ls.core.product', '-Dlog.protocol=true', '-Dlog.level=ALL', '-Xms1g', '--add-modules=ALL-SYSTEM', '--add-opens', 'java.base/java.util=ALL-UNNAMED', '--add-opens', 'java.base/java.lang=ALL-UNNAMED', '-javaagent:' .. jdtls_path .. '/plugins/lombok.jar', '-jar', jdtls_path .. '/plugins/org.eclipse.equinox.launcher_1.6.400.v20210924-0641.jar', '-configuration', jdtls_path .. '/config_linux', '-data', jdtls_cache_path .. '/jdtls-' .. vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t'), },

-- This is the default if not provided, you can remove it. Or adjust as needed. -- One dedicated LSP server & client will be started per unique root_dir root_dir = require('jdtls.setup').find_root({'.git', 'mvnw', 'gradlew'}),

-- Here you can configure eclipse.jdt.ls specific settings -- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request -- for a list of options settings = { java = { runtimes = { name = "javaSE-8", path = jdk8_path }, contentProvider = { preferred = 'fernflower' }, } },

-- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this init_options = { bundles = bundles }, }

config['on_attach'] = function(client, bufnr) -- With hotcodereplace = 'auto' the debug adapter will try to apply code changes -- you make during a debug session immediately. -- Remove the option if you do not want that. -- You can use theJdtHotcodeReplace` command to trigger it manually require('jdtls').setup_dap({ hotcodereplace = 'auto' }) vim.cmd([[ command! JdtRefresh lua require('jdtls.dap').setup_dap_main_class_configs() ]]) end

-- This starts a new client & server, -- or attaches to an existing client & server depending on the root_dir. require('jdtls').start_or_attach(config)

Eclipse.jdt.ls version

1.19.0

Steps to Reproduce

Jump to definition of Class without source(in my example, the class is from animal.jar file) screenshot

Expected Result

file name like Animal.class

Actual Result

file name display in format %3Ctop.spicychicken(Animal.class screenshot

mfussenegger commented 1 year ago

That's part of the URI that's required for eclipse.jdt.ls to resolve the sources.

Neovim has no concept of a user friendly display name, there is only the buffer filename, but you could customize the display in your status line with a function like this:

https://github.com/mfussenegger/dotfiles/blob/8329963f586310ebd871bb484f117cc2307f1d92/vim/.config/nvim/lua/me/init.lua#L227-L238

And in the quickfix list with a function like this:

https://github.com/mfussenegger/dotfiles/blob/8329963f586310ebd871bb484f117cc2307f1d92/vim/.config/nvim/lua/me/init.lua#L241-L264