Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lua/telescope-orgmode/entry_maker/orgfiles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ local entry_display = require('telescope.pickers.entry_display')

local M = {}

---@param file_results { file: OrgApiFile, filename: string }[]
---@param file_results { filename: string, title: string, headline: string }[]
---@return OrgFileEntry[]
local function index_orgfiles(file_results)
local results = {}
for _, file_entry in ipairs(file_results) do
local entry = {
file = file_entry.file,
filename = file_entry.filename,
-- not beautiful to access a private property, but this is the only way to get the title
---@diagnostic disable-next-line: invisible, undefined-field
title = file_entry.file._file:get_directive('TITLE') or nil,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get the title from the file result after the suggested change below.

title = file_entry.title,
headline = nil,
}
table.insert(results, entry)
Expand Down
9 changes: 4 additions & 5 deletions lua/telescope-orgmode/org.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@ local OrgApi = require('orgmode.api')
local M = {}

function M.load_files(opts)
---@type { file: OrgApiFile, filename: string, last_used: number }[]
---@type { filename: string, last_used: number, title: string }[]
local file_results = vim.tbl_map(function(file)
local file_stat = vim.uv.fs_stat(file.filename) or 0
return { file = file, filename = file.filename, last_used = file_stat.mtime.sec }
end, OrgApi.load())
return { filename = file.filename, last_used = file.metadata.mtime, title = file:get_title() }
end, require('orgmode').files:all())

if not opts.archived then
file_results = vim.tbl_filter(function(entry)
return not entry.file.is_archive_file
return not (vim.fn.fnamemodify(entry.filename, ':e') == 'org_archive')
end, file_results)
end

Expand Down