From fbf475f179a7848bff8944d8c77ebeef88fb448d Mon Sep 17 00:00:00 2001 From: Drew Haven Date: Tue, 27 May 2025 10:23:07 -0700 Subject: [PATCH] [nvim] Updates obsidian options: better file names --- .../neovim/config/lua/plugins/obsidian.lua | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/home-manager/features/neovim/config/lua/plugins/obsidian.lua b/home-manager/features/neovim/config/lua/plugins/obsidian.lua index 5991247..7d06027 100644 --- a/home-manager/features/neovim/config/lua/plugins/obsidian.lua +++ b/home-manager/features/neovim/config/lua/plugins/obsidian.lua @@ -24,6 +24,14 @@ return { path = "~/Documents/Notes", }, }, + + -- Can I enable this somehow? I'm using blink.cmp but this is triggering + -- it to look for nvim-cmp directly. + -- completion = { + -- nvim_cmp = true, + -- min_chars = 2, + -- }, + daily_notes = { -- Optional, if you keep daily notes in a separate directory. folder = "Daily Notes", @@ -32,11 +40,13 @@ return { -- Optional, if you want to automatically insert a template from your template directory like '' template = "Daily Note", }, + templates = { folder = "Templates", date_format = "%Y-%m-%d", time_format = "%H:%M", }, + ui = { -- Disable the UI features and let render-markdown.nvim handle it. enable = false, @@ -48,5 +58,25 @@ return { [">"] = { char = "⛝", hl_group = "ObsidianDone" }, }, }, + + -- Put the note ID in the wiki links + wiki_link_func = "prepend_note_id", + preferred_link_style = "wiki", + + -- Customize how note IDs are generated given an optional title. + ---@param title string|? + ---@return string + note_id_func = function(title) + if title ~= nil then + -- If title is given, transform it into valid file name by removing most special characters + -- Note that parens are not supported because they interfere with markdown links. + return title:gsub("[^A-Za-z0-9-_]", ""):lower() + else + -- If title is nil, just put the date and four random characters + for _ = 1, 4 do + return os.date("%Y-%m-%d ") .. string.char(math.random(65, 90)) + end + end + end, }, }