Skip to content

Commit

Permalink
go.nvim assert as neovim/neovim#25512 been integrated into nightly
Browse files Browse the repository at this point in the history
issue #398
  • Loading branch information
ray-x committed Nov 14, 2023
1 parent f9672fd commit a78d5e1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lua/go/inlay.lua
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit a78d5e1

Please sign in to comment.