Skip to content

Latest commit

 

History

History
160 lines (120 loc) · 2.6 KB

layout.md

File metadata and controls

160 lines (120 loc) · 2.6 KB

🍿 layout

📦 Setup

-- lazy.nvim
{
  "folke/snacks.nvim",
  ---@type snacks.Config
  opts = {
    layout = {
      -- your layout configuration comes here
      -- or leave it empty to use the default settings
      -- refer to the configuration section below
    }
  }
}

⚙️ Config

---@class snacks.layout.Config
---@field show? boolean show the layout on creation (default: true)
---@field wins table<string, snacks.win> windows to include in the layout
---@field layout snacks.layout.Box layout definition
---@field fullscreen? boolean open in fullscreen
---@field hidden? string[] list of windows that will be excluded from the layout (but can be toggled)
---@field on_update? fun(layout: snacks.layout)
{
  layout = {
    width = 0.6,
    height = 0.6,
    zindex = 50,
  },
}

📚 Types

---@class snacks.layout.Win: snacks.win.Config,{}
---@field depth? number
---@field win string layout window name
---@class snacks.layout.Box: snacks.layout.Win,{}
---@field box "horizontal" | "vertical"
---@field id? number
---@field [number] snacks.layout.Win | snacks.layout.Box children
---@alias snacks.layout.Widget snacks.layout.Win | snacks.layout.Box

📦 Module

---@class snacks.layout
---@field opts snacks.layout.Config
---@field root snacks.win
---@field wins table<string, snacks.win|{enabled?:boolean}>
---@field box_wins snacks.win[]
---@field win_opts table<string, snacks.win.Config>
---@field closed? boolean
---@field split? boolean
---@field screenpos number[]?
Snacks.layout = {}

Snacks.layout.new()

---@param opts snacks.layout.Config
Snacks.layout.new(opts)

layout:close()

Close the layout

---@param opts? {wins?: boolean}
layout:close(opts)

layout:each()

---@param cb fun(widget: snacks.layout.Widget, parent?: snacks.layout.Box)
---@param opts? {wins?:boolean, boxes?:boolean, box?:snacks.layout.Box}
layout:each(cb, opts)

layout:hide()

layout:hide()

layout:is_enabled()

Check if the window has been used in the layout

---@param w string
layout:is_enabled(w)

layout:is_hidden()

Check if a window is hidden

---@param win string
layout:is_hidden(win)

layout:maximize()

Toggle fullscreen

layout:maximize()

layout:show()

Show the layout

layout:show()

layout:toggle()

Toggle a window

---@param win string
layout:toggle(win)

layout:unhide()

layout:unhide()

layout:valid()

Check if layout is valid (visible)

layout:valid()