mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-23 12:16:24 +02:00
feat(pick): move pickers to extras (telescope still the default) (#3606)
## What is this PR for? Refactoring of pickers in LazyVim: - [x] telescope moved to extras - [x] dressing was moved to the telescope extra. Not needed with fzf-lua and noice - [x] when none of the two is enabled, then telescope will be enabled - [x] when using `:LazyExtras` to enable fzf-lua, the telescope spec will never be parsed - [x] when not using `:LazyExras`, the spec will be parsed, but one of the two will be disabled. - [x] only one picker extra can be used to prevent issues - [ ] cleanup lsp keymaps
This commit is contained in:
parent
d82c11f889
commit
39a908c9fa
10 changed files with 331 additions and 284 deletions
|
@ -12,14 +12,43 @@ local M = setmetatable({}, {
|
|||
---@field buf? number
|
||||
---@field show_untracked? boolean
|
||||
|
||||
---@class LazyPicker
|
||||
---@field name string
|
||||
---@field open fun(command:string, opts?:lazyvim.util.pick.Opts)
|
||||
---@field commands table<string, string>
|
||||
|
||||
---@type LazyPicker?
|
||||
M.picker = nil
|
||||
|
||||
---@type table<string, string>
|
||||
M.commands = {
|
||||
files = "find_files",
|
||||
}
|
||||
|
||||
---@param picker LazyPicker
|
||||
function M.register(picker)
|
||||
-- this only happens when using :LazyExtras
|
||||
-- so allow to get the full spec
|
||||
if vim.v.vim_did_enter == 1 then
|
||||
return true
|
||||
end
|
||||
if M.picker then
|
||||
LazyVim.warn(
|
||||
"`LazyVim.pick`: picker already set to `" .. M.picker.name .. "`,\nignoring new picker `" .. picker.name .. "`"
|
||||
)
|
||||
return false
|
||||
end
|
||||
M.picker = picker
|
||||
return true
|
||||
end
|
||||
|
||||
---@param command? string
|
||||
---@param opts? lazyvim.util.pick.Opts
|
||||
function M.open(command, opts)
|
||||
if not M.picker then
|
||||
return LazyVim.error("LazyVim.pick: picker not set")
|
||||
end
|
||||
|
||||
command = command or "auto"
|
||||
opts = opts or {}
|
||||
|
||||
|
@ -46,8 +75,8 @@ function M.open(command, opts)
|
|||
opts.show_untracked = opts.show_untracked ~= false
|
||||
end
|
||||
end
|
||||
command = M.commands[command] or command
|
||||
M._open(command, opts)
|
||||
command = M.picker.commands[command] or command
|
||||
M.picker.open(command, opts)
|
||||
end
|
||||
|
||||
---@param command? string
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue