From fb8a6a246fbd1a97a6a23f56a2b600755ce1c0e7 Mon Sep 17 00:00:00 2001 From: Hugo Levy-Falk Date: Sat, 31 Aug 2024 16:54:12 +0200 Subject: [PATCH] feat(config): Add a configuration option to not show evaluation results and images. --- README.md | 2 ++ doc/smuggler.txt | 2 ++ lua/smuggler/config.lua | 2 ++ lua/smuggler/ui.lua | 5 ++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 93d6b96..7230ff5 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,8 @@ values): invalidated_hl = "WarningMsg", -- highlight group for invalidated evaluated chunks. result_line_length = 80, -- line length of displayed results. result_hl_group = "DiagnosticVirtualTextInfo", -- highlight group used for results. + display_results = true, -- Display evaluation results. + display_images = true, -- Display images if `images.nvim` is present. }, log = { level = "warn", -- available: trace, debug, info, warn, error, fatal diff --git a/doc/smuggler.txt b/doc/smuggler.txt index 94efb11..d1a19b6 100644 --- a/doc/smuggler.txt +++ b/doc/smuggler.txt @@ -179,6 +179,8 @@ values): > invalidated_hl = "WarningMsg", -- highlight group for invalidated evaluated chunks. result_line_length = 80, -- line length of displayed results. result_hl_group = "DiagnosticVirtualTextInfo", -- highlight group used for results. + display_results = true, -- Display evaluation results. + display_images = true, -- Display images if `images.nvim` is present. }, log = { level = "warn", -- available: trace, debug, info, warn, error, fatal diff --git a/lua/smuggler/config.lua b/lua/smuggler/config.lua index ddb978b..0cb42b4 100644 --- a/lua/smuggler/config.lua +++ b/lua/smuggler/config.lua @@ -6,6 +6,8 @@ config.ui = { invalidated_hl = "WarningMsg", result_line_length = 80, result_hl_group = "DiagnosticVirtualTextInfo", + display_results = true, + display_images = true, mappings = {}, -- Default mappings are defined in their own file. } diff --git a/lua/smuggler/ui.lua b/lua/smuggler/ui.lua index e4d315b..376f468 100644 --- a/lua/smuggler/ui.lua +++ b/lua/smuggler/ui.lua @@ -251,7 +251,7 @@ end function ui.add_an_image_to_result(bufnbr, result, winid) -- Do not display images when the module is not loaded. - if image == nil then + if image == nil or not config.ui.display_images then return end local winlist = {} @@ -323,6 +323,9 @@ end function ui.show_evaluation_results(bufnbr) log.debug("Showing evaluation results") + if not config.ui.display_results then + return + end bufnbr = (bufnbr == nil) and vim.api.nvim_get_current_buf() or bufnbr local buffer = run.buffers[bufnbr] for msgid, results in pairs(buffer.results) do