Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(view): add collapsed on start option to pinned views #89

Merged
merged 2 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading