state (buffers, windows, etc) be directly
accessed from threads.
A subset of the `vim.*` stdlib is available in threads, including:
- `vim.uv` with a separate event loop per thread.
- `vim.mpack` and `vim.json` (useful for serializing messages between threads)
- `require` in threads can use Lua packages from the global |package.path|
- `print()` and `vim.inspect`
- `vim.diff`
- Most utility functions in `vim.*` that work with pure Lua values, like
`vim.split`, `vim.tbl_*`, `vim.list_*`, etc.
- `vim.is_thread()` returns true from a non-main thread.
==============================================================================
VIM.HL *vim.hl*
vim.hl.on_yank({opts}) *vim.hl.on_yank()*
Highlight the yanked text during a |TextYankPost| event.
Add the following to your `init.vim`: >vim
autocmd TextYankPost * silent! lua vim.hl.on_yank {higroup='Visual', timeout=300}
<
Parameters: ~
• {opts} (`table?`) Optional parameters
• higroup highlight group for yanked region (default
"IncSearch")
• timeout time in ms before highlight is cleared (default 150)
• on_macro highlight when executing macro (default false)
• on_visual highlight when yanking visual selection (default
true)
• event event structure (default vim.v.event)
• priority integer priority (default
|vim.hl.priorities|`.user`)
vim.hl.priorities *vim.hl.priorities*
Table with default priorities used for highlighting:
• `syntax`: `50`, used for standard syntax highlighting
• `treesitter`: `100`, used for treesitter-based highlighting
• `semantic_tokens`: `125`, used for LSP semantic token highlighting
• `diagnostics`: `150`, used for code analysis such as diagnostics
• `user`: `200`, used for user-triggered highlights such as LSP document
symbols or `on_yank` autocommands
*vim.hl.range()*
vim.hl.range({bufnr}, {ns}, {higroup}, {start}, {finish}, {opts})
Apply highlight group to range of text.
Parameters: ~
• {bufnr} (`integer`) Buffer number to apply highlighting to
• {ns} (`integer`) Namespace to add highlight to
• {higroup} (`string`) Highlight group to use for highlighting
• {start} (`[integer,integer]|string`) Start of region as a (line,
column) tuple or string accepted by |getpos()|
• {finish} (`[integer,integer]|string`) End of region as a (line,
column) tuple or string accepted by |getpos()|
• {opts} (`table?`) A table with the following fields:
• {regtype}? (`string`, default: `'v'` i.e. charwise) Type
of range. See |getregtype()|
• {inclusive}? (`boolean`, default: `false`) Indicates
whether the range is end-inclusive
• {priority}? (`integer`, default:
`vim.hl.priorities.user`) Highlight priority
• {timeout}? (`integer`, default: -1 no timeout) Time in ms
before highlight is cleared
Return (multiple): ~
(`uv.uv_timer_t?`) range_timer A timer which manages how much time the
highlight has left
(`fun()?`) range_clear A function which allows clearing the highlight
manually. nil is returned if timeout is not specified
==============================================================================
VIM.DIFF *vim.diff*
vim.diff({a}, {b}, {opts}) *vim.diff()*
Run diff on strings {a} and {b}. Any indices returned by this function,
either directly or via callback arguments,