Skip to content

Commit

Permalink
doc: add command desc
Browse files Browse the repository at this point in the history
  • Loading branch information
chenasraf committed May 5, 2024
1 parent ecd4d6b commit 972a44c
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions lua/text-transform/commands.lua
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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

0 comments on commit 972a44c

Please sign in to comment.