docs: added documentation on how to customize styles

This commit is contained in:
Folke Lemaitre 2024-12-15 11:17:32 +01:00
parent fd9ef30206
commit 05602b6caf
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
46 changed files with 759 additions and 9 deletions

View file

@ -67,6 +67,7 @@ Install the plugin with your package manager:
"folke/snacks.nvim",
priority = 1000,
lazy = false,
---@type snacks.Config
opts = {
-- your configuration comes here
-- or leave it empty to use the default settings

View file

@ -34,6 +34,7 @@ Doing this, will disable `scroll`, `indent`, `dim` and all other animations.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
animate = {
-- your animate configuration comes here

View file

@ -23,6 +23,7 @@ mini.animate <https://github.com/echasnovski/mini.animate> (if used)
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
bigfile = {
-- your bigfile configuration comes here

View file

@ -149,6 +149,7 @@ In the example below, both sections are equivalent.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
dashboard = {
-- your dashboard configuration comes here
@ -486,6 +487,10 @@ Similar to the Vim Startify dashboard
==============================================================================
6. Styles *snacks-dashboard-styles*
Check the styles
<https://github.com/folke/snacks.nvim/blob/main/docs/styles.md> docs for more
information on how to customize these styles
DASHBOARD *snacks-dashboard-styles-dashboard*

View file

@ -26,6 +26,7 @@ Similar plugins:
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
dim = {
-- your dim configuration comes here

View file

@ -12,6 +12,10 @@ Table of Contents *snacks-git-table-of-contents*
==============================================================================
1. Styles *snacks-git-styles*
Check the styles
<https://github.com/folke/snacks.nvim/blob/main/docs/styles.md> docs for more
information on how to customize these styles
BLAME_LINE *snacks-git-styles-blame_line*

View file

@ -20,6 +20,7 @@ Open the repo of the active file in the browser (e.g., GitHub)
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
gitbrowse = {
-- your gitbrowse configuration comes here

View file

@ -25,6 +25,7 @@ Similar plugins:
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
indent = {
-- your indent configuration comes here

View file

@ -24,6 +24,7 @@ Better `vim.ui.input`.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
input = {
-- your input configuration comes here
@ -59,6 +60,10 @@ Better `vim.ui.input`.
==============================================================================
3. Styles *snacks-input-styles*
Check the styles
<https://github.com/folke/snacks.nvim/blob/main/docs/styles.md> docs for more
information on how to customize these styles
INPUT *snacks-input-styles-input*

View file

@ -25,6 +25,7 @@ colorscheme and integrate edit with the current neovim instance.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
lazygit = {
-- your lazygit configuration comes here
@ -81,6 +82,10 @@ colorscheme and integrate edit with the current neovim instance.
==============================================================================
3. Styles *snacks-lazygit-styles*
Check the styles
<https://github.com/folke/snacks.nvim/blob/main/docs/styles.md> docs for more
information on how to customize these styles
LAZYGIT *snacks-lazygit-styles-lazygit*

View file

@ -9,7 +9,7 @@ Table of Contents *snacks-notifier-table-of-contents*
4. Config |snacks-notifier-config|
5. Styles |snacks-notifier-styles|
- notification |snacks-notifier-styles-notification|
- notification.history |snacks-notifier-styles-notification.history|
- notification_history |snacks-notifier-styles-notification_history|
6. Types |snacks-notifier-types|
- Notifications |snacks-notifier-types-notifications|
- Rendering |snacks-notifier-types-rendering|
@ -116,6 +116,7 @@ Advanced LSP Progress ~
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
notifier = {
-- your notifier configuration comes here
@ -172,6 +173,10 @@ Advanced LSP Progress ~
==============================================================================
5. Styles *snacks-notifier-styles*
Check the styles
<https://github.com/folke/snacks.nvim/blob/main/docs/styles.md> docs for more
information on how to customize these styles
NOTIFICATION *snacks-notifier-styles-notification*
@ -191,7 +196,7 @@ NOTIFICATION *snacks-notifier-styles-notification*
<
NOTIFICATION.HISTORY *snacks-notifier-styles-notification.history*
NOTIFICATION_HISTORY *snacks-notifier-styles-notification_history*
>lua
{

View file

@ -175,6 +175,7 @@ field.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
profiler = {
-- your profiler configuration comes here

View file

@ -16,6 +16,7 @@ before loading your plugins.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
quickfile = {
-- your quickfile configuration comes here

View file

@ -24,6 +24,7 @@ The indent-based algorithm is similar to what is used in mini.indentscope
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
scope = {
-- your scope configuration comes here

View file

@ -49,6 +49,7 @@ Suggested config:
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
scratch = {
-- your scratch configuration comes here
@ -116,6 +117,10 @@ Suggested config:
==============================================================================
4. Styles *snacks-scratch-styles*
Check the styles
<https://github.com/folke/snacks.nvim/blob/main/docs/styles.md> docs for more
information on how to customize these styles
SCRATCH *snacks-scratch-styles-scratch*

View file

@ -24,6 +24,7 @@ Similar plugins:
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
scroll = {
-- your scroll configuration comes here

View file

@ -17,6 +17,7 @@ Table of Contents *snacks-statuscolumn-table-of-contents*
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
statuscolumn = {
-- your statuscolumn configuration comes here

328
doc/snacks-styles.txt Normal file
View file

@ -0,0 +1,328 @@
*snacks-styles.txt* snacks.nvim
==============================================================================
Table of Contents *snacks-styles-table-of-contents*
1. Setup |snacks-styles-setup|
2. Styles |snacks-styles-styles|
- blame_line |snacks-styles-styles-blame_line|
- dashboard |snacks-styles-styles-dashboard|
- float |snacks-styles-styles-float|
- input |snacks-styles-styles-input|
- lazygit |snacks-styles-styles-lazygit|
- minimal |snacks-styles-styles-minimal|
- notification |snacks-styles-styles-notification|
- notification_history |snacks-styles-styles-notification_history|
- scratch |snacks-styles-styles-scratch|
- split |snacks-styles-styles-split|
- terminal |snacks-styles-styles-terminal|
- zen |snacks-styles-styles-zen|
- zoom_indicator |snacks-styles-styles-zoom_indicator|
Plugins provide window styles that can be customized with the `opts.styles`
option of `snacks.nvim`.
==============================================================================
1. Setup *snacks-styles-setup*
>lua
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
---@type table<string, snacks.win.Config>
styles = {
-- your styles configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}
}
<
==============================================================================
2. Styles *snacks-styles-styles*
These are the default styles that Snacks provides. You can customize them by
adding your own styles to `opts.styles`.
BLAME_LINE *snacks-styles-styles-blame_line*
>lua
{
width = 0.6,
height = 0.6,
border = "rounded",
title = " Git Blame ",
title_pos = "center",
ft = "git",
}
<
DASHBOARD *snacks-styles-styles-dashboard*
The default style for the dashboard. When opening the dashboard during startup,
only the `bo` and `wo` options are used. The other options are used with `:lua
Snacks.dashboard()`
>lua
{
zindex = 10,
height = 0,
width = 0,
bo = {
bufhidden = "wipe",
buftype = "nofile",
buflisted = false,
filetype = "snacks_dashboard",
swapfile = false,
undofile = false,
},
wo = {
colorcolumn = "",
cursorcolumn = false,
cursorline = false,
foldmethod = "manual",
list = false,
number = false,
relativenumber = false,
sidescrolloff = 0,
signcolumn = "no",
spell = false,
statuscolumn = "",
statusline = "",
winbar = "",
winhighlight = "Normal:SnacksDashboardNormal,NormalFloat:SnacksDashboardNormal",
wrap = false,
},
}
<
FLOAT *snacks-styles-styles-float*
>lua
{
position = "float",
backdrop = 60,
height = 0.9,
width = 0.9,
zindex = 50,
}
<
INPUT *snacks-styles-styles-input*
>lua
{
backdrop = false,
position = "float",
border = "rounded",
title_pos = "center",
height = 1,
width = 60,
relative = "editor",
noautocmd = true,
row = 2,
-- relative = "cursor",
-- row = -3,
-- col = 0,
wo = {
winhighlight = "NormalFloat:SnacksInputNormal,FloatBorder:SnacksInputBorder,FloatTitle:SnacksInputTitle",
cursorline = false,
},
bo = { filetype = "snacks_input" },
keys = {
i_esc = { "<esc>", { "cmp_close", "cancel" }, mode = "i" },
-- i_esc = { "<esc>", "stopinsert", mode = "i" },
i_cr = { "<cr>", { "cmp_accept", "confirm" }, mode = "i" },
i_tab = { "<tab>", { "cmp_select_next", "cmp" }, mode = "i" },
q = "cancel",
},
}
<
LAZYGIT *snacks-styles-styles-lazygit*
>lua
{}
<
MINIMAL *snacks-styles-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,
},
}
<
NOTIFICATION *snacks-styles-styles-notification*
>lua
{
border = "rounded",
zindex = 100,
ft = "markdown",
wo = {
winblend = 5,
wrap = false,
conceallevel = 2,
colorcolumn = "",
},
bo = { filetype = "snacks_notif" },
}
<
NOTIFICATION_HISTORY *snacks-styles-styles-notification_history*
>lua
{
border = "rounded",
zindex = 100,
width = 0.6,
height = 0.6,
minimal = false,
title = " Notification History ",
title_pos = "center",
ft = "markdown",
bo = { filetype = "snacks_notif_history", modifiable = false },
wo = { winhighlight = "Normal:SnacksNotifierHistory" },
keys = { q = "close" },
}
<
SCRATCH *snacks-styles-styles-scratch*
>lua
{
width = 100,
height = 30,
bo = { buftype = "", buflisted = false, bufhidden = "hide", swapfile = false },
minimal = false,
noautocmd = false,
-- position = "right",
zindex = 20,
wo = { winhighlight = "NormalFloat:Normal" },
border = "rounded",
title_pos = "center",
footer_pos = "center",
}
<
SPLIT *snacks-styles-styles-split*
>lua
{
position = "bottom",
height = 0.4,
width = 0.4,
}
<
TERMINAL *snacks-styles-styles-terminal*
>lua
{
bo = {
filetype = "snacks_terminal",
},
wo = {},
keys = {
q = "hide",
gf = function(self)
local f = vim.fn.findfile(vim.fn.expand("<cfile>"), "**")
if f == "" then
Snacks.notify.warn("No file under cursor")
else
self:hide()
vim.schedule(function()
vim.cmd("e " .. f)
end)
end
end,
term_normal = {
"<esc>",
function(self)
self.esc_timer = self.esc_timer or (vim.uv or vim.loop).new_timer()
if self.esc_timer:is_active() then
self.esc_timer:stop()
vim.cmd("stopinsert")
else
self.esc_timer:start(200, 0, function() end)
return "<esc>"
end
end,
mode = "t",
expr = true,
desc = "Double escape to normal mode",
},
},
}
<
ZEN *snacks-styles-styles-zen*
>lua
{
enter = true,
fixbuf = false,
minimal = false,
width = 120,
height = 0,
backdrop = { transparent = true, blend = 40 },
keys = { q = false },
wo = {
winhighlight = "NormalFloat:Normal",
},
}
<
ZOOM_INDICATOR *snacks-styles-styles-zoom_indicator*
fullscreen indicator only shown when the window is maximized
>lua
{
text = "▍ zoom 󰊓 ",
minimal = true,
enter = false,
focusable = false,
height = 1,
row = 0,
col = -1,
backdrop = false,
}
<
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
vim:tw=78:ts=8:noet:ft=help:norl:

View file

@ -64,6 +64,7 @@ EDGY INTEGRATION *snacks-terminal-usage-edgy-integration*
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
terminal = {
-- your terminal configuration comes here
@ -91,6 +92,10 @@ EDGY INTEGRATION *snacks-terminal-usage-edgy-integration*
==============================================================================
4. Styles *snacks-terminal-styles*
Check the styles
<https://github.com/folke/snacks.nvim/blob/main/docs/styles.md> docs for more
information on how to customize these styles
TERMINAL *snacks-terminal-styles-terminal*

View file

@ -35,6 +35,7 @@ Toggle keymaps integrated with which-key icons / colors
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
toggle = {
-- your toggle configuration comes here

View file

@ -63,6 +63,7 @@ Easily create and manage floating windows or splits
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
win = {
-- your win configuration comes here
@ -118,6 +119,10 @@ Easily create and manage floating windows or splits
==============================================================================
4. Styles *snacks-win-styles*
Check the styles
<https://github.com/folke/snacks.nvim/blob/main/docs/styles.md> docs for more
information on how to customize these styles
FLOAT *snacks-win-styles-float*

View file

@ -21,6 +21,7 @@ Auto-show LSP references and quickly navigate between them
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
words = {
-- your words configuration comes here

View file

@ -29,6 +29,7 @@ Similar plugins:
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
zen = {
-- your zen configuration comes here
@ -86,6 +87,10 @@ Similar plugins:
==============================================================================
3. Styles *snacks-zen-styles*
Check the styles
<https://github.com/folke/snacks.nvim/blob/main/docs/styles.md> docs for more
information on how to customize these styles
ZEN *snacks-zen-styles-zen*

View file

@ -23,6 +23,7 @@ Doing this, will disable `scroll`, `indent`, `dim` and all other animations.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
animate = {
-- your animate configuration comes here

View file

@ -18,6 +18,7 @@ The default implementation enables `syntax` for the buffer and disables
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
bigfile = {
-- your bigfile configuration comes here

View file

@ -105,6 +105,7 @@ In the example below, both sections are equivalent.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
dashboard = {
-- your dashboard configuration comes here
@ -436,6 +437,9 @@ Similar to the Vim Startify dashboard
## 🎨 Styles
Check the [styles](https://github.com/folke/snacks.nvim/blob/main/docs/styles.md)
docs for more information on how to customize these styles
### `dashboard`
The default style for the dashboard.

View file

@ -19,6 +19,7 @@ Similar plugins:
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
dim = {
-- your dim configuration comes here

View file

@ -4,6 +4,9 @@
## 🎨 Styles
Check the [styles](https://github.com/folke/snacks.nvim/blob/main/docs/styles.md)
docs for more information on how to customize these styles
### `blame_line`
```lua

View file

@ -10,6 +10,7 @@ Open the repo of the active file in the browser (e.g., GitHub)
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
gitbrowse = {
-- your gitbrowse configuration comes here

View file

@ -17,6 +17,7 @@ Similar plugins:
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
indent = {
-- your indent configuration comes here

View file

@ -12,6 +12,7 @@ Better `vim.ui.input`.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
input = {
-- your input configuration comes here
@ -43,6 +44,9 @@ Better `vim.ui.input`.
## 🎨 Styles
Check the [styles](https://github.com/folke/snacks.nvim/blob/main/docs/styles.md)
docs for more information on how to customize these styles
### `input`
```lua

View file

@ -13,6 +13,7 @@ and integrate edit with the current neovim instance.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
lazygit = {
-- your lazygit configuration comes here
@ -65,6 +66,9 @@ and integrate edit with the current neovim instance.
## 🎨 Styles
Check the [styles](https://github.com/folke/snacks.nvim/blob/main/docs/styles.md)
docs for more information on how to customize these styles
### `lazygit`
```lua

View file

@ -103,6 +103,7 @@ vim.api.nvim_create_autocmd("LspProgress", {
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
notifier = {
-- your notifier configuration comes here
@ -155,6 +156,9 @@ vim.api.nvim_create_autocmd("LspProgress", {
## 🎨 Styles
Check the [styles](https://github.com/folke/snacks.nvim/blob/main/docs/styles.md)
docs for more information on how to customize these styles
### `notification`
```lua
@ -172,7 +176,7 @@ vim.api.nvim_create_autocmd("LspProgress", {
}
```
### `notification.history`
### `notification_history`
```lua
{

View file

@ -139,6 +139,7 @@ All other fields equal to `true` will match if the trace has a value for that fi
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
profiler = {
-- your profiler configuration comes here

View file

@ -11,6 +11,7 @@ before loading your plugins.
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
quickfile = {
-- your quickfile configuration comes here

View file

@ -13,6 +13,7 @@ in [mini.indentscope](https://github.com/echasnovski/mini.indentscope).
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
scope = {
-- your scope configuration comes here

View file

@ -35,6 +35,7 @@ Suggested config:
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
scratch = {
-- your scratch configuration comes here
@ -98,6 +99,9 @@ Suggested config:
## 🎨 Styles
Check the [styles](https://github.com/folke/snacks.nvim/blob/main/docs/styles.md)
docs for more information on how to customize these styles
### `scratch`
```lua

View file

@ -16,6 +16,7 @@ Similar plugins:
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
scroll = {
-- your scroll configuration comes here

View file

@ -8,6 +8,7 @@
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
statuscolumn = {
-- your statuscolumn configuration comes here

293
docs/styles.md Normal file
View file

@ -0,0 +1,293 @@
# 🍿 styles
Plugins provide window styles that can be customized
with the `opts.styles` option of `snacks.nvim`.
<!-- docgen -->
## 📦 Setup
```lua
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
---@type table<string, snacks.win.Config>
styles = {
-- your styles configuration comes here
-- or leave it empty to use the default settings
-- refer to the configuration section below
}
}
}
```
## 🎨 Styles
These are the default styles that Snacks provides.
You can customize them by adding your own styles to `opts.styles`.
### `blame_line`
```lua
{
width = 0.6,
height = 0.6,
border = "rounded",
title = " Git Blame ",
title_pos = "center",
ft = "git",
}
```
### `dashboard`
The default style for the dashboard.
When opening the dashboard during startup, only the `bo` and `wo` options are used.
The other options are used with `:lua Snacks.dashboard()`
```lua
{
zindex = 10,
height = 0,
width = 0,
bo = {
bufhidden = "wipe",
buftype = "nofile",
buflisted = false,
filetype = "snacks_dashboard",
swapfile = false,
undofile = false,
},
wo = {
colorcolumn = "",
cursorcolumn = false,
cursorline = false,
foldmethod = "manual",
list = false,
number = false,
relativenumber = false,
sidescrolloff = 0,
signcolumn = "no",
spell = false,
statuscolumn = "",
statusline = "",
winbar = "",
winhighlight = "Normal:SnacksDashboardNormal,NormalFloat:SnacksDashboardNormal",
wrap = false,
},
}
```
### `float`
```lua
{
position = "float",
backdrop = 60,
height = 0.9,
width = 0.9,
zindex = 50,
}
```
### `input`
```lua
{
backdrop = false,
position = "float",
border = "rounded",
title_pos = "center",
height = 1,
width = 60,
relative = "editor",
noautocmd = true,
row = 2,
-- relative = "cursor",
-- row = -3,
-- col = 0,
wo = {
winhighlight = "NormalFloat:SnacksInputNormal,FloatBorder:SnacksInputBorder,FloatTitle:SnacksInputTitle",
cursorline = false,
},
bo = { filetype = "snacks_input" },
keys = {
i_esc = { "<esc>", { "cmp_close", "cancel" }, mode = "i" },
-- i_esc = { "<esc>", "stopinsert", mode = "i" },
i_cr = { "<cr>", { "cmp_accept", "confirm" }, mode = "i" },
i_tab = { "<tab>", { "cmp_select_next", "cmp" }, mode = "i" },
q = "cancel",
},
}
```
### `lazygit`
```lua
{}
```
### `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,
},
}
```
### `notification`
```lua
{
border = "rounded",
zindex = 100,
ft = "markdown",
wo = {
winblend = 5,
wrap = false,
conceallevel = 2,
colorcolumn = "",
},
bo = { filetype = "snacks_notif" },
}
```
### `notification_history`
```lua
{
border = "rounded",
zindex = 100,
width = 0.6,
height = 0.6,
minimal = false,
title = " Notification History ",
title_pos = "center",
ft = "markdown",
bo = { filetype = "snacks_notif_history", modifiable = false },
wo = { winhighlight = "Normal:SnacksNotifierHistory" },
keys = { q = "close" },
}
```
### `scratch`
```lua
{
width = 100,
height = 30,
bo = { buftype = "", buflisted = false, bufhidden = "hide", swapfile = false },
minimal = false,
noautocmd = false,
-- position = "right",
zindex = 20,
wo = { winhighlight = "NormalFloat:Normal" },
border = "rounded",
title_pos = "center",
footer_pos = "center",
}
```
### `split`
```lua
{
position = "bottom",
height = 0.4,
width = 0.4,
}
```
### `terminal`
```lua
{
bo = {
filetype = "snacks_terminal",
},
wo = {},
keys = {
q = "hide",
gf = function(self)
local f = vim.fn.findfile(vim.fn.expand("<cfile>"), "**")
if f == "" then
Snacks.notify.warn("No file under cursor")
else
self:hide()
vim.schedule(function()
vim.cmd("e " .. f)
end)
end
end,
term_normal = {
"<esc>",
function(self)
self.esc_timer = self.esc_timer or (vim.uv or vim.loop).new_timer()
if self.esc_timer:is_active() then
self.esc_timer:stop()
vim.cmd("stopinsert")
else
self.esc_timer:start(200, 0, function() end)
return "<esc>"
end
end,
mode = "t",
expr = true,
desc = "Double escape to normal mode",
},
},
}
```
### `zen`
```lua
{
enter = true,
fixbuf = false,
minimal = false,
width = 120,
height = 0,
backdrop = { transparent = true, blend = 40 },
keys = { q = false },
wo = {
winhighlight = "NormalFloat:Normal",
},
}
```
### `zoom_indicator`
fullscreen indicator
only shown when the window is maximized
```lua
{
text = "▍ zoom 󰊓 ",
minimal = true,
enter = false,
focusable = false,
height = 1,
row = 0,
col = -1,
backdrop = false,
}
```

View file

@ -46,6 +46,7 @@ Based on the provided options, some defaults will be set:
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
terminal = {
-- your terminal configuration comes here
@ -69,6 +70,9 @@ Based on the provided options, some defaults will be set:
## 🎨 Styles
Check the [styles](https://github.com/folke/snacks.nvim/blob/main/docs/styles.md)
docs for more information on how to customize these styles
### `terminal`
```lua

View file

@ -12,6 +12,7 @@ Toggle keymaps integrated with which-key icons / colors
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
toggle = {
-- your toggle configuration comes here

View file

@ -28,6 +28,7 @@ Snacks.win({
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
win = {
-- your win configuration comes here
@ -79,6 +80,9 @@ Snacks.win({
## 🎨 Styles
Check the [styles](https://github.com/folke/snacks.nvim/blob/main/docs/styles.md)
docs for more information on how to customize these styles
### `float`
```lua

View file

@ -10,6 +10,7 @@ Auto-show LSP references and quickly navigate between them
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
words = {
-- your words configuration comes here

View file

@ -19,6 +19,7 @@ Similar plugins:
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
zen = {
-- your zen configuration comes here
@ -72,6 +73,9 @@ Similar plugins:
## 🎨 Styles
Check the [styles](https://github.com/folke/snacks.nvim/blob/main/docs/styles.md)
docs for more information on how to customize these styles
### `zen`
```lua

View file

@ -61,6 +61,7 @@ local query = vim.treesitter.query.parse(
---@field mod? string
---@field methods {name: string, args: string, comment?: string, types?: string, type: "method"|"function"}[]
---@field types string[]
---@field setup? string
---@field examples table<string, string>
---@field styles {name:string, opts:string, comment?:string}[]
@ -239,14 +240,14 @@ function M.render(name, info)
prefix = "Snacks"
end
if info.config then
if name ~= "init" then
add("## 📦 Setup\n")
add(([[
if name ~= "init" and (info.config or info.setup) then
add("## 📦 Setup\n")
add(([[
```lua
-- lazy.nvim
{
"folke/snacks.nvim",
---@type snacks.Config
opts = {
%s = {
-- your %s configuration comes here
@ -256,9 +257,10 @@ function M.render(name, info)
}
}
```
]]):format(name, name))
end
]]):format(info.setup or name, name))
end
if info.config then
add("## ⚙️ Config\n")
add(M.md(info.config))
end
@ -280,6 +282,18 @@ function M.render(name, info)
return a.name < b.name
end)
add("## 🎨 Styles\n")
if name == "styles" then
add([[These are the default styles that Snacks provides.
You can customize them by adding your own styles to `opts.styles`.
]])
else
add([[Check the [styles](https://github.com/folke/snacks.nvim/blob/main/docs/styles.md)
docs for more information on how to customize these styles
]])
end
for _, style in pairs(info.styles) do
add(("### `%s`\n"):format(style.name))
if style.comment and style.comment ~= "" then
@ -380,12 +394,22 @@ function M._build()
config = {}, ---@type string[]
}
---@type snacks.docs.Info
local styles = {
methods = {},
types = {},
examples = {},
styles = {},
setup = "---@type table<string, snacks.win.Config>\n styles",
}
for _, plugin in pairs(plugins) do
if plugin.meta.docs then
local name = plugin.name
print("[gen] " .. name .. ".md")
local lines = vim.fn.readfile(plugin.file)
local info = M.extract(lines)
vim.list_extend(styles.styles, info.styles)
info.config = name ~= "init" and info.config or nil
plugin.meta.config = info.config ~= nil
M.write(name, M.render(name, info))
@ -397,6 +421,7 @@ function M._build()
end
end
end
M.write("styles", M.render("styles", styles))
M.readme(plugins, types)
M.types(types)