nvim: lsp: Inlay hints API has changed

This commit is contained in:
Sanchayan Maity 2023-11-13 10:53:48 +05:30
parent 7810c43679
commit 020d9ed8a6
Signed by: sanchayanmaity
GPG key ID: 6F6A0609C12038F3

View file

@ -15,6 +15,11 @@ local peek_definition = function()
return vim.lsp.buf_request(0, 'textDocument/definition', params, preview_location_callback) return vim.lsp.buf_request(0, 'textDocument/definition', params, preview_location_callback)
end end
local inlay_hint_toggle = function()
vim.lsp.inlay_hint.enable(nil, not vim.lsp.inlay_hint.is_enabled())
end
_G.InlayHintToggle = inlay_hint_toggle
_G.PeekDefinition = peek_definition _G.PeekDefinition = peek_definition
protocol.CompletionItemKind = { protocol.CompletionItemKind = {
@ -58,7 +63,7 @@ local lsp_key_mappings = {
{ "workspace/symbol" , 'n', '1gD' , '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>' }, { "workspace/symbol" , 'n', '1gD' , '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>' },
{ "textDocument/signatureHelp" , 'n', '<Leader>S', '<cmd>lua vim.lsp.buf.signature_help()<CR>' }, { "textDocument/signatureHelp" , 'n', '<Leader>S', '<cmd>lua vim.lsp.buf.signature_help()<CR>' },
{ "textDocument/rename" , 'n', 'gR' , '<cmd>lua vim.lsp.buf.rename()<CR>' }, { "textDocument/rename" , 'n', 'gR' , '<cmd>lua vim.lsp.buf.rename()<CR>' },
{ "textDocument/inlayHint" , 'n', 'gi' , '<cmd>lua vim.lsp.inlay_hint(0, nil)<CR>' }, { "textDocument/inlayHint" , 'n', 'gi' , '<cmd>lua InlayHintToggle()<CR>' },
{ "textDocument/rangeFormatting", 'x', 'gq', '<cmd>lua vim.lsp.buf.format({async=true})<CR>' }, { "textDocument/rangeFormatting", 'x', 'gq', '<cmd>lua vim.lsp.buf.format({async=true})<CR>' },
{ "textDocument/formatting" , 'n', 'gq', '<cmd>lua vim.lsp.buf.format({async=true})<CR>' }, { "textDocument/formatting" , 'n', 'gq', '<cmd>lua vim.lsp.buf.format({async=true})<CR>' },
@ -236,7 +241,7 @@ local on_attach = function(client, bufnr)
end end
if client.supports_method('textDocument/inlayHint') then if client.supports_method('textDocument/inlayHint') then
vim.lsp.inlay_hint(bufnr, false) vim.lsp.inlay_hint.enable(bufnr, false)
end end
end end