Skip to content

Commit

Permalink
feat(view): add collapsed on start option to pinned views (#89)
Browse files Browse the repository at this point in the history
Add collapsed option to view for starting up pinned views in closed
mode.

## What is this PR for?
This provides option to set pinned views(not needed immediately) as
collapsed on start. This helps tidying startup view of panes with
multiple views.

## Does this PR fix an existing issue?
No. Purely aesthetic/visual.

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
  • Loading branch information
gj86 and folke authored Jul 7, 2024
1 parent fd43550 commit 2546a8e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lua/edgy/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ local Window = require("edgy.window")
-- When a view is pinned, it will always be shown
-- in the edgebar, even if it has no windows.
---@field pinned? boolean
---When a view is pinned and collapsed, it will be
---shown closed on start.
---@field collapsed? boolean
-- Open function or command to open a pinned view
---@field open? fun()|string
---@field wo? vim.wo View specific window options
Expand Down
4 changes: 2 additions & 2 deletions lua/edgy/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ M.cache = setmetatable({}, { __mode = "v" })
---@param view Edgy.View
function M.new(win, view)
local self = setmetatable({}, M)
self.visible = true
self.visible = not view.collapsed
self.view = view
self.idx = 1
self.win = win
Expand Down Expand Up @@ -111,7 +111,7 @@ end

---@param visibility? boolean
function M:show(visibility)
self.visible = visibility == nil and true or visibility or false
self.visible = (visibility == nil and not self.view.collapsed) or visibility or false
if self.visible and self:is_pinned() then
-- self.visible = false
return self.view:open_pinned()
Expand Down

0 comments on commit 2546a8e

Please sign in to comment.