chore(pickers): move vault picker file

This commit is contained in:
Thomas Lambert
2023-04-28 22:22:33 +02:00
parent e2bc0755f3
commit 9d2e4fd1e1
3 changed files with 46 additions and 46 deletions

View File

@@ -19,7 +19,7 @@ local tagutils = require("taglinks.tagutils")
local linkutils = require("taglinks.linkutils") local linkutils = require("taglinks.linkutils")
local dateutils = require("taglinks.dateutils") local dateutils = require("taglinks.dateutils")
local Path = require("plenary.path") local Path = require("plenary.path")
local vaultPicker = require("vaultpicker") local tkpickers = require("telekasten.pickers")
local tkutils = require("telekasten.utils") local tkutils = require("telekasten.utils")
-- declare locals for the nvim api stuff to avoid more lsp warnings -- declare locals for the nvim api stuff to avoid more lsp warnings
@@ -3018,7 +3018,7 @@ local function _setup(cfg)
end end
local function ChangeVault(opts) local function ChangeVault(opts)
vaultPicker.vaults(M, opts) tkpickers.vaults(M, opts)
end end
local function chdir(cfg) local function chdir(cfg)

View File

@@ -0,0 +1,44 @@
local M = {}
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local conf = require("telescope.config").values
-- Pick between the various configured vaults
function M.vaults(telekasten, opts)
opts = opts or {}
local vaults = telekasten.vaults
local _vaults = {}
for k, v in pairs(vaults) do
table.insert(_vaults, { k, v })
end
pickers
.new(opts, {
prompt_title = "Vaults",
finder = finders.new_table({
results = _vaults,
entry_maker = function(entry)
return {
value = entry,
display = entry[1],
ordinal = entry[1],
}
end,
}),
sorter = conf.generic_sorter(opts),
attach_mappings = function(prompt_bufnr, map)
actions.select_default:replace(function()
actions.close(prompt_bufnr)
local selection = action_state.get_selected_entry()
-- print(vim.inspect(selection))
telekasten.chdir(selection.value[2])
end)
return true
end,
})
:find()
end
return M

View File

@@ -1,44 +0,0 @@
local actions = require("telescope.actions")
local action_state = require("telescope.actions.state")
local pickers = require("telescope.pickers")
local finders = require("telescope.finders")
local conf = require("telescope.config").values
local M = {}
local vaults = function(telekasten, opts)
opts = opts or {}
local vaults = telekasten.vaults
local _vaults = {}
for k, v in pairs(vaults) do
table.insert(_vaults, { k, v })
end
pickers
.new(opts, {
prompt_title = "Vaults",
finder = finders.new_table({
results = _vaults,
entry_maker = function(entry)
return {
value = entry,
display = entry[1],
ordinal = entry[1],
}
end,
}),
sorter = conf.generic_sorter(opts),
attach_mappings = function(prompt_bufnr, map)
actions.select_default:replace(function()
actions.close(prompt_bufnr)
local selection = action_state.get_selected_entry()
-- print(vim.inspect(selection))
telekasten.chdir(selection.value[2])
end)
return true
end,
})
:find()
end
M.vaults = vaults
return M