Skip to content

Refactoring Extra

editor.refactoring installs refactoring.nvim, a Treesitter-powered refactoring helper for extracting, inlining, and print-debug workflows.

Enable it

return {
extras = {
enabled = {
"editor.refactoring",
},
},
}

Because this extra adds a plugin, run:

:BlakExtras sync

What it adds

SurfaceContribution
PluginThePrimeagen/refactoring.nvim
Dependenciesplenary.nvim, nvim-treesitter
Keymap<leader>re extracts a function
Keymap<leader>rf extracts a function to a file
Keymap<leader>rv extracts a variable
Keymap<leader>ri inlines a variable
Keymap<leader>rI inlines a function
Keymap<leader>rp inserts a print-debug statement
Keymap<leader>rc cleans up print-debug statements

The keymaps appear in :BlakKeys.

Most refactors are visual-mode actions because they operate on a selected code range.