Skip to content

"File already exists" error when creating new notes with obsidian.nvim #31

@RobberFox

Description

@RobberFox

When I create a new note (either from a link, or with :ObsidianNew, etc.) next things happen:

  • Obsidian switches from reading mode to edit mode.
  • The file is empty inside of Obsidian, while in nvim it has the obsidian.nvim's header alias
  • I can't save the file without overriding

Obsidian-bridge-nvim

Here is a minimal working plugin

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
	local lazyrepo = "https://github.com/folke/lazy.nvim.git"
	local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
	if vim.v.shell_error ~= 0 then
		vim.api.nvim_echo({
			{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
			{ out, "WarningMsg" },
			{ "\nPress any key to exit..." },
		}, true, {})
		vim.fn.getchar()
		os.exit(1)
	end
end

vim.opt.rtp:prepend(lazypath)


require("lazy").setup({
	spec = {
		{
			"epwalsh/obsidian.nvim",
			version = "*",  -- recommended, use latest release instead of latest commit
			lazy = true,
			ft = "markdown",
			dependencies = {
				-- Required.
				"nvim-lua/plenary.nvim",
				"ibhagwan/fzf-lua",
				"nvim-treesitter/nvim-treesitter",
			},

			opts = require("custom.obsidian_opts"),
		},

		{
			"oflisback/obsidian-bridge.nvim",
			lazy = true,
			event = {
				"BufReadPre *.md",
				"BufNewFile *.md",
			},
			dependencies = {
				"nvim-lua/plenary.nvim",
				"nvim-telescope/telescope.nvim",
			},
			opts = {
				--	obsidian_server_address = "https://127.0.0.1:27124",
				--	cert_path = "~/.ssl/obsidian.crt",
			},
		}
	},
})

Try to write in some new link and do :ObsidianLink

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions