]>
Commit | Line | Data |
---|---|---|
1 | --- @type tNotaConfiguration | |
2 | -- @field [nota_home] string the location of your notes. All other paths will be relative to this. Defaults to $XDG_DATA_HOME/nota or ~/.local/share/nota | |
3 | -- @field [default_keybinds] boolean whether to use the default key bindings or not. Defaults to true. | |
4 | -- @field [periodic_locations] tPeriodicLocationsConfiguration (optional) the location of periodic notes. | |
5 | -- @field [templates] tTemplatesConfiguration (optional) the location of templates for periodic notes. | |
6 | -- @field [tasks] tTasksConfiguration (optional) configuration for task tools | |
7 | -- @field [learning] tLearningConfiguration (optional) configuration for learning tools | |
8 | -- @field [plan] tPlanConfiguration (optional) configuration for .plan file tools | |
9 | ||
10 | --- @type tPeriodicLocationsConfiguration | |
11 | -- @field [daily] string (optional) the location where daily notes are stored relative to nota_home. Defaults to periodic/daily. | |
12 | -- @field [weekly] string (optional) the location where weekly notes are stored relative to nota_home. Defaults to periodic/weekly. | |
13 | -- @field [monthly] string (optional) the location where monthly notes are stored relative to nota_home. Defaults to periodic/monthly. | |
14 | -- @field [seasonal] string (optional) the location where seasonal notes are stored relative to nota_home. Defaults to periodic/seasonal. | |
15 | -- @field [yearly] string (optional) the location where yearly notes are stored relative to nota_home. Defaults to periodic/yearly. | |
16 | ||
17 | --- @type tTemplatesConfiguration | |
18 | -- @field [daily] string (optional) the location to the daily note template file relative to nota_home. Defaults to templates/daily.md | |
19 | -- @field [weekly] string (optional) the location to the weekly note template file relative to nota_home. Defaults to templates/weekly.md | |
20 | -- @field [monthly] string (optional) the location to the monthly note template file relative to nota_home. Defaults to templates/monthly.md | |
21 | -- @field [seasonal] string (optional) the location to the seasonal note template file relative to nota_home. Defaults to templates/seasonal.md | |
22 | -- @field [yearly] string (optional) the location to the seasonal note template file relative to nota_home. Defaults to templates/yearly.md | |
23 | -- @field [plan] string (optional) the location to the plan template file relative to nota_home. Defaults to templates/plan.md | |
24 | ||
25 | --- @type tTasksConfiguration | |
26 | -- @field [inbox] string (optional) the location of the inbox for capturing tasks relative to nota_home. Default is "inbox.md" | |
27 | -- @field [someday] string (optional) the location of the inbox for indefinitely deferred tasks relative to nota_home. Default is "someday.md" | |
28 | ||
29 | --- @type tLearningConfiguration | |
30 | -- @field [learning_file] string (optional) the location of the learning file for capturing entries relative to nota_home. Default is "learning.md" | |
31 | -- @field [prefix] string (optional) the prefix to add when capturing learning entries. Default is "%Y-%m-%d: " | |
32 | ||
33 | --- @type tPlanConfiguration | |
34 | -- @field [archive] string (optional) the location of the plan archive relative to nota_home. Default is "plans" | |
35 | -- @field [plan_file] string (optional) the location of the active plan file. Default is "~/.plan" | |
36 | ||
37 | --- Sets up the Nota commands and keybins | |
38 | -- @param user_configuration tNotaConfiguration the user provided configuration for the plugin | |
39 | local api = vim.api | |
40 | local fs = vim.loop | |
41 | local fn = vim.fs | |
42 | ||
43 | if not api.nvim_create_user_command then | |
44 | return | |
45 | end | |
46 | ||
47 | local command = api.nvim_create_user_command | |
48 | ||
49 | local configuration = require('configuration').configuration | |
50 | ||
51 | if configuration.default_keybinds then | |
52 | require('keybinds').bind() | |
53 | end | |
54 | ||
55 | -- Note Handling Commands | |
56 | command('NotaOpenDailyNote', function(options) require('notes').open_daily(options.args) end, { nargs = '?' }) | |
57 | command('NotaOpenWeeklyNote', function() require('notes').open_weekly() end, { nargs = 0 }) | |
58 | command('NotaOpenMonthlyNote', function() require('notes').open_monthly() end, { nargs = 0 }) | |
59 | command('NotaOpenSeasonalNote', function() require('notes').open_seasonal() end, { nargs = 0 }) | |
60 | command('NotaOpenYearlyNote', function() require('notes').open_yearly() end, { nargs = 0 }) | |
61 | command('NotaOpenNote', function() require('notes').open() end, { nargs = 0 }) | |
62 | ||
63 | -- Task View Handling Commands | |
64 | command('NotaOpenAgenda', function() require('task_views').open_agenda() end, { nargs = 0 }) | |
65 | command('NotaOpenOpen', function() require('task_views').open_open() end, { nargs = 0 }) | |
66 | command('NotaOpenOpenImportant', function() require('task_views').open_open_important() end, { nargs = 0 }) | |
67 | command('NotaOpenJournal', function() require('task_views').open_journal() end, { nargs = 0 }) | |
68 | ||
69 | -- Task Handling Commands | |
70 | command('NotaToggleTask', function() require('tasks').toggle() end, { nargs = 0 }) | |
71 | command('NotaToggleTaskImportance', function() require('tasks').toggle_importance() end, { nargs = 0 }) | |
72 | command('NotaInsertTask', function() require('tasks').insert() end, { nargs = 0 }) | |
73 | command('NotaCaptureTask', function() require('tasks').capture() end, { nargs = 0 }) | |
74 | command('NotaTagTask', function(options) require('tasks').tag(options.args) end, { nargs = '?' }) | |
75 | command('NotaRemoveTagTask', function(options) require('tasks').remove_tag(options.args) end, { nargs = '?' }) | |
76 | command('NotaRescheduleTaskToday', function() require('tasks').reschedule_for_today() end, { nargs = 0 }) | |
77 | command('NotaRescheduleTaskTomorrow', function() require('tasks').reschedule_for_tomorrow() end, { nargs = 0 }) | |
78 | command('NotaRescheduleTaskSomeday', function() require('tasks').reschedule_for_someday() end, { nargs = 0 }) | |
79 | command('NotaRescheduleTask', function(options) require('tasks').reschedule(options.args) end, { nargs = '?' }) | |
80 | ||
81 | -- .plan Handling Commands | |
82 | command('NotaOpenPlan', function() require('plan').open() end, { nargs = 0 }) | |
83 | command('NotaCapturePlan', function() require('plan').capture() end, { nargs = 0 }) | |
84 | ||
85 | -- Learning File Handling Commands | |
86 | command('NotaOpenLearning', function() require('learning').open() end, { nargs = 0 }) | |
87 | command('NotaCaptureLearning', function() require('learning').capture() end, { nargs = 0 }) |