8000 mini.nvim/doc/mini-hipatterns.txt at main · epheien/mini.nvim · GitHub
[go: up one dir, main page]

Skip to content

Latest commit

 

History

History
481 lines (390 loc) · 19.3 KB

mini-hipatterns.txt

File metadata and controls

481 lines (390 loc) · 19.3 KB
Return ~
`(table)` Array of buffer identifiers with enabled highlighting.
------------------------------------------------------------------------------
*MiniHipatterns.get_matches()*
`MiniHipatterns.get_matches`({buf_id}, {highlighters})
Get buffer matches
Parameters ~
{buf_id} `(number|nil)` Buffer identifier for which to return matches.
Default: `nil` for current buffer.
{highlighters} `(table|nil)` Array of highlighter identifiers (as in
`highlighters` field of |MiniHipatterns.config|) for which to return matches.
Default: all available highlighters (ordered by string representation).
Return ~
`(table)` Array of buffer matches which are tables with following fields:
- <bufnr> `(number)` - buffer identifier of a match.
- <highlighter> `(any)` - highlighter identifier which produced the match.
- <lnum> `(number)` - line number of the match start (starts with 1).
- <col> `(number)` - column number of the match start (starts with 1).
- <end_lnum> `(number|nil)` - line number of the match end (starts with 1).
- <end_col> `(number|nil)` - column number next to the match end
(implements end-exclusive region; starts with 1).
- <hl_group> `(string|nil)` - name of match's highlight group.
Matches are ordered first by supplied `highlighters`, then by line and
column of match start.
------------------------------------------------------------------------------
*MiniHipatterns.gen_highlighter*
`MiniHipatterns.gen_highlighter`
Generate builtin highlighters
This is a table with function elements. Call to actually get highlighter.
------------------------------------------------------------------------------
*MiniHipatterns.gen_highlighter.hex_color()*
`MiniHipatterns.gen_highlighter.hex_color`({opts})
Highlight hex color string
This will match color hex string in format `#rrggbb` and highlight it
according to `opts.style` displaying matched color.
Highlight group is computed using |MiniHipatterns.compute_hex_color_group()|,
so all its usage notes apply here.
Parameters ~
{opts} `(table|nil)` Options. Possible fields:
- <style> `(string)` - one of:
- `'full'` - highlight background of whole hex string with it. Default.
- `'#'` - highlight background of only `#`.
- `'line'` - highlight underline with that color.
- `'inline'` - highlight text of <inline_text>.
Note: requires Neovim>=0.10.
- <priority> `(number)` - priority of highlighting. Default: 200.
- <filter> `(function)` - callable object used to filter buffers in which
highlighting will take place. It should take buffer identifier as input
and return `false` or `nil` to not highlight inside this buffer.
- <inline_text> `(string)` - string to be placed and highlighted with color
to the right of match in case <style> is "inline". Default: "█".
Return ~
`(table)` Highlighter table ready to be used as part of `config.highlighters`.
Both `pattern` and `group` are callable.
Usage ~
>lua
local hipatterns = require('mini.hipatterns')
hipatterns.setup({
highlighters = {
hex_color = hipatterns.gen_highlighter.hex_color(),
}
})
<
------------------------------------------------------------------------------
*MiniHipatterns.compute_hex_color_group()*
`MiniHipatterns.compute_hex_color_group`({hex_color}, {style})
Compute and create group to highlight hex color string
Notes:
- This works properly only with enabled |termguicolors|.
- To increase performance, it caches highlight groups per `hex_color` and
`style` combination. Needs a call to |MiniHipatterns.setup()| to have
these groups be persistent across color scheme changes.
Parameters ~
{hex_color} `(string)` Hex color string in format `#rrggbb`.
{style|nil} `(string)` One of:
- `'bg'` - highlight background with `hex_color` and foreground with black or
white (whichever is more visible). Default.
- `'fg'` - highlight foreground with `hex_color`.
- `'line'` - highlight underline with `hex_color`.
Return ~
`(string)` Name of created highlight group appropriate to show `hex_color`.
vim:tw=78:ts=8:noet:ft=help:norl:
0