Skip to content

Commit c79e06c

Browse files
feat(files): Do not load files on instance creation
1 parent d160a95 commit c79e06c

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

lua/orgmode/files/init.lua

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@ function OrgFiles:new(opts)
2525
}
2626
setmetatable(data, self)
2727
self.__index = self
28-
data:load_sync()
2928
return data
3029
end
3130

3231
---@param force? boolean Force reload all files
33-
---@return OrgPromise
32+
---@return OrgPromise<OrgFiles>
3433
function OrgFiles:load(force)
3534
if not force and self.load_state then
3635
if self.load_state == 'loading' then
3736
self:ensure_loaded()
3837
end
39-
return Promise.resolve(self.files)
38+
return Promise.resolve(self)
4039
end
4140

4241
self.load_state = 'loading'
@@ -51,7 +50,7 @@ function OrgFiles:load(force)
5150

5251
return Promise.all(actions):next(function()
5352
self.load_state = 'loaded'
54-
return self.files
53+
return self
5554
end)
5655
end
5756

lua/orgmode/init.lua

+5-3
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ function Org:init()
4848
require('orgmode.events').init()
4949
self.highlighter = require('orgmode.colors.highlighter'):new()
5050
require('orgmode.colors.highlights').define_highlights()
51-
self.files = require('orgmode.files'):new({
52-
paths = require('orgmode.config').org_agenda_files,
53-
})
51+
self.files = require('orgmode.files')
52+
:new({
53+
paths = require('orgmode.config').org_agenda_files,
54+
})
55+
:load_sync()
5456
self.agenda = require('orgmode.agenda'):new({
5557
files = self.files,
5658
})

lua/orgmode/parser/files.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ end
2626

2727
function Files.load(callback)
2828
Files.loader():load():next(function(files)
29-
Files.orgfiles = files
29+
Files.orgfiles = Files.loader().files
3030
Files._build_tags()
3131
if callback then
3232
callback()

0 commit comments

Comments
 (0)