Add obsidian plugin

This commit is contained in:
pro100ton 2025-02-03 20:55:31 +03:00
parent 3af7600379
commit a28b24c943
3 changed files with 101 additions and 26 deletions

64
lua/custom/obsidian.lua Normal file
View file

@ -0,0 +1,64 @@
require("obsidian").setup {
-- Set workspace setting
workspaces = {
{
name = "personal",
path = "~/Documents/t0xa_vault",
}
},
-- Disable conceal level to supress varning log message
ui = {
enable = false
},
-- Set notes subdir to store new notes
notes_subdir = "Unsorted",
new_notes_location = "notes_subdir",
-- Set template params
templates = {
folder = "Templates",
date_format = "%Y-%m-%d",
time_format = "%H:%M",
substitutions = {
yesterday = function()
return os.date("%Y-%m-%d", os.time() - 86400)
end
}
},
-- Set behaviour of following links
follow_url_func = function(url)
-- vim.fn.jobstart({ "open", url }) -- Mac OS
vim.fn.jobstart({ "xdg-open", url }) -- linux
-- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows
-- vim.ui.open(url) -- need Neovim 0.10.0+
end,
-- Set behaviour for opening images
follow_img_func = function(img)
-- vim.fn.jobstart { "qlmanage", "-p", img } -- Mac OS quick look preview
vim.fn.jobstart({ "xdg-open", url }) -- linux
-- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows
end,
-- Set sorting for creation date
sort_by = "created",
-- Set attachements new folder
attachments = {
img_folder = "Media"
}
}
-- Obsidian-related keybinds
vim.keymap.set("n", "<leader>oit", "<cmd>ObsidianTemplate<CR>",
{ silent = true, noremap = true, desc = "Obsidian: insert template" })
vim.keymap.set("n", "<leader>oo", "<cmd>ObsidianQuickSwitch<CR>",
{ silent = true, noremap = true, desc = "Obsidian: open file" })
vim.keymap.set("n", "<leader>opi", "<cmd>ObsidianPasteImg<CR>",
{ silent = true, noremap = true, desc = "Obsidian: paste image" })
vim.keymap.set("n", "<leader>or", "<cmd>ObsidianRename<CR>",
{ silent = true, noremap = true, desc = "Obsidian: rename file" })
vim.keymap.set("n", "<leader>ol", "<cmd>ObsidianToggleCheckbox<CR>",
{ silent = true, noremap = true, desc = "Obsidian: toggle checkbox" })
vim.keymap.set("n", "<leader>on", "<cmd>ObsidianNew<CR>", { silent = true, noremap = true, desc = "Obsidian: new file" })
vim.keymap.set("n", "<leader>otoc", "<cmd>ObsidianTOC<CR>",
{ silent = true, noremap = true, desc = "Obsidian: open TOC" })
vim.keymap.set("n", "<leader>ofl", "<cmd>ObsidianFollowLink<CR>",
{ silent = true, noremap = true, desc = "Obsidian: follow link" })

View file

@ -1,27 +1,26 @@
require("oil").setup{
opts = {
keymaps = {
["g?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<C-s>"] = { "actions.select", opts = { vertical = true }, desc = "Open the entry in a vertical split" },
["<C-h>"] = false,
["<C-t>"] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" },
["<C-p>"] = "actions.preview",
["<C-c>"] = "actions.close",
["<C-l>"] = false,
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = { "actions.cd", opts = { scope = "tab" }, desc = ":tcd to the current oil directory", mode = "n" },
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
["g\\"] = "actions.toggle_trash",
},
view_options = {
show_hidden = true,
},
},
-- Open parent directory in current window
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" }),
require("oil").setup {
keymaps = {
["g?"] = "actions.show_help",
["<CR>"] = "actions.select",
["<C-s>"] = { "actions.select", opts = { vertical = true }, desc = "Open the entry in a vertical split" },
["<C-h>"] = false,
["<C-t>"] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" },
["<C-p>"] = "actions.preview",
["<C-c>"] = "actions.close",
["<C-l>"] = false,
["-"] = "actions.parent",
["_"] = "actions.open_cwd",
["`"] = "actions.cd",
["~"] = { "actions.cd", opts = { scope = "tab" }, desc = ":tcd to the current oil directory", mode = "n" },
["gs"] = "actions.change_sort",
["gx"] = "actions.open_external",
["g."] = "actions.toggle_hidden",
["g\\"] = "actions.toggle_trash",
},
view_options = {
show_hidden = true,
},
-- Open parent directory in current window
}
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })

View file

@ -0,0 +1,12 @@
return {
"epwalsh/obsidian.nvim",
version = "*",
lazy = true,
ft = "markdown",
dependencies = {
"nvim-lua/plenary.nvim",
},
config = function()
require "custom.obsidian"
end
}