obsidian.nvim
Table of Content
Obsidian Nvim Plugin¶
https://github.com/epwalsh/obsidian.nvim
A Neovim plugin for writing and navigating Obsidian vaults, written in Lua.
Requirements:
- [x] [[nvim]] >= 0.8.0
- [x] ripgrep installed
- [x] wsl-open on WSL for
:ObsidianOpen
command -curl -o ~/.local/bin/wsl-open https://raw.githubusercontent.com/4U6U57/wsl-open/master/wsl-open.sh
-chmod u+x ~/.local/bin/wsl-open
- [ ]
export BROWSER={browser path like /mnt/c/Program\ Files/.../browser.exe}
for:ObsidianPasteImg
to work on WSL - [x] pngpaste on Mac for
:ObsidianPasteImg
- [ ] xclip or wl-clipboard on Linux for
:ObsidianPasteImg
- [x] telescope for some search functionality
- [x] set conceal option value to 1 or 2
~/.config/nvim/lua/plugins/obsidian.lua
return {
-- https://github.com/epwalsh/obsidian.nvim
-- A Neovim plugin for writing and navigating Obsidian vaults, written in Lua.
"epwalsh/obsidian.nvim",
version = "*", -- recommended, use latest release instead of latest commit
lazy = true,
ft = "markdown",
dependencies = {
-- Required.
"nvim-lua/plenary.nvim",
},
opts = {
-- workspaces
workspaces = {
{
name = "beryl",
path = "~/repos/cp.blink-1x52.net/pages/beryl",
overrides = {
notes_subdir = "docs",
},
},
{
name = "citrine",
path = "~/repos/cp.blink-1x52.net/pages/citrine",
overrides = {
notes_subdir = "docs",
},
},
{
-- outside of obsidian vault
-- https://github.com/epwalsh/obsidian.nvim?tab=readme-ov-file#usage-outside-of-a-workspace-or-vault
name = "no-vault",
path = function()
return assert(vim.fs.dirname(vim.api.nvim_buf_get_name(0)))
end,
overrides = {
notes_subdir = vim.NIL,
completion = {
new_notes_location = "current_dir",
},
templates = {
subdir = vim.NIL,
},
disable_frontmatter = true,
},
},
},
-- log level
log_level = vim.log.levels.INFO,
-- daily notes
daily_notes = {
folder = "docs/daily",
template = nil,
},
-- Optional, configure key mappings.
-- These are the defaults.
-- If you don't want to set any keymappings this way
-- then set 'mappings = {}'.
mappings = {
-- Overrides the 'gf' mapping to work on markdown/wiki links within your vault.
["gf"] = {
action = function()
return require("obsidian").util.gf_passthrough()
end,
opts = { noremap = false, expr = true, buffer = true },
},
-- Toggle check-boxes.
["<leader>ch"] = {
action = function()
return require("obsidian").util.toggle_checkbox()
end,
opts = { buffer = true },
},
},
-- Specify how to handle attachments.
attachments = {
-- The default folder to place images in via `:ObsidianPasteImg`.
-- If this is a relative path it will be interpreted as relative to the vault root.
-- You can always override this per image by passing a full path to the command instead of just a filename.
-- img_folder = "assets/imgs", -- This is the default
img_folder = "docs/assets/imgs",
-- A function that determines the text to insert in the note when pasting an image.
-- It takes two arguments, the `obsidian.Client` and a plenary `Path` to the image file.
-- This is the default implementation.
---@param client obsidian.Client
---@param path Path the absolute path to the image file
---@return string
img_text_func = function(client, path)
local link_path
local vault_relative_path = client:vault_relative_path(path)
if vault_relative_path ~= nil then
-- Use relative path if the image is saved in the vault dir.
link_path = vault_relative_path
else
-- Otherwise use the absolute path.
link_path = tostring(path)
end
local display_name = vim.fs.basename(link_path)
return string.format("![%s](%s)", display_name, link_path)
end,
},
},
}