mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 18:58:12 +00:00
319 lines
9.1 KiB
Text
319 lines
9.1 KiB
Text
*snacks-win.txt* snacks.nvim
|
|
|
|
==============================================================================
|
|
Table of Contents *snacks-win-table-of-contents*
|
|
|
|
1. Usage |snacks-win-usage|
|
|
2. Config |snacks-win-config|
|
|
3. Styles |snacks-win-styles|
|
|
- float |snacks-win-styles-float|
|
|
- minimal |snacks-win-styles-minimal|
|
|
- split |snacks-win-styles-split|
|
|
4. Types |snacks-win-types|
|
|
5. Module |snacks-win-module|
|
|
- Snacks.win() |snacks-win-module-snacks.win()|
|
|
- Snacks.win.new() |snacks-win-module-snacks.win.new()|
|
|
- win:add_padding() |snacks-win-module-win:add_padding()|
|
|
- win:border_text_width() |snacks-win-module-win:border_text_width()|
|
|
- win:buf_valid() |snacks-win-module-win:buf_valid()|
|
|
- win:close() |snacks-win-module-win:close()|
|
|
- win:focus() |snacks-win-module-win:focus()|
|
|
- win:has_border() |snacks-win-module-win:has_border()|
|
|
- win:hide() |snacks-win-module-win:hide()|
|
|
- win:is_floating() |snacks-win-module-win:is_floating()|
|
|
- win:lines() |snacks-win-module-win:lines()|
|
|
- win:parent_size() |snacks-win-module-win:parent_size()|
|
|
- win:show() |snacks-win-module-win:show()|
|
|
- win:size() |snacks-win-module-win:size()|
|
|
- win:text() |snacks-win-module-win:text()|
|
|
- win:toggle() |snacks-win-module-win:toggle()|
|
|
- win:update() |snacks-win-module-win:update()|
|
|
- win:valid() |snacks-win-module-win:valid()|
|
|
- win:win_valid() |snacks-win-module-win:win_valid()|
|
|
6. Links |snacks-win-links|
|
|
Easily create and manage floating windows or splits
|
|
|
|
|
|
==============================================================================
|
|
1. Usage *snacks-win-usage*
|
|
|
|
>lua
|
|
Snacks.win({
|
|
file = vim.api.nvim_get_runtime_file("doc/news.txt", false)[1],
|
|
width = 0.6,
|
|
height = 0.6,
|
|
wo = {
|
|
spell = false,
|
|
wrap = false,
|
|
signcolumn = "yes",
|
|
statuscolumn = " ",
|
|
conceallevel = 3,
|
|
},
|
|
})
|
|
<
|
|
|
|
|
|
==============================================================================
|
|
2. Config *snacks-win-config*
|
|
|
|
>lua
|
|
---@class snacks.win.Config: vim.api.keyset.win_config
|
|
---@field style? string merges with config from `Snacks.config.styles[style]`
|
|
---@field show? boolean Show the window immediately (default: true)
|
|
---@field height? number Height of the window. Use <1 for relative height. 0 means full height. (default: 0.9)
|
|
---@field width? number Width of the window. Use <1 for relative width. 0 means full width. (default: 0.9)
|
|
---@field minimal? boolean Disable a bunch of options to make the window minimal (default: true)
|
|
---@field position? "float"|"bottom"|"top"|"left"|"right"
|
|
---@field buf? number If set, use this buffer instead of creating a new one
|
|
---@field file? string If set, use this file instead of creating a new buffer
|
|
---@field enter? boolean Enter the window after opening (default: false)
|
|
---@field backdrop? number|false Opacity of the backdrop (default: 60)
|
|
---@field wo? vim.wo window options
|
|
---@field bo? vim.bo buffer options
|
|
---@field ft? string filetype to use for treesitter/syntax highlighting. Won't override existing filetype
|
|
---@field keys? table<string, false|string|fun(self: snacks.win)|snacks.win.Keys> Key mappings
|
|
---@field on_buf? fun(self: snacks.win) Callback after opening the buffer
|
|
---@field on_win? fun(self: snacks.win) Callback after opening the window
|
|
{
|
|
show = true,
|
|
relative = "editor",
|
|
position = "float",
|
|
minimal = true,
|
|
wo = {
|
|
winhighlight = "Normal:SnacksNormal,NormalNC:SnacksNormalNC,WinBar:SnacksWinBar,WinBarNC:SnacksWinBarNC",
|
|
},
|
|
bo = {},
|
|
keys = {
|
|
q = "close",
|
|
},
|
|
}
|
|
<
|
|
|
|
|
|
==============================================================================
|
|
3. Styles *snacks-win-styles*
|
|
|
|
|
|
FLOAT *snacks-win-styles-float*
|
|
|
|
>lua
|
|
{
|
|
position = "float",
|
|
backdrop = 60,
|
|
height = 0.9,
|
|
width = 0.9,
|
|
zindex = 50,
|
|
}
|
|
<
|
|
|
|
|
|
MINIMAL *snacks-win-styles-minimal*
|
|
|
|
>lua
|
|
{
|
|
wo = {
|
|
cursorcolumn = false,
|
|
cursorline = false,
|
|
cursorlineopt = "both",
|
|
fillchars = "eob: ,lastline:…",
|
|
list = false,
|
|
listchars = "extends:…,tab: ",
|
|
number = false,
|
|
relativenumber = false,
|
|
signcolumn = "no",
|
|
spell = false,
|
|
winbar = "",
|
|
statuscolumn = "",
|
|
wrap = false,
|
|
sidescrolloff = 0,
|
|
},
|
|
}
|
|
<
|
|
|
|
|
|
SPLIT *snacks-win-styles-split*
|
|
|
|
>lua
|
|
{
|
|
position = "bottom",
|
|
height = 0.4,
|
|
width = 0.4,
|
|
}
|
|
<
|
|
|
|
|
|
==============================================================================
|
|
4. Types *snacks-win-types*
|
|
|
|
>lua
|
|
---@class snacks.win.Keys: vim.api.keyset.keymap
|
|
---@field [1]? string
|
|
---@field [2]? string|fun(self: snacks.win): any
|
|
---@field mode? string|string[]
|
|
<
|
|
|
|
|
|
==============================================================================
|
|
5. Module *snacks-win-module*
|
|
|
|
>lua
|
|
---@class snacks.win
|
|
---@field id number
|
|
---@field buf? number
|
|
---@field win? number
|
|
---@field opts snacks.win.Config
|
|
---@field augroup? number
|
|
---@field backdrop? snacks.win
|
|
Snacks.win = {}
|
|
<
|
|
|
|
|
|
`Snacks.win()` *Snacks.win()*
|
|
|
|
>lua
|
|
---@type fun(opts? :snacks.win.Config): snacks.win
|
|
Snacks.win()
|
|
<
|
|
|
|
|
|
`Snacks.win.new()` *Snacks.win.new()*
|
|
|
|
>lua
|
|
---@param opts? snacks.win.Config
|
|
---@return snacks.win
|
|
Snacks.win.new(opts)
|
|
<
|
|
|
|
|
|
WIN:ADD_PADDING() *snacks-win-module-win:add_padding()*
|
|
|
|
>lua
|
|
win:add_padding()
|
|
<
|
|
|
|
|
|
WIN:BORDER_TEXT_WIDTH() *snacks-win-module-win:border_text_width()*
|
|
|
|
>lua
|
|
win:border_text_width()
|
|
<
|
|
|
|
|
|
WIN:BUF_VALID() *snacks-win-module-win:buf_valid()*
|
|
|
|
>lua
|
|
win:buf_valid()
|
|
<
|
|
|
|
|
|
WIN:CLOSE() *snacks-win-module-win:close()*
|
|
|
|
>lua
|
|
---@param opts? { buf: boolean }
|
|
win:close(opts)
|
|
<
|
|
|
|
|
|
WIN:FOCUS() *snacks-win-module-win:focus()*
|
|
|
|
>lua
|
|
win:focus()
|
|
<
|
|
|
|
|
|
WIN:HAS_BORDER() *snacks-win-module-win:has_border()*
|
|
|
|
>lua
|
|
win:has_border()
|
|
<
|
|
|
|
|
|
WIN:HIDE() *snacks-win-module-win:hide()*
|
|
|
|
>lua
|
|
win:hide()
|
|
<
|
|
|
|
|
|
WIN:IS_FLOATING() *snacks-win-module-win:is_floating()*
|
|
|
|
>lua
|
|
win:is_floating()
|
|
<
|
|
|
|
|
|
WIN:LINES() *snacks-win-module-win:lines()*
|
|
|
|
>lua
|
|
---@param from? number
|
|
---@param to? number
|
|
win:lines(from, to)
|
|
<
|
|
|
|
|
|
WIN:PARENT_SIZE() *snacks-win-module-win:parent_size()*
|
|
|
|
>lua
|
|
win:parent_size()
|
|
<
|
|
|
|
|
|
WIN:SHOW() *snacks-win-module-win:show()*
|
|
|
|
>lua
|
|
win:show()
|
|
<
|
|
|
|
|
|
WIN:SIZE() *snacks-win-module-win:size()*
|
|
|
|
>lua
|
|
---@return { height: number, width: number }
|
|
win:size()
|
|
<
|
|
|
|
|
|
WIN:TEXT() *snacks-win-module-win:text()*
|
|
|
|
>lua
|
|
---@param from? number
|
|
---@param to? number
|
|
win:text(from, to)
|
|
<
|
|
|
|
|
|
WIN:TOGGLE() *snacks-win-module-win:toggle()*
|
|
|
|
>lua
|
|
win:toggle()
|
|
<
|
|
|
|
|
|
WIN:UPDATE() *snacks-win-module-win:update()*
|
|
|
|
>lua
|
|
win:update()
|
|
<
|
|
|
|
|
|
WIN:VALID() *snacks-win-module-win:valid()*
|
|
|
|
>lua
|
|
win:valid()
|
|
<
|
|
|
|
|
|
WIN:WIN_VALID() *snacks-win-module-win:win_valid()*
|
|
|
|
>lua
|
|
win:win_valid()
|
|
<
|
|
|
|
==============================================================================
|
|
6. Links *snacks-win-links*
|
|
|
|
1. *image*: https://github.com/user-attachments/assets/250acfbd-a624-4f42-a36b-9aab316ebf64
|
|
|
|
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
|
|
|
|
vim:tw=78:ts=8:noet:ft=help:norl:
|