mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-22 08:53:33 +02:00
fix(pick): allow configuring pickers without LazyExtras. Fixes #3626
This commit is contained in:
parent
c9380a309d
commit
304e7439aa
5 changed files with 42 additions and 2 deletions
|
@ -5,6 +5,12 @@ vim.g.maplocalleader = "\\"
|
||||||
-- LazyVim auto format
|
-- LazyVim auto format
|
||||||
vim.g.autoformat = true
|
vim.g.autoformat = true
|
||||||
|
|
||||||
|
-- LazyVim picker to use.
|
||||||
|
-- Can be one of: telescope, fzf
|
||||||
|
-- Leave it to "auto" to automatically use the picker
|
||||||
|
-- enabled with `:LazyExtras`
|
||||||
|
vim.g.lazyvim_picker = "auto"
|
||||||
|
|
||||||
-- LazyVim root dir detection
|
-- LazyVim root dir detection
|
||||||
-- Each entry can be:
|
-- Each entry can be:
|
||||||
-- * the name of a detector function like `lsp` or `cwd`
|
-- * the name of a detector function like `lsp` or `cwd`
|
||||||
|
|
|
@ -301,13 +301,13 @@ return {
|
||||||
{
|
{
|
||||||
import = "lazyvim.plugins.extras.editor.fzf",
|
import = "lazyvim.plugins.extras.editor.fzf",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
return LazyVim.has_extra("editor.fzf")
|
return LazyVim.pick.want() == "fzf"
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
import = "lazyvim.plugins.extras.editor.telescope",
|
import = "lazyvim.plugins.extras.editor.telescope",
|
||||||
enabled = function()
|
enabled = function()
|
||||||
return not LazyVim.has_extra("editor.fzf")
|
return LazyVim.pick.want() == "telescope"
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
if lazyvim_docs then
|
||||||
|
-- In case you don't want to use `:LazyExtras`,
|
||||||
|
-- then you need to set the option below.
|
||||||
|
vim.g.lazyvim_picker = "fzf"
|
||||||
|
end
|
||||||
|
|
||||||
---@class FzfLuaOpts: lazyvim.util.pick.Opts
|
---@class FzfLuaOpts: lazyvim.util.pick.Opts
|
||||||
---@field cmd string?
|
---@field cmd string?
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
if lazyvim_docs then
|
||||||
|
-- In case you don't want to use `:LazyExtras`,
|
||||||
|
-- then you need to set the option below.
|
||||||
|
vim.g.lazyvim_picker = "telescope"
|
||||||
|
end
|
||||||
|
|
||||||
local have_make = vim.fn.executable("make") == 1
|
local have_make = vim.fn.executable("make") == 1
|
||||||
local have_cmake = vim.fn.executable("cmake") == 1
|
local have_cmake = vim.fn.executable("cmake") == 1
|
||||||
|
|
||||||
|
@ -49,6 +55,9 @@ return {
|
||||||
{
|
{
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
cmd = "Telescope",
|
cmd = "Telescope",
|
||||||
|
enabled = function()
|
||||||
|
return LazyVim.pick.want() == "telescope"
|
||||||
|
end,
|
||||||
version = false, -- telescope did only one release, so use HEAD for now
|
version = false, -- telescope did only one release, so use HEAD for now
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{
|
{
|
||||||
|
@ -228,6 +237,9 @@ return {
|
||||||
{
|
{
|
||||||
"stevearc/dressing.nvim",
|
"stevearc/dressing.nvim",
|
||||||
lazy = true,
|
lazy = true,
|
||||||
|
enabled = function()
|
||||||
|
return LazyVim.pick.want() == "telescope"
|
||||||
|
end,
|
||||||
init = function()
|
init = function()
|
||||||
---@diagnostic disable-next-line: duplicate-set-field
|
---@diagnostic disable-next-line: duplicate-set-field
|
||||||
vim.ui.select = function(...)
|
vim.ui.select = function(...)
|
||||||
|
@ -245,6 +257,9 @@ return {
|
||||||
{
|
{
|
||||||
"neovim/nvim-lspconfig",
|
"neovim/nvim-lspconfig",
|
||||||
opts = function()
|
opts = function()
|
||||||
|
if LazyVim.pick.want() ~= "telescope" then
|
||||||
|
return
|
||||||
|
end
|
||||||
local Keys = require("lazyvim.plugins.lsp.keymaps").get()
|
local Keys = require("lazyvim.plugins.lsp.keymaps").get()
|
||||||
-- stylua: ignore
|
-- stylua: ignore
|
||||||
vim.list_extend(Keys, {
|
vim.list_extend(Keys, {
|
||||||
|
|
|
@ -32,6 +32,11 @@ function M.register(picker)
|
||||||
if vim.v.vim_did_enter == 1 then
|
if vim.v.vim_did_enter == 1 then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if M.picker and M.picker.name ~= M.want() then
|
||||||
|
M.picker = nil
|
||||||
|
end
|
||||||
|
|
||||||
if M.picker and M.picker.name ~= picker.name then
|
if M.picker and M.picker.name ~= picker.name then
|
||||||
LazyVim.warn(
|
LazyVim.warn(
|
||||||
"`LazyVim.pick`: picker already set to `" .. M.picker.name .. "`,\nignoring new picker `" .. picker.name .. "`"
|
"`LazyVim.pick`: picker already set to `" .. M.picker.name .. "`,\nignoring new picker `" .. picker.name .. "`"
|
||||||
|
@ -42,6 +47,14 @@ function M.register(picker)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function M.want()
|
||||||
|
vim.g.lazyvim_picker = vim.g.lazyvim_picker or "auto"
|
||||||
|
if vim.g.lazyvim_picker == "auto" then
|
||||||
|
return LazyVim.has_extra("editor.fzf") and "fzf" or "telescope"
|
||||||
|
end
|
||||||
|
return vim.g.lazyvim_picker
|
||||||
|
end
|
||||||
|
|
||||||
---@param command? string
|
---@param command? string
|
||||||
---@param opts? lazyvim.util.pick.Opts
|
---@param opts? lazyvim.util.pick.Opts
|
||||||
function M.open(command, opts)
|
function M.open(command, opts)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue