From 75ba42519c6b1f7734339a5aa7a3c848e124c400 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Wed, 13 Nov 2024 00:22:41 -0600 Subject: [PATCH] feat(nvim): add keybind to toggle markview in markdown files --- .../.config/nvim/after/ftplugin/markdown.lua | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/users/price/dots/.config/nvim/after/ftplugin/markdown.lua b/users/price/dots/.config/nvim/after/ftplugin/markdown.lua index 955c2c98..edf50ce1 100644 --- a/users/price/dots/.config/nvim/after/ftplugin/markdown.lua +++ b/users/price/dots/.config/nvim/after/ftplugin/markdown.lua @@ -4,15 +4,26 @@ vim.opt_local.textwidth = 0 vim.keymap.set("n", "fr", "GithubPreviewToggle", { buffer = true, - desc = "Preview Markdown in Browser" + desc = "Preview Markdown in Browser", }) + +local markview = require("markview") vim.keymap.set("n", "ff", function() - vim.cmd("Markview hybridToggle") - local hybrid_state = require("markview").state.hybrid_mode and "Enabled" or "Disabled" + markview.state.hybrid_mode = not markview.state.hybrid_mode + local hybrid_state = markview.state.hybrid_mode and "Enabled" or "Disabled" vim.notify(("%s Markview Hybrid Mode"):format(hybrid_state), vim.log.levels.INFO, { title = "Markview" }) end, { buffer = true, - desc = "Toggle Markview Hybrid Mode" + desc = "Toggle Markview Hybrid Mode", +}) + +vim.keymap.set("n", "ft", function() + vim.cmd("Markview toggle") + local mview_state = markview.state.enabled and "Enabled" or "Disabled" + vim.notify(("Markview %s"):format(mview_state), vim.log.levels.INFO, { title = "Markview" }) +end, { + buffer = true, + desc = "Toggle Markview", }) vim.keymap.set("n", "", function()