Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

structure of inlayHint reply changed in newest clangd 19 #55

Closed
ZhiyuanLck opened this issue Mar 28, 2024 · 3 comments
Closed

structure of inlayHint reply changed in newest clangd 19 #55

ZhiyuanLck opened this issue Mar 28, 2024 · 3 comments

Comments

@ZhiyuanLck
Copy link

ZhiyuanLck commented Mar 28, 2024

Logs
reply:textDocument/inlayHint

{
  "id": 2,
  "jsonrpc": "2.0",
  "result": [
    {
      "kind": 1,
      "label": [
        {
          "value": ": std::expected<int, int>"
        }
      ],
      "paddingLeft": false,
      "paddingRight": false,
      "position": {
        "character": 10,
        "line": 9
      }
    }
  ]
}

label of reply:textDocument/inlayHint is no longer string but an array of table.

for _, hint in pairs(result) do
local text = hint.label
if hint.paddingLeft then text = " " .. text end
if hint.paddingRight then text = text .. " " end
local line = hint.position.line
if
line == current_line - 1
or not config.options.inlay_hints.only_current_line
then
local col = hint.position.character
vim.api.nvim_buf_set_extmark(bufnr, namespace, line, col, {
virt_text_pos = "inline",
virt_text = {
{ text, config.options.inlay_hints.highlight },
},
hl_mode = "combine",
priority = config.options.inlay_hints.priority,
})
end
end

@p00f
Copy link
Owner

p00f commented Apr 3, 2024

Can you make a PR? My distro is still on LLVM 17

@lseman
Copy link

lseman commented Aug 2, 2024

This worked for me:

   for _, hint in pairs(result) do 
        local text = ""
        for _, labelPart in ipairs(hint.label) do
            text = text .. labelPart.value
        end
        if hint.paddingLeft then text = " " .. text end 
        if hint.paddingRight then text = text .. " " end 
        local line = hint.position.line 
        if line == current_line - 1 or not config.options.inlay_hints.only_current_line then 
            local col = hint.position.character 
            vim.api.nvim_buf_set_extmark(bufnr, namespace, line, col, { 
                virt_text_pos = "inline", 
                virt_text = { 
                    { text, config.options.inlay_hints.highlight }, 
                }, 
                hl_mode = "combine", 
                priority = config.options.inlay_hints.priority, 
            }) 
        end 
    end

@p00f
Copy link
Owner

p00f commented Aug 6, 2024

neovim 0.10 has been released for quite a while now, which has inlay hints built-in. closing this

@p00f p00f closed this as completed Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants