-------------------------------------------------------------------------------
-- Tools to deal with the learning file
-------------------------------------------------------------------------------
+local Learning = {}
+
+local Configuration = require('configuration')
+local Util = require('util')
+-------------------------------------------------------------------------------
+-- Internal Functions
+-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Public Interface
-------------------------------------------------------------------------------
--- Opens the learning file
--- @param configuration tNotaConfiguration the plugin configuration
-function open_learning(configuration)
- error("Not yet implemented")
+function Learning.open()
+ local learning_path = Configuration.path_for(Configuration.configuration.learning.learning_file)
+ local learning_parent = Util.directory_name(learning_path)
+ Util.ensure_directory_exists(learning_parent)
+ vim.cmd('edit ' .. learning_path)
end
--- Capture a learning entry
--- @param configuration tNotaConfiguration the plugin configuration
-function capture_learning(configuration)
- error("Not yet implemented")
+function Learning.capture()
+ local prefix = os.date(Configuration.configuration.learning.prefix)
+ Learning.open()
+ vim.cmd('normal! ggO'..prefix)
+ vim.cmd('startinsert!')
end
--------------------------------------------------------------------------------
--- Internal Functions
--------------------------------------------------------------------------------
+return Learning