mirror of
https://github.com/js0ny/dotfiles.git
synced 2025-12-21 00:33:00 +00:00
feat(nvim): obsidian-nvim frontmatter, clip image
This commit is contained in:
parent
5140f754cc
commit
d7ddf1f060
6 changed files with 92 additions and 21 deletions
|
|
@ -10,7 +10,7 @@
|
|||
require("config.options")
|
||||
if vim.g.vscode then -- TODO: VSCode Neovim Integration
|
||||
require("config.vscode")
|
||||
else -- Vanilla neovim
|
||||
else
|
||||
require("config.plugins")
|
||||
require("config.colorscheme")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ return {
|
|||
"js0ny/luasnip-latex-snippets.nvim",
|
||||
dependencies = { "L3MON4D3/LuaSnip", "lervag/vimtex" },
|
||||
ft = { "tex", "latex", "markdown", "org" },
|
||||
opts = {}
|
||||
opts = {},
|
||||
dev = true,
|
||||
dir = "~/Source/Forks/luasnip-latex-snippets.nvim/"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ return {
|
|||
{ "<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.autopairs" },
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
"obsidian-nvim/obsidian.nvim",
|
||||
version = "*", -- recommended, use latest release instead of latest commit
|
||||
|
|
@ -63,6 +72,53 @@ return {
|
|||
ui = {
|
||||
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 = {
|
||||
folder = "_Global/Periodic",
|
||||
date_format = "%Y-%m-%d",
|
||||
|
|
|
|||
|
|
@ -30,24 +30,6 @@ return {
|
|||
"hrsh7th/nvim-cmp", -- autocompletion for avante commands and mentions
|
||||
"nvim-tree/nvim-web-devicons", -- or echasnovski/mini.icons
|
||||
"zbirenbaum/copilot.lua", -- for providers='copilot'
|
||||
{
|
||||
-- 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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
30
tools/nvim/lua/plugins/mod/img-clip.lua
Normal file
30
tools/nvim/lua/plugins/mod/img-clip.lua
Normal 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,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue