diff --git a/lua/text-transform/commands.lua b/lua/text-transform/commands.lua index 257f9a9..ec188eb 100644 --- a/lua/text-transform/commands.lua +++ b/lua/text-transform/commands.lua @@ -1,7 +1,9 @@ -- local D = require("text-transform.util.debug") +local util = require("text-transform.util") local state = require("text-transform.state") local replacers = require("text-transform.replacers") local popup = require("text-transform.popup") +local common = require("text-transform.popup_common") local TextTransform = {} --- Initializes user commands @@ -18,26 +20,36 @@ function TextTransform.init_commands() } local cmdopts = { range = true, force = true } + local opts = function(desc) + return util.merge(cmdopts, { desc = desc }) + end for cmd, transformer_name in pairs(map) do + local item + for _, t in ipairs(common.items) do + if t.value == transformer_name then + item = t.label + break + end + end vim.api.nvim_create_user_command(cmd, function() state.save_positions() replacers.replace_selection(transformer_name) - end, cmdopts) + end, opts("Change to " .. item)) end -- specific popups vim.api.nvim_create_user_command("TtTelescope", function() local telescope = require("text-transform.telescope") telescope.telescope_popup() - end, cmdopts) + end, opts("Change Case with Telescope")) vim.api.nvim_create_user_command("TtSelect", function() local select = require("text-transform.select") select.select_popup() - end, cmdopts) + end, opts("Change Case with Select")) -- auto popup by config - vim.api.nvim_create_user_command("TextTransform", popup.show_popup, {}) + vim.api.nvim_create_user_command("TextTransform", popup.show_popup, opts("Change Case")) end return TextTransform