aboutsummaryrefslogtreecommitdiff
path: root/lua/denote
diff options
context:
space:
mode:
authorHumanEntity <human_entity@icloud.com>2023-12-24 23:07:17 +0100
committerHumanEntity <human_entity@icloud.com>2023-12-24 23:07:17 +0100
commit2b2f7f954a8ca24acde44e4e4497b27775ed83b9 (patch)
tree4779af880f7f9a90e300babe2367ab3f255449dd /lua/denote
parent03f4e3bf7ac2d0a63fd3bc75395534e1a0cf9c21 (diff)
downloadsimple-denote.nvim-2b2f7f954a8ca24acde44e4e4497b27775ed83b9.tar.gz
Added some docs
Diffstat (limited to 'lua/denote')
-rw-r--r--lua/denote/config.lua30
-rw-r--r--lua/denote/init.lua17
-rw-r--r--lua/denote/util.lua23
3 files changed, 50 insertions, 20 deletions
diff --git a/lua/denote/config.lua b/lua/denote/config.lua
index f6ec007..fce9a50 100644
--- a/lua/denote/config.lua
+++ b/lua/denote/config.lua
@@ -1,12 +1,26 @@
+---@class DenoteConfigFilename
+---@field ext string defaults to "norg"
+---@field date_sep string defaults to "_"
+---@field name_sep string defaults to "-"
+---@field tag_sep string defaults to "="
+
+---@class DenoteConfigVault
+---@field dir string defaults to "~/.denote/"
+
+---@class DenoteConfig
+---@field filename DenoteConfigFilename
+---@field vault DenoteConfigVault
+
+---@type DenoteConfig
local M = {
- config = {
- filename = {
- ext = "norg",
- date_sep = "_",
- name_sep = "-",
- tag_sep = "=",
- },
- vault_dir = "~/.denote/",
+ filename = {
+ ext = "norg",
+ date_sep = "_",
+ name_sep = "-",
+ tag_sep = "=",
+ },
+ vault = {
+ dir = "~/.denote/",
},
}
diff --git a/lua/denote/init.lua b/lua/denote/init.lua
index 18f57c1..814653f 100644
--- a/lua/denote/init.lua
+++ b/lua/denote/init.lua
@@ -1,13 +1,13 @@
local M = {}
local U = require("denote.util")
-local function splitlines(str)
- local result = {}
- for line in string.gmatch(str .. "\n", "(.-)\n") do
- table.insert(result, line)
- end
- return result
-end
+-- local function splitlines(str)
+-- local result = {}
+-- for line in string.gmatch(str .. "\n", "(.-)\n") do
+-- table.insert(result, line)
+-- end
+-- return result
+-- end
local function splitspace(str)
local chunks = {}
@@ -57,7 +57,7 @@ function M.search()
local status = U.search(date, name, function(input)
if input then
- vim.cmd("e " .. U.config.vault_dir .. "/" .. input)
+ vim.cmd("e " .. U.config.vault.dir .. "/" .. input)
end
if date then
print(date.year, " ", date.month, " ", date.day)
@@ -75,6 +75,7 @@ function M.search()
end
end
+---@param config DenoteConfig
function M.setup(config)
if config then
U.config = config
diff --git a/lua/denote/util.lua b/lua/denote/util.lua
index 3bd7cec..657da9d 100644
--- a/lua/denote/util.lua
+++ b/lua/denote/util.lua
@@ -1,5 +1,14 @@
-local M = require("denote.config")
+local M = {}
+M.config = require("denote.config")
+---@class DenoteDate
+---@field year string
+---@field month string
+---@field day string
+
+---@param name string
+---@param tags table|nil
+---@return string filename format of files in denote.nvim
function M.file(name, tags)
local file = ""
@@ -24,15 +33,21 @@ function M.file(name, tags)
return file .. "." .. M.config.filename.ext
end
+---@param name string
+---@param tags table|nil
+--- Opens your note
function M.note(name, tags)
- local filename = M.config.vault_dir .. M.file(name, tags)
+ local filename = M.config.vault.dir .. M.file(name, tags)
-- Echo template
- vim.cmd("!mkdir -p " .. M.config.vault_dir)
+ vim.cmd("!mkdir -p " .. M.config.vault.dir)
vim.cmd("e " .. filename)
end
+---@param date DenoteDate|nil
+---@param name string|nil
+---@param func function
function M.search(date, name, func)
local items = {}
local matcher = ""
@@ -67,7 +82,7 @@ function M.search(date, name, func)
-- matcher = matcher .. M.config.filename.name_sep .. "?" .. M.config.filename.name_sep .. "?" .. ".-"
- for file in io.popen("ls " .. M.config.vault_dir):lines() do
+ for file in io.popen("ls " .. M.config.vault.dir):lines() do
local matched = file:match(matcher)
if matched then