mattn / vim-lsp-settings

Auto configurations for Language Server for vim-lsp
MIT License
1.3k stars 232 forks source link

rust-analyzer not starting in any way documented. #505

Open ghost opened 2 years ago

ghost commented 2 years ago

Well, the title says it all. I've abandoned vim-racer because it's development stopped and racer for rust is already deprecated.

This said I have these plugins in my init.vim file:

    Plug 'prabirshrestha/vim-lsp'
    Plug 'mattn/vim-lsp-settings'
    Plug 'prabirshrestha/async.vim'
    Plug 'prabirshrestha/asyncomplete.vim'
    Plug 'prabirshrestha/asyncomplete-lsp.vim'

I think the important ones are vim-lsp and vim-lsp-settings as async*.vim ones barely have any docs.

I also have this snippet of code taken from vim-lsp (yes, I also tried using this package without this snippet, both with or without don't work either way):

if executable('rust-analyzer')
    au User lsp_setup call lsp#register_server({
        \ 'name': 'rust-analyzer',
        \ 'cmd': {server_info->['rust-analyzer']},
        \ 'whitelist': ['rust'],
        \ })
endif

However things are not going better after this. At first I thought that my current rust-analyzer path may be wrong, so I did :LspInstallServer and it got rust-analyzer downloaded but no completions or anything else is shown. :LspStatus shows rust-analyzer as not running. On top of all there's only a :LspStopServer command but not a Start one (which sucks for vim-lsp).

I don't know what am I doing wrong here. Is it that this needs an update to work with newer rust-analyzer releases? :thinking: Am I overlooking something? I don't see any way on how to proceed with this.

I apologize in advance if this can be read as a rant to the devs. It isn't. It's just I cannot wrap in my head the idea of something that's so simple to get running in other editors like emacs something so complicated, frustrating and infuriating in vim.

prabirshrestha commented 2 years ago

Please include vim-lsp logs.

FYI: you don’t need async.vim, since it is embedded as part of vim-lsp. But this shouldn’t be an issue.

ghost commented 2 years ago

Sorry to keep you waiting. I was trying to figure the log files but failed miserably.

My vim-lsp.log doesn't show much tho:


mar 14 dic 2021 22:18:47:["s:on_text_document_did_open()", 1, "", "/home/omar", "file:///home/omar/__NO_NAME_1__"]
mar 14 dic 2021 22:18:51:["s:on_text_document_did_open()", 2, "", "/home/omar/GitHub/upventrs", "file:///home/omar/GitHub/upventrs/NERD_tree_1"]
mar 14 dic 2021 22:18:51:["s:on_text_document_did_open()", 2, "nerdtree", "/home/omar/GitHub/upventrs", "file:///home/omar/GitHub/upventrs/NERD_tree_1"]
mar 14 dic 2021 22:18:51:["s:on_text_document_did_change()", 2]
mar 14 dic 2021 22:18:51:["s:send_didchange_queue() will be triggered"]
mar 14 dic 2021 22:18:52:["s:send_event_queue()"]
mar 14 dic 2021 22:18:52:["s:on_text_document_did_change()", 2]
mar 14 dic 2021 22:18:52:["s:send_didchange_queue() will be triggered"]
mar 14 dic 2021 22:18:53:["s:on_text_document_did_open()", 1, "rust", "/home/omar/GitHub/upventrs/src", "file:///home/omar/GitHub/upventrs/src/main.rs"]
mar 14 dic 2021 22:18:53:["s:on_text_document_did_open()", 1, "rust", "/home/omar/GitHub/upventrs/src", "file:///home/omar/GitHub/upventrs/src/main.rs"]
mar 14 dic 2021 22:18:53:["s:on_text_document_did_open()", 1, "rust", "/home/omar/GitHub/upventrs/src", "file:///home/omar/GitHub/upventrs/src/main.rs"]
mar 14 dic 2021 22:18:53:["s:send_event_queue()"]
mar 14 dic 2021 22:18:55:["s:on_text_document_did_close()", 2]
mar 14 dic 2021 22:19:02:["s:on_text_document_did_change()", 1]
mar 14 dic 2021 22:19:02:["s:send_didchange_queue() will be triggered"]
mar 14 dic 2021 22:19:03:["s:on_text_document_did_change()", 1]
mar 14 dic 2021 22:19:03:["s:send_event_queue()"]
mar 14 dic 2021 22:19:04:["s:on_text_document_did_save()", 1]
mar 14 dic 2021 22:19:04:["s:on_text_document_did_change()", 1]
mar 14 dic 2021 22:19:04:["s:send_didchange_queue() will be triggered"]
mar 14 dic 2021 22:19:05:["s:send_event_queue()"]
mar 14 dic 2021 22:19:06:["s:on_text_document_did_close()", 1]
`` `
I also have the `asyncomplete.log` but I think that's irrelevant to this case.
prabirshrestha commented 2 years ago

There should be logs about server starting/failures or ignoring to start.

ghost commented 2 years ago

There were no logs different. I even left it there for a couple minutes to see if any error popped up.

Anyways I managed to fix it following the next steps:

I don't know what could have caused this, no blinking wifi or .vimrc / init.vim config errors. My guess is that the rust-analyzer binary doesn't come with the execute permission and that may be causing a problem. However I don't have much proof since I was the binary on the latest releases page. I don't know if lsp-settings downloads a fixed version or the latest bin.

If you need some testing to see what's going on I'm open to hep :)

prabirshrestha commented 2 years ago

You should be seeing logs from here.

https://github.com/prabirshrestha/vim-lsp/blob/69e6340c48571cc813c52d6acc2057b8aea6e742/autoload/lsp.vim#L408

search for lsp#log on the above file.