vim.hl
Methods3
function M.range(buf: integer, ns: integer, hlgroup: integer | integer[] | string | string[], start: (integer, integer) | string, finish: (integer, integer) | string, opts: vim.hl.range.Opts | nil) -> (range_timer uv.uv_timer_t | nil, range_clear fun() -> nil | nil)
Apply highlight group to range of text.
Parameters
bufintegerBuffer number to apply highlighting to
nsintegerNamespace to add highlight to
hlgroupinteger | integer[] | string | string[]Highlight group used for the text range. See the
hl_groupoption in |nvimbufset_extmark()|.start(integer, integer) | stringStart of region as a (line, column) tuple or string accepted by |getpos()|
finish(integer, integer) | stringEnd of region as a (line, column) tuple or string accepted by |getpos()|
optsvim.hl.range.Opts | nil
Returns
range_timeruv.uv_timer_t | nilA timer which manages how much time the highlight has left
range_clearfun() -> nil | nilA function which allows clearing the highlight manually. nil is returned if timeout is not specified
function M.hl_op(opts: nil | table) -> nil
Highlights the affected text region during a |TextYankPost| or |TextPutPost| event.
Add this to your init.vim:
autocmd TextYankPost * silent! lua vim.hl.hl_op {higroup='Visual', timeout=300}
autocmd TextPutPost * silent! lua vim.hl.hl_op {higroup='Visual', timeout=300}
Parameters
optsnil | tableOptional parameters
- event (default: vim.v.event) Event structure.
- higroup (default: "IncSearch") Highlight group for the text region.
- on_macro (default: false) Highlight during |macro| execution.
- on_visual (default: true) Highlight during |Visual| mode.
- priority (default: |vim.hl.priorities|
.user) Integer priority. - timeout (default: 150) Time in ms before highlight is cleared.
Returns
- nil
function M.on_yank(opts) -> nil
Deprecated
Use |vim.hl.hl_op()| instead.
Fields1
M.priorities: table
Table with default priorities used for highlighting:
syntax:50, used for standard syntax highlightingtreesitter:100, used for treesitter-based highlightingsemantic_tokens:125, used for LSP semantic token highlightingdiagnostics:150, used for code analysis such as diagnosticsuser:200, used for user-triggered highlights such as LSP document
symbols or hl_op autocommands