From b45d4ed62c613a4c47dd9183cf51985f2b153b21 Mon Sep 17 00:00:00 2001 From: Iordanis Petkakis <12776461+dpetka2001@users.noreply.github.com> Date: Sun, 23 Jun 2024 08:01:58 +0300 Subject: [PATCH] fix(refactoring): use `pick` for both Telescope and fzf-lua (#3769) ## What is this PR for? Provide a `pick` function to `refactoring.nvim` similar to `project.nvim` ## Does this PR fix an existing issue? Fixes #3762 ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines. --- .../plugins/extras/editor/refactoring.lua | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/lua/lazyvim/plugins/extras/editor/refactoring.lua b/lua/lazyvim/plugins/extras/editor/refactoring.lua index 9d8f8f9c..29920347 100644 --- a/lua/lazyvim/plugins/extras/editor/refactoring.lua +++ b/lua/lazyvim/plugins/extras/editor/refactoring.lua @@ -1,3 +1,24 @@ +local pick = function() + if LazyVim.pick.picker.name == "telescope" then + return require("telescope").extensions.refactoring.refactors() + elseif LazyVim.pick.picker.name == "fzf" then + local fzf_lua = require("fzf-lua") + local results = require("refactoring").get_refactors() + local refactoring = require("refactoring") + + local opts = { + fzf_opts = {}, + fzf_colors = true, + actions = { + ["default"] = function(selected) + refactoring.refactor(selected[1]) + end, + }, + } + fzf_lua.fzf_exec(results, opts) + end +end + return { { "ThePrimeagen/refactoring.nvim", @@ -10,9 +31,7 @@ return { { "r", "", desc = "+refactor", mode = { "n", "v" } }, { "rs", - function() - require("telescope").extensions.refactoring.refactors() - end, + pick, mode = "v", desc = "Refactor", },