-
Notifications
You must be signed in to change notification settings - Fork 10
[RFC] refactor: only load filenames to decrease loading time #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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.
lua/telescope-orgmode/org.lua
Outdated
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()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try doing this:
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, |
There was a problem hiding this comment.
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.
eea012a
to
458a7ec
Compare
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!) |
There was a problem hiding this 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.
Changes look good, thanks to both of you. 👍 |
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.