marleyvim/nvim/lua/plugins/editor/refactoring-nvim.lua

127 lines
2.8 KiB
Lua
Raw Normal View History

2025-01-03 20:02:38 -08:00
return {
'refactoring.nvim',
event = { 'BufReadPre', 'BufNewFile' },
keys = {
{ '<LEADER>r', '', desc = '+refactor', mode = { 'n', 'v' } },
{
'<LEADER>rb',
function()
require('refactoring').refactor('Extract Block')
end,
desc = 'extract block',
},
{
'<LEADER>rc',
function()
require('refactoring').debug.cleanup({})
end,
desc = 'debug cleanup',
},
{
'<LEADER>rf',
function()
require('refactoring').refactor('Extract Block To File')
end,
desc = 'extract block to file',
},
{
'<LEADER>rf',
function()
require('refactoring').refactor('Extract Function')
end,
mode = 'v',
desc = 'extract function',
},
{
'<LEADER>rF',
function()
require('refactoring').refactor('Extract Function To File')
end,
mode = 'v',
desc = 'extract function to file',
},
{
'<LEADER>ri',
function()
require('refactoring').refactor('Inline Variable')
end,
mode = { 'n', 'v' },
desc = 'inline variable',
},
{
'<LEADER>rp',
function()
require('refactoring').debug.print_var({ normal = true })
end,
desc = 'debug print variable',
},
{
'<LEADER>rp',
function()
require('refactoring').debug.print_var()
end,
mode = 'v',
desc = 'debug print variable',
},
{
'<LEADER>rP',
function()
require('refactoring').debug.printf({ below = false })
end,
desc = 'debug print',
},
{
'<LEADER>rs',
function()
require('fzf-lua').fzf_exec(require('refactoring').get_refactors(), {
fzf_opts = {},
fzf_colors = true,
actions = {
['default'] = function(selected)
require('refactoring').refactor(selected[1])
end,
},
})
end,
mode = 'v',
desc = 'refactor',
},
{
'<LEADER>rx',
function()
require('refactoring').refactor('Extract Variable')
end,
mode = 'v',
desc = 'extract variable',
},
},
before = function()
require('lz.n').trigger_load({ 'plenary.nvim', 'nvim-treesitter' })
end,
after = function()
require('refactoring').setup({
prompt_func_param_type = {
go = false,
java = false,
cpp = false,
c = false,
h = false,
hpp = false,
cxx = false,
},
prompt_func_return_type = {
go = false,
java = false,
cpp = false,
c = false,
h = false,
hpp = false,
cxx = false,
},
printf_statements = {},
print_var_statements = {},
show_success_message = false,
})
end,
}