Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tadsn3w opened this issue Feb 12, 2025 · 5 comments
Open
Labels
bug Something isn't working

Comments

@tadsn3w
Copy link

tadsn3w commented Feb 12, 2025

🐛 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 tadsn3w added the bug Something isn't working label Feb 12, 2025
@utilitron000
Copy link

utilitron000 commented Feb 14, 2025

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

@tadsn3w
Copy link
Author

tadsn3w commented Feb 14, 2025

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

@RomaP13
Copy link

RomaP13 commented Feb 24, 2025

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
Copy link

RomaP13 commented Feb 24, 2025

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

@utilitron000
Copy link

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!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants