feat: fennelize obsidian
This commit is contained in:
parent
168dd73429
commit
98be3f4254
2 changed files with 39 additions and 39 deletions
24
fnl/plugins/obsidian.fnl
Normal file
24
fnl/plugins/obsidian.fnl
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
(fn get-workspaces []
|
||||||
|
(let [all-workspaces [{:name :vault
|
||||||
|
:path (vim.fs.normalize "~/Documents/vaults/vault")}
|
||||||
|
{:name :alexandria
|
||||||
|
:path (vim.fs.normalize "~/Documents/alexandria/content")}]
|
||||||
|
existing-workspaces {}]
|
||||||
|
(each [i x (ipairs all-workspaces)]
|
||||||
|
(when (= (vim.fn.isdirectory x.path) 1)
|
||||||
|
(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)))
|
||||||
|
existing-workspaces))
|
||||||
|
|
||||||
|
{1 :obsidian.nvim
|
||||||
|
:after (fn []
|
||||||
|
(local workspaces (get-workspaces))
|
||||||
|
(when (> (length workspaces) 0)
|
||||||
|
(local opts {:completion {:nvim_cmp false}
|
||||||
|
:ui {:enable false}
|
||||||
|
: workspaces})
|
||||||
|
((. (require :obsidian) :setup) opts)))
|
||||||
|
:ft [:markdown]}
|
50
lua/plugins/obsidian.lua
generated
50
lua/plugins/obsidian.lua
generated
|
@ -1,47 +1,23 @@
|
||||||
|
-- [nfnl] Compiled from ./fnl/plugins/obsidian.fnl by https://github.com/Olical/nfnl, do not edit.
|
||||||
local function get_workspaces()
|
local function get_workspaces()
|
||||||
local all_workspaces = {
|
local all_workspaces = {{name = "vault", path = vim.fs.normalize("~/Documents/vaults/vault")}, {name = "alexandria", path = vim.fs.normalize("~/Documents/alexandria/content")}}
|
||||||
{
|
|
||||||
name = "vault",
|
|
||||||
path = vim.fs.normalize("~/Documents/vaults/vault"),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name = "alexandria",
|
|
||||||
path = vim.fs.normalize("~/Documents/alexandria/content"),
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
local existing_workspaces = {}
|
local existing_workspaces = {}
|
||||||
|
|
||||||
for i, x in ipairs(all_workspaces) do
|
for i, x in ipairs(all_workspaces) do
|
||||||
if vim.fn.isdirectory(x.path) == 1 then
|
if (vim.fn.isdirectory(x.path) == 1) then
|
||||||
table.insert(existing_workspaces, all_workspaces[i])
|
table.insert(existing_workspaces, all_workspaces[i])
|
||||||
vim.notify(
|
vim.notify(("Detected Obsidian workspace " .. x.path .. ", adding " .. vim.inspect(all_workspaces[i]) .. " to obsidian workspaces"), vim.log.levels.DEBUG)
|
||||||
[[Detected Obsidian workspace ]]
|
else
|
||||||
.. x.path
|
|
||||||
.. [[, adding ]]
|
|
||||||
.. vim.inspect(all_workspaces[i])
|
|
||||||
.. [[ to obsidian workspaces]],
|
|
||||||
vim.log.levels.DEBUG
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return existing_workspaces
|
return existing_workspaces
|
||||||
end
|
end
|
||||||
|
local function _2_()
|
||||||
return {
|
|
||||||
"obsidian.nvim",
|
|
||||||
ft = { "markdown" },
|
|
||||||
after = function()
|
|
||||||
local workspaces = get_workspaces()
|
local workspaces = get_workspaces()
|
||||||
|
if (#workspaces > 0) then
|
||||||
if #workspaces > 0 then
|
local opts = {completion = {nvim_cmp = false}, ui = {enable = false}, workspaces = workspaces}
|
||||||
local opts = {
|
return require("obsidian").setup(opts)
|
||||||
ui = { enable = false },
|
else
|
||||||
workspaces = workspaces,
|
return nil
|
||||||
completion = { nvim_cmp = false },
|
|
||||||
}
|
|
||||||
require("obsidian").setup(opts)
|
|
||||||
end
|
end
|
||||||
end,
|
end
|
||||||
}
|
return {"obsidian.nvim", after = _2_, ft = {"markdown"}}
|
||||||
|
|
Loading…
Reference in a new issue