Skip to content

Commit

Permalink
Allow picker.name to be nil
Browse files Browse the repository at this point in the history
Fixes #389.
  • Loading branch information
epwalsh committed Feb 11, 2024
1 parent 225453f commit 06e62fd
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lua/obsidian/pickers/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,23 @@ local M = {}
--- Get the default Picker.
---
---@param client obsidian.Client
---@param picker_name obsidian.config.Picker|?
---
---@return obsidian.Picker|?
M.get = function(client)
local picker_name = string.lower(client.opts.picker.name)
M.get = function(client, picker_name)
picker_name = picker_name and picker_name or client.opts.picker.name
if picker_name then
picker_name = string.lower(picker_name)
else
for _, name in ipairs { PickerName.telescope, PickerName.fzf_lua, PickerName.mini } do
local ok, res = pcall(M.get, client, name)
if ok then
return res
end
end
return nil
end

if picker_name == string.lower(PickerName.telescope) then
return require("obsidian.pickers._telescope").new(client)
elseif picker_name == string.lower(PickerName.mini) then
Expand All @@ -17,8 +30,6 @@ M.get = function(client)
return require("obsidian.pickers._fzf").new(client)
elseif picker_name then
error("not implemented for " .. picker_name)
else
return nil
end
end

Expand Down

0 comments on commit 06e62fd

Please sign in to comment.