Skip to content

Commit

Permalink
feat(cmd): use cmd table instead of trying to create the cmd string. F…
Browse files Browse the repository at this point in the history
…ixes #472
  • Loading branch information
folke committed Feb 7, 2023
1 parent 0dcc907 commit 3c29f19
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lua/lazy/core/handler/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,22 @@ end
---@param cmd string
function M:_add(cmd)
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)
vim.cmd(
("%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 ""
)
)
vim.cmd(command)
end, {
bang = true,
range = true,
Expand Down

0 comments on commit 3c29f19

Please sign in to comment.