mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
nvim: refactor jdtls configuration
This commit is contained in:
parent
35787ab423
commit
508151ccec
2 changed files with 18 additions and 23 deletions
18
.config/nvim/ftplugin/java.lua
Normal file
18
.config/nvim/ftplugin/java.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
local mylsp = require("lsp")
|
||||||
|
local capabilities = mylsp.capabilities
|
||||||
|
local on_attach = mylsp.on_attach
|
||||||
|
|
||||||
|
-- Java
|
||||||
|
local config = {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
cmd = {
|
||||||
|
-- https://github.com/NixOS/nixpkgs/issues/232822#issuecomment-1564243667
|
||||||
|
-- `-data` argument is necessary
|
||||||
|
"jdtls",
|
||||||
|
"-data",
|
||||||
|
vim.fn.expand("~/.cache/jdtls") .. vim.fn.expand("%:p:h"),
|
||||||
|
},
|
||||||
|
root_dir = vim.fs.dirname(vim.fs.find({ "gradlew", ".git", "mvnw" }, { upward = true })[1]),
|
||||||
|
}
|
||||||
|
require("jdtls").start_or_attach(config)
|
||||||
|
|
@ -120,26 +120,3 @@ for name, config in pairs(servers) do
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
------------------------
|
|
||||||
-- Standalone plugins --
|
|
||||||
------------------------
|
|
||||||
-- Java
|
|
||||||
local config = {
|
|
||||||
on_attach = mylsp.on_attach,
|
|
||||||
capabilities = mylsp.capabilities,
|
|
||||||
cmd = {
|
|
||||||
-- https://github.com/NixOS/nixpkgs/issues/232822#issuecomment-1564243667
|
|
||||||
-- `-data` argument is necessary
|
|
||||||
"jdtls",
|
|
||||||
"-data",
|
|
||||||
vim.fn.expand("~/.cache/jdtls") .. vim.fn.expand("%:p:h"),
|
|
||||||
},
|
|
||||||
root_dir = vim.fs.dirname(vim.fs.find({ "gradlew", ".git", "mvnw" }, { upward = true })[1]),
|
|
||||||
}
|
|
||||||
local jdtls_group = vim.api.nvim_create_augroup("jdtls", { clear = true })
|
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
|
||||||
pattern = { "java" },
|
|
||||||
callback = function() require("jdtls").start_or_attach(config) end,
|
|
||||||
group = jdtls_group,
|
|
||||||
})
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue