Skip to content
Open
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: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
vendor/plenary.nvim
.test_plugins
proj
.envrc
.direnv
flake.*
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Just install and start writing `public static void main(String[] args)`.

**Requirements:** Neovim 0.11.5+

**Do not call `vim.lsp.enable('jdtls')` yourself!**

### Using `vim.pack`

```lua
Expand All @@ -60,7 +62,6 @@ vim.pack.add({
})

require('java').setup()
vim.lsp.enable('jdtls')
```

### Using `lazy.nvim`
Expand All @@ -72,7 +73,6 @@ Install using [lazy.nvim](https://github.com/folke/lazy.nvim):
'nvim-java/nvim-java',
config = function()
require('java').setup()
vim.lsp.enable('jdtls')
end,
}
```
Expand Down Expand Up @@ -291,7 +291,7 @@ require('java').settings.change_runtime()
## :clamp: How to Use JDK X.X Version?

<details>

<summary>:small_orange_diamond:details</summary>

Use `vim.lsp.config()` to override the default JDTLS settings:
Expand Down
10 changes: 5 additions & 5 deletions doc/nvim-java.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*nvim-java.txt* For Neovim >= 0.11.5 Last change: 2026 February 05
*nvim-java.txt* For Neovim >= 0.11.5 Last change: 2026 June 08

==============================================================================
Table of Contents *nvim-java-table-of-contents*
Expand Down Expand Up @@ -56,6 +56,8 @@ HOW TO INSTALL *nvim-java-how-to-install*

**Requirements:** Neovim 0.11.5+

**Do not call vim.lsp.enable('jdtls') yourself!**


USING VIM.PACK ~

Expand All @@ -72,25 +74,23 @@ USING VIM.PACK ~
})

require('java').setup()
vim.lsp.enable('jdtls')
<


USING LAZY.NVIM ~

Install using lazy.nvim <https://github.com/folke/lazy.nvim>:
Install using lazy.nvim <https://github.com/folke/lazy.nvim>

>lua
{
'nvim-java/nvim-java',
config = function()
require('java').setup()
vim.lsp.enable('jdtls')
end,
}
<

Yep! That’s all :)
Yep!That’s all :)


COMMANDS *nvim-java-commands*
Expand Down
31 changes: 19 additions & 12 deletions lua/java.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ function M.setup(custom_config)
----------------------------------------------------------------------
local Manager = require('pkgm.manager')
local pkgm = Manager()
local to_install = {}

pkgm:install('jdtls', config.jdtls.version)
table.insert(to_install, { name = 'jdtls', version = config.jdtls.version })

if config.java_test.enable then
----------------------------------------------------------------------
-- test --
----------------------------------------------------------------------
pkgm:install('java-test', config.java_test.version)
table.insert(to_install, { name = 'java-test', version = config.java_test.version })

M.test = {
run_current_class = test_api.run_current_class,
Expand All @@ -54,7 +55,7 @@ function M.setup(custom_config)
----------------------------------------------------------------------
-- debugger --
----------------------------------------------------------------------
pkgm:install('java-debug', config.java_debug_adapter.version)
table.insert(to_install, { name = 'java-debug', version = config.java_debug_adapter.version })
require('java-dap').setup()

M.dap = {
Expand All @@ -65,23 +66,29 @@ function M.setup(custom_config)
end

if config.spring_boot_tools.enable then
pkgm:install('spring-boot-tools', config.spring_boot_tools.version)
table.insert(to_install, { name = 'spring-boot-tools', version = config.spring_boot_tools.version })
end

if config.lombok.enable then
pkgm:install('lombok', config.lombok.version)
table.insert(to_install, { name = 'lombok', version = config.lombok.version })
end

if config.jdk.auto_install then
pkgm:install('openjdk', config.jdk.version)
table.insert(to_install, { name = 'openjdk', version = config.jdk.version })
end

----------------------------------------------------------------------
-- init --
----------------------------------------------------------------------
require('java.startup.lsp_setup').setup(config)
require('java.startup.decompile-watcher').setup()
require('java-refactor').setup()
pkgm:install_all(
to_install,
vim.schedule_wrap(function()
----------------------------------------------------------------------
-- init --
----------------------------------------------------------------------
require('java.startup.lsp_setup').setup(config)
require('java.startup.decompile-watcher').setup()
require('java-refactor').setup()
vim.lsp.enable('jdtls')
Comment thread
diego-velez marked this conversation as resolved.
end)
)
end

----------------------------------------------------------------------
Expand Down
38 changes: 22 additions & 16 deletions lua/pkgm/downloaders/curl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,35 @@ function Curl:_init(opts)
end

---Download file using curl
---@return string|nil # Path to downloaded file, or nil on failure
---@return string|nil # Error message if failed
function Curl:download()
---@param on_finished fun(file_path: string|nil, err: string|nil)
function Curl:download(on_finished)
log.debug('curl downloading:', self.url, 'to', self.dest)
local cmd = string.format(
'curl --retry %d --connect-timeout %d -o %s %s',
local cmd = {
'curl',
'--retry',
self.retry_count,
'--connect-timeout',
self.timeout,
vim.fn.shellescape(self.dest),
vim.fn.shellescape(self.url)
)
'-o',
self.dest,
self.url,
}
log.debug('curl command:', cmd)

local result = vim.fn.system(cmd)
local exit_code = vim.v.shell_error
vim.system(cmd, { text = true }, function(out)
local result = out.stderr
local exit_code = out.code

if exit_code ~= 0 then
log.error('curl failed:', exit_code, result)
return nil, string.format('curl failed (exit %d): %s', exit_code, result)
end
if exit_code ~= 0 then
local err = string.format('curl failed (exit %d): %s', exit_code, result)
log.error(err)
on_finished(nil, err)
return
end

log.debug('curl download completed:', self.dest)
return self.dest, nil
log.debug('curl download completed:', self.dest)
on_finished(self.dest, nil)
end)
end

return Curl
38 changes: 24 additions & 14 deletions lua/pkgm/downloaders/powershell.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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
Expand Down Expand Up @@ -36,8 +35,8 @@ function PowerShell:_init(opts)
end

---Download file using PowerShell
---@return string # Path to downloaded file
function PowerShell:download()
---@param on_finished fun(file_path: string|nil, err: string|nil)
function PowerShell:download(on_finished)
local pwsh = vim.fn.executable('pwsh') == 1 and 'pwsh' or 'powershell'
log.debug('PowerShell downloading:', self.url, 'to', self.dest)
log.debug('Using PowerShell binary:', pwsh)
Expand All @@ -49,24 +48,35 @@ function PowerShell:download()
self.dest
)

local cmd = string.format(
local inner_cmd = string.format(
-- luacheck: ignore
"%s -NoProfile -NonInteractive -Command \"$ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; %s\"",
pwsh,
"$ProgressPreference = 'SilentlyContinue'; $ErrorActionPreference = 'Stop'; [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; %s",
pwsh_cmd
)

local cmd = {
pwsh,
'-NoProfile',
'-NonInteractive',
'-Command',
inner_cmd,
}
log.debug('PowerShell command:', cmd)

local result = vim.fn.system(cmd)
local exit_code = vim.v.shell_error
vim.system(cmd, { text = true }, function(out)
local result = out.stderr
local exit_code = out.code

if exit_code ~= 0 then
local err = string.format('PowerShell download failed (exit %d): %s', exit_code, result)
err_util.throw(err)
end
if exit_code ~= 0 then
local err = string.format('PowerShell download failed (exit %d): %s', exit_code, result)
log.error(err)
on_finished(nil, err)
return
end

log.debug('PowerShell download completed:', self.dest)
return self.dest
log.debug('PowerShell download completed:', self.dest)
on_finished(self.dest)
end)
end

return PowerShell
38 changes: 22 additions & 16 deletions lua/pkgm/downloaders/wget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,35 @@ function Wget:_init(opts)
end

---Download file using wget
---@return string|nil # Path to downloaded file, or nil on failure
---@return string|nil # Error message if failed
function Wget:download()
---@param on_finished fun(file_path: string|nil, err: string|nil)
function Wget:download(on_finished)
log.debug('wget downloading:', self.url, 'to', self.dest)
local cmd = string.format(
'wget -t %d -T %d -O %s %s',
local cmd = {
'wget',
'-t',
self.retry_count,
'-T',
self.timeout,
vim.fn.shellescape(self.dest),
vim.fn.shellescape(self.url)
)
'-O',
self.dest,
self.url,
}
log.debug('wget command:', cmd)

local result = vim.fn.system(cmd)
local exit_code = vim.v.shell_error
vim.system(cmd, { text = true }, function(out)
local result = out.stderr
local exit_code = out.code

if exit_code ~= 0 then
log.error('wget failed:', exit_code, result)
return nil, string.format('wget failed (exit %d): %s', exit_code, result)
end
if exit_code ~= 0 then
local err = string.format('wget failed (exit %d): %s', exit_code, result)
log.error(err)
on_finished(nil, err)
return
end
Comment thread
diego-velez marked this conversation as resolved.

log.debug('wget download completed:', self.dest)
return self.dest, nil
log.debug('wget download completed:', self.dest)
on_finished(self.dest, nil)
end)
end

return Wget
Loading