From a78d5e1d81033f94c9bd58325c842b66f547e0de Mon Sep 17 00:00:00 2001 From: ray-x Date: Tue, 14 Nov 2023 20:58:19 +1100 Subject: [PATCH] go.nvim assert as https://github.com/neovim/neovim/pull/25512 been integrated into nightly issue #398 --- lua/go/inlay.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lua/go/inlay.lua b/lua/go/inlay.lua index 427415430..29fc591f3 100644 --- a/lua/go/inlay.lua +++ b/lua/go/inlay.lua @@ -8,7 +8,12 @@ local utils = require('go.utils') local log = utils.log local trace = utils.trace local config -local inlay_display = vim.fn.has('nvim-0.10') == 1 and _GO_NVIM_CFG.lsp_inlay_hints.style == 'inlay' and vim.lsp.inlay_hint +local inlay_display = vim.fn.has('nvim-0.10') == 1 + and _GO_NVIM_CFG.lsp_inlay_hints.style == 'inlay' + and vim.lsp.inlay_hint and type(vim.lsp.inlay_hint) == 'table' +if type(vim.lsp.inlay_hint) == 'function' then + utils.warn('unsupported neovim nightly,please upgrade') +end -- local inlay_display = true -- whether the hints are enabled or not local enabled = nil @@ -264,7 +269,9 @@ end function M.toggle_inlay_hints() if inlay_display then - vim.lsp.inlay_hint(vim.api.nvim_get_current_buf()) + local bufnr=vim.api.nvim_get_current_buf() + enabled = vim.lsp.inlay_hint.is_enabled(bufnr) + vim.lsp.inlay_hint.enable(bufnr, not enabled) elseif enabled then M.disable_inlay_hints(true) else @@ -275,8 +282,9 @@ end function M.disable_inlay_hints(update) if inlay_display then + local toggle = vim.lsp.inlay_hint local bufnr = vim.api.nvim_get_current_buf() - vim.lsp.inlay_hint(bufnr, false) + vim.lsp.inlay_hint.enable(bufnr, false) return end -- clear namespace which clears the virtual text as well @@ -309,7 +317,7 @@ function M.set_inlay_hints() local filetime = fn.getftime(fname) if inlay_display then local wrap = utils.throttle(function() - vim.lsp.inlay_hint(bufnr, enabled) + vim.lsp.inlay_hint.enable(bufnr) should_update[fname] = filetime end, 300) return wrap()