refactor: frontmatter for markdown;
feat: plugin for rendering images in markdown; feat: pastify; feat: markdown preview in browser
This commit is contained in:
@@ -102,6 +102,13 @@ vim.keymap.set("n", "<leader>gpg", function()
|
|||||||
os.execute("gpg --detach-sign " .. opened_file_path) -- Execute the GPG sign command
|
os.execute("gpg --detach-sign " .. opened_file_path) -- Execute the GPG sign command
|
||||||
end, { desc = "Sign currently open file with GPG" })
|
end, { desc = "Sign currently open file with GPG" })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd({ "CursorMoved", "WinEnter", "BufEnter" }, {
|
||||||
|
callback = function()
|
||||||
|
vim.defer_fn(function()
|
||||||
|
vim.cmd("redraw!")
|
||||||
|
end, 50)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
function Leave_snippet()
|
function Leave_snippet()
|
||||||
if
|
if
|
||||||
|
|||||||
@@ -5,6 +5,15 @@ require "nvchad.options"
|
|||||||
-- local o = vim.o
|
-- local o = vim.o
|
||||||
-- o.cursorlineopt ='both' -- to enable cursorline!
|
-- o.cursorlineopt ='both' -- to enable cursorline!
|
||||||
|
|
||||||
|
local enable_providers = {
|
||||||
|
"python3_provider",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, plugin in pairs(enable_providers) do
|
||||||
|
vim.g["loaded_" .. plugin] = nil
|
||||||
|
vim.cmd("runtime " .. plugin)
|
||||||
|
end
|
||||||
|
|
||||||
-- disable wrap
|
-- disable wrap
|
||||||
vim.o.wrap = false
|
vim.o.wrap = false
|
||||||
|
|
||||||
|
|||||||
48
nvim/lua/plugins/image.lua
Normal file
48
nvim/lua/plugins/image.lua
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
return {
|
||||||
|
"3rd/image.nvim",
|
||||||
|
event = 'BufEnter',
|
||||||
|
build = false, -- so that it doesn't build the rock https://github.com/3rd/image.nvim/issues/91#issuecomment-2453430239
|
||||||
|
config = function()
|
||||||
|
require("image").setup({
|
||||||
|
backend = "kitty",
|
||||||
|
processor = "magick_cli", -- or "magick_rock"
|
||||||
|
integrations = {
|
||||||
|
markdown = {
|
||||||
|
enabled = true,
|
||||||
|
clear_in_insert_mode = true,
|
||||||
|
download_remote_images = true,
|
||||||
|
only_render_image_at_cursor = false,
|
||||||
|
only_render_image_at_cursor_mode = "popup",
|
||||||
|
floating_windows = false, -- if true, images will be rendered in floating markdown windows
|
||||||
|
filetypes = { "markdown", "vimwiki" }, -- markdown extensions (ie. quarto) can go here
|
||||||
|
},
|
||||||
|
neorg = {
|
||||||
|
enabled = true,
|
||||||
|
filetypes = { "norg" },
|
||||||
|
},
|
||||||
|
typst = {
|
||||||
|
enabled = true,
|
||||||
|
filetypes = { "typst" },
|
||||||
|
},
|
||||||
|
html = {
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
|
css = {
|
||||||
|
enabled = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
max_width = 800,
|
||||||
|
max_height = 400,
|
||||||
|
max_width_window_percentage = nil,
|
||||||
|
max_height_window_percentage = nil,
|
||||||
|
window_overlap_clear_enabled = false, -- toggles images when windows are overlapped
|
||||||
|
window_overlap_clear_ft_ignore = { "cmp_menu", "cmp_docs", "snacks_notif", "scrollview", "scrollview_sign" },
|
||||||
|
editor_only_render_when_focused = false, -- auto show/hide images when the editor gains/looses focus
|
||||||
|
tmux_show_only_in_active_window = false, -- auto show/hide images in the correct Tmux window (needs visual-activity off)
|
||||||
|
hijack_file_patterns = { "*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp", "*.avif" }, -- render image files as images when opened
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
opts = {
|
||||||
|
processor = "magick_cli",
|
||||||
|
}
|
||||||
|
}
|
||||||
11
nvim/lua/plugins/markdown-preview.lua
Normal file
11
nvim/lua/plugins/markdown-preview.lua
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
return {
|
||||||
|
{
|
||||||
|
"iamcco/markdown-preview.nvim",
|
||||||
|
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
|
||||||
|
build = "cd app && npm install",
|
||||||
|
init = function()
|
||||||
|
vim.g.mkdp_filetypes = { "markdown" }
|
||||||
|
end,
|
||||||
|
ft = { "markdown" },
|
||||||
|
},
|
||||||
|
}
|
||||||
41
nvim/lua/plugins/pastify.lua
Normal file
41
nvim/lua/plugins/pastify.lua
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
return {
|
||||||
|
'TobinPalmer/pastify.nvim',
|
||||||
|
cmd = { 'Pastify', 'PastifyAfter' },
|
||||||
|
config = function()
|
||||||
|
require('pastify').setup {
|
||||||
|
opts = {
|
||||||
|
absolute_path = false, -- use absolute or relative path to the working directory
|
||||||
|
apikey = '', -- Api key, required for online saving
|
||||||
|
local_path = '/assets/imgs/', -- The path to put local files in, ex <cwd>/assets/images/<filename>.png
|
||||||
|
save = 'local', -- Either 'local' or 'online' or 'local_file'
|
||||||
|
filename = function() return vim.fn.expand("%:t:r") .. '_' .. os.date("%H-%M-%S_%d.%m.Y") end, -- The file name to save the image as, if empty pastify will ask for a name
|
||||||
|
-- Example function for the file name that I like to use:
|
||||||
|
-- filename = function() return vim.fn.expand("%:t:r") .. '_' .. os.date("%Y-%m-%d_%H-%M-%S") end,
|
||||||
|
-- Example result: 'file_2021-08-01_12-00-00'
|
||||||
|
default_ft = 'markdown', -- Default filetype to use
|
||||||
|
},
|
||||||
|
ft = { -- Custom snippets for different filetypes, will replace $IMG$ with the image url
|
||||||
|
html = '<img src="$IMG$" alt="">',
|
||||||
|
markdown = '',
|
||||||
|
tex = [[\includegraphics[width=\linewidth]{$IMG$}]],
|
||||||
|
css = 'background-image: url("$IMG$");',
|
||||||
|
js = 'const img = new Image(); img.src = "$IMG$";',
|
||||||
|
xml = '<image src="$IMG$" />',
|
||||||
|
php = '<?php echo "<img src=\"$IMG$\" alt=\"\">"; ?>',
|
||||||
|
python = '# $IMG$',
|
||||||
|
java = '// $IMG$',
|
||||||
|
c = '// $IMG$',
|
||||||
|
cpp = '// $IMG$',
|
||||||
|
swift = '// $IMG$',
|
||||||
|
kotlin = '// $IMG$',
|
||||||
|
go = '// $IMG$',
|
||||||
|
typescript = '// $IMG$',
|
||||||
|
ruby = '# $IMG$',
|
||||||
|
vhdl = '-- $IMG$',
|
||||||
|
verilog = '// $IMG$',
|
||||||
|
systemverilog = '// $IMG$',
|
||||||
|
lua = '-- $IMG$',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ local i = ls.insert_node
|
|||||||
local f = ls.function_node
|
local f = ls.function_node
|
||||||
local extras = require("luasnip.extras")
|
local extras = require("luasnip.extras")
|
||||||
local rep = extras.rep
|
local rep = extras.rep
|
||||||
|
|
||||||
local timestamp = function()
|
local timestamp = function()
|
||||||
return tostring(os.time())
|
return tostring(os.time())
|
||||||
end
|
end
|
||||||
@@ -23,29 +22,23 @@ return {
|
|||||||
s("frontmatter", {
|
s("frontmatter", {
|
||||||
t("---"),
|
t("---"),
|
||||||
t({ "", "Markdown note", "" }),
|
t({ "", "Markdown note", "" }),
|
||||||
t({ "", "title: \"" }), i(1), t("\""),
|
t({ "", "title: \"" }), i(8), t("\""),
|
||||||
t({ "", "date: \"" }), f(get_date, {}), t("\""),
|
t({ "", "date: \"" }), f(get_date, {}), t("\""),
|
||||||
t({ "", "author: \"" }), f(get_name, {}), t("\""),
|
t({ "", "author: \"" }), f(get_name, {}), t("\""),
|
||||||
t({ "", "keywords: ["}), i(2), t("]"),
|
t({ "", "keywords: ["}), i(6), t("]"),
|
||||||
t({ "", "tags: [["}), i(3), t("]]"),
|
t({ "", "tags: [["}), i(7), t("]]"),
|
||||||
t({ "", "id: " }), f(timestamp, {}),
|
t({ "", "id: " }), f(timestamp, {}),
|
||||||
t({ "", "---", "", "# " }),
|
t({ "", "" }),
|
||||||
rep(1), -- Reuses the first insert node
|
|
||||||
t({ "", ""}),
|
|
||||||
t({ "", ""}),
|
|
||||||
i(4) -- Final cursor position
|
|
||||||
}),
|
|
||||||
|
|
||||||
-- Creates a mood report template
|
|
||||||
s("wellbeingreport", {
|
|
||||||
t("---"),
|
|
||||||
t({ "", "Well-being report", "" }),
|
|
||||||
t({ "", "date: " }), f(get_date, {}),
|
|
||||||
t({ "", "sleep: " }), i(1), t("/5"),
|
t({ "", "sleep: " }), i(1), t("/5"),
|
||||||
t({ "", "emotions: [" }), i(2), t("]"),
|
t({ "", "emotions: [" }), i(2), t("]"),
|
||||||
t({ "", "comfort: " }), i(3), t("/5"),
|
t({ "", "comfort: " }), i(3), t("/5"),
|
||||||
t({ "", "complaints: ["}), i(4), t("]"),
|
t({ "", "complaints: ["}), i(4), t("]"),
|
||||||
t({ "", "mood: " }), i(5), t("/10"),
|
t({ "", "mood: " }), i(5), t("/10"),
|
||||||
t({ "", "---" }),
|
|
||||||
|
t({ "", "---", "", "# " }),
|
||||||
|
rep(8), -- Reuses the first insert node
|
||||||
|
t({ "", ""}),
|
||||||
|
t({ "", ""}),
|
||||||
|
i(9) -- Final cursor position
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user