feat(extras): enhance incremane

bind C+u to clean renaming words
This commit is contained in:
zeekrs 2024-06-08 18:46:37 +08:00
parent 51854046db
commit 5dbb4c04ec

View file

@ -1,3 +1,18 @@
-- enhances the 'IncRename' command cleaning
-- retaining only 'IncRename ' if the command starts with it and has additional characters.
local function enhance_rename_cleaner()
local cmd_line = vim.fn.getcmdline()
local prefix = "IncRename "
local prefix_length = #prefix
if cmd_line:sub(1, prefix_length) == prefix and #cmd_line > prefix_length then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-u>" .. prefix, true, true, true), "n")
else
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<C-u>", true, true, true), "n")
end
end
vim.keymap.set("c", "<C-u>", enhance_rename_cleaner, { noremap = true, silent = false })
return {
-- Rename with cmdpreview