+32
plugin/neorg.lua
+32
plugin/neorg.lua
···
1
+
-- this is not actual Neorg related stuffs.
2
+
-- its just a custom scripts mimicing Neorg.
3
+
4
+
local JOURNAL_PATH = vim.fs.normalize("~/projects/greyrat/journal/")
5
+
6
+
7
+
vim.api.nvim_create_user_command("Journal", function(args)
8
+
if args.fargs[1] == "new" then
9
+
vim.ui.input({ default = os.date("%Y-%m-%d") }, function(input)
10
+
if not input then
11
+
return
12
+
end
13
+
local filepath = vim.fs.joinpath(JOURNAL_PATH, input .. ".norg")
14
+
local today = os.date("!%Y-%m-%dT%H:%M:%S+00:00")
15
+
local lines = {
16
+
"@document.meta",
17
+
"title: " .. input,
18
+
"created: " .. today,
19
+
"updated: " .. today,
20
+
"@end",
21
+
"",
22
+
"* " .. input,
23
+
""
24
+
}
25
+
vim.cmd.edit(filepath)
26
+
local buf = vim.api.nvim_get_current_buf()
27
+
vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
28
+
end)
29
+
end
30
+
end, {
31
+
nargs = "*"
32
+
})