Skip to content
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

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

Open
RobberFox opened this issue Dec 15, 2024 · 1 comment
Open

Comments

@RobberFox
Copy link

RobberFox commented Dec 15, 2024

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

@RobberFox RobberFox changed the title "File already exists" error when creating new noties with obsidian.nvim "File already exists" error when creating new notes with obsidian.nvim Dec 17, 2024
@oflisback
Copy link
Owner

Thanks for reporting and for the minimal config suggestion, I hope it doesn't matter because I'm not using the exact same config when I try this (I don't have custom.obsidian_opts). Maybe we can focus on one of the ways to reproduce the problem and see if we do the same thing. What I do is:

  1. Inside a.md I give the command :ObsidianNew b.md.
  2. A b document opens in obsidian, in neovim I get a warning: File "~/Documents/test/b.md" has been created after editing started.
  3. I press L in neovim. An empty file b.md is opened in neovim, I can edit and save it and the change is reflected in Obsidian.

I've tried a few different variants of the scenario that behave in the same way but perhaps we can focus on that exact one first to see what's different when you do it. I'm using Obsidian 1.7.7.

First thing to try is probably to run obsidian.nvim without any custom options and see how that behaves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants