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`
<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

## Does this PR fix an existing issue?
Fixes #3762
<!--
  If this PR fixes any issues, please link to the issue here.
  Fixes #<issue_number>
-->

## Checklist

- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
This commit is contained in:
Iordanis Petkakis
2024-06-23 08:01:58 +03:00
committed by GitHub
parent 55464b77c6
commit b45d4ed62c

View File

@ -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 {
{ "<leader>r", "", desc = "+refactor", mode = { "n", "v" } },
{
"<leader>rs",
function()
require("telescope").extensions.refactoring.refactors()
end,
pick,
mode = "v",
desc = "Refactor",
},