♻️ refactor(nvim): obsidian extra now has keymaps as well as some new options

This commit is contained in:
Sergio Laín 2024-02-29 13:01:57 +01:00
parent 25bf8585f0
commit b2248d64da
No known key found for this signature in database
GPG key ID: 14C9B8080681777B

View file

@ -1,19 +1,24 @@
return { return {
{
"epwalsh/obsidian.nvim", "epwalsh/obsidian.nvim",
event = { "BufReadPre /docs/Documentos/Obsidian/**.md" }, event = { "BufReadPre /docs/Documentos/Obsidian/**.md" },
keys = { keys = {
{ { "<leader>oo", "<cmd>ObsidianOpen<CR>", desc = "Open on App" },
"gf", { "<leader>og", "<cmd>ObsidianSearch<CR>", desc = "Grep" },
function() { "<leader>sO", "<cmd>ObsidianSearch<CR>", desc = "Obsidian Grep" },
if require("obsidian").util.cursor_on_markdown_link() then { "<leader>on", "<cmd>ObsidianNew<CR>", desc = "New Note" },
return "<cmd>ObsidianFollowLink<CR>" { "<leader>o<space>", "<cmd>ObsidianQuickSwitch<CR>", desc = "Find Files" },
else { "<leader>fo", "<cmd>ObsidianQuickSwitch<CR>", desc = "Find Obsidian Files" },
return "gf" { "<leader>ob", "<cmd>ObsidianBacklinks<CR>", desc = "Backlinks" },
end { "<leader>ot", "<cmd>ObsidianTags<CR>", desc = "Tags" },
end, { "<leader>ot", "<cmd>ObsidianTemplate<CR>", desc = "Template" },
noremap = false, { "<leader>ol", "<cmd>ObsidianLink<CR>", desc = "Link" },
expr = true, { "<leader>oL", "<cmd>ObsidianLinks<CR>", desc = "Links" },
}, { "<leader>oN", "<cmd>ObsidianLinkNew<CR>", desc = "New Link" },
{ "<leader>oe", "<cmd>ObsidianExtractNote<CR>", desc = "Extract Note" },
{ "<leader>ow", "<cmd>ObsidianWorkspace<CR>", desc = "Workspace" },
{ "<leader>or", "<cmd>ObsidianRename<CR>", desc = "Rename" },
{ "<leader>oi", "<cmd>ObsidianPasteImg<CR>", desc = "Paste Image" },
}, },
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
@ -28,6 +33,9 @@ return {
path = "~/Documentos/Obsidian/obsidianVault/root", path = "~/Documentos/Obsidian/obsidianVault/root",
}, },
}, },
notes_subdir = "Notes",
daily_notes = { daily_notes = {
folder = "Journal/Entries/Daily", folder = "Journal/Entries/Daily",
date_format = "%Y-%m-%d", date_format = "%Y-%m-%d",
@ -36,14 +44,12 @@ return {
}, },
mappings = { mappings = {
-- Overrides the 'gf' mapping to work on markdown/wiki links within your vault.
["gf"] = { ["gf"] = {
action = function() action = function()
return require("obsidian").util.gf_passthrough() return require("obsidian").util.gf_passthrough()
end, end,
opts = { noremap = false, expr = true, buffer = true }, opts = { noremap = false, expr = true, buffer = true },
}, },
-- Toggle check-boxes.
["<C-c>"] = { ["<C-c>"] = {
action = function() action = function()
return require("obsidian").util.toggle_checkbox() return require("obsidian").util.toggle_checkbox()
@ -58,41 +64,21 @@ return {
time_format = "%H:%M", time_format = "%H:%M",
}, },
backlinks = { height = 10, wrap = true },
-- Optional, by default when you use `:ObsidianFollowLink` on a link to an external
-- URL it will be ignored but you can customize this behavior here.
follow_url_func = function(url) follow_url_func = function(url)
-- Open the URL in the default web browser. vim.fn.jobstart({ "xdg-open", url })
vim.fn.jobstart({ "xdg-open", url }) -- linux
end, end,
-- Optional, set to true if you use the Obsidian Advanced URI plugin.
-- https://github.com/Vinzent03/obsidian-advanced-uri
use_advanced_uri = false,
-- Optional, set to true to force ':ObsidianOpen' to bring the app to the foreground.
open_app_foreground = false,
finder = "telescope.nvim",
open_notes_in = "current",
attachments = { attachments = {
img_folder = "_data_/media", img_folder = "_data_/media",
}, },
},
note_frontmatter_func = function(note) },
-- This is equivalent to the default frontmatter function. {
local out = { id = note.id, aliases = note.aliases, tags = note.tags } "folke/which-key.nvim",
-- `note.metadata` contains any manually added fields in the frontmatter. opts = {
-- So here we just make sure those fields are kept in the frontmatter. defaults = {
if note.metadata ~= nil and require("obsidian").util.table_length(note.metadata) > 0 then ["<leader>o"] = { name = " obsidian" },
for k, v in pairs(note.metadata) do },
out[k] = v },
end
end
return out
end,
}, },
} }