Skip to content

Commit

Permalink
fix(editing-support): wrap all require calls to refactoring in function
Browse files Browse the repository at this point in the history
Before this, I got a module not found error. Wrapping it in a function, the require call is deferred until the keypress is run where the module is now available
  • Loading branch information
jay-babu authored Jan 1, 2024
1 parent 3027bdc commit 82304d9
Showing 1 changed file with 52 additions and 16 deletions.
68 changes: 52 additions & 16 deletions lua/astrocommunity/editing-support/refactoring-nvim/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,28 @@ return {
opts = {
mappings = {
n = {
["<Leader>rb"] = { require("refactoring").refactor "Extract Block", desc = "Extract Block" },
["<Leader>ri"] = { require("refactoring").refactor "Inline Variable", desc = "Inline Variable" },
["<Leader>rp"] = { require("refactoring").debug.printf { below = false }, desc = "Debug: Print Function" },
["<Leader>rc"] = { require("refactoring").debug.cleanup {}, desc = "Debug: Clean Up" },
["<Leader>rb"] = {
function() require("refactoring").refactor "Extract Block" end,
desc = "Extract Block",
},
["<Leader>ri"] = {
function() require("refactoring").refactor "Inline Variable" end,
desc = "Inline Variable",
},
["<Leader>rp"] = {
function() require("refactoring").debug.printf { below = false } end,
desc = "Debug: Print Function",
},
["<Leader>rc"] = {
function() require("refactoring").debug.cleanup {} end,
desc = "Debug: Clean Up",
},
["<Leader>rd"] = {
require("refactoring").debug.print_var { below = false },
function() require("refactoring").debug.print_var { below = false } end,
desc = "Debug: Print Variable",
},
["<Leader>rbf"] = {
require("refactoring").refactor "Extract Block To File",
function() require("refactoring").refactor "Extract Block To File" end,
desc = "Extract Block To File",
},
},
Expand All @@ -30,8 +42,14 @@ return {
function() require("refactoring").refactor "Extract Function To File" end,
desc = "Extract Function To File",
},
["<leadeer>rv"] = { require("refactoring").refactor "Extract Variable", desc = "Extract Variable" },
["<Leader>ri"] = { require("refactoring").refactor "Inline Variable", desc = "Inline Variable" },
["<Leader>rv"] = {
function() require("refactoring").refactor "Extract Variable" end,
desc = "Extract Variable",
},
["<Leader>ri"] = {
function() require("refactoring").refactor "Inline Variable" end,
desc = "Inline Variable",
},
},
v = {
["<Leader>re"] = {
Expand All @@ -42,18 +60,36 @@ return {
function() require("refactoring").refactor "Extract Function To File" end,
desc = "Extract Function To File",
},
["<leadeer>rv"] = { require("refactoring").refactor "Extract Variable", desc = "Extract Variable" },
["<Leader>ri"] = { require("refactoring").refactor "Inline Variable", desc = "Inline Variable" },
["<Leader>rb"] = { require("refactoring").refactor "Extract Block", desc = "Extract Block" },
["<Leader>rv"] = {
function() require("refactoring").refactor "Extract Variable" end,
desc = "Extract Variable",
},
["<Leader>ri"] = {
function() require("refactoring").refactor "Inline Variable" end,
desc = "Inline Variable",
},
["<Leader>rb"] = {
function() require("refactoring").refactor "Extract Block" end,
desc = "Extract Block",
},
["<Leader>rbf"] = {
require("refactoring").refactor "Extract Block To File",
function() require("refactoring").refactor "Extract Block To File" end,
desc = "Extract Block To File",
},
["<Leader>rr"] = { require("refactoring").select_refactor, desc = "Select Refactor" },
["<Leader>rp"] = { require("refactoring").debug.printf { below = false }, desc = "Debug: Print Function" },
["<Leader>rc"] = { require("refactoring").debug.cleanup {}, desc = "Debug: Clean Up" },
["<Leader>rr"] = {
function() require("refactoring").select_refactor() end,
desc = "Select Refactor",
},
["<Leader>rp"] = {
function() require("refactoring").debug.printf { below = false } end,
desc = "Debug: Print Function",
},
["<Leader>rc"] = {
function() require("refactoring").debug.cleanup {} end,
desc = "Debug: Clean Up",
},
["<Leader>rd"] = {
require("refactoring").debug.print_var { below = false },
function() require("refactoring").debug.print_var { below = false } end,
desc = "Debug: Print Variable",
},
},
Expand Down

0 comments on commit 82304d9

Please sign in to comment.