Closed ranebrown closed 2 years ago
clangd's server_capabilities doesn't have anything for inlay hints (even though https://clangd.llvm.org/extensions#inlay-hints says it should have clangdInlayHintsProvider
) so I don't think this can be checked
Seemed like this might work with some quick testing? if client.supports_method("clangd/inlayHints") then
.
Seemed like the same response for if client.supports_method("textDocument/inlayHints") then
which might be better.
ah ok i'll do that
Might not be the best solution but this works.
vim.api.nvim_create_autocmd(
{ "BufEnter", "BufWinEnter", "TabEnter", "BufWritePost" },
{
group = clangd_augroup,
buffer = bufnr,
callback = function()
local buf = vim.api.nvim_get_current_buf()
local clients = vim.lsp.buf_get_clients(buf)
for _, c in pairs(clients) do
if c.name == "clangd" then
require("clangd_extensions.inlay_hints").set_inlay_hints()
break
end
end
end,
desc = "Clangd set inlay hints",
}
)
looks ok, can you open a pr?
Would it be possible to add a check that the running server supports inlay hints prior to running the
set_inlay_hints
autocmd? I normally run with clangd and null-ls. Sometimes when I do a clean it wipes out my compile_commands.json and the clangd server dies. Then I get spammed with messages about the server not supporting inlay hints when the autocmd runs.