Closed fengwk closed 1 year ago
Here is my usage:
vim.api.nvim_create_augroup("user_jdtls_setup", { clear = true })
vim.api.nvim_create_autocmd(
{ "FileType" },
{ group = "user_jdtls_setup", pattern = "java,ant", callback = setup })
vim.api.nvim_create_autocmd(
{ "FileType" },
{ group = "user_jdtls_setup", pattern = "xml", callback = function()
local name = vim.fn.expand("%:t")
if name == "pom.xml" then
setup()
end
end})
The reason for adding the pom.xml file is that the jdt server seems to recognize the pom file. Also, it makes it easier for me to use it because it is much easier to go into the project directory and use nvim pom.xml
than to open the java file after delving into the java package.
I still don't understand why this requires the change.
Opening a jdt://
URI should set the filetype for that buffer to java:
And then the attach routine should run and go through the check here:
What's the behavior you're seeing that this is supposed to fix?
When I search for the workspace symbol from pom.xml and jump to the jdt:// file, the following code will work:
251d959c95c05f3ad04e71024bd809992805d66b#L88-L96
local altbuf = vim.fn.bufnr("#", -1)
if altbuf and altbuf > 0 and try_attach(altbuf) then
return true
end
for _, buf in ipairs(api.nvim_list_bufs()) do
if api.nvim_buf_is_loaded(buf) and try_attach(buf) then
return true
end
end
It will get the corresponding buf of pom.xml, so it cannot satisfy the condition set by try_attach.
Oh, now I get it. Thanks for explaining
Here is my usage:
vim.api.nvim_create_augroup("user_jdtls_setup", { clear = true }) vim.api.nvim_create_autocmd( { "FileType" }, { group = "user_jdtls_setup", pattern = "java,ant", callback = setup }) vim.api.nvim_create_autocmd( { "FileType" }, { group = "user_jdtls_setup", pattern = "xml", callback = function() local name = vim.fn.expand("%:t") if name == "pom.xml" then setup() end end})
The reason for adding the pom.xml file is that the jdt server seems to recognize the pom file. Also, it makes it easier for me to use it because it is much easier to go into the project directory and use
nvim pom.xml
than to open the java file after delving into the java package.
by this usage, I can get jdtls startup with pom.xml, but can't jump to any jdt://
URI.Sorry for disturbance, am I missing something?
This is my configuration, you can check it: https://github.com/fengwk/enjoy-neovim/blob/main/lua/fengwk/plugins/lsp/lsp-jdtls/jdtls-setup.lua
Support jumping from pom.xml or gradle.build files to files associated with the jdt://protocol.