Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lua/java-core/ls/servers/jdtls/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ local M = {}
---Returns the workspace directory path based on the current dir
---@return string
function M.get_workspace_path()
local project_path =
string.gsub(vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h'), '/', '_')
local project_path = vim.fn.fnamemodify(vim.fn.getcwd(), ':p:h')
local project_path_hash = string.gsub(project_path, '[/\\:+-]', '_')

local nvim_cache_path = vim.fn.stdpath('cache')
return join(nvim_cache_path, 'jdtls', 'workspaces', project_path)
return join(nvim_cache_path, 'jdtls', 'workspaces', project_path_hash)
end

---Returns the jdtls config cache directory
Expand Down
8 changes: 7 additions & 1 deletion lua/java-core/utils/path.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
local M = {}

if vim.fn.has('win32') == 1 or vim.fn.has('win32unix') == 1 then
M.path_separator = '\\'
else
M.path_separator = '/'
end

---Join a given list of paths to one path
---@param ... string paths to join
---@return string # joined path
function M.join(...)
return table.concat({ ... }, '/')
return table.concat({ ... }, M.path_separator)
end

return M