obsidian.nvim icon indicating copy to clipboard operation
obsidian.nvim copied to clipboard

The front matter is automatically replaced when saved using obsidian.nvim.

Open tadsn3w opened this issue 10 months ago β€’ 5 comments

πŸ› 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: Image

After saving the file: Image

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:

tadsn3w avatar Feb 12 '25 23:02 tadsn3w

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 avatar Feb 14 '25 04:02 utilitron000

@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.

tadsn3w avatar Feb 14 '25 18:02 tadsn3w

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,

RomaP13 avatar Feb 24 '25 06:02 RomaP13

I think I see the issue. You set disable_frontmatter = true outside of opts, but it needs to be inside opts.

RomaP13 avatar Feb 24 '25 06:02 RomaP13

I think I see the issue. You set disable_frontmatter = true outside of opts, but it needs to be inside opts.

AH!! Thank you so much, you are my hero!!!

utilitron000 avatar Feb 24 '25 18:02 utilitron000