@ -4,7 +4,6 @@ local conf = require("telescope.config").values
local actions = require ( " telescope.actions " )
local actions = require ( " telescope.actions " )
local action_state = require ( " telescope.actions.state " )
local action_state = require ( " telescope.actions.state " )
local action_utils = require ( " telescope.actions.utils " )
local action_utils = require ( " telescope.actions.utils " )
local putils = require ( " telescope.previewers.utils " )
local entry_display = require ( " telescope.pickers.entry_display " )
local entry_display = require ( " telescope.pickers.entry_display " )
local previewers = require ( " telescope.previewers " )
local previewers = require ( " telescope.previewers " )
@ -50,11 +49,10 @@ end
function M . make_note_previewer ( )
function M . make_note_previewer ( )
return previewers.new_buffer_previewer ( {
return previewers.new_buffer_previewer ( {
define_preview = function ( self , entry )
define_preview = function ( self , entry )
conf.buffer_previewer_maker (
conf.buffer_previewer_maker ( entry.value . absPath , self.state . bufnr , {
entry.value . absPath ,
bufname = entry.value . title or entry.value . path ,
self.state . bufnr ,
winid = self.state . winid ,
{ bufname = entry.value . title or entry.value . path }
} )
)
end ,
end ,
} )
} )
end
end
@ -63,64 +61,68 @@ function M.show_note_picker(notes, options, cb)
options = options or { }
options = options or { }
local telescope_options = vim.tbl_extend ( " force " , { prompt_title = options.title } , options.telescope or { } )
local telescope_options = vim.tbl_extend ( " force " , { prompt_title = options.title } , options.telescope or { } )
pickers.new ( telescope_options , {
pickers
finder = finders.new_table ( {
. new ( telescope_options , {
results = notes ,
finder = finders.new_table ( {
entry_maker = M.create_note_entry_maker ( options ) ,
results = notes ,
} ) ,
entry_maker = M.create_note_entry_maker ( options ) ,
sorter = conf.file_sorter ( options ) ,
} ) ,
previewer = M.make_note_previewer ( ) ,
sorter = conf.file_sorter ( options ) ,
attach_mappings = function ( prompt_bufnr )
previewer = M.make_note_previewer ( ) ,
actions.select_default : replace ( function ( )
attach_mappings = function ( prompt_bufnr )
if options.multi_select then
actions.select_default : replace ( function ( )
local selection = { }
if options.multi_select then
action_utils.map_selections ( prompt_bufnr , function ( entry , _ )
local selection = { }
table.insert ( selection , entry.value )
action_utils.map_selections ( prompt_bufnr , function ( entry , _ )
end )
table.insert ( selection , entry.value )
if vim.tbl_isempty ( selection ) then
end )
selection = { action_state.get_selected_entry ( ) . value }
if vim.tbl_isempty ( selection ) then
selection = { action_state.get_selected_entry ( ) . value }
end
actions.close ( prompt_bufnr )
cb ( selection )
else
actions.close ( prompt_bufnr )
cb ( action_state.get_selected_entry ( ) . value )
end
end
actions.close ( prompt_bufnr )
end )
cb ( selection )
return true
else
end ,
actions.close ( prompt_bufnr )
} )
cb ( action_state.get_selected_entry ( ) . value )
: find ( )
end
end )
return true
end ,
} ) : find ( )
end
end
function M . show_tag_picker ( tags , options , cb )
function M . show_tag_picker ( tags , options , cb )
options = options or { }
options = options or { }
local telescope_options = vim.tbl_extend ( " force " , { prompt_title = options.title } , options.telescope or { } )
local telescope_options = vim.tbl_extend ( " force " , { prompt_title = options.title } , options.telescope or { } )
pickers.new ( telescope_options , {
pickers
finder = finders.new_table ( {
. new ( telescope_options , {
results = tags ,
finder = finders.new_table ( {
entry_maker = M.create_tag_entry_maker ( options ) ,
results = tags ,
} ) ,
entry_maker = M.create_tag_entry_maker ( options ) ,
sorter = conf.generic_sorter ( options ) ,
} ) ,
attach_mappings = function ( prompt_bufnr , _ )
sorter = conf.generic_sorter ( options ) ,
actions.select_default : replace ( function ( )
attach_mappings = function ( prompt_bufnr , _ )
if options.multi_select then
actions.select_default : replace ( function ( )
local selection = { }
if options.multi_select then
action_utils.map_selections ( prompt_bufnr , function ( entry , _ )
local selection = { }
table.insert ( selection , entry.value )
action_utils.map_selections ( prompt_bufnr , function ( entry , _ )
end )
table.insert ( selection , entry.value )
if vim.tbl_isempty ( selection ) then
end )
selection = { action_state.get_selected_entry ( ) . value }
if vim.tbl_isempty ( selection ) then
selection = { action_state.get_selected_entry ( ) . value }
end
actions.close ( prompt_bufnr )
cb ( selection )
else
cb ( action_state.get_selected_entry ( ) . value )
end
end
actions.close ( prompt_bufnr )
end )
cb ( selection )
return true
else
end ,
cb ( action_state.get_selected_entry ( ) . value )
} )
end
: find ( )
end )
return true
end ,
} ) : find ( )
end
end
return M
return M