FFFF mini.nvim/doc/mini-animate.txt at main · figjeti/mini.nvim · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
977 lines (772 loc) · 39.8 KB

mini-animate.txt

File metadata and controls

977 lines (772 loc) · 39.8 KB
<Cmd>lua vim.cmd('normal! n'); MiniAnimate.execute_after('scroll', 'normal! zvzz')<CR>
Parameters~
{animation_type} `(string)` One of supported animation types
(as in |MiniAnimate.is_active()|).
{action} `(string|function)` Action to be executed. If string, executed as
command (via |vim.cmd()|).
------------------------------------------------------------------------------
*MiniAnimate.animate()*
`MiniAnimate.animate`({step_action}, {step_timing}, {opts})
Animate action
This is equivalent to asynchronous execution of the following algorithm:
- Call `step_action(0)` immediately after calling this function. Stop if
action returned `false` or `nil`.
- Wait `step_timing(1)` milliseconds.
- Call `step_action(1)`. Stop if it returned `false` or `nil`.
- Wait `step_timing(2)` milliseconds.
- Call `step_action(2)`. Stop if it returned `false` or `nil`.
- ...
Notes:
- Animation is also stopped on action error or if maximum number of steps
is reached.
- Asynchronous execution is done with |uv.new_timer()|. It only allows
integer parts as repeat value. This has several implications:
- Outputs of `step_timing()` are accumulated in order to preserve total
execution time.
- Any wait time less than 1 ms means that action will be executed
immediately.
Parameters~
{step_action} `(function|table)` Callable which takes `step` (integer 0, 1, 2,
etc. indicating current step) and executes some action. Its return value
defines when animation should stop: values `false` and `nil` (equivalent
to no explicit return) stop animation timer; any other continues it.
{step_timing} `(function|table)` Callable which takes `step` (integer 1, 2, etc.
indicating next step) and returns how many milliseconds to wait before
executing this step action.
{opts} `(table|nil)` Options. Possible fields:
- <max_steps> - Maximum value of allowed step to execute. Default: 10000000.
------------------------------------------------------------------------------
*MiniAnimate.gen_timing*
`MiniAnimate.gen_timing`
Generate animation timing
Each field corresponds to one family of progression which can be customized
further by supplying appropriate arguments.
This is a table with function elements. Call to actually get timing function.
Example: >
local animate = require('mini.animate')
animate.setup({
cursor = {
timing = animate.gen_timing.linear({ duration = 100, unit = 'total' })
},
})
See also~
|MiniIndentscope.gen_animation| for similar concept in 'mini.indentscope'.
------------------------------------------------------------------------------
*MiniAnimate.gen_timing.none()*
`MiniAnimate.gen_timing.none`()
Generate timing with no animation
Show final result immediately. Usually better to use `enable` field in `config`
if you want to disable animation.
------------------------------------------------------------------------------
*MiniAnimate.gen_timing.linear()*
`MiniAnimate.gen_timing.linear`({opts})
Generate timing with linear progression
Parameters~
{opts} `(table|nil)` Options that control progression. Possible keys:
- <easing> `(string)` - a subtype of progression. One of "in"
(accelerating from zero speed), "out" (decelerating to zero speed),
"in-out" (default; accelerating halfway, decelerating after).
- <duration> `(number)` - duration (in ms) of a unit. Default: 20.
- <unit> `(string)` - which unit's duration `opts.duration` controls. One
of "step" (default; ensures average duration of step to be `opts.duration`)
or "total" (ensures fixed total duration regardless of scope's range).
Return~
`(function)` Timing function (see |MiniAnimate-timing|).
------------------------------------------------------------------------------
*MiniAnimate.gen_timing.quadratic()*
`MiniAnimate.gen_timing.quadratic`({opts})
Generate timing with quadratic progression
Parameters~
{opts} `(table|nil)` Options that control progression. Possible keys:
- <easing> `(string)` - a subtype of progression. One of "in"
(accelerating from zero speed), "out" (decelerating to zero speed),
"in-out" (default; accelerating halfway, decelerating after).
- <duration> `(number)` - duration (in ms) of a unit. Default: 20.
- <unit> `(string)` - which unit's duration `opts.duration` controls. One
of "step" (default; ensures average duration of step to be `opts.duration`)
or "total" (ensures fixed total duration regardless of scope's range).
Return~
`(function)` Timing function (see |MiniAnimate-timing|).
------------------------------------------------------------------------------
*MiniAnimate.gen_timing.cubic()*
`MiniAnimate.gen_timing.cubic`({opts})
Generate timing with cubic progression
Parameters~
{opts} `(table|nil)` Options that control progression. Possible keys:
- <easing> `(string)` - a subtype of progression. One of "in"
(accelerating from zero speed), "out" (decelerating to zero speed),
"in-out" (default; accelerating halfway, decelerating after).
- <duration> `(number)` - duration (in ms) of a unit. Default: 20.
- <unit> `(string)` - which unit's duration `opts.duration` controls. One
of "step" (default; ensures average duration of step to be `opts.duration`)
or "total" (ensures fixed total duration regardless of scope's range).
Return~
`(function)` Timing function (see |MiniAnimate-timing|).
------------------------------------------------------------------------------
*MiniAnimate.gen_timing.quartic()*
`MiniAnimate.gen_timing.quartic`({opts})
Generate timing with quartic progression
Parameters~
{opts} `(table|nil)` Options that control progression. Possible keys:
- <easing> `(string)` - a subtype of progression. One of "in"
(accelerating from zero speed), "out" (decelerating to zero speed),
"in-out" (default; accelerating halfway, decelerating after).
- <duration> `(number)` - duration (in ms) of a unit. Default: 20.
- <unit> `(string)` - which unit's duration `opts.duration` controls. One
of "step" (default; ensures average duration of step to be `opts.duration`)
or "total" (ensures fixed total duration regardless of scope's range).
Return~
`(function)` Timing function (see |MiniAnimate-timing|).
------------------------------------------------------------------------------
*MiniAnimate.gen_timing.exponential()*
`MiniAnimate.gen_timing.exponential`({opts})
Generate timing with exponential progression
Parameters~
{opts} `(table|nil)` Options that control progression. Possible keys:
- <easing> `(string)` - a subtype of progression. One of "in"
(accelerating from zero speed), "out" (decelerating to zero speed),
"in-out" (default; accelerating halfway, decelerating after).
- <duration> `(number)` - duration (in ms) of a unit. Default: 20.
- <unit> `(string)` - which unit's duration `opts.duration` controls. One
of "step" (default; ensures average duration of step to be `opts.duration`)
or "total" (ensures fixed total duration regardless of scope's range).
Return~
`(function)` Timing function (see |MiniAnimate-timing|).
------------------------------------------------------------------------------
*MiniAnimate.gen_path*
`MiniAnimate.gen_path`
Generate cursor animation path
For more information see |MiniAnimate.config.cursor|.
This is a table with function elements. Call to actually get generator.
Example: >
local animate = require('mini.animate')
animate.setup({
cursor = {
-- Animate with line-column angle instead of shortest line
path = animate.gen_path.angle(),
}
})
------------------------------------------------------------------------------
*MiniAnimate.gen_path.line()*
`MiniAnimate.gen_path.line`({opts})
Generate path as shortest line
Parameters~
{opts} `(table|nil)` Options that control generator. Possible keys:
- <predicate> `(function)` - a callable which takes `destination` as input and
returns boolean value indicating whether animation should be done.
Default: `false` if `destination` is within one line of origin (reduces
flickering), `true` otherwise.
Return~
`(function)` Path function (see |MiniAnimate.config.cursor|).
------------------------------------------------------------------------------
*MiniAnimate.gen_path.angle()*
`MiniAnimate.gen_path.angle`({opts})
Generate path as line/column angle
Parameters~
{opts} `(table|nil)` Options that control generator. Possible keys:
- <predicate> `(function)` - a callable which takes `destination` as input and
returns boolean value indicating whether animation should be done.
Default: `false` if `destination` is within one line of origin (reduces
flickering), `true` otherwise.
- <first_direction> `(string)` - one of `"horizontal"` (default; animates
across initial line first) or `"vertical"` (animates across initial
column first).
Return~
`(function)` Path function (see |MiniAnimate.config.cursor|).
------------------------------------------------------------------------------
*MiniAnimate.gen_path.walls()*
`MiniAnimate.gen_path.walls`({opts})
Generate path as closing walls at final position
Parameters~
{opts} `(table|nil)` Options that control generator. Possible keys:
- <predicate> `(function)` - a callable which takes `destination` as input and
returns boolean value indicating whether animation should be done.
Default: `false` if `destination` is within one line of origin (reduces
flickering), `true` otherwise.
- <width> `(number)` - initial width of left and right walls. Default: 10.
Return~
`(function)` Path function (see |MiniAnimate.config.cursor|).
------------------------------------------------------------------------------
*MiniAnimate.gen_path.spiral()*
`MiniAnimate.gen_path.spiral`({opts})
Generate path as diminishing spiral at final position
Parameters~
{opts} `(table|nil)` Options that control generator. Possible keys:
- <predicate> `(function)` - a callable which takes `destination` as input and
returns boolean value indicating whether animation should be done.
Default: `false` if `destination` is within one line of origin (reduces
flickering), `true` otherwise.
- <width> `(number)` - initial width of spiral. Default: 2.
Return~
`(function)` Path function (see |MiniAnimate.config.cursor|).
------------------------------------------------------------------------------
*MiniAnimate.gen_subscroll*
`MiniAnimate.gen_subscroll`
Generate scroll animation subscroll
For more information see |MiniAnimate.config.scroll|.
This is a table with function elements. Call to actually get generator.
Example: >
local animate = require('mini.animate')
animate.setup({
scroll = {
-- Animate equally but with 120 maximum steps instead of default 60
subscroll = animate.gen_subscroll.equal({ max_output_steps = 120 }),
}
})
------------------------------------------------------------------------------
*MiniAnimate.gen_subscroll.equal()*
`MiniAnimate.gen_subscroll.equal`({opts})
Generate subscroll with equal steps
Parameters~
{opts} `(table|nil)` Options that control generator. Possible keys:
- <predicate> `(function)` - a callable which takes `total_scroll` as
input and returns boolean value indicating whether animation should be
done. Default: `false` if `total_scroll` is 1 or less (reduces
unnecessary waiting), `true` otherwise.
- <max_output_steps> `(number)` - maximum number of subscroll steps in output.
Adjust this to reduce computations in expense of reduced smoothness.
Default: 60.
Return~
`(function)` Subscroll function (see |MiniAnimate.config.scroll|).
------------------------------------------------------------------------------
*MiniAnimate.gen_subresize*
`MiniAnimate.gen_subresize`
Generate resize animation subresize
For more information see |MiniAnimate.config.resize|.
This is a table with function elements. Call to actually get generator.
Example: >
local is_many_wins = function(sizes_from, sizes_to)
return vim.tbl_count(sizes_from) >= 3
end
local animate = require('mini.animate')
animate.setup({
resize = {
-- Animate only if there are at least 3 windows
subresize = animate.gen_subresize.equal({ predicate = is_many_wins }),
}
})
------------------------------------------------------------------------------
*MiniAnimate.gen_subresize.equal()*
`MiniAnimate.gen_subresize.equal`({opts})
Generate subresize with equal steps
Parameters~
{opts} `(table|nil)` Options that control generator. Possible keys:
- <predicate> `(function)` - a callable which takes `sizes_from` and
`sizes_to` as input and returns boolean value indicating whether
animation should be done. Default: always `true`.
Return~
`(function)` Subresize function (see |MiniAnimate.config.resize|).
------------------------------------------------------------------------------
*MiniAnimate.gen_winconfig*
`MiniAnimate.gen_winconfig`
Generate open/close animation winconfig
For more information see |MiniAnimate.config.open| or |MiniAnimate.config.close|.
This is a table with function elements. Call to actually get generator.
Example: >
local is_not_single_window = function(win_id)
local tabpage_id = vim.api.nvim_win_get_tabpage(win_id)
return #vim.api.nvim_tabpage_list_wins(tabpage_id) > 1
end
local animate = require('mini.animate')
animate.setup({
open = {
-- Animate with wiping from nearest edge instead of default static one
-- and only if it is not a single window in tabpage
winconfig = animate.gen_winconfig.wipe({
predicate = is_not_single_window,
direction = 'from_edge',
}),
},
close = {
-- Animate with wiping to nearest edge instead of default static one
-- and only if it is not a single window in tabpage
winconfig = animate.gen_winconfig.wipe({
predicate = is_not_single_window,
direction = 'to_edge',
}),
},
})
------------------------------------------------------------------------------
*MiniAnimate.gen_winconfig.static()*
`MiniAnimate.gen_winconfig.static`({opts})
Generate winconfig for static floating window
This will result into floating window statically covering whole target
window.
Parameters~
{opts} `(table|nil)` Options that control generator. Possible keys:
- <predicate> `(function)` - a callable which takes `win_id` as input and
returns boolean value indicating whether animation should be done.
Default: always `true`.
- <n_steps> `(number)` - number of output steps, all with same config.
Usefule to tweak smoothness of transparency animation (done inside
`winblend` config option). Default: 25.
Return~
`(function)` Winconfig function (see |MiniAnimate.config.open|
or |MiniAnimate.config.close|).
------------------------------------------------------------------------------
*MiniAnimate.gen_winconfig.center()*
`MiniAnimate.gen_winconfig.center`({opts})
Generate winconfig for center-focused animated floating window
This will result into floating window growing from or shrinking to the
target window center.
Parameters~
{opts} `(table|nil)` Options that control generator. Possible keys:
- <predicate> `(function)` - a callable which takes `win_id` as input and
returns boolean value indicating whether animation should be done.
Default: always `true`.
- <direction> `(string)` - one of `"to_center"` (default; window will
shrink from full coverage to center) or `"from_center"` (window will
grow from center to full coverage).
Return~
`(function)` Winconfig function (see |MiniAnimate.config.open|
or |MiniAnimate.config.close|).
------------------------------------------------------------------------------
*MiniAnimate.gen_winconfig.wipe()*
`MiniAnimate.gen_winconfig.wipe`({opts})
Generate winconfig for wiping animated floating window
This will result into floating window growing from or shrinking to the
nearest edge. This also takes into account the split type of target window:
vertically split window will progress towards vertical edge; horizontally -
towards horizontal.
Parameters~
{opts} `(table|nil)` Options that control generator. Possible keys:
- <predicate> `(function)` - a callable which takes `win_id` as input and
returns boolean value indicating whether animation should be done.
Default: always `true`.
- <direction> `(string)` - one of `"to_edge"` (default; window will
shrink from full coverage to nearest edge) or `"from_edge"` (window
will grow from edge to full coverage).
Return~
`(function)` Winconfig function (see |MiniAnimate.config.open|
or |MiniAnimate.config.close|).
------------------------------------------------------------------------------
*MiniAnimate.gen_winblend*
`MiniAnimate.gen_winblend`
Generate open/close animation `winblend` progression
For more information see |MiniAnimate.config.open| or |MiniAnimate.config.close|.
This is a table with function elements. Call to actually get transparency
function.
Example: >
local animate = require('mini.animate')
animate.setup({
open = {
-- Change transparency from 60 to 80 instead of default 80 to 100
winblend = animate.gen_winblend.linear({ from = 60, to = 80 }),
},
close = {
-- Change transparency from 60 to 80 instead of default 80 to 100
winblend = animate.gen_winblend.linear({ from = 60, to = 80 }),
},
})
------------------------------------------------------------------------------
*MiniAnimate.gen_winblend.linear()*
`MiniAnimate.gen_winblend.linear`({opts})
Generate linear `winblend` progression
Parameters~
{opts} `(table|nil)` Options that control generator. Possible keys:
- <from> `(number)` - initial value of 'winblend'.
- <to> `(number)` - final value of 'winblend'.
Return~
`(function)` Winblend function (see |MiniAnimate.config.open|
or |MiniAnimate.config.close|).
------------------------------------------------------------------------------
*MiniAnimate.auto_cursor()*
`MiniAnimate.auto_cursor`()
Automatically animate cursor movement
Designed to be used with |autocmd|. No need to use it directly, everything
is setup in |MiniAnimate.setup()|.
------------------------------------------------------------------------------
*MiniAnimate.auto_scroll()*
`MiniAnimate.auto_scroll`()
Automatically animate window scroll
Designed to be used with |autocmd|. No need to use it directly, everything
is setup in |MiniAnimate.setup()|.
------------------------------------------------------------------------------
*MiniAnimate.track_scroll_state()*
`MiniAnimate.track_scroll_state`()
Track scroll state
Designed to be used with |autocmd|. No need to use it directly, everything
is setup in |MiniAnimate.setup()|.
------------------------------------------------------------------------------
*MiniAnimate.track_scroll_state_partial()*
`MiniAnimate.track_scroll_state_partial`()
Partially track scroll state
Designed to be used with |autocmd|. No need to use it directly, everything
is setup in |MiniAnimate.setup()|.
------------------------------------------------------------------------------
*MiniAnimate.auto_resize()*
`MiniAnimate.auto_resize`()
Automatically animate window resize
Designed to be used with |autocmd|. No need to use it directly, everything
is setup in |MiniAnimate.setup()|.
------------------------------------------------------------------------------
*MiniAnimate.auto_openclose()*
`MiniAnimate.auto_openclose`({action_type})
Automatically animate window open/close
Designed to be used with |autocmd|. No need to use it directly, everything
is setup in |MiniAnimate.setup()|.
vim:tw=78:ts=8:noet:ft=help:norl:
0