fix(nvim): update live command to use v2 setup
This commit is contained in:
parent
3e48185577
commit
0792690518
@ -11,16 +11,25 @@ return {
|
|||||||
commands = {
|
commands = {
|
||||||
GG = { cmd = "g" },
|
GG = { cmd = "g" },
|
||||||
Norm = { cmd = "norm" },
|
Norm = { cmd = "norm" },
|
||||||
Reg = {
|
|
||||||
cmd = "norm",
|
|
||||||
-- This will transform ":5Reg a" into ":norm 5@a"
|
|
||||||
args = function(opts)
|
|
||||||
return (opts.count == -1 and "" or opts.count) .. "@" .. opts.args
|
|
||||||
end,
|
|
||||||
range = "",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
-- Transforms ":5Reg a" into ":norm 5@a"
|
||||||
|
local function get_command_string(cmd)
|
||||||
|
local get_range_string = require("live-command").get_range_string
|
||||||
|
local args = (cmd.count == -1 and "" or cmd.count) .. "@" .. cmd.args
|
||||||
|
return get_range_string(cmd) .. "norm " .. args
|
||||||
|
end
|
||||||
|
|
||||||
|
vim.api.nvim_create_user_command("Reg", function(cmd)
|
||||||
|
vim.cmd(get_command_string(cmd))
|
||||||
|
end, {
|
||||||
|
nargs = "?",
|
||||||
|
range = true,
|
||||||
|
preview = function(cmd, preview_ns, preview_buf)
|
||||||
|
local cmd_to_preview = get_command_string(cmd)
|
||||||
|
return require("live-command").preview_callback(cmd_to_preview, preview_ns, preview_buf)
|
||||||
|
end,
|
||||||
|
})
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user