X-Git-Url: https://git.r.bdr.sh/rbdr/nota.nvim/blobdiff_plain/56292c7915662bbf721ca8c3d2cee6a04134a9c6..ca10d2a36e3e7d8d28f15f36f0812384606c238d:/lua/learning.lua diff --git a/lua/learning.lua b/lua/learning.lua index 0994b31..b730c6a 100644 --- a/lua/learning.lua +++ b/lua/learning.lua @@ -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