Only load obsidian if we have at least one workspace
This commit is contained in:
parent
c348b80b9f
commit
8f70e5e8a1
|
@ -20,8 +20,10 @@ return {
|
||||||
config = function(_, opts)
|
config = function(_, opts)
|
||||||
local notes_path = (os.getenv "HOME") .. "/Workspace/Notes"
|
local notes_path = (os.getenv "HOME") .. "/Workspace/Notes"
|
||||||
local scan = require("plenary.scandir").scan_dir(notes_path, {add_dirs = true, depth = 1 })
|
local scan = require("plenary.scandir").scan_dir(notes_path, {add_dirs = true, depth = 1 })
|
||||||
|
local found = false
|
||||||
for _, v in ipairs(scan) do
|
for _, v in ipairs(scan) do
|
||||||
local subdir = v:match("([^/]+)$")
|
local subdir = v:match("([^/]+)$")
|
||||||
|
found = true
|
||||||
if vim.fn.isdirectory(notes_path .. "/" .. subdir .. "/.obsidian") == 1 then
|
if vim.fn.isdirectory(notes_path .. "/" .. subdir .. "/.obsidian") == 1 then
|
||||||
table.insert(opts.workspaces, {
|
table.insert(opts.workspaces, {
|
||||||
name = subdir,
|
name = subdir,
|
||||||
|
@ -34,7 +36,9 @@ return {
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
require("obsidian").setup(opts)
|
if found then
|
||||||
|
require("obsidian").setup(opts)
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
opts = {
|
opts = {
|
||||||
workspaces = {},
|
workspaces = {},
|
||||||
|
|
Loading…
Reference in New Issue