diff --git a/users/price/dots/.config/nvim/lua/plugins/configs/live-command.lua b/users/price/dots/.config/nvim/lua/plugins/configs/live-command.lua index cbf13383..1449880b 100644 --- a/users/price/dots/.config/nvim/lua/plugins/configs/live-command.lua +++ b/users/price/dots/.config/nvim/lua/plugins/configs/live-command.lua @@ -11,16 +11,25 @@ return { commands = { GG = { cmd = "g" }, 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, }, }