]> git.r.bdr.sh - rbdr/nota.nvim/blobdiff - lua/learning.lua
Add minimum workable functionality
[rbdr/nota.nvim] / lua / learning.lua
index 0994b31dbd4ab4ce863c7acf71791ef12144a964..b730c6a082d05c27dc2bffcdb3dbeb83a67a9956 100644 (file)
@@ -1,22 +1,31 @@
 -------------------------------------------------------------------------------
 -- 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