Files
dotfiles/nvim/.config/nvim/lua/plugins/markdown.lua
T
2025-12-21 14:25:58 +01:00

226 lines
6.4 KiB
Lua

return {
{
"OXY2DEV/markview.nvim",
lazy = false,
ft = "markdown",
dependencies = {
"nvim-treesitter/nvim-treesitter",
"nvim-tree/nvim-web-devicons",
},
config = function()
local presets = require("markview.presets")
require("markview").setup({
modes = { "n", "no", "c" },
hybrid_modes = { "n" },
callbacks = {
on_enable = function(_, win)
vim.wo[win].conceallevel = 2
vim.wo[win].concealcursor = ""
end,
},
-- Glow headings preset
headings = presets.headings.glow,
-- Code blocks configuration
code_blocks = {
enable = true,
style = "language",
position = "overlay",
min_width = 60,
pad_amount = 2,
pad_char = " ",
language_names = {
{ "py", "python" },
{ "cpp", "C++" },
{ "js", "javascript" },
{ "ts", "typescript" },
{ "sh", "bash" },
},
hl = "MarkviewCode",
sign = true,
sign_hl = "MarkviewCodeSign",
},
-- Block quotes configuration
block_quotes = {
enable = true,
default = {
border = "",
border_hl = "MarkviewBlockQuoteBorder",
},
callouts = {
{
match_string = "NOTE",
callout_preview = "󰋽 Note",
callout_preview_hl = "MarkviewBlockQuoteNote",
border = "",
border_hl = "MarkviewBlockQuoteNote",
},
{
match_string = "TIP",
callout_preview = "󰌶 Tip",
callout_preview_hl = "MarkviewBlockQuoteTip",
border = "",
border_hl = "MarkviewBlockQuoteTip",
},
{
match_string = "IMPORTANT",
callout_preview = " Important",
callout_preview_hl = "MarkviewBlockQuoteImportant",
border = "",
border_hl = "MarkviewBlockQuoteImportant",
},
{
match_string = "WARNING",
callout_preview = " Warning",
callout_preview_hl = "MarkviewBlockQuoteWarn",
border = "",
border_hl = "MarkviewBlockQuoteWarn",
},
{
match_string = "CAUTION",
callout_preview = " Caution",
callout_preview_hl = "MarkviewBlockQuoteError",
border = "",
border_hl = "MarkviewBlockQuoteError",
},
},
},
-- Checkboxes configuration
checkboxes = {
enable = true,
checked = {
text = "",
hl = "MarkviewCheckboxChecked",
scope_hl = nil,
},
unchecked = {
text = "",
hl = "MarkviewCheckboxUnchecked",
scope_hl = nil,
},
custom = {
{
match_string = "!",
text = "!",
hl = "MarkviewCheckboxImportant",
scope_hl = nil,
},
{
match_string = "-",
text = "",
hl = "MarkviewCheckboxPending",
scope_hl = nil,
},
{
match_string = "~",
text = "",
hl = "MarkviewCheckboxProgress",
scope_hl = nil,
},
},
},
-- Tables with rounded borders
tables = {
enable = true,
parts = {
top = { "", "", "", "", "" },
header = { "", "", "", "", "" },
separator = { "", "", "", "", "" },
row = { "", " ", "", " ", "" },
bottom = { "", "", "", "", "" },
overlap = { "" },
},
hl = {
"MarkviewTableHeader",
"MarkviewTableBorder",
"MarkviewTableBorder",
"MarkviewTableBorder",
"MarkviewTableBorder",
},
use_virt_lines = true,
},
-- List items
list_items = {
enable = true,
indent_size = 2,
shift_width = 2,
marker_minus = {
add_padding = true,
text = "",
hl = "MarkviewListItemMinus",
},
marker_plus = {
add_padding = true,
text = "",
hl = "MarkviewListItemPlus",
},
marker_star = {
add_padding = true,
text = "",
hl = "MarkviewListItemStar",
},
},
})
-- Catppuccin Mocha colors
vim.cmd([[
" Code blocks - Catppuccin Mocha
highlight MarkviewCode guibg=#181825
highlight MarkviewCodeSign guifg=#89b4fa
" Block quotes - Catppuccin Mocha
highlight MarkviewBlockQuoteBorder guifg=#6c7086
highlight MarkviewBlockQuoteNote guifg=#89b4fa
highlight MarkviewBlockQuoteTip guifg=#a6e3a1
highlight MarkviewBlockQuoteImportant guifg=#cba6f7
highlight MarkviewBlockQuoteWarn guifg=#fab387
highlight MarkviewBlockQuoteError guifg=#f38ba8
" Checkboxes - Catppuccin Mocha
highlight MarkviewCheckboxChecked guifg=#a6e3a1
highlight MarkviewCheckboxUnchecked guifg=#6c7086
highlight MarkviewCheckboxImportant guifg=#f38ba8 gui=bold
highlight MarkviewCheckboxPending guifg=#fab387
highlight MarkviewCheckboxProgress guifg=#89b4fa
" List items - Catppuccin Mocha
highlight MarkviewListItemMinus guifg=#89b4fa
highlight MarkviewListItemPlus guifg=#a6e3a1
highlight MarkviewListItemStar guifg=#cba6f7
" Tables - Catppuccin Mocha
highlight MarkviewTableHeader guifg=#cba6f7 gui=bold
highlight MarkviewTableBorder guifg=#6c7086
]])
-- Setup checkbox toggle extras
require("markview.extras.checkboxes").setup({
default = "X",
remove_markers = false,
exit = true,
default_marker = "-",
default_state = "X",
})
-- Keymaps
vim.keymap.set("n", "<leader>mt", "<cmd>Markview toggle<cr>", { desc = "Toggle Markview" })
vim.keymap.set("n", "<leader>ch", "<cmd>Checkboxes toggle<cr>", { desc = "Toggle checkbox" })
end,
},
}