feat: add workspace detection functionality to obsidian.nvim
This commit is contained in:
parent
dc61ca5949
commit
c5ff1fd608
2 changed files with 46 additions and 0 deletions
|
@ -13,6 +13,7 @@ return {
|
|||
require("plugins.toggleterm"),
|
||||
require("plugins.by-lang.latex"),
|
||||
require("plugins.neogit"),
|
||||
require("plugins.obsidian"),
|
||||
{ "vim-wakatime" },
|
||||
{ "clangd_extensions.nvim" },
|
||||
{ "vim-sleuth" },
|
||||
|
|
45
lua/plugins/obsidian.lua
Normal file
45
lua/plugins/obsidian.lua
Normal file
|
@ -0,0 +1,45 @@
|
|||
local function get_workspaces()
|
||||
local all_workspaces = {
|
||||
{
|
||||
name = "vault",
|
||||
path = vim.fs.normalize("~/Documents/vaults/vault"),
|
||||
},
|
||||
{
|
||||
name = "alexandria",
|
||||
path = vim.fs.normalize("~/Documents/alexandria/content"),
|
||||
},
|
||||
}
|
||||
|
||||
local existing_workspaces = {}
|
||||
|
||||
for i, x in ipairs(all_workspaces) do
|
||||
if vim.fn.isdirectory(x.path) == 1 then
|
||||
table.insert(existing_workspaces, all_workspaces[i])
|
||||
vim.notify(
|
||||
[[Detected Obsidian workspace ]]
|
||||
.. x.path
|
||||
.. [[, adding ]]
|
||||
.. vim.inspect(all_workspaces[i])
|
||||
.. [[ to obsidian workspaces]],
|
||||
vim.log.levels.DEBUG
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
return existing_workspaces
|
||||
end
|
||||
|
||||
return {
|
||||
"obsidian.nvim",
|
||||
ft = { "markdown" },
|
||||
after = function()
|
||||
local workspaces = get_workspaces()
|
||||
|
||||
if #workspaces > 0 then
|
||||
require("obsidian").setup({
|
||||
ui = { enable = false },
|
||||
workspaces = workspaces,
|
||||
})
|
||||
end
|
||||
end,
|
||||
}
|
Loading…
Reference in a new issue