mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-07-25 14:01:06 +00:00
Limit refactor's ft to the supported languages
This commit is contained in:
parent
ec5981dfb1
commit
e4a27015c5
1 changed files with 42 additions and 1 deletions
|
|
@ -1,3 +1,26 @@
|
||||||
|
-- Source: https://github.com/ThePrimeagen/refactoring.nvim/blob/2be7ea3f10b7e59658f5abf6dffc50b5d61964d6/lua/refactoring/config/init.lua#L57
|
||||||
|
local refactoring_supported_ft = {
|
||||||
|
"ts",
|
||||||
|
"js",
|
||||||
|
"typescriptreact",
|
||||||
|
"javascriptreact",
|
||||||
|
"vue",
|
||||||
|
"typescript",
|
||||||
|
"javascript",
|
||||||
|
"java",
|
||||||
|
"lua",
|
||||||
|
"go",
|
||||||
|
"php",
|
||||||
|
"cpp",
|
||||||
|
"c",
|
||||||
|
"h",
|
||||||
|
"hpp",
|
||||||
|
"cxx",
|
||||||
|
"python",
|
||||||
|
"ruby",
|
||||||
|
"cs",
|
||||||
|
}
|
||||||
|
|
||||||
local pick = function()
|
local pick = function()
|
||||||
local refactoring = require("refactoring")
|
local refactoring = require("refactoring")
|
||||||
if LazyVim.pick.picker.name == "telescope" then
|
if LazyVim.pick.picker.name == "telescope" then
|
||||||
|
|
@ -29,11 +52,19 @@ return {
|
||||||
"nvim-lua/plenary.nvim",
|
"nvim-lua/plenary.nvim",
|
||||||
"nvim-treesitter/nvim-treesitter",
|
"nvim-treesitter/nvim-treesitter",
|
||||||
},
|
},
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
keys = {
|
keys = {
|
||||||
{ "<leader>r", "", desc = "+refactor", mode = { "n", "v" } },
|
{
|
||||||
|
"<leader>r",
|
||||||
|
"",
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
|
mode = { "n", "v" },
|
||||||
|
desc = "+refactor",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"<leader>rs",
|
"<leader>rs",
|
||||||
pick,
|
pick,
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
mode = "v",
|
mode = "v",
|
||||||
desc = "Refactor",
|
desc = "Refactor",
|
||||||
},
|
},
|
||||||
|
|
@ -42,6 +73,7 @@ return {
|
||||||
function()
|
function()
|
||||||
require("refactoring").refactor("Inline Variable")
|
require("refactoring").refactor("Inline Variable")
|
||||||
end,
|
end,
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
mode = { "n", "v" },
|
mode = { "n", "v" },
|
||||||
desc = "Inline Variable",
|
desc = "Inline Variable",
|
||||||
},
|
},
|
||||||
|
|
@ -50,6 +82,7 @@ return {
|
||||||
function()
|
function()
|
||||||
require("refactoring").refactor("Extract Block")
|
require("refactoring").refactor("Extract Block")
|
||||||
end,
|
end,
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
desc = "Extract Block",
|
desc = "Extract Block",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -57,6 +90,7 @@ return {
|
||||||
function()
|
function()
|
||||||
require("refactoring").refactor("Extract Block To File")
|
require("refactoring").refactor("Extract Block To File")
|
||||||
end,
|
end,
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
desc = "Extract Block To File",
|
desc = "Extract Block To File",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -64,6 +98,7 @@ return {
|
||||||
function()
|
function()
|
||||||
require("refactoring").debug.printf({ below = false })
|
require("refactoring").debug.printf({ below = false })
|
||||||
end,
|
end,
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
desc = "Debug Print",
|
desc = "Debug Print",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -71,6 +106,7 @@ return {
|
||||||
function()
|
function()
|
||||||
require("refactoring").debug.print_var({ normal = true })
|
require("refactoring").debug.print_var({ normal = true })
|
||||||
end,
|
end,
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
desc = "Debug Print Variable",
|
desc = "Debug Print Variable",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -78,6 +114,7 @@ return {
|
||||||
function()
|
function()
|
||||||
require("refactoring").debug.cleanup({})
|
require("refactoring").debug.cleanup({})
|
||||||
end,
|
end,
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
desc = "Debug Cleanup",
|
desc = "Debug Cleanup",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -85,6 +122,7 @@ return {
|
||||||
function()
|
function()
|
||||||
require("refactoring").refactor("Extract Function")
|
require("refactoring").refactor("Extract Function")
|
||||||
end,
|
end,
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
mode = "v",
|
mode = "v",
|
||||||
desc = "Extract Function",
|
desc = "Extract Function",
|
||||||
},
|
},
|
||||||
|
|
@ -93,6 +131,7 @@ return {
|
||||||
function()
|
function()
|
||||||
require("refactoring").refactor("Extract Function To File")
|
require("refactoring").refactor("Extract Function To File")
|
||||||
end,
|
end,
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
mode = "v",
|
mode = "v",
|
||||||
desc = "Extract Function To File",
|
desc = "Extract Function To File",
|
||||||
},
|
},
|
||||||
|
|
@ -101,6 +140,7 @@ return {
|
||||||
function()
|
function()
|
||||||
require("refactoring").refactor("Extract Variable")
|
require("refactoring").refactor("Extract Variable")
|
||||||
end,
|
end,
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
mode = "v",
|
mode = "v",
|
||||||
desc = "Extract Variable",
|
desc = "Extract Variable",
|
||||||
},
|
},
|
||||||
|
|
@ -109,6 +149,7 @@ return {
|
||||||
function()
|
function()
|
||||||
require("refactoring").debug.print_var()
|
require("refactoring").debug.print_var()
|
||||||
end,
|
end,
|
||||||
|
ft = refactoring_supported_ft,
|
||||||
mode = "v",
|
mode = "v",
|
||||||
desc = "Debug Print Variable",
|
desc = "Debug Print Variable",
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue