From 0127a5caf733b868da7e4746e5692eb1a7dfb788 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Sat, 14 Jun 2025 19:42:33 +0900 Subject: modified plugins/refactoring.lua --- .../lua/thesiahxyz/plugins/refactoring.lua | 34 +++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/refactoring.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/refactoring.lua index 9c0603c..8bcf274 100644 --- a/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/refactoring.lua +++ b/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/refactoring.lua @@ -9,8 +9,10 @@ return { wk.add({ mode = { "n", "v", "x" }, { "r", group = "Compiler/Refactoring" }, + { "rb", group = "Extract block" }, }) end, + lazy = false, config = function() require("refactoring").setup({ prompt_func_return_type = { @@ -39,16 +41,32 @@ return { print_var_statements = {}, show_success_message = false, }) - vim.keymap.set("x", "re", ":Refactor extract ", { desc = "Extract" }) - vim.keymap.set("x", "rf", ":Refactor extract_to_file ", { desc = "Extract to file" }) - vim.keymap.set("x", "rv", ":Refactor extract_var ", { desc = "Extract variable" }) - vim.keymap.set({ "n", "x" }, "ri", ":Refactor inline_var", { desc = "Refactor inline variable" }) - vim.keymap.set("n", "rI", ":Refactor inline_func", { desc = "Refactor inline function" }) - vim.keymap.set("n", "rb", ":Refactor extract_block", { desc = "Extract block" }) - vim.keymap.set("n", "rbf", ":Refactor extract_block_to_file", { desc = "Extract block to file" }) + vim.keymap.set({ "n", "x" }, "re", function() + return require("refactoring").refactor("Extract Function") + end, { expr = true, desc = "Extract" }) + vim.keymap.set({ "n", "x" }, "rf", function() + return require("refactoring").refactor("Extract Function To File") + end, { expr = true, desc = "Extract to file" }) + vim.keymap.set({ "n", "x" }, "rv", function() + return require("refactoring").refactor("Extract Variable") + end, { expr = true, desc = "Extract variable" }) + vim.keymap.set({ "n", "x" }, "rI", function() + return require("refactoring").refactor("Inline Function") + end, { expr = true, desc = "Refactor inline function" }) + vim.keymap.set({ "n", "x" }, "ri", function() + return require("refactoring").refactor("Inline Variable") + end, { expr = true, desc = "Refactor inline variable" }) + + vim.keymap.set({ "n", "x" }, "rbb", function() + return require("refactoring").refactor("Extract Block") + end, { expr = true, desc = "Extract block" }) + vim.keymap.set({ "n", "x" }, "rbf", function() + return require("refactoring").refactor("Extract Block To File") + end, { expr = true, desc = "Extract block to file" }) + -- prompt for a refactor to apply when the remap is triggered vim.keymap.set({ "n", "x" }, "rs", function() - require("refactoring").select_refactor() + require("refactoring").select_refactor({ prefer_ex_cmd = true }) end, { desc = "Refactor selection" }) -- Note that not all refactor support both normal and visual mode -- load refactoring Telescope extension -- cgit v1.2.3