neovim configuration using rocks.nvim plugin manager
1-- this is not actual Neorg related stuffs.
2-- its just a custom scripts mimicing Neorg.
3
4local JOURNAL_PATH = vim.fs.normalize("~/projects/greyrat/journal/")
5
6
7vim.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 }
23 vim.cmd.edit(filepath)
24 local buf = vim.api.nvim_get_current_buf()
25 vim.api.nvim_buf_set_lines(buf, 0, -1, false, lines)
26 end)
27 end
28end, {
29 nargs = "*"
30})