mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
Fix "Run with Args" for Java
This commit is contained in:
parent
a7b4c4391b
commit
7a0731212f
1 changed files with 28 additions and 1 deletions
|
|
@ -1,5 +1,20 @@
|
||||||
|
---@param config {args?:string|fun():string?}
|
||||||
|
local function get_args_as_string(config)
|
||||||
|
local args = type(config.args) == "function" and (config.args() or "") or config.args or ""
|
||||||
|
---@cast args string
|
||||||
|
if string.len(args) > 0 then
|
||||||
|
args = args .. " "
|
||||||
|
end
|
||||||
|
config = vim.deepcopy(config)
|
||||||
|
config.args = function()
|
||||||
|
local new_args = vim.fn.input("Run with args: ", args) --[[@as string]]
|
||||||
|
return new_args --[[@as string]]
|
||||||
|
end
|
||||||
|
return config
|
||||||
|
end
|
||||||
|
|
||||||
---@param config {args?:string[]|fun():string[]?}
|
---@param config {args?:string[]|fun():string[]?}
|
||||||
local function get_args(config)
|
local function get_args_as_table(config)
|
||||||
local args = type(config.args) == "function" and (config.args() or {}) or config.args or {}
|
local args = type(config.args) == "function" and (config.args() or {}) or config.args or {}
|
||||||
config = vim.deepcopy(config)
|
config = vim.deepcopy(config)
|
||||||
---@cast args string[]
|
---@cast args string[]
|
||||||
|
|
@ -10,6 +25,18 @@ local function get_args(config)
|
||||||
return config
|
return config
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param config {type?:string}
|
||||||
|
local function get_args(config)
|
||||||
|
--- Java Dap expects "args" to be a string, not a table
|
||||||
|
if config.type and config.type == "java" then
|
||||||
|
---@cast config {type?:string, args?:string|fun():string?}
|
||||||
|
return get_args_as_string(config)
|
||||||
|
else
|
||||||
|
---@cast config {type?:string, args?:string[]|fun():string[]?}
|
||||||
|
return get_args_as_table(config)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
{
|
{
|
||||||
"mfussenegger/nvim-dap",
|
"mfussenegger/nvim-dap",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue