mirror of
https://github.com/mickael-menu/zk-nvim
synced 2024-11-09 19:10:45 +00:00
Allow empty note titles in pickers (#25)
This commit is contained in:
parent
5826043421
commit
910253023e
@ -10,13 +10,14 @@ vim.cmd([[
|
|||||||
endfunction
|
endfunction
|
||||||
]])
|
]])
|
||||||
|
|
||||||
M.note_picker_list_api_selection = { "title", "absPath" }
|
M.note_picker_list_api_selection = { "title", "path", "absPath" }
|
||||||
|
|
||||||
function M.show_note_picker(notes, options, cb)
|
function M.show_note_picker(notes, options, cb)
|
||||||
options = options or {}
|
options = options or {}
|
||||||
vim.fn._fzf_wrap_and_run({
|
vim.fn._fzf_wrap_and_run({
|
||||||
source = vim.tbl_map(function(v)
|
source = vim.tbl_map(function(v)
|
||||||
return table.concat({ v.absPath, v.title }, delimiter)
|
local title = v.title or v.path
|
||||||
|
return table.concat({ v.absPath, title }, delimiter)
|
||||||
end, notes),
|
end, notes),
|
||||||
options = vim.list_extend({
|
options = vim.list_extend({
|
||||||
"--delimiter=" .. delimiter,
|
"--delimiter=" .. delimiter,
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.note_picker_list_api_selection = { "title", "absPath" }
|
M.note_picker_list_api_selection = { "title", "path", "absPath" }
|
||||||
|
|
||||||
function M.show_note_picker(notes, options, cb)
|
function M.show_note_picker(notes, options, cb)
|
||||||
options = options or {}
|
options = options or {}
|
||||||
local select_options = vim.tbl_extend("force", {
|
local select_options = vim.tbl_extend("force", {
|
||||||
prompt = options.title,
|
prompt = options.title,
|
||||||
format_item = function(item)
|
format_item = function(item)
|
||||||
return item.title
|
return item.title or item.path
|
||||||
end,
|
end,
|
||||||
}, options.select or {})
|
}, options.select or {})
|
||||||
vim.ui.select(notes, select_options, function(item)
|
vim.ui.select(notes, select_options, function(item)
|
||||||
|
@ -10,15 +10,16 @@ local previewers = require("telescope.previewers")
|
|||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
M.note_picker_list_api_selection = { "title", "absPath", "rawContent" }
|
M.note_picker_list_api_selection = { "title", "absPath", "path", "rawContent" }
|
||||||
|
|
||||||
function M.create_note_entry_maker(_)
|
function M.create_note_entry_maker(_)
|
||||||
return function(note)
|
return function(note)
|
||||||
|
local title = note.title or note.path
|
||||||
return {
|
return {
|
||||||
value = note,
|
value = note,
|
||||||
path = note.absPath,
|
path = note.absPath,
|
||||||
display = note.title,
|
display = title,
|
||||||
ordinal = note.title,
|
ordinal = title,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user