Skip to content

Conversation

Maltimore
Copy link

As discussed in nvim-orgmode/orgmode#999, this is a first attempt to reduce the loading time of getting the org files.

The downside of this PR is that we are not parsing the TITLE anymore, so telescope entries are just based on the filename.

Copy link
Member

@kristijanhusak kristijanhusak left a comment

Choose a reason for hiding this comment

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

Did you try keeping the title but not use the OrgApi? Try the suggested changes and let me know how it works.

Comment on lines 7 to 10
local file_results = vim.tbl_map(function(filename)
local file_stat = vim.uv.fs_stat(filename) or 0
return { filename = filename, last_used = file_stat.mtime.sec }
end, require('orgmode').files:_files())
Copy link
Member

Choose a reason for hiding this comment

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

Try doing this:

Suggested change
local file_results = vim.tbl_map(function(filename)
local file_stat = vim.uv.fs_stat(filename) or 0
return { filename = filename, last_used = file_stat.mtime.sec }
end, require('orgmode').files:_files())
local file_results = vim.tbl_map(function(file)
return { filename = file.filename, last_used = file.metadata.mtime, title = file:get_title() }
end, require('orgmode').files:all())

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.

@Maltimore Maltimore force-pushed the just_load_filenames branch from eea012a to 458a7ec Compare June 29, 2025 19:39
@Maltimore
Copy link
Author

Thanks a ton for your help. Worked flawlessly. I'm marking this ready for review! (This is AFAIK my first-ever commit to a lua project so be careful!)

@Maltimore Maltimore changed the title [WIP] refactor: only load filenames to decrease loading time [RFC] refactor: only load filenames to decrease loading time Jun 29, 2025
Copy link
Member

@kristijanhusak kristijanhusak left a comment

Choose a reason for hiding this comment

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

LGTM. I'll let @seflue confirm and merge this in, I'm not really a user of this plugin.

@kristijanhusak kristijanhusak requested a review from seflue July 1, 2025 13:09
@seflue
Copy link
Collaborator

seflue commented Jul 1, 2025

Changes look good, thanks to both of you. 👍

@seflue seflue merged commit d53b8e9 into nvim-orgmode:main Jul 1, 2025
@Maltimore Maltimore deleted the just_load_filenames branch July 11, 2025 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants