dotfiles/nvim/lua/plugins/obsidian.lua

38 lines
1.2 KiB
Lua

local function handle_enter()
local util = require("obsidian.util")
if util.cursor_on_markdown_link(nil, nil, true) then
vim.cmd("ObsidianFollowLink")
else
local line = vim.api.nvim_get_current_line()
if string.match(line, "^%s*- %[ %].*") then
util.toggle_checkbox()
else
vim.cmd("normal! viw:'<,'>ObsidianLink")
end
end
end
return {
"epwalsh/obsidian.nvim",
version = "*", -- recommended, use latest release instead of latest commit
ft = "markdown",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {
workspaces = {
{
name = "Lumentis",
path = "~/Workspace/DnD/Lumentis Campaign Setting/",
},
},
disable_frontmatter = true,
},
keys = {
{"<cr>", handle_enter, ft = "markdown" },
{"<cr>", ":ObsidianLink<cr>", ft = "markdown", mode = "v"},
{"gd", handle_enter, ft = "markdown" },
{"<leader>rn", ":ObsidianRename<cr>", ft = "markdown" },
{"<tab>", ":set nohlsearch<cr>/\\[[^\\[\\]]*\\]([^()]*)<cr>:let @/ = \"\"<cr>:set hlsearch<cr>", ft = "markdown", silent = true },
},
detect_cwd = true,
}