Skip to content

Commit

Permalink
feat(config): Add a configuration option to not show evaluation resul…
Browse files Browse the repository at this point in the history
…ts and images.
  • Loading branch information
Klafyvel committed Aug 31, 2024
1 parent 50ae13f commit fb8a6a2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions doc/smuggler.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lua/smuggler/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

Expand Down
5 changes: 4 additions & 1 deletion lua/smuggler/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fb8a6a2

Please sign in to comment.