mirror of
https://github.com/Baipyrus/nvim-config.git
synced 2024-11-15 05:23:50 +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 function jdtls_setup()
|
||||||
local project_name = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h:t')
|
--- @param workspace_dir string
|
||||||
-- calculate workspace dir
|
local function generate_config(workspace_dir)
|
||||||
local workspace_dir = vim.fn.stdpath 'data' .. '/site/java/workspace-root/' .. project_name
|
|
||||||
-- get the mason install path
|
-- get the mason install path
|
||||||
local install_path = require('mason-registry').get_package('jdtls'):get_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')
|
local jdtls_path = vim.fn.glob(install_path .. '/plugins/org.eclipse.equinox.launcher_*.jar')
|
||||||
@ -262,10 +261,15 @@ return {
|
|||||||
bundles = {},
|
bundles = {},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
return config
|
||||||
|
end
|
||||||
vim.api.nvim_create_autocmd('FileType', {
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
pattern = 'java',
|
pattern = 'java',
|
||||||
callback = function()
|
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,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user