epwalsh / epwalsh/obsidian.nvim

Could you add an option to turn off the automatic update of the frontmatter

Open
#758 1 comment 2 reactions 0 assignees View on GitHub
bug
Dominant language
Lua
Stars
6.2k
Forks
250
PR merge metrics
No merged PRs in 30d

Description

### 🐛 Describe the bug

Currently, the automatic update of the frontmatter is breaking the link format by converting them to tag format. Could you add an option to turn off this feature?

### Config

```lua
local user = "phuongpd"
return {
"epwalsh/obsidian.nvim",
version = "*",
lazy = false,
ft = "markdown",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
vim.keymap.set("n", "gl", function()
if require("obsidian").util.cursor_on_markdown_link() then
return "ObsidianFollowLink"
else
return "gi"
end
end, { noremap = false, expr = true })
require("obsidian").setup({
workspaces = {
{
name = "digital-brain",
path = ("/Users/" .. user .. "/library/Mobile Documents/iCloud~md~obsidian/Documents/digital-brain/"),
},
},
notes_subdir = "[0]-fleeting",
completion = {
nvim_cmp = true,
min_chars = 2,
},
daily_notes = {
folder = "[5]-dailies/2024",
date_format = "%Y-%m-%d",
alias_format = "%B %-d, %Y",
default_tags = { "daily-notes" },
template =
("/Users/" .. user .. "/Library/Mobile Documents/iCloud~md~obsidian/Documents/digital-brain/[9]-meta/template/tp_daily.md")
},
note_frontmatter_func = function(note)
local out = {
aliases = note.aliases,
links = {},
tags = note.tags,
date = os.date(
'%Y-%m-%d', os.time())
}
-- Check for multiple aliases
if #note.aliases > 1 then
out.aliases = note.aliases
end
-- Write date first if metadata exists
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,
mappings = {},
templates = {
subdir = ("/Users/" .. user .. "/Library/Mobile Documents/iCloud~md~obsidian/Documents/digital-brain/[9]-meta/template"),
date_format = "%Y-%m-%d",
time_format = "%H:%M",
tags = "",
substitutions = {
yesterday = function()
return os.date("%Y-%m-%d", os.time() - 86400)
end,
tomorrow = function()
return os.date("%Y-%m-%d", os.time() + 86400)
end,
},
},
note_path_func = function(spec)
-- local formatted_title = spec.title:lower():gsub(" ", "-")
-- return (spec.dir / (os.date("%Y-%m-%d") .. "-" .. formatted_title)):with_suffix(".md")
local path = spec.dir / tostring(spec.title)
return path:with_suffix(".md")
-- return (spec.title):with_suffix(".md")
end,
note_id_func = function(title)
local formatted_title = title:lower():gsub(" ", "-")
return (os.date("%Y%m%d") .. "-" .. formatted_title)
end,
attachments = {
-- The default folder to place images in via `:ObsidianPasteImg`.
-- If this is a relative path it will be interpreted as relative to the vault root.
-- You can always override this per image by passing a full path to the command instead of just a filename.
img_folder = ("/Users/" .. user .. "/Library/Mobile Documents/iCloud~md~obsidian/Documents/digital-brain/[3]-resources/images/"),
-- A function that determines the text to insert in the note when pasting an image.
-- It takes two arguments, the `obsidian.Client` and an `obsidian.Path` to the image file.
-- This is the default implementation.
---@param client obsidian.Client
---@param path obsidian.Path the absolute path to the image file
---@return string
img_text_func = function(client, path)
path = client:vault_relative_path(path) or path
return string.format("![%s](%s)", path.name, path)
end,
},
ui = {
enable = false, -- using render-markdown.nvim instead
},
})
end,
}

```

### Environment

```bash
NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1727870382
Run "nvim -V1 -v" for more info
[better-escape.nvim]: Rewrite! Check: https://github.com/max397574/better-escape.nvim
[better-escape.nvim]: Rewrite! Check: https://github.com/max397574/better-escape.nvim
Obsidian.nvim v3.9.0 (ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b)
Status:
• buffer directory: nil
• working directory: /Users/phuongpd/.config/nvim
Workspaces:
✓ active workspace: Workspace(name='digital-brain', path='/Users/phuongpd/Library/Mobile Documents/iCloud~md~obsidian/Documents/digital-brain', root='/Users/phuongpd/Library/Mobile Documents/iCloud~md~obsidian/Documents/digital-brain')
Dependencies:
✓ plenary.nvim: 2d9b06177a975543726ce5c73fca176cedbffe9d
✓ nvim-cmp: 29fb4854573355792df9e156cb779f0d31308796
✓ telescope.nvim: 7011eaae0ac1afe036e30c95cf80200b8dc3f21a
Integrations:
✓ picker: TelescopePicker()
✓ completion: enabled (nvim-cmp) ✗ refs, ✗ tags, ✗ new
all sources:
Tools:
✓ rg: ripgrep 14.1.0
Environment:
• operating system: Darwin
Config:
• notes_subdir: [0]-fleeting⏎
```

Contributor guide

Open the contributing guide

Research direction

Start from the configured note_frontmatter_func entry point and trace where obsidian.nvim automatically updates frontmatter and converts links to tags. Reproduce the reported conversion, then verify that a new configuration option disables the automatic update while preserving the link format.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.