Skip to content

Commit ff5413f

Browse files
authored
fix: various compile issues due to shared common workspace between projects (#63)
1 parent dcb1170 commit ff5413f

File tree

3 files changed

+27
-30
lines changed

3 files changed

+27
-30
lines changed

lua/java-core/ls/servers/jdtls/init.lua

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local mason_reg = require('mason-registry')
55
local path = require('java-core.utils.path')
66
local plugins = require('java-core.ls.servers.jdtls.plugins')
77
local util = require('lspconfig.util')
8-
local workspace = require('java-core.ls.servers.jdtls.workspace')
8+
local utils = require('java-core.ls.servers.jdtls.utils')
99

1010
local M = {}
1111

@@ -33,8 +33,6 @@ function M.get_config(opts)
3333
local equinox_launcher =
3434
path.join(jdtls_root, 'plugins', 'org.eclipse.equinox.launcher.jar')
3535
local plugin_paths = plugins.get_plugin_paths(opts.jdtls_plugins)
36-
local jdtls_cache_path = path.join(vim.fn.stdpath('cache'), 'jdtls')
37-
3836
local base_config = config.get_config()
3937

4038
base_config.cmd = {
@@ -61,10 +59,10 @@ function M.get_config(opts)
6159
equinox_launcher,
6260

6361
'-configuration',
64-
jdtls_cache_path,
62+
utils.get_jdtls_config_path(),
6563

6664
'-data',
67-
workspace.get_default_workspace(),
65+
utils.get_workspace_path(),
6866
}
6967

7068
if opts.use_mason_jdk then
@@ -84,7 +82,7 @@ function M.get_config(opts)
8482

8583
base_config.root_dir = M.get_root_finder(opts.root_markers)
8684
base_config.init_options.bundles = plugin_paths
87-
base_config.init_options.workspace = workspace.get_default_workspace()
85+
base_config.init_options.workspace = utils.get_workspace_path()
8886

8987
log.debug('generated jdtls setup config: ', base_config)
9088

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
local util = require('lspconfig.util')
2+
3+
local join = util.path.join
4+
5+
local M = {}
6+
7+
---Returns the workspace directory path based on the current dir
8+
---@return string
9+
function M.get_workspace_path()
10+
local project_path =
11+
string.gsub(vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h'), '/', '_')
12+
13+
local nvim_cache_path = vim.fn.stdpath('cache')
14+
return join(nvim_cache_path, 'jdtls', 'workspaces', project_path)
15+
end
16+
17+
---Returns the jdtls config cache directory
18+
---@return string
19+
function M.get_jdtls_config_path()
20+
return join(vim.fn.stdpath('cache'), 'jdtls', 'config')
21+
end
22+
23+
return M

lua/java-core/ls/servers/jdtls/workspace.lua

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)