semantic token.
Apply an extmark with a given highlight group for a semantic token. The
mark will be deleted by the semantic token engine when appropriate; for
example, when the LSP sends updated tokens. This function is intended for
use inside |LspTokenUpdate| callbacks.
Parameters: ~
• {token} (`table`) A semantic token, found as `args.data.token` in
|LspTokenUpdate|
• {bufnr} (`integer`) The buffer to highlight, or `0` for current
buffer
• {client_id} (`integer`) The ID of the |vim.lsp.Client|
• {hl_group} (`string`) Highlight group name
• {opts} (`table?`) Optional parameters:
• {priority}? (`integer`, default:
`vim.hl.priorities.semantic_tokens + 3`) Priority for
the applied extmark.
start({bufnr}, {client_id}, {opts}) *vim.lsp.semantic_tokens.start()*
Start the semantic token highlighting engine for the given buffer with the
given client. The client must already be attached to the buffer.
NOTE: This is currently called automatically by
|vim.lsp.buf_attach_client()|. To opt-out of semantic highlighting with a
server that supports it, you can delete the semanticTokensProvider table
from the {server_capabilities} of your client in your |LspAttach| callback
or your configuration's `on_attach` callback: >lua
client.server_capabilities.semanticTokensProvider = nil
<
Parameters: ~
• {bufnr} (`integer`) Buffer number, or `0` for current buffer
• {client_id} (`integer`) The ID of the |vim.lsp.Client|
• {opts} (`table?`) Optional keyword arguments
• debounce (integer, default: 200): Debounce token
requests to the server by the given number in
milliseconds
stop({bufnr}, {client_id}) *vim.lsp.semantic_tokens.stop()*
Stop the semantic token highlighting engine for the given buffer with the
given client.
NOTE: This is automatically called by a |LspDetach| autocmd that is set up
as part of `start()`, so you should only need this function to manually
disengage the semantic token engine without fully detaching the LSP client
from the buffer.
Parameters: ~
• {bufnr} (`integer`) Buffer number, or `0` for current buffer
• {client_id} (`integer`) The ID of the |vim.lsp.Client|
==============================================================================
Lua module: vim.lsp.document_color *lsp-document_color*
enable({enable}, {bufnr}, {opts}) *vim.lsp.document_color.enable()*
Enables document highlighting from the given language client in the given
buffer.
You can enable document highlighting when a client attaches to a buffer as
follows: >lua
vim.api.nvim_create_autocmd('LspAttach', {
callback = function(args)
vim.lsp.document_color.enable(true, args.buf)
end
})
<
To "toggle", pass the inverse of `is_enabled()`: >lua
vim.lsp.document_color.enable(not vim.lsp.document_color.is_enabled())
<
Parameters: ~
• {enable} (`boolean?`) True to enable, false to disable. (default:
`true`)
• {bufnr} (`integer?`) Buffer handle, or 0 for current. (default: 0)
• {opts} (`table?`) A table with the following fields:
• {style}?
(`'background'|'foreground'|'virtual'|string|fun(bufnr: integer, range: Range4, hex_code: string)`)
Highlight style. It can be one of the pre-defined styles,
a string to be used as virtual text, or a function that
receives the buffer handle, the range (start line, start
col, end line, end col) and the resolved hex color.
(default: `'background'`)
is_enabled({bufnr})