simrat39 / rust-tools.nvim

Tools for better development in rust using neovim's builtin lsp
MIT License
2.17k stars 158 forks source link

InlayHint is not working #295

Closed SDGLBL closed 1 year ago

SDGLBL commented 1 year ago

InlayHint is not working I fix this problem when i using pairs instead of ipairs in cache_render #296

function M.cache_render(self, bufnr)
  local buffer = bufnr or vim.api.nvim_get_current_buf()

  for _, v in pairs(vim.lsp.buf_get_clients(buffer)) do
  # use pairs fix this problem
  # for _, v in ipairs(vim.lsp.buf_get_clients(buffer)) do
    if rt.utils.is_ra_server(v) then
      v.request(
        "textDocument/inlayHint",
        get_params(v, buffer),
        function(err, result, ctx)
          if err then
            return
          end

          if not vim.api.nvim_buf_is_valid(ctx.bufnr) then
            self.cache[ctx.bufnr] = nil
            return
          end

          self.cache[ctx.bufnr] = parse_hints(result)

          M.render(self, ctx.bufnr)
        end,
        buffer
      )
    end
  end
end
TornaxO7 commented 1 year ago

Are you referencing to this error message?


Error executing vim.schedule lua callback: ...nvim/lazy/rust-tools.nvim/lua/rust-tools/inlay_hints.lua:216: bad argument #1 to 'sub' (string expected, got table)
stack traceback:
    [C]: in function 'sub'
    ...nvim/lazy/rust-tools.nvim/lua/rust-tools/inlay_hints.lua:216: in function 'render_line'
    ...nvim/lazy/rust-tools.nvim/lua/rust-tools/inlay_hints.lua:260: in function 'render'
    ...nvim/lazy/rust-tools.nvim/lua/rust-tools/inlay_hints.lua:170: in function 'handler'
    /usr/share/nvim/runtime/lua/vim/lsp.lua:1388: in function ''
    vim/_editor.lua: in function <vim/_editor.lua:0>
```?
peytondmurray commented 1 year ago

@TornaxO7 :point_up: I'm seeing this one as well, but the fix above doesn't solve the issue for me. The fix mentioned in #300 does, though.