summaryrefslogtreecommitdiff
path: root/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/refactoring.lua
diff options
context:
space:
mode:
authorTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-24 20:35:27 +0900
committerTheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com>2025-01-24 20:35:27 +0900
commitc80a54e42b52ce297f0f2f71af23c562832025c7 (patch)
treedcce8bb977a770f473325d48f6f70b21d9818a40 /ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/refactoring.lua
init
Diffstat (limited to 'ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/refactoring.lua')
-rw-r--r--ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/refactoring.lua60
1 files changed, 60 insertions, 0 deletions
diff --git a/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/refactoring.lua b/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/refactoring.lua
new file mode 100644
index 0000000..9c0603c
--- /dev/null
+++ b/ar/.config/TheSiahxyz/lua/thesiahxyz/plugins/refactoring.lua
@@ -0,0 +1,60 @@
+return {
+ "ThePrimeagen/refactoring.nvim",
+ dependencies = {
+ "nvim-lua/plenary.nvim",
+ "nvim-treesitter/nvim-treesitter",
+ },
+ init = function()
+ local wk = require("which-key")
+ wk.add({
+ mode = { "n", "v", "x" },
+ { "<leader>r", group = "Compiler/Refactoring" },
+ })
+ end,
+ config = function()
+ require("refactoring").setup({
+ prompt_func_return_type = {
+ c = true,
+ cpp = true,
+ cxx = true,
+ go = true,
+ h = true,
+ hpp = true,
+ java = true,
+ lua = true,
+ python = true,
+ },
+ prompt_func_param_type = {
+ c = true,
+ cpp = true,
+ cxx = true,
+ go = true,
+ h = true,
+ hpp = true,
+ java = true,
+ lua = true,
+ python = true,
+ },
+ printf_statements = {},
+ print_var_statements = {},
+ show_success_message = false,
+ })
+ vim.keymap.set("x", "<leader>re", ":Refactor extract ", { desc = "Extract" })
+ vim.keymap.set("x", "<leader>rf", ":Refactor extract_to_file ", { desc = "Extract to file" })
+ vim.keymap.set("x", "<leader>rv", ":Refactor extract_var ", { desc = "Extract variable" })
+ vim.keymap.set({ "n", "x" }, "<leader>ri", ":Refactor inline_var", { desc = "Refactor inline variable" })
+ vim.keymap.set("n", "<leader>rI", ":Refactor inline_func", { desc = "Refactor inline function" })
+ vim.keymap.set("n", "<leader>rb", ":Refactor extract_block", { desc = "Extract block" })
+ vim.keymap.set("n", "<leader>rbf", ":Refactor extract_block_to_file", { desc = "Extract block to file" })
+ -- prompt for a refactor to apply when the remap is triggered
+ vim.keymap.set({ "n", "x" }, "<leader>rs", function()
+ require("refactoring").select_refactor()
+ end, { desc = "Refactor selection" })
+ -- Note that not all refactor support both normal and visual mode
+ -- load refactoring Telescope extension
+ require("telescope").load_extension("refactoring")
+ vim.keymap.set({ "n", "x" }, "<leader>rf", function()
+ require("telescope").extensions.refactoring.refactors()
+ end, { desc = "Open refactor" })
+ end,
+}