diff --git a/tools/nvim/init.lua b/tools/nvim/init.lua index 364ba8a..17084ea 100644 --- a/tools/nvim/init.lua +++ b/tools/nvim/init.lua @@ -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 diff --git a/tools/nvim/lua/plugins/completion.lua b/tools/nvim/lua/plugins/completion.lua index 9541f9e..af9e473 100644 --- a/tools/nvim/lua/plugins/completion.lua +++ b/tools/nvim/lua/plugins/completion.lua @@ -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/" } } diff --git a/tools/nvim/lua/plugins/edit.lua b/tools/nvim/lua/plugins/edit.lua index a414cda..a3b8fa0 100644 --- a/tools/nvim/lua/plugins/edit.lua +++ b/tools/nvim/lua/plugins/edit.lua @@ -12,6 +12,7 @@ return { { "", 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" }, { diff --git a/tools/nvim/lua/plugins/lang/markdown/obsidian-nvim.lua b/tools/nvim/lua/plugins/lang/markdown/obsidian-nvim.lua index 584c96a..0b1aa92 100644 --- a/tools/nvim/lua/plugins/lang/markdown/obsidian-nvim.lua +++ b/tools/nvim/lua/plugins/lang/markdown/obsidian-nvim.lua @@ -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", diff --git a/tools/nvim/lua/plugins/mod/avante-nvim.lua b/tools/nvim/lua/plugins/mod/avante-nvim.lua index 90b0d6b..708f663 100644 --- a/tools/nvim/lua/plugins/mod/avante-nvim.lua +++ b/tools/nvim/lua/plugins/mod/avante-nvim.lua @@ -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, - }, - }, - }, + "HakonHarnes/img-clip.nvim", }, } diff --git a/tools/nvim/lua/plugins/mod/img-clip.lua b/tools/nvim/lua/plugins/mod/img-clip.lua new file mode 100644 index 0000000..4cb4bc4 --- /dev/null +++ b/tools/nvim/lua/plugins/mod/img-clip.lua @@ -0,0 +1,30 @@ +return { + { + -- support for image pasting + "HakonHarnes/img-clip.nvim", + event = "VeryLazy", + ft = { "avante", "markdown", "typst", "org", "tex" }, + cmd = "PasteImage", + keys = { + { + "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, + }, + } + } +}