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
3 changes: 1 addition & 2 deletions .devcontainer/config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
"nui.nvim": { "branch": "main", "commit": "de740991c12411b663994b2860f1a4fd0937c130" },
"nvim-dap": { "branch": "master", "commit": "b38f7d30366d9169d0a623c4c85fbcf99d8d58bb" },
"nvim-jdtls": { "branch": "master", "commit": "943e2398aba6b7e976603708450c6c93c600e830" },
"nvim-dap": { "branch": "master", "commit": "5860c7c501eb428d3137ee22c522828d20cca0b3" },
"spring-boot.nvim": { "branch": "main", "commit": "218c0c26c14d99feca778e4d13f5ec3e8b1b60f0" }
}
28 changes: 26 additions & 2 deletions lua/java-core/ls/servers/jdtls/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ function M.get_cmd(opts)
return function(dispatchers, config)
local cmd = M.get_jvm_args(opts):concat(M.get_jar_args())

M.validate_java_version(config.cmd_env)
-- NOTE: eventhough we are setting the PATH env var, due to a bug, it's not
-- working on Windows. So just lanching 'java' will result in executing the
-- system java. So as a workaround, we use the absolute path to java instead
-- So following check is not needed when we have auto_install set to true
-- @see https://github.com/neovim/neovim/issues/36818
if not conf.jdk.auto_install then
M.validate_java_version(config.cmd_env)
end

log.debug('Starting jdtls with cmd', cmd)

Expand All @@ -40,8 +47,25 @@ end
function M.get_jvm_args(opts)
local jdtls_config = path.join(jdtls_root, system.get_config_suffix())

local java_exe = 'java'

-- NOTE: eventhough we are setting the PATH env var, due to a bug, it's not
-- working on Windows. So we are using the absolute path to java instead
-- @see https://github.com/neovim/neovim/issues/36818
if conf.jdk.auto_install then
local jdk_root = Manager:get_install_dir('openjdk', conf.jdk.version)
local java_home
if system.get_os() == 'mac' then
java_home = vim.fn.glob(path.join(jdk_root, 'jdk-*', 'Contents', 'Home'))
else
java_home = vim.fn.glob(path.join(jdk_root, 'jdk-*'))
end

java_exe = path.join(java_home, 'bin', 'java')
end

local jvm_args = List:new({
'java',
java_exe,
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
'-Dosgi.bundles.defaultStartLevel=4',
'-Declipse.product=org.eclipse.jdt.ls.core.product',
Expand Down
5 changes: 4 additions & 1 deletion lua/pkgm/downloaders/powershell.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
local class = require('java-core.utils.class')
local log = require('java-core.utils.log2')
local err_util = require('java-core.utils.errors')
local path = require('java-core.utils.path')

---@class java-core.PowerShell
---@field url string
Expand All @@ -21,7 +22,9 @@ function PowerShell:_init(opts)

if not opts.dest then
local filename = vim.fs.basename(opts.url)
self.dest = vim.fn.tempname() .. '-' .. filename
local tmp_dir = vim.fn.tempname()
vim.fn.mkdir(tmp_dir, 'p')
self.dest = path.join(tmp_dir, filename)
log.debug('Using temp destination:', self.dest)
else
self.dest = opts.dest
Expand Down
20 changes: 19 additions & 1 deletion lua/pkgm/extractors/tar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ function Tar:_init(opts)
self.dest = opts.dest
end

---@private
---Check if tar supports --force-local
---@param tar_cmd string
---@return boolean
function Tar:tar_supports_force_local(tar_cmd)
local ok, out = pcall(vim.fn.system, { tar_cmd, '--help' })
if not ok then
return false
end
return out:match('%-%-force%-local') ~= nil
end

---Extract tar file using tar
---@return boolean|nil # true on success, nil on failure
---@return string|nil # Error message if failed
Expand All @@ -30,7 +42,13 @@ function Tar:extract()
-- Windows: convert backslashes to forward slashes (tar accepts them)
local source = self.source:gsub('\\', '/')
local dest = self.dest:gsub('\\', '/')
cmd = string.format('%s --no-same-owner --force-local -xf "%s" -C "%s"', tar_cmd, source, dest)
cmd = string.format(
'%s --no-same-owner %s -xf "%s" -C "%s"',
tar_cmd,
self:tar_supports_force_local(tar_cmd) and '--force-local' or '',
source,
dest
)
else
-- Unix: use shellescape
cmd = string.format(
Expand Down
4 changes: 4 additions & 0 deletions tests/specs/lsp_spec.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local lsp_utils = dofile('tests/utils/lsp-utils.lua')
local assert = require('luassert')
local system = require('java-core.utils.system')

describe('LSP Attach', function()
it('should attach when opening a Java buffer', function()
Expand All @@ -8,6 +9,9 @@ describe('LSP Attach', function()
local jdtls = lsp_utils.wait_for_lsp_attach('jdtls', 30000)
local spring = lsp_utils.wait_for_lsp_attach('spring-boot', 30000)

if system.get_os() == 'win' then
vim.fn.readfile('C:/Users/runneradmin/AppData/Local/nvim-data/lsp.log')
end
assert.is_not_nil(jdtls, 'JDTLS should attach to Java buffer')
assert.is_not_nil(spring, 'Spring Boot should attach to Java buffer')
end)
Expand Down