Squashed PR #158 and fixup into 1 commit

Squashed PR#158 into 1 single commit;

        Add vaults

        Add documentation:

        Make luachack happy.

        Address review comments

    fixed tabs and formatting of PR #158
This commit is contained in:
Shivanth
2022-08-07 23:54:19 +08:00
committed by Rene Schallner
parent 74ff3a9e64
commit fa66746981
4 changed files with 208 additions and 107 deletions

42
lua/vaultpicker.lua Normal file
View File

@@ -0,0 +1,42 @@
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