epwalsh / obsidian.nvim

Obsidian 🀝 Neovim
Apache License 2.0
4.23k stars 190 forks source link

Invalid YAML frontmatter deletes the whole frontmatter #712

Open Julian opened 2 months ago

Julian commented 2 months ago

πŸ› Describe the bug

Create a new note, and type some invalid frontmatter (below shown with markdown lists instead of YAML ones), e.g.:

---
id: Foo
aliases:
  * bar
tags:
  * foo
---

# Really Important Stuff

On save, the entire frontmatter is deleted and replaced with empty frontmatter.

This seems almost certainly like it should be filed somewhere, but apologies as I couldn't find it through a search.

Config

return {
  {
    'epwalsh/obsidian.nvim',
    version = '*',
    ft = 'markdown',
    cmd = {
      'ObsidianOpen',
      'ObsidianNew',
      'ObsidianQuickSwitch',
      'ObsidianFollowLink',
      'ObsidianBacklinks',
      'ObsidianTags',
      'ObsidianToday',
      'ObsidianYesterday',
      'ObsidianTomorrow',
      'ObsidianDailies',
      'ObsidianTemplate',
      'ObsidianSearch',
      'ObsidianLink',
      'ObsidianLinkNew',
      'ObsidianLinks',
      'ObsidianExtractNote',
      'ObsidianWorkspace',
      'ObsidianPasteImg',
      'ObsidianRename',
      'ObsidianToggleCheckbox',
      'ObsidianNewFromTemplate',
      'ObsidianTOC',
    },
    dependencies = { 'nvim-lua/plenary.nvim' },
    opts = {
      workspaces = {
        {
          name = 'vault',
          path = vim.env.XDG_DOCUMENTS_DIR .. '/Obsidian',
        },
      },
      follow_url_func = vim.ui.open,
    },
  },
}

Environment


NVIM v0.10.1
Build type: Release
LuaJIT 2.1.1725453128
Run "nvim -V1 -v" for more info
Obsidian.nvim v3.9.0 (ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b)
Status:
  β€’ buffer directory: nil
  β€’ working directory: /Users/julian/Documents/Obsidian
Workspaces:
  βœ“ active workspace: Workspace(name='vault', path='/Users/julian/Documents/Obsidian', root='/Users/julian/Documents/Obsidian')
Dependencies:
  βœ“ plenary.nvim: ec289423a1693aeae6cd0d503bac2856af74edaa
  βœ“ nvim-cmp: ae644feb7b67bf1ce4260c231d1d4300b19c6f30
Integrations:
  βœ“ picker: TelescopePicker()
  βœ“ completion: enabled (nvim-cmp) βœ— refs, βœ— tags, βœ— new
    all sources:
      β€’ nvim_lsp
      β€’ nvim_lsp_signature_help
      β€’ path
      β€’ lazydev
      β€’ buffer
Tools:
  βœ“ rg: ripgrep 14.1.1
Environment:
  β€’ operating system: Darwin
Config:
  β€’ notes_subdir: nil%                                                                                                                                                                                                                                                                                                          ```
Julian commented 2 months ago

For cross-reference because I just saw it, #509 is related in that the behavior I reported here is observed there (invalid YAML deletes what was added). But I personally still think this is undesirable general behavior in any case.