Allow empty note titles in pickers (#25)

This commit is contained in:
Karim Abou Zeid 2022-01-15 14:33:02 +01:00 committed by GitHub
parent 5826043421
commit 910253023e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 7 deletions

View File

@ -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,

View File

@ -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)

View File

@ -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