1
1
local OrgFile = require (' orgmode.files.file' )
2
2
local orgmode = require (' orgmode' )
3
3
4
- local function load_file (path )
5
- vim .cmd (string.format (' e %s' , path ))
4
+ local M = {}
5
+
6
+ --- @param path string
7
+ function M .load_file (path )
8
+ vim .cmd .edit (path )
6
9
return orgmode .files :get (path )
7
10
end
8
11
9
- local function create_file (lines )
12
+ --- @param lines string[]
13
+ function M .create_file (lines )
10
14
local fname = vim .fn .tempname () .. ' .org'
11
15
vim .fn .writefile (lines or {}, fname )
12
- return load_file (fname )
16
+ return M . load_file (fname )
13
17
end
14
18
19
+ --- @param lines string[]
20
+ --- @param config ? table
15
21
--- @return OrgFile
16
- local function create_agenda_file (lines , config )
22
+ function M . create_agenda_file (lines , config )
17
23
local fname = vim .fn .tempname () .. ' .org'
18
24
vim .fn .writefile (lines or {}, fname )
19
25
@@ -22,11 +28,13 @@ local function create_agenda_file(lines, config)
22
28
}, config or {})
23
29
local org = orgmode .setup (cfg )
24
30
org :init ()
25
- return load_file (fname )
31
+ return M . load_file (fname )
26
32
end
27
33
34
+ --- @param lines string[]
35
+ --- @param filename string
28
36
--- @return OrgFile
29
- local function create_file_instance (lines , filename )
37
+ function M . create_file_instance (lines , filename )
30
38
local file = OrgFile :new ({
31
39
filename = filename or vim .fn .tempname () .. ' .org' ,
32
40
lines = lines ,
@@ -36,9 +44,9 @@ local function create_file_instance(lines, filename)
36
44
end
37
45
38
46
--- @param fixtures { filename : string , content : string[] } []
39
- --- @param config table ?
47
+ --- @param config ? table
40
48
--- @return table
41
- local function create_agenda_files (fixtures , config )
49
+ function M . create_agenda_files (fixtures , config )
42
50
-- NOTE: content is only 1 line for 1 file
43
51
local temp_fname = vim .fn .tempname ()
44
52
local temp_dir = vim .fn .fnamemodify (temp_fname , ' :p:h' )
@@ -65,10 +73,4 @@ local function create_agenda_files(fixtures, config)
65
73
return files
66
74
end
67
75
68
- return {
69
- load_file = load_file ,
70
- create_file = create_file ,
71
- create_file_instance = create_file_instance ,
72
- create_agenda_file = create_agenda_file ,
73
- create_agenda_files = create_agenda_files ,
74
- }
76
+ return M
0 commit comments