I noticed any markdown in a given repository will cause a conflict between Obsidian and DiffView,
How to reproduce: Have DiffView.nvim and obsidian.nvim installed modify any given md file in any given git repository and launch the DiffView for the modified md file
Original bug report
This is my vault structure
~/vaults/
βββ .git
βββ dev
βββ job
βββ vie
Where each folder : job, dev and vie are a obsidian vault :
workspaces = {
-- Default vault
{
name = "dev",
path = "~/vaults/dev",
},
-- Other vaults
{
name = "vie",
path = "~/vaults/vie",
},
{
name = "job",
path = "~/vaults/job",
},
When something is changed in the repo, if I open the plugin with diffView I got these errors :
...re/nvim/lazy/diffview.nvim/lua/diffview/scene/window.lua:150: BufEnter Autocommands for "*.md": Vim(append):Error executing lua callback: ...ocal/share/nvim/lazy/obsidian.nvim/lua/obsidian/path.lua:402: FileNotFoundError: diffview:/home/stabei/vaults/.git/:0:/vie
stack traceback:
[C]: in function 'error'
...ocal/share/nvim/lazy/obsidian.nvim/lua/obsidian/path.lua:402: in function 'resolve'
...share/nvim/lazy/obsidian.nvim/lua/obsidian/workspace.lua:159: in function 'get_workspace_for_dir'
...ocal/share/nvim/lazy/obsidian.nvim/lua/obsidian/init.lua:125: in function <...ocal/share/nvim/lazy/obsidian.nvim/lua/obsidian/init.lua:117>
It seems this function in the path.lua
---@return obsidian.Path
Path.resolve = function(self, opts)
opts = opts or {}
local realpath = self:fs_realpath()
if realpath then
return Path.new(realpath)
elseif opts.strict then
error("FileNotFoundError: " .. self.filename)
end
-- File doesn't exist, but some parents might. Traverse up until we find a parent that
-- does exist, and then put the path back together from there.
local parents = self:parents()
for _, parent in ipairs(parents) do
local parent_realpath = parent:fs_realpath()
if parent_realpath then
return Path.new(parent_realpath) / self:relative_to(parent)
end
end
return self
end
is trying to find the vault under .git folder
Config
return {
'epwalsh/obsidian.nvim',
lazy = false,
dependencies = {
"hrsh7th/nvim-cmp",
"preservim/vim-markdown",
},
opts = {
workspaces = {
-- Default vault
{
name = "dev",
path = "~/vaults/dev",
},
-- Other vault
{
name = "vie",
path = "~/vaults/vie",
},
{
name = "job",
path = "~/vaults/job",
},
},
-- Optional, completion.
completion = {
nvim_cmp = true, -- if using nvim-cmp, otherwise set to false
},
wiki_link_func = "use_alias_only",
preferred_link_style = "wiki",
-- Optional, customize how names/IDs for new notes are created.
note_id_func = function(title)
-- Create note IDs in a Zettelkasten format with a timestamp and a suffix.
-- In this case a note with the title 'My new note' will given an ID that looks
-- like '1657296016-my-new-note', and therefore the file name '1657296016-my-new-note.md'
local suffix = ""
if title ~= nil then
-- If title is given, transform it into valid file name
-- replace spaces with hyphens and all lower case.
suffix = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower()
else
-- If title is nil, just add 4 random uppercase letters to the suffix.
for _ = 1, 4 do
suffix = suffix .. string.char(math.random(65, 90))
end
suffix = tostring(os.time()) .. "-" .. suffix
end
return suffix
end,
-- Optional, by default when you use `:ObsidianFollowLink` on a link to an external
follow_url_func = function(url)
vim.fn.jobstart({ "xdg-open", url }) -- linux
end,
-- Optional, set to true to force ':ObsidianOpen' to bring the app to the foreground.
open_app_foreground = true,
-- Optional, set to true if you don't want Obsidian to manage frontmatter.
disable_frontmatter = false,
note_frontmatter_func = function(note)
-- Add a custom property as date
local currentDate = os.date("%Y/%m/%d %I:%M %p")
local out = {
tags = note.tags,
created = currentDate,
}
-- `note.metadata` contains any manually added fields in the frontmatter.
-- So here we just make sure those fields are kept in the frontmatter.
if note.metadata ~= nil and not vim.tbl_isempty(note.metadata) then
for k, v in pairs(note.metadata) do
out[k] = v
end
end
return out
end,
-- templates = {
-- subdir = "templates",
-- date_format = "%Y-%m-%d",
-- time_format = "%H:%M",
-- -- A map for custom variables, the key should be the variable and the value a function
-- substitutions = {},
-- },
-- Mapping to be available in a obsidian note file
mappings = {
-- Overrides the 'gf' mapping to work on markdown/wiki links within your vault.
["gf"] = {
action = function()
return require("obsidian").util.gf_passthrough()
end,
opts = { noremap = false, expr = true, buffer = true },
},
-- Toggle check-boxes.
["<space>oc"] = {
action = function()
return require("obsidian").util.toggle_checkbox()
end,
opts = { buffer = true, silent = true, desc = "Toggle Checkbox" },
},
}
}
}
π Describe the bug
UPDATE:
I noticed any markdown in a given repository will cause a conflict between Obsidian and DiffView,
How to reproduce: Have DiffView.nvim and obsidian.nvim installed modify any given md file in any given git repository and launch the DiffView for the modified md file
Original bug report
This is my vault structure
Where each folder : job, dev and vie are a obsidian vault :
When something is changed in the repo, if I open the plugin with diffView I got these errors :
It seems this function in the path.lua
is trying to find the vault under
.git
folderConfig
Environment