feat(nvim): obsidian-nvim frontmatter, clip image

This commit is contained in:
js0ny 2025-04-13 19:10:34 +01:00
parent 5140f754cc
commit d7ddf1f060
6 changed files with 92 additions and 21 deletions

View file

@ -10,7 +10,7 @@
require("config.options") require("config.options")
if vim.g.vscode then -- TODO: VSCode Neovim Integration if vim.g.vscode then -- TODO: VSCode Neovim Integration
require("config.vscode") require("config.vscode")
else -- Vanilla neovim else
require("config.plugins") require("config.plugins")
require("config.colorscheme") require("config.colorscheme")
end end

View file

@ -17,6 +17,8 @@ return {
"js0ny/luasnip-latex-snippets.nvim", "js0ny/luasnip-latex-snippets.nvim",
dependencies = { "L3MON4D3/LuaSnip", "lervag/vimtex" }, dependencies = { "L3MON4D3/LuaSnip", "lervag/vimtex" },
ft = { "tex", "latex", "markdown", "org" }, ft = { "tex", "latex", "markdown", "org" },
opts = {} opts = {},
dev = true,
dir = "~/Source/Forks/luasnip-latex-snippets.nvim/"
} }
} }

View file

@ -12,6 +12,7 @@ return {
{ "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, { "<c-s>", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" },
}, },
}, },
{ import = "plugins.mod.img-clip" },
{ import = "plugins.mod.mc" }, -- Multiple-cursors { import = "plugins.mod.mc" }, -- Multiple-cursors
{ import = "plugins.mod.autopairs" }, { import = "plugins.mod.autopairs" },
{ {

View file

@ -1,3 +1,12 @@
local uuid = function()
local template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
return string.gsub(template, '[xy]', function(c)
local v = (c == 'x') and math.random(0, 0xf) or math.random(8, 0xb)
return string.format('%x', v)
end)
end
return { return {
"obsidian-nvim/obsidian.nvim", "obsidian-nvim/obsidian.nvim",
version = "*", -- recommended, use latest release instead of latest commit version = "*", -- recommended, use latest release instead of latest commit
@ -63,6 +72,53 @@ return {
ui = { ui = {
enable = false, enable = false,
}, },
templates = {
folder = "_Global/LuaTemplates",
date_format = "%Y-%m-%d",
time_format = "%H:%M",
substitutions = {
yesterday = function()
return os.date("%Y-%m-%d", os.time() - 86400)
end,
uuid = uuid()
},
},
---@return table
note_frontmatter_func = function(note)
-- Add the title of the note as an alias.
if note.title then
note:add_alias(note.title)
end
-- Force to use UUID as the note id.
local note_id
if note.metadata then
note_id = note.id
else
note_id = uuid()
end
local out = {
id = note_id,
aliases = note.aliases,
tags = note.tags,
title = note.id,
date = os.date(
"%Y-%m-%dT00:00:00"),
}
-- `note.metadata` contains any manually added fields in the frontmatter.
-- So here we just make sure those fields are kept in the frontmatter.
if note.metadata ~= nil and not vim.tbl_isempty(note.metadata) then
for k, v in pairs(note.metadata) do
out[k] = v
end
end
-- Force to update mtime.
out.mtime = os.date("%Y-%m-%dT%H:%M:%S")
return out
end,
daily_notes = { daily_notes = {
folder = "_Global/Periodic", folder = "_Global/Periodic",
date_format = "%Y-%m-%d", date_format = "%Y-%m-%d",

View file

@ -30,24 +30,6 @@ return {
"hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions "hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons "nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
"zbirenbaum/copilot.lua", -- for providers='copilot' "zbirenbaum/copilot.lua", -- for providers='copilot'
{ "HakonHarnes/img-clip.nvim",
-- support for image pasting
"HakonHarnes/img-clip.nvim",
event = "VeryLazy",
ft = { "avante", "markdown", "typst", "org", "tex" },
cmd = "PasteImage",
opts = {
-- recommended settings
default = {
embed_image_as_base64 = false,
prompt_for_file_name = false,
drag_and_drop = {
insert_mode = true,
},
-- required for Windows users
use_absolute_path = true,
},
},
},
}, },
} }

View file

@ -0,0 +1,30 @@
return {
{
-- support for image pasting
"HakonHarnes/img-clip.nvim",
event = "VeryLazy",
ft = { "avante", "markdown", "typst", "org", "tex" },
cmd = "PasteImage",
keys = {
{
"<localleader>p",
function()
require("img-clip").paste_image()
end,
desc = "Paste Image",
}
},
opts = {
-- recommended settings
default = {
embed_image_as_base64 = false,
prompt_for_file_name = false,
drag_and_drop = {
insert_mode = true,
},
-- required for Windows users
use_absolute_path = true,
},
}
}
}