The front matter is automatically replaced when saved using obsidian.nvim.
π Describe the bug
If a file has frontmatter and itβs saved in Neovim, the front matter changes. It doesnβt matter if itβs an old file with front matter or if I just added a new template when itβs saved; the changes occur.
This is originally in Obsidian:
After saving the file:
Config
return {
"epwalsh/obsidian.nvim",
version = "*",
lazy = true,
disable_frontmatter = true,
ft = { "markdown", "markdown.obsidian" }, -- Ensures it only loads for Obsidian-specific Markdown files
dependencies = {
"nvim-lua/plenary.nvim",
},
opts = {
workspaces = {
{
name = "mind",
path = "/Users/Developer/vaults/My_mind",
},
},
notes_subdir = "notes",
completion = {
nvim_cmp = true,
min_chars = 2,
},
new_notes_location = "notes_subdir",
preferred_link_style = "wiki",
templates = {
folder = "Templates",
date_format = "%Y-%m-%d",
time_format = "%H:%M",
},
picker = {
name = "telescope.nvim",
},
sort_by = "modified",
sort_reversed = true,
attachments = {
img_folder = "assets/imgs",
},
},
config = function(_, opts)
vim.opt.conceallevel = 1
opts.mappings = opts.mappings or {} -- β
Ensure mappings exist
opts.mappings["<CR>"] = nil -- β
Correct way to disable Enter remap
-- Ensure Obsidian is set up correctly
require("obsidian").setup(opts)
end,
}
Environment
nvim --version
NVIM v0.10.3
Build type: Release
LuaJIT 2.1.1734355927
nvim --headless -c 'lua require("obsidian").info()' -c q
Obsidian.nvim v3.9.0 (ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b)
Status:
β’ buffer directory: nil
β’ working directory: /Volumes/S-980-1TB/Developer/.config/zellij
Workspaces:
β active workspace: Workspace(name='mind', path='/Users/Developer/vaults/My_mind', root='/Users/Developer/vaults/My_mind')
Dependencies:
β plenary.nvim: 857c5ac632080dba10aae49dba902ce3abf91b35
β nvim-cmp: 12509903a5723a876abd65953109f926f4634c30
β telescope.nvim: a0bbec21143c7bc5f8bb02e0005fa0b982edc026
β fzf-lua: 562593abac4f2796d0cf622876527cfb8d274639
Integrations:
β picker: TelescopePicker()
β completion: enabled (nvim-cmp) β refs, β tags, β new
all sources:
β’ lazydev
β’ nvim_lsp
β’ luasnip
β’ path
β’ tabnine
Tools:
β rg: ripgrep 14.1.1
Environment:
β’ operating system: Darwin
Config:
can confirm, this is also happening on my setups (laptop and desktop.) Also having issues with templates in general, which I know is another open issue.
EDIT: in case you don't read as deeply as I do, this has not been maintained in a number of months, and there has been discussion of forking the repository and continuing development in these issues. AFAIK we have not heard back from the maintainer of this repository, the inimitable epwalsh about either adding folks to the repository or forking it, or, you know, maintaining it himself.
(I'd like to add we are all extremely grateful to epwalsh for the work they have done on this, and don't want to replace them, simply continue this project and get updates and bug fixes for the accumulating bugs.)
@utilitron000, Thanks for confirming it. At this moment, I have to turn off this plugin because I lose data when I save files. I will have to use other plugins (telescope and ripgrep) and some custom functions to mimic what the plugin was doing.
This is not a bug; it's the default behavior(which is very annoying). You need to set disable_frontmatter = true in your options for this plugin.
Check the default configuration:
-- Optional, boolean or a function that takes a filename and returns a boolean.
-- `true` indicates that you don't want obsidian.nvim to manage frontmatter.
disable_frontmatter = false,
I think I see the issue. You set disable_frontmatter = true outside of opts, but it needs to be inside opts.
I think I see the issue. You set
disable_frontmatter = trueoutside ofopts, but it needs to be insideopts.
AH!! Thank you so much, you are my hero!!!