diff --git a/lua/lazyvim/plugins/extras/editor/refactoring.lua b/lua/lazyvim/plugins/extras/editor/refactoring.lua new file mode 100644 index 00000000..e5852a3c --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/refactoring.lua @@ -0,0 +1,125 @@ +return { + { + "ThePrimeagen/refactoring.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + }, + keys = { + { + "rs", + function() + require("telescope").extensions.refactoring.refactors() + end, + mode = "v", + desc = "Refactor", + }, + { + "ri", + function() + require("refactoring").refactor("Inline Variable") + end, + mode = { "n", "v" }, + desc = "Inline Variable", + }, + { + "rb", + function() + require("refactoring").refactor("Extract Block") + end, + desc = "Extract Block", + }, + { + "rf", + function() + require("refactoring").refactor("Extract Block To File") + end, + desc = "Extract Block To File", + }, + { + "rP", + function() + require("refactoring").debug.printf({ below = false }) + end, + desc = "Debug Print", + }, + { + "rp", + function() + require("refactoring").debug.print_var({ normal = true }) + end, + desc = "Debug Print Variable", + }, + { + "rc", + function() + require("refactoring").debug.cleanup({}) + end, + desc = "Debug Cleanup", + }, + { + "rf", + function() + require("refactoring").refactor("Extract Function") + end, + mode = "v", + desc = "Extract Function", + }, + { + "rF", + function() + require("refactoring").refactor("Extract Function To File") + end, + mode = "v", + desc = "Extract Function To File", + }, + { + "rx", + function() + require("refactoring").refactor("Extract Variable") + end, + mode = "v", + desc = "Extract Variable", + }, + { + "rp", + function() + require("refactoring").debug.print_var() + end, + mode = "v", + desc = "Debug Print Variable", + }, + }, + opts = { + prompt_func_return_type = { + go = false, + java = false, + cpp = false, + c = false, + h = false, + hpp = false, + cxx = false, + }, + prompt_func_param_type = { + go = false, + java = false, + cpp = false, + c = false, + h = false, + hpp = false, + cxx = false, + }, + printf_statements = {}, + print_var_statements = {}, + }, + config = function(_, opts) + require("refactoring").setup(opts) + if LazyVim.has("telescope.nvim") then + LazyVim.on_load("telescope.nvim", function() + require("telescope").load_extension("refactoring") + end) + end + end, + }, +}