From 2517fd02692dbe5382f9387a1a15275b3062c656 Mon Sep 17 00:00:00 2001 From: Martin Date: Wed, 9 Jul 2025 21:21:25 +0200 Subject: [PATCH] Configure nvim obsidian --- nvim/plugins.lua | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/nvim/plugins.lua b/nvim/plugins.lua index c4d5ce9..f54d3d3 100644 --- a/nvim/plugins.lua +++ b/nvim/plugins.lua @@ -312,6 +312,11 @@ require("obsidian").setup({ path = "~/Documents/notes/fromjoplin", }, }, + templates = { + folder = "_templates", + date_format = "%Y-%m-%d-%a", + time_format = "%H:%M", + }, ui = { checkboxes = { [" "] = { char = "󰄱", hl_group = "ObsidianTodo" }, @@ -321,5 +326,38 @@ require("obsidian").setup({ ["!"] = { char = "", hl_group = "ObsidianImportant" }, }, }, - disable_frontmatter = true, + disable_frontmatter = false, + note_frontmatter_func = function(note) + -- Add the title of the note as an alias. + if note.title then + note:add_alias(note.title) + end + + local out = { id = note.id, tags = note.tags } + + -- `note.metadata` contains any manually added fields in the frontmatter. + -- So here we just make sure those fields are kept in the frontmatter. + if note.metadata ~= nil and not vim.tbl_isempty(note.metadata) then + for k, v in pairs(note.metadata) do + out[k] = v + end + end + + return out + end, + note_path_func = function(spec) + -- This is equivalent to the default behavior. + local path = spec.dir / spec.title + return path:with_suffix(".md") + end, + daily_notes = { + -- Optional, if you keep daily notes in a separate directory. + folder = "Journal", + -- Optional, if you want to change the date format for the ID of daily notes. + date_format = "%Y-%m-%d", + -- Optional, default tags to add to each new daily note created. + default_tags = { "journal" }, + -- Optional, if you want to automatically insert a template from your template directory like 'daily.md' + template = "daily.md" + }, })