refactor: frontmatter for markdown;
feat: plugin for rendering images in markdown; feat: pastify; feat: markdown preview in browser
This commit is contained in:
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
|
||||
}
|
||||
Reference in New Issue
Block a user