nvim_runtime_lua

vim.lsp.inlay_hint

Methods3

function M.get(filter: vim.lsp.inlay_hint.get.Filter | nil) -> vim.lsp.inlay_hint.get.ret[]

Get the list of inlay hints, (optionally) restricted by buffer or range.

Example usage:

local hint = vim.lsp.inlay_hint.get({ bufnr = 0 })[1] -- 0 for current buffer

local client = vim.lsp.get_client_by_id(hint.client_id)
local resp = client:request_sync('inlayHint/resolve', hint.inlay_hint, 100, 0)
local resolved_hint = assert(
  resp and resp.result,
  resp and resp.err and vim.lsp.rpc.format_rpc_error(resp.err) or 'request failed'
)
vim.lsp.util.apply_text_edits(resolved_hint.textEdits, 0, client.encoding)

location = resolved_hint.label[1].location
client:request('textDocument/hover', {
  textDocument = { uri = location.uri },
  position = location.range.start,
})

@since 12

function M.is_enabled(filter: vim.lsp.capability.enable.Filter | nil) -> boolean

Query whether inlay hint is enabled in the {filter}ed scope

@since 12

function M.enable(enable: nil | boolean, filter: vim.lsp.capability.enable.Filter | nil) -> nil

Enables or disables inlay hints for the {filter}ed scope.

To "toggle", pass the inverse of is_enabled():

vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled())
Parameters
enablenil | boolean

true/nil to enable, false to disable

Returns
nil

@since 12