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

Setup with rust_analyzer and rust_tools #33

Closed
nixypanda opened this issue Jun 24, 2021 · 5 comments
Closed

Setup with rust_analyzer and rust_tools #33

nixypanda opened this issue Jun 24, 2021 · 5 comments
Labels
bug Something isn't working

Comments

@nixypanda
Copy link

First off, awesome plugin.

Rust Setup (Not Working)

Tried a normal setup with rust it does not work.

Minimal Not Working RC (look caveat below)

lua << EOF
require'lspconfig'.rust_analyzer.setup{}
require'lsp_signature'.on_attach({})
EOF

Though as mentioned in the readme if I add this in the rust_analyzer setup everything works perfectly fine.

There is a plugin called rust-tools which I use in my setup. I ran into an issue where this plugin was not working with rust_tools.

Rust Setup (Not Working)

Minimal Not Working RC (look caveat below)

lua << EOF
require'lspconfig'.rust_analyzer.setup{
    on_attach = function() require'lsp_signature'.on_attach({bind = true}) end
}
require'rust-tools'.setup()
EOF

Rust Setup (Working)

But if I change the ordering of these then it does work. Example -
Minimal Wokring RC (look caveat below)

lua << EOF
require'rust-tools'.setup()
require'lspconfig'.rust_analyzer.setup{
    on_attach = function() require'lsp_signature'.on_attach({bind = true}) end
}
EOF

Why report this issue if this is working?

  1. I would like to understand why this is happening and if you can provide any help in that regard would appreciate it.
  2. It might be helpful for someone else who stumbles on something similar. (Probably worthwhile to add this info in the Readme)

Caveat

Note: I am using NixOS and I have installed these with the nix pckage manager, so I don't have a vim/neovim installer. Don't really know how they work. But should be standard enough to set up.

Packages used here are

  1. nvim-lspconfig
  2. lsp_signature.nvim
  3. rust-tools.nvim
@ray-x ray-x added the bug Something isn't working label Jun 24, 2021
@ray-x
Copy link
Owner

ray-x commented Jun 25, 2021

Thanks for the feedback. I do not think you need {bind=true} as your configure does not bind anything

I can not reproduce the issue you saw:

Here is my vimrc


set termguicolors
call plug#begin('~/.vim/plugged')

Plug 'neovim/nvim-lspconfig'
Plug 'simrat39/rust-tools.nvim'

Plug 'ray-x/aurora'
Plug 'ray-x/lsp_signature.nvim'
call plug#end()

lua <<EOF

require'lspconfig'.rust_analyzer.setup{}

require'lsp_signature'.on_attach({})
require('rust-tools').setup(opts)

EOF

set mouse=a
colorscheme aurora

But I do notice that it takes rust analyzer a few seconds to startup. During that time, there is no response from rust lsp.
So to avoid that, open your rust file. Take a really deep breath (or maybe two), and then begin to write code....

@nixypanda
Copy link
Author

Thanks for the tip about bind

I tried this with my nix setup on MacOS as well, and I got the same results, as I mentioned in the first post

Details

For completion, this is the exact config I am using. (This is in home-manager)

  programs.neovim = {
    enable = true;
    vimAlias = true;

    plugins = with pkgs.vimPlugins; [
      nvim-lspconfig
      lsp_signature-nvim
      rust-tools-nvim
    ];

    extraConfig = ''
      lua <<EOF
        require'lspconfig'.rust_analyzer.setup{}
        require'lsp_signature'.on_attach({})
        require('rust-tools').setup(opts)
      EOF
    '';

    package = pkgs.neovim-nightly;
  };

And the following is the generated vimrc

set packpath^=/nix/store/9j0dz6fdi2ccpddim5w13i5zcsvmf0yl-vim-pack-dir
set runtimepath^=/nix/store/9j0dz6fdi2ccpddim5w13i5zcsvmf0yl-vim-pack-dir

lua <<EOF
  require'lspconfig'.rust_analyzer.setup{}
  require'lsp_signature'.on_attach({})
  require('rust-tools').setup(opts)
EOF

But I do notice that it takes rust-analyzer a few seconds to startup.

I did make sure that rust-analyzer was up and running.

Additionally, I currently do not have access to non-nixified systems, when I do get it I will give it a shot again.

@ray-x
Copy link
Owner

ray-x commented Jun 27, 2021

Is the issue reproducible with my vimrc (with Plug)

I will maintain the plugin set up for Plug, Dein, Packer and minipac.

Also when the plugin not working. If you trigger the plugin manually by running

lua require'lsp_signature'.signature()

Dose it show the signature?

@nixypanda
Copy link
Author

I don't really have access to a non-nix system, so I can't really test it with Plug, Dein, etc. Moreover, I would like to avoid installing any of them. In future, I will give it a shot and try in a non-nix system and see if this works.

lua require'lsp_signature'.signature() works. Additionally if I manually execute lua require'lsp_signature'.on_attach() then the plugin works as intended.

This could be an issue that is specific to nix (i.e. if one uses nix package manager instead of other like Plug, Dein etc)

@ray-x
Copy link
Owner

ray-x commented Jun 13, 2022

Close as no plan for me to move to nix system.
Also there are users who report rust is working.

@ray-x ray-x closed this as completed Jun 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants