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

Not working with rust-analyzer #2

Open
ghost opened this issue Sep 20, 2021 · 3 comments
Open

Not working with rust-analyzer #2

ghost opened this issue Sep 20, 2021 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 20, 2021

I've followed readme instructions step by step, installed virtual-types.nvim, included the on_attach snippet, but it simply doesn't works, no error or warning output is displayed, but the virtual texts aren't showing up when i open a .rs file

Not sure if this is relevant, but I'm using nvim-lspinstall for easing the process of setting up language servers

Here's my system details:

@jubnzv
Copy link
Owner

jubnzv commented Sep 21, 2021

This plugin works with any LSP server that supports textDocument/codeLens.

Please check the documentation of rust-analyzer to make sure that it supports textDocument/codeLens request, and you have configured it correctly.

@ajitid
Copy link

ajitid commented Feb 25, 2022

@henriquehbr @sbaildon @beauwilliams have you guys got this plugin working with rust-analyzer? If yes, care to share the code for it?

I expected types to show up in virtual text, but I only can see run commands at the top of the file.

@aspeddro
Copy link

textDocument/codeLens in rust_analyzer not show type hints, he providers command to build, debug and tests.

Type hints in rust_analyzer is supported by experimental/inlayHints. See https://github.com/simrat39/rust-tools.nvim/ plugin.

https://github.com/simrat39/rust-tools.nvim/blob/9f89fe6d9762ef89973bbb698c750dd21b94ec44/lua/rust-tools/inlay_hints.lua#L257-L259

LSP espeficifcation for 3.17: microsoft/language-server-protocol#956

ocamllsp has not yet implemented the type hint feature in the textDocument/inlayHints method, so some servers show a different result.

Note

Neovim has built-in support for codelens.

local on_attach = function(client, bufnr)
  --- Only Neovim 0.7
  if client.resolved_capabilities.code_lens then
    local codelens = vim.api.nvim_create_augroup(
      'LSPCodeLens',
      { clear = true }
    )
    vim.api.nvim_create_autocmd({ 'BufEnter' }, {
      group = codelens,
      callback = function()
        vim.lsp.codelens.refresh()
      end,
      buffer = bufnr,
      once = true,
    })
    vim.api.nvim_create_autocmd({ 'BufWritePost', 'CursorHold' }, {
      group = codelens,
      callback = function()
        vim.lsp.codelens.refresh()
      end,
      buffer = bufnr,
    })
  end
end

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