mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00

## Description More info coming tomorrow. In short: - very fast. pretty much realtime filtering/sorting in huge repos (like 1.7 million files) - extensible - easy to customize the layout (and lots of presets) with `snacks.layout` - simple to create custom pickers - `vim.ui.select` - lots of builtin pickers - uses treesitter highlighting wherever it makes sense - fast lua fuzzy matcher which supports the [fzf syntax](https://junegunn.github.io/fzf/search-syntax/) and additionally supports field filters, like `file:lua$ 'function` There's no snacks picker command, just use lua. ```lua -- all pickers Snacks.picker() -- run files picker Snacks.picker.files(opts) Snacks.picker.pick("files", opts) Snacks.picker.pick({source = "files", ...}) ``` <!-- Describe the big picture of your changes to communicate to the maintainers why we should accept this pull request. --> ## Todo - [x] issue with preview loc not always correct when scrolling fast in list (probably due to `snacks.scroll`) - [x] `grep` (`live_grep`) is sometimes too fast in large repos and can impact ui rendering. Not very noticeable, but something I want to look at. - [x] docs - [x] treesitter highlights are broken. Messed something up somewhere ## Related Issue(s) <!-- If this PR fixes any issues, please link to the issue here. - Fixes #<issue_number> --> ## Screenshots <!-- Add screenshots of the changes if applicable. -->
2.5 KiB
2.5 KiB
🍿 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
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: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:valid()
Check if layout is valid (visible)
layout:valid()