mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
feat(lsp): inlay hints #23984
Add automatic refresh and a public interface on top of #23736 * add on_reload, on_detach handlers in `enable()` buf_attach, and LspDetach autocommand in case of manual detach * unify `__buffers` and `hint_cache_by_buf` * use callback bufnr in `on_lines` callback, bufstate: remove __index override * move user-facing functions into vim.lsp.buf, unify enable/disable/toggle Closes #18086
This commit is contained in:
@@ -810,4 +810,19 @@ function M.execute_command(command_params)
|
||||
request('workspace/executeCommand', command_params)
|
||||
end
|
||||
|
||||
--- Enable/disable/toggle inlay hints for a buffer
|
||||
---@param bufnr (integer) Buffer handle, or 0 for current
|
||||
---@param enable (boolean|nil) true/false to enable/disable, nil to toggle
|
||||
function M.inlay_hint(bufnr, enable)
|
||||
vim.validate({ enable = { enable, { 'boolean', 'nil' } }, bufnr = { bufnr, 'number' } })
|
||||
local inlay_hint = require('vim.lsp._inlay_hint')
|
||||
if enable then
|
||||
inlay_hint.enable(bufnr)
|
||||
elseif enable == false then
|
||||
inlay_hint.disable(bufnr)
|
||||
else
|
||||
inlay_hint.toggle(bufnr)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
Reference in New Issue
Block a user