]>
Commit | Line | Data |
---|---|---|
1 | ------------------------------------------------------------------------------- | |
2 | -- Tools to deal with the learning file | |
3 | ------------------------------------------------------------------------------- | |
4 | local Learning = {} | |
5 | ||
6 | local Configuration = require('configuration') | |
7 | local Util = require('util') | |
8 | ------------------------------------------------------------------------------- | |
9 | -- Internal Functions | |
10 | ------------------------------------------------------------------------------- | |
11 | ------------------------------------------------------------------------------- | |
12 | -- Public Interface | |
13 | ------------------------------------------------------------------------------- | |
14 | ||
15 | --- Opens the learning file | |
16 | function Learning.open() | |
17 | local learning_path = Configuration.path_for(Configuration.configuration.learning.learning_file) | |
18 | local learning_parent = Util.directory_name(learning_path) | |
19 | Util.ensure_directory_exists(learning_parent) | |
20 | vim.cmd('edit ' .. learning_path) | |
21 | end | |
22 | ||
23 | --- Capture a learning entry | |
24 | function Learning.capture() | |
25 | local prefix = os.date(Configuration.configuration.learning.prefix) | |
26 | Learning.open() | |
27 | vim.cmd('normal! ggO'..prefix) | |
28 | vim.cmd('startinsert!') | |
29 | end | |
30 | ||
31 | return Learning |