Skip to content

Commit

Permalink
feat(output_panel): clear function (#249)
Browse files Browse the repository at this point in the history
* feat: add output_panel.clear()

* feat(output_panel): clear entire buffer

---------

Co-authored-by: Rónán Carrigan <ronan@calypsoai.com>
  • Loading branch information
marcelbeumer and Rónán Carrigan authored Oct 20, 2023
1 parent b04332c commit da628ed
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions doc/neotest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,14 @@ Toggle the output panel
lua require("neotest").output_panel.toggle()
<

*neotest.output_panel.clear()*
`clear`()

Clears the output panel
>vim
lua require("neotest").output_panel.clear()
<


==============================================================================
neotest.run *neotest.run*
Expand Down
10 changes: 10 additions & 0 deletions lua/neotest/consumers/output_panel/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ function neotest.output_panel.toggle()
end
end

--- Clears the output panel
--- >vim
--- lua require("neotest").output_panel.clear()
--- <
function neotest.output_panel.clear()
nio.api.nvim_buf_set_option(panel.win:buffer(), "modifiable", true)
nio.api.nvim_buf_set_lines(panel.win:buffer(), 0, -1, false, {})
nio.api.nvim_buf_set_option(panel.win:buffer(), "modifiable", false)
end

neotest.output_panel = setmetatable(neotest.output_panel, {
__call = function(_, client)
init(client)
Expand Down
4 changes: 4 additions & 0 deletions plugin/neotest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ local cmd_completion_store = {
"open",
"close",
"toggle",
"clear",
},
run = {
"file",
Expand Down Expand Up @@ -78,6 +79,9 @@ commands = {
toggle = function()
require("neotest").output_panel.toggle()
end,
clear = function()
require("neotest").output_panel.clear()
end,
},
run = {
function(params)
Expand Down

0 comments on commit da628ed

Please sign in to comment.