neovim

Personal neovim configuration files
git clone git://gtms.dev/neovim
Log | Files | Refs

refactoring.lua (1772B)


      1 if not pcall(require, 'refactoring') then
      2   return
      3 end
      4 
      5 local refactor = require('refactoring')
      6 refactor.setup({ printf_statements = { dart = { 'print("%s");' } } })
      7 
      8 vim.keymap.set('n', '<space>re', function()
      9   require('refactoring').refactor('Extract Function')
     10 end, { silent = true, desc = 'Refactor Extract Function' })
     11 
     12 vim.keymap.set('v', '<space>rf', function()
     13   require('refactoring').refactor('Extract Function To File')
     14 end, { silent = true, desc = 'Refactor Extract Function To File' })
     15 
     16 vim.keymap.set('n', '<space>rv', function()
     17   require('refactoring').refactor('Extract Variable')
     18 end, { silent = true, desc = 'Refactor Extract Variable' })
     19 
     20 vim.keymap.set('n', '<space>ri', function()
     21   require('refactoring').refactor('Inline Variable')
     22 end, { silent = true, desc = 'Refactor Inline Variable' })
     23 
     24 vim.keymap.set('v', '<space>rr', function()
     25   require('refactoring').select_refactor()
     26 end, { silent = true, desc = 'Refactor Select Refactor' })
     27 
     28 vim.keymap.set('n', '<space>rp', function()
     29   require('refactoring').debug.printf({ below = false })
     30 end, { desc = 'Refactor Debug PrintF' })
     31 
     32 -- Remap in normal mode and passing { normal = true } will automatically find the variable under the cursor and print it
     33 vim.keymap.set('n', '<space>rv', function()
     34   require('refactoring').debug.print_var({ normal = true })
     35 end, { desc = 'Refactor Debug Print Var' })
     36 -- Remap in visual mode will print whatever is in the visual selection
     37 vim.keymap.set('v', '<space>rv', function()
     38   require('refactoring').debug.print_var({})
     39 end, { desc = 'Refactor Debug Print Var' })
     40 
     41 -- Cleanup function: this remap should be made in normal mode
     42 vim.keymap.set('n', '<space>rc', function()
     43   require('refactoring').debug.cleanup({})
     44 end, { desc = 'Refactor Debug Cleanup' })