mirror of https://github.com/folke/lazy.nvim.git
feat(cmd): use cmd table instead of trying to create the cmd string. Fixes #472
This commit is contained in:
parent
0dcc9071df
commit
3c29f196f4
|
@ -14,16 +14,22 @@ end
|
||||||
---@param cmd string
|
---@param cmd string
|
||||||
function M:_add(cmd)
|
function M:_add(cmd)
|
||||||
vim.api.nvim_create_user_command(cmd, function(event)
|
vim.api.nvim_create_user_command(cmd, function(event)
|
||||||
|
local command = {
|
||||||
|
cmd = cmd,
|
||||||
|
bang = event.bang or nil,
|
||||||
|
mods = event.smods,
|
||||||
|
args = event.fargs,
|
||||||
|
count = event.count >= 0 and event.count or nil,
|
||||||
|
}
|
||||||
|
|
||||||
|
if event.range == 1 then
|
||||||
|
command.range = { event.line1 }
|
||||||
|
elseif event.range == 2 then
|
||||||
|
command.range = { event.line1, event.line2 }
|
||||||
|
end
|
||||||
|
|
||||||
self:_load(cmd)
|
self:_load(cmd)
|
||||||
vim.cmd(
|
vim.cmd(command)
|
||||||
("%s %s%s%s %s"):format(
|
|
||||||
event.mods or "",
|
|
||||||
event.line1 == event.line2 and "" or event.line1 .. "," .. event.line2,
|
|
||||||
cmd,
|
|
||||||
event.bang and "!" or "",
|
|
||||||
event.args or ""
|
|
||||||
)
|
|
||||||
)
|
|
||||||
end, {
|
end, {
|
||||||
bang = true,
|
bang = true,
|
||||||
range = true,
|
range = true,
|
||||||
|
|
Loading…
Reference in New Issue