mirror of
https://github.com/Baipyrus/nvim-config.git
synced 2024-11-14 21:13:49 +00:00
wrap jdtls config in function for dynamic workspace
This commit is contained in:
parent
d9eca6205a
commit
9373dd686a
@ -200,9 +200,8 @@ return {
|
||||
}
|
||||
|
||||
local function jdtls_setup()
|
||||
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
|
||||
-- calculate workspace dir
|
||||
local workspace_dir = vim.fn.stdpath 'data' .. '/site/java/workspace-root/' .. project_name
|
||||
--- @param workspace_dir string
|
||||
local function generate_config(workspace_dir)
|
||||
-- get the mason install path
|
||||
local install_path = require('mason-registry').get_package('jdtls'):get_install_path()
|
||||
local jdtls_path = vim.fn.glob(install_path .. '/plugins/org.eclipse.equinox.launcher_*.jar')
|
||||
@ -262,10 +261,15 @@ return {
|
||||
bundles = {},
|
||||
},
|
||||
}
|
||||
return config
|
||||
end
|
||||
vim.api.nvim_create_autocmd('FileType', {
|
||||
pattern = 'java',
|
||||
callback = function()
|
||||
require('jdtls').start_or_attach(config)
|
||||
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
|
||||
-- calculate workspace dir
|
||||
local workspace_dir = vim.fn.stdpath 'data' .. '/site/java/workspace-root/' .. project_name
|
||||
require('jdtls').start_or_attach(generate_config(workspace_dir))
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user