From 068fc77019bbba7a723b66fe8ea4e7393e462127 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sat, 22 Feb 2025 13:28:30 +0100 Subject: [PATCH] nvim: Only enable markdown mdeval mappings if available Check for the existence of the 'mdeval' plugin before setting the corresponding key mappings in markdown type files. --- nvim/.config/nvim/after/ftplugin/markdown.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/nvim/.config/nvim/after/ftplugin/markdown.lua b/nvim/.config/nvim/after/ftplugin/markdown.lua index 50d5511..ac9769d 100644 --- a/nvim/.config/nvim/after/ftplugin/markdown.lua +++ b/nvim/.config/nvim/after/ftplugin/markdown.lua @@ -11,12 +11,19 @@ if require("core.util").is_available("zk") and require("zk.util").notebook_root( map("n", "", "lua vim.lsp.buf.definition()", { silent = true }) end --- execute code cells -if vim.fn.mapcheck("cc") == "" then - map("n", "cc", require("mdeval").eval_code_block, { silent = true, desc = "evaluate code block" }) -end -if vim.fn.mapcheck("cx") == "" then - map("n", "cx", require("mdeval").eval_clean_results, { silent = true, desc = "clear code results" }) +if require("core.util").is_available("mdeval") then + -- execute code cells + if vim.fn.mapcheck("cc") == "" then + map("n", "cc", require("mdeval").eval_code_block, { silent = true, desc = "evaluate code block" }) + end + if vim.fn.mapcheck("cx") == "" then + map( + "n", + "cx", + require("mdeval").eval_clean_results, + { silent = true, desc = "clear code results" } + ) + end end -- jump to beginning of previous/ next cell code