From 4570022e4a4e4c8be99d5763ed4cd55e21a25d7f Mon Sep 17 00:00:00 2001 From: CharlesChiuGit Date: Fri, 9 Aug 2024 10:59:10 +0800 Subject: [PATCH 1/4] feat: add `render-markdown.nvim` for md workflow --- lua/modules/configs/lang/render-markdown.lua | 5 +++++ lua/modules/configs/ui/catppuccin.lua | 1 + lua/modules/plugins/lang.lua | 8 ++++++++ 3 files changed, 14 insertions(+) create mode 100644 lua/modules/configs/lang/render-markdown.lua diff --git a/lua/modules/configs/lang/render-markdown.lua b/lua/modules/configs/lang/render-markdown.lua new file mode 100644 index 000000000..fbfc49410 --- /dev/null +++ b/lua/modules/configs/lang/render-markdown.lua @@ -0,0 +1,5 @@ +return function() + require("modules.utils").load_plugin("render-markdown", { + enabled = true, + }) +end diff --git a/lua/modules/configs/ui/catppuccin.lua b/lua/modules/configs/ui/catppuccin.lua index c0a9048b1..2af1da1c6 100644 --- a/lua/modules/configs/ui/catppuccin.lua +++ b/lua/modules/configs/ui/catppuccin.lua @@ -83,6 +83,7 @@ return function() overseer = false, pounce = false, rainbow_delimiters = true, + render_markdown = true, sandwich = false, semantic_tokens = true, symbols_outline = false, diff --git a/lua/modules/plugins/lang.lua b/lua/modules/plugins/lang.lua index 2cfc3974d..78933ff43 100644 --- a/lua/modules/plugins/lang.lua +++ b/lua/modules/plugins/lang.lua @@ -28,6 +28,14 @@ lang["Saecki/crates.nvim"] = { config = require("lang.crates"), dependencies = { "nvim-lua/plenary.nvim" }, } +lang["MeanderingProgrammer/render-markdown.nvim"] = { + lazy = true, + ft = "markdown", + config = require("lang.render-markdown"), + dependencies = { + "nvim-treesitter/nvim-treesitter", + }, +} lang["iamcco/markdown-preview.nvim"] = { lazy = true, ft = "markdown", From c700c8aceeef2357e8eef07b9d4378c14350a9ff Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Fri, 9 Aug 2024 12:32:29 +0800 Subject: [PATCH 2/4] feat: `` toggles the plugin Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/keymap/lang.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lua/keymap/lang.lua b/lua/keymap/lang.lua index 46ec703ff..aef337350 100644 --- a/lua/keymap/lang.lua +++ b/lua/keymap/lang.lua @@ -5,6 +5,11 @@ local map_cr = bind.map_cr -- local map_callback = bind.map_callback local plug_map = { + -- Plugin render-markdown.nvim + ["n|"] = map_cr("RenderMarkdown toggle") + :with_noremap() + :with_silent() + :with_desc("tool: toggle markdown preview within nvim"), -- Plugin MarkdownPreview ["n|"] = map_cr("MarkdownPreviewToggle"):with_noremap():with_silent():with_desc("tool: Preview markdown"), } From 99fa3a3844f7f7f167728ddfd74ac8833df346bd Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Fri, 9 Aug 2024 12:33:41 +0800 Subject: [PATCH 3/4] fix: add `nvim-web-devicons` as a dependency Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/plugins/lang.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/modules/plugins/lang.lua b/lua/modules/plugins/lang.lua index 78933ff43..5b5bc6259 100644 --- a/lua/modules/plugins/lang.lua +++ b/lua/modules/plugins/lang.lua @@ -33,6 +33,7 @@ lang["MeanderingProgrammer/render-markdown.nvim"] = { ft = "markdown", config = require("lang.render-markdown"), dependencies = { + "nvim-tree/nvim-web-devicons", "nvim-treesitter/nvim-treesitter", }, } From 0baa7c9cd48e51941f893cafb6d81ee2c973c66d Mon Sep 17 00:00:00 2001 From: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> Date: Fri, 9 Aug 2024 12:34:07 +0800 Subject: [PATCH 4/4] perf: disable for files larger than 2 MiB Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com> --- lua/modules/configs/lang/render-markdown.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lua/modules/configs/lang/render-markdown.lua b/lua/modules/configs/lang/render-markdown.lua index fbfc49410..65ad80fec 100644 --- a/lua/modules/configs/lang/render-markdown.lua +++ b/lua/modules/configs/lang/render-markdown.lua @@ -1,5 +1,21 @@ return function() require("modules.utils").load_plugin("render-markdown", { + -- Whether Markdown should be rendered by default or not enabled = true, + -- Maximum file size (in MB) that this plugin will attempt to render + -- Any file larger than this will effectively be ignored + max_file_size = 2.0, + -- Milliseconds that must pass before updating marks, updates occur + -- within the context of the visible window, not the entire buffer + debounce = 100, + -- Vim modes that will show a rendered view of the markdown file + -- All other modes will be uneffected by this plugin + render_modes = { "n", "c", "t" }, + -- This enables hiding any added text on the line the cursor is on + -- This does have a performance penalty as we must listen to the 'CursorMoved' event + anti_conceal = { enabled = true }, + -- The level of logs to write to file: vim.fn.stdpath('state') .. '/render-markdown.log' + -- Only intended to be used for plugin development / debugging + log_level = "error", }) end