dotfiles/nvim/lua/plugins/obsidian.lua

81 lines
2.5 KiB
Lua
Raw Normal View History

2024-01-21 16:23:44 +01:00
local function handle_enter()
2024-01-21 12:24:56 +01:00
local util = require("obsidian.util")
if util.cursor_on_markdown_link(nil, nil, true) then
vim.cmd("ObsidianFollowLink")
else
2024-01-21 16:23:44 +01:00
local line = vim.api.nvim_get_current_line()
2024-01-25 18:20:36 +01:00
if string.match(line, "^%s*- %[[x ]%].*") then
2024-01-21 16:23:44 +01:00
util.toggle_checkbox()
else
vim.cmd("normal! viw:'<,'>ObsidianLink")
end
2024-01-21 12:24:56 +01:00
end
end
return {
"epwalsh/obsidian.nvim",
version = "*", -- recommended, use latest release instead of latest commit
2024-02-10 14:02:40 +01:00
lazy = false,
2024-01-21 12:24:56 +01:00
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
workspaces = {
{
name = "Lumentis",
2024-02-12 00:08:09 +01:00
path = "~/Workspace/Notes/Lumentis",
2024-01-21 12:24:56 +01:00
},
2024-01-25 18:20:36 +01:00
{
2024-02-12 00:08:09 +01:00
name = "Lumentis-Players",
path = "~/Workspace/Notes/Lumentis-Players",
2024-01-25 18:20:36 +01:00
},
{
2024-02-12 00:08:09 +01:00
name = "Personal",
path = "~/Workspace/Notes/Personal",
overrides = {
daily_notes = {
folder = "Daily",
},
},
2024-01-25 18:20:36 +01:00
},
2024-02-10 14:02:40 +01:00
{
2024-02-12 00:08:09 +01:00
name = "PhD",
path = "~/Workspace/Notes/PhD",
overrides = {
daily_notes = {
folder = "Daily",
},
},
2024-02-10 14:02:40 +01:00
},
{
2024-02-12 00:08:09 +01:00
name = "DnD",
path = "~/Workspace/Notes/DnD",
override = {
daily_notes = {
folder = ".",
2024-02-10 14:02:40 +01:00
},
},
},
},
2024-01-24 21:45:15 +01:00
disable_frontmatter = true,
ui = {
hl_groups = {
ObsidianRefText = { fg = "#61afef" },
}
}
2024-01-21 12:24:56 +01:00
},
keys = {
2024-01-21 16:23:44 +01:00
{"<cr>", handle_enter, ft = "markdown" },
2024-02-10 14:02:40 +01:00
{"<cr>", "<cmd>ObsidianLink<cr>", ft = "markdown", mode = "v"},
{"<leader>rn", "<cmd>ObsidianRename<cr>", ft = "markdown" },
2024-02-08 15:16:48 +01:00
{"<leader>l", "i- [ ] ", ft = "markdown"},
2024-02-11 23:58:36 +01:00
{"<leader>o", "o- [ ] ", ft = "markdown"},
2024-02-08 15:16:48 +01:00
{"<leader>l", "- [ ] ", ft = "markdown", mode = "i" },
2024-02-10 14:26:58 +01:00
{"<leader>jt", "<cmd>ObsidianToday<cr>"},
{"<leader>jy", "<cmd>ObsidianYesterday<cr>"},
{"<leader>ju", "<cmd>ObsidianTomorrow<cr>"},
2024-01-21 16:23:44 +01:00
{"<tab>", ":set nohlsearch<cr>/\\[[^\\[\\]]*\\]([^()]*)<cr>:let @/ = \"\"<cr>:set hlsearch<cr>", ft = "markdown", silent = true },
2024-01-21 12:24:56 +01:00
},
2024-01-24 21:45:15 +01:00
config = function (_, opts)
require("obsidian").setup(opts)
end
2024-01-21 12:24:56 +01:00
}