load obsidian.nvim workspaces from .obsidian_vaults file

this decouples the user-specific vaults from the repo
the `.obsidian_vaults` file is expected to be in the root of the nvim
config
This commit is contained in:
2025-05-23 06:48:22 +02:00
parent c5a11347b2
commit 23b911e176
2 changed files with 23 additions and 6 deletions

1
.gitignore vendored
View File

@@ -1 +1,2 @@
spell/ spell/
.obsidian_vaults

View File

@@ -41,11 +41,27 @@ return {
ui = { ui = {
enable = false, enable = false,
}, },
workspaces = { workspaces = (function()
{ local vaults = {}
name = "personal",
path = "~/obsidian/409", local vaults_file_path = vim.fn.stdpath("config") .. "/.obsidian_vaults"
}, local vaults_file = io.open(vaults_file_path, "r")
},
if vaults_file == nil then
return vaults
end
for line in vaults_file:lines() do
for vault_name, vault_path in string.gmatch(line, "%s*(%S+)%s*=%s*(.+)%s*") do
vaults[#vaults + 1] = {
name = vault_name,
path = vault_path,
}
vim.print(vaults[#vaults])
end
end
return vaults
end)(),
}, },
} }