From bd142e38b1683795fc03b6581a9d1b4103cc0b60 Mon Sep 17 00:00:00 2001 From: iGor milhit Date: Thu, 10 Oct 2024 14:40:45 +0200 Subject: [PATCH] plugins: folds .md frontmatter and code blocks - Folds the frontmatter YAML and fenced code blocks in markdown file. - Removes unneccessary filetype for lazy loading markdown plugins. - Moves a markdownpreview settings that was wrongfully placed in the pandoc plugin configuration. - Lazy loads mkdnflow plugin for quarto filetype. Co-Authored-by: iGor milhit --- after/ftplugin/pandoc.lua | 6 ++---- lua/plugins/markdown/markdownpreview.lua | 4 +++- lua/plugins/markdown/mkdnflow.lua | 2 +- lua/plugins/markdown/pandoc.lua | 22 +++++++++++++--------- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/after/ftplugin/pandoc.lua b/after/ftplugin/pandoc.lua index b6e9a33..6da8148 100644 --- a/after/ftplugin/pandoc.lua +++ b/after/ftplugin/pandoc.lua @@ -3,7 +3,5 @@ -- See :h awa vim.opt.awa=true --- vim.opt.foldmethod = "expr" --- vim.opt.foldexpr = "nvim_treesitter#foldexpr()" -vim.opt.foldlevel = 1 -vim.opt.conceallevel = 2 +-- vim.opt.foldlevel = 1 +-- vim.opt.conceallevel = 2 diff --git a/lua/plugins/markdown/markdownpreview.lua b/lua/plugins/markdown/markdownpreview.lua index 7843b19..971ced9 100644 --- a/lua/plugins/markdown/markdownpreview.lua +++ b/lua/plugins/markdown/markdownpreview.lua @@ -2,13 +2,15 @@ -- https://github.com/iamcco/markdown-preview.nvim -- https://github.com/iamcco/markdown-preview.nvim/issues/558#issuecomment-1514701537 +-- Defines the filetypes that should be recognize by markdown-preview. +vim.cmd([[ let g:mkdp_filetypes = ['markdown', 'pandoc',] ]]) + return { { "iamcco/markdown-preview.nvim", ft = { 'pandoc', 'markdown', - 'pandoc.markdown' }, lazy = true, build = "cd app && npm install && git reset --hard", diff --git a/lua/plugins/markdown/mkdnflow.lua b/lua/plugins/markdown/mkdnflow.lua index 6795397..03ca144 100644 --- a/lua/plugins/markdown/mkdnflow.lua +++ b/lua/plugins/markdown/mkdnflow.lua @@ -17,7 +17,7 @@ return { ft = { 'pandoc', 'markdown', - 'pandoc.markdown', + 'quarto' }, lazy = true, config = function () diff --git a/lua/plugins/markdown/pandoc.lua b/lua/plugins/markdown/pandoc.lua index d76a4f0..64f2a24 100644 --- a/lua/plugins/markdown/pandoc.lua +++ b/lua/plugins/markdown/pandoc.lua @@ -1,11 +1,17 @@ -- Install and configure Pandoc plugins: vim-pandoc, vim-pandoc-syntax --- Defines the filetypes that should be recognize by vim-pandoc. Allows --- mardown-preview to be available with pandoc filetype. -vim.cmd([[ let g:mkdp_filetypes = ['markdown', 'pandoc', 'pandoc.markdown'] ]]) - -- Sets the pandoc formatting mode to hardwrap -vim.cmd([[ let g:pandoc#formatting#mode="hA" ]]) +vim.cmd([[ let g:pandoc#formatting#mode = "hA" ]]) + +-- Pandoc folding settings +-- Fold level 2 headings +vim.cmd([[ let g:pandoc#folding#level=1 ]]) +-- Enable YAML folding +vim.cmd([[ let g:pandoc#folding#fold_yaml=1 ]]) +-- Fold the entire frontmatter +vim.cmd([[ let g:pandoc#folding#foldlevel_yaml=2 ]]) +-- Fold fenced code blocks +vim.cmd([[ let g:pandoc#folding#fold_fenced_codeblocks=1 ]]) -- Keymaps to switch to soft or hardwarp, or to toggle. vim.keymap.set( @@ -40,8 +46,7 @@ return { "vim-pandoc/vim-pandoc", ft = { 'markdown', - 'pandoc', - 'pandoc.markdown' + 'pandoc' }, lazy = true, }, @@ -49,8 +54,7 @@ return { "vim-pandoc/vim-pandoc-syntax", ft = { 'markdown', - 'pandoc', - 'pandoc.markdown' + 'pandoc' }, lazy = true, },