1 -------------------------------------------------------------------------------
2 -- Configuration for nota
3 -------------------------------------------------------------------------------
4 local Configuration = {}
6 local Util = require('util')
7 -------------------------------------------------------------------------------
9 -------------------------------------------------------------------------------
13 nota_home = '~/.local/share/nota', -- Root location in which to store all notes
14 default_keybinds = true, -- Whether or not to set the default keybinds
15 periodic_locations = {
16 daily = 'periodic/daily', -- Location to store daily notes, relative to nota_home
17 weekly = 'periodic/weekly', -- Location to store weekly notes, relative to nota_home
18 monthly = 'periodic/monthly', -- Location to store monthly notes, relative to nota_home
19 seasonal = 'periodic/seasonal', -- Location to store seasonal notes, relative to nota_home
20 yearly = 'periodic/yearly' -- Location to store yearly notes, relative to nota_home
23 daily = 'templates/daily.md', -- Template for daily notes, relative to nota_home
24 weekly = 'templates/weekly.md', -- Template for weekly notes, relative to nota_home
25 monthly = 'templates/monthly.md', -- Template for monthly notes, relative to nota_home
26 seasonal = 'templates/seasonal.md', -- Template for seasonal notes, relative to nota_home
27 yearly = 'templates/yearly.md', -- Template for yearly notes, relative to nota_home
28 plan = 'templates/plan.md' -- Template for plan notes, relative to nota_home
31 inbox = 'inbox.md', -- Location of the file in which to store newly captured tasks, relative to nota_home
32 someday = 'someday.md' -- Location of the file in which to store indefinitely deferred tasks, relative to nota_home
35 learning_file = 'learning.md', -- Location of the file in which to store learning entries, relative to nota_home
36 prefix = '%Y-%m-%d: ' -- Prefix to add when capturing learning entries
39 archive = 'plans', -- Location of the plan archives.
40 plan_file = '~/.plan' -- Location of the active plan, the default is what is expected by finger.
44 -- Recursively extends a table with another
45 local function extend(target, extender)
46 for key, value in pairs(extender) do
47 if type(target[key]) == 'table' and type(value) == 'table' then
48 extend(target[key], value)
55 -------------------------------------------------------------------------------
57 -------------------------------------------------------------------------------
59 Configuration.configuration = {}
60 extend(Configuration.configuration, defaults)
62 --- Extends configuration with another configuration
63 function Configuration.configure(configuration)
64 configuration = configuration or {}
65 extend(Configuration.configuration, configuration)
68 --- Gets expanded paths relative to nota_home
69 -- @param path string the relative path to expand
70 function Configuration.path_for(path)
72 return vim.fn.expand(Configuration.configuration.nota_home)
74 return Util.join(vim.fn.expand(Configuration.configuration.nota_home), path)
77 --- Loads a template by template name
78 function Configuration.load_template(type)
79 local template_path = Configuration.path_for(Configuration.configuration.templates[type])
81 local template_file = io.open(template_path, 'r')
82 if not template_file then
85 local content = template_file:read('*a')