Remove the need to check vim version

This commit is contained in:
Gary Murray 2023-11-16 10:33:33 -07:00
parent 8a24b61aed
commit 8f25c56bf6
2 changed files with 5 additions and 12 deletions

View file

@ -115,16 +115,12 @@ 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 local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint.enable
if opts.inlay_hints.enabled and inlay_hint 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
if vim.fn.has("nvim-0.10") == 1 then inlay_hint(buffer, true)
inlay_hint.enable(buffer, true)
else
inlay_hint(buffer, true)
end
end end
end) end)
end end

View file

@ -125,12 +125,9 @@ end
---@param bufnr? number ---@param bufnr? number
function M.toggle_inline_hint(bufnr) function M.toggle_inline_hint(bufnr)
bufnr = bufnr or 0 bufnr = bufnr or 0
if vim.fn.has("nvim-0.10") then local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint
if vim.lsp.inlay_hint.is_enabled() then if inlay_hint.enable then
vim.lsp.inlay_hint.enable(bufnr, false) vim.lsp.inlay_hint.enable(bufnr, not inlay_hint.is_enabled())
else
vim.lsp.inlay_hint.enable(bufnr, true)
end
else else
vim.lsp.inlay_hint(bufnr, nil) vim.lsp.inlay_hint(bufnr, nil)
end end