mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-24 17:58:51 +02:00
fix(lsp): fix inlay hints for older nightlies. See #2007
This commit is contained in:
parent
6ac331b588
commit
8baf9b5459
2 changed files with 13 additions and 12 deletions
|
@ -115,12 +115,10 @@ return {
|
||||||
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
||||||
end
|
end
|
||||||
|
|
||||||
local inlay_hint = vim.lsp.buf.inlay_hint or (vim.lsp.inlay_hint and vim.lsp.inlay_hint.enable)
|
if opts.inlay_hints.enabled then
|
||||||
|
|
||||||
if opts.inlay_hints.enabled and inlay_hint then
|
|
||||||
Util.lsp.on_attach(function(client, buffer)
|
Util.lsp.on_attach(function(client, buffer)
|
||||||
if client.supports_method("textDocument/inlayHint") then
|
if client.supports_method("textDocument/inlayHint") then
|
||||||
inlay_hint(buffer, true)
|
Util.toggle.inlay_hints(buffer, true)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,14 +53,17 @@ function M.diagnostics()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param bufnr? number
|
---@param buf? number
|
||||||
function M.inlay_hints(bufnr)
|
---@param value? boolean
|
||||||
bufnr = bufnr or 0
|
function M.inlay_hints(buf, value)
|
||||||
local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint
|
local ih = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint
|
||||||
if inlay_hint.enable then
|
if type(ih) == "function" then
|
||||||
vim.lsp.inlay_hint.enable(bufnr, not inlay_hint.is_enabled())
|
ih(buf, value)
|
||||||
else
|
elseif type(ih) == "table" and ih.enable then
|
||||||
vim.lsp.inlay_hint(bufnr, nil)
|
if value == nil then
|
||||||
|
value = not ih.is_enabled(buf)
|
||||||
|
end
|
||||||
|
ih.enable(buf, value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue