Skip to content

Commit

Permalink
Merge pull request #30 from pablopunk/keep-all-buffers
Browse files Browse the repository at this point in the history
tabline.keep_all_buffers
  • Loading branch information
pablopunk authored Nov 14, 2024
2 parents 1a38cd9 + eeb380a commit ff0099a
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
1 change: 0 additions & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ jobs:
run: |
# We have to build the parser every single time to keep up with parser changes
cd ~/.local/share/nvim/site/pack/vendor/start/tree-sitter-lua
git checkout 86f74dfb69c570f0749b241f8f5489f8f50adbea
make dist
cd -
Expand Down
16 changes: 12 additions & 4 deletions doc/unclutter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ unclutter.setup({opts}) *unclutter.setup()*


Parameters: ~
{opts} (unclutter.config)
{opts} (unclutter) .config



Expand Down Expand Up @@ -252,7 +252,7 @@ config.set({opts}) *config.set()*


Parameters: ~
{opts} (unclutter.config)
{opts} (unclutter) .config



Expand All @@ -270,7 +270,7 @@ plugin.enable({opts}) *plugin.enable()*


Parameters: ~
{opts} (unclutter.config)
{opts} (unclutter) .config


plugin.disable() *plugin.disable()*
Expand Down Expand Up @@ -399,10 +399,13 @@ tabline.get_tab_label({buf}) *tabline.get_tab_label()*
string|nil


tabline.list() *tabline.list()*
tabline.list({hide_current}) *tabline.list()*
Get all buffers to be displayed in the tabline


Parameters: ~
{hide_current} (boolean) ?

Return: ~
table<number, number>

Expand Down Expand Up @@ -430,6 +433,11 @@ tabline.prev() *tabline.prev()*



tabline.keep_all_buffers() *tabline.keep_all_buffers()*
Mark all open buffers as listed




================================================================================
unclutter.telescope *unclutter.telescope*
Expand Down
7 changes: 7 additions & 0 deletions lua/unclutter/tabline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,11 @@ function tabline.prev()
end
end

--- Mark all open buffers as listed
function tabline.keep_all_buffers()
for _, buf in ipairs(vim.api.nvim_list_bufs()) do
tabline.keep_buffer(buf)
end
end

return tabline
10 changes: 10 additions & 0 deletions lua/unclutter/tabline_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ describe("Buffer management", function()
assert.is_true(M.is_buffer_kept(1))
end)

it("keeps all open buffers", function()
vim.api.nvim_list_bufs = function()
return { 1, 2, 3 }
end
M.keep_all_buffers()
assert.is_true(M.is_buffer_kept(1))
assert.is_true(M.is_buffer_kept(2))
assert.is_true(M.is_buffer_kept(3))
end)

it("removes a buffer", function()
M.keep_buffer(1)
M.remove_buffer(1)
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ local buffer = require("unclutter.buffer")
local plugin = require("unclutter.plugin")

tabline.keep_buffer(bufnr) -- Show buffer in tabline
tabline.keep_all_buffers() -- Show all open buffers in tabline
tabline.remove_buffer(bufnr) -- Show buffer in tabline
tabline.toggle_buffer(bufnr) -- Toggle buffer in tabline
tabline.list() -- List tabline buffers
Expand Down

0 comments on commit ff0099a

Please sign in to comment.