-
Notifications
You must be signed in to change notification settings - Fork 918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(java): don't accumulate on_attach, and make more configurable #1388
Conversation
a9dcc24
to
236029b
Compare
@aqav @appelgriebsch I made another pass to move defaults into opts. Let me know if you can find the time to review! |
Good work, I have tested the fixes from #1300 and added, they all work as expected I really like that you allow users to override the config, like There are little questions I meet when I test:
The 2 and 3 also occur in my version #1300. |
This does not happen for me.
Your filetype auto-commands are running twice for some reason. This bug is why item 1 appears to work for you.
This doesn't happen for me. I should mention that I am testing this personally by installing it as Could you share your full neovim configuration and version? |
If you'd like to look at mine, it's here: https://github.com/agriffis/skel/tree/master/neovim/.config/nvim |
Also I'm running neovim nightly, which might matter because there was a change to how nested autocmds are handled. Related issues folke/lazy.nvim#228 and neovim/neovim#23368 |
My neovim version is v0.9.1, I test it when installing it in I think it's very likely that this is due to the related issues you mentioned, but it is not your fault Anyway, please go on with your PR progress |
@folke I think you could merge this now. It's a pretty big improvement over the original java extra. |
Thanks! |
This is a replacement for #1300. It keeps the fixes from that PR:
nvim-jdtls
andnvim-lspconfig
so the former isn't loaded unnecessarily.on_attach
for each java buffer opened.and adds the following fixes:
ft = { "java" }
but additionally handle the race condition internally by callingattach_jdtls()
directly when the plugin loads.Util.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter")
(the original code in feat(java): better java lang support #1300 calledmason_registry.has_package()
which isn't the right check)and improves configuration with the following optional in
opts
:opts.root_dir
function to find root dir for given filenameopts.project_name
function to find project name for given root diropts.jdtls_config_dir
function to find config dir for given project nameopts.jdtls_workspace_dir
function to find workspace dir for given project nameopts.cmd
base command, so you can use{ "java", ... }
instead of the scriptopts.full_cmd
function to compute the full command from the base commandopts.jdtls
table (or function modifying/returning table) of configuration forrequire("jdtls").start_or_attach(config)
opts.dap
can be false to disable, or table (or function modifying/returning table) of configuration forrequire("jdtls").setup_dap(config)
opts.test
can be false to disableopts.on_attach
can augment the existingLspAttach
autocmd for additional keybindingsFor example you can configure a replacement
jdtls
command to avoid the script: