autozimu / LanguageClient-neovim

Language Server Protocol (LSP) support for vim and neovim.
MIT License
3.55k stars 272 forks source link

initializationOptions are not passed to rust-analyzer #1182

Closed ta3pks closed 3 years ago

ta3pks commented 3 years ago

Describe the bug

Initialization options described in rust analyzer manual has no effect on the language client. I enabled procmacros but still i get proc macro errors I also cannot seem to disable those diagnostics for the same reason usage of the options are clearly documented so either LanguageClient-neovim uses non-standard way of defining things or simply this is not implemented

let g:LanguageClient_serverCommands = {
            \ 'rust': {
            \"name":"rust-analyzer",
            \ "command":['rust-analyzer'],
            \ "initializationOptions":{
            \"rust-analyzer.procMacro.enable": v:true,
            \"rust-analyzer.cargo.loadOutDirsFromCheck": v:true,
            \},
            \ },
            \ }

Environment

To Reproduce

Steps to reproduce the behavior:


- open a rust file which uses some proc macro such as `Serialize` derive macro
- watch the errors despite the initOptions

## Current behavior

Described above and the title multiple times.

## Expected behavior

Init options to take effect

## Screenshots

![image](https://user-images.githubusercontent.com/9097437/104828790-0cdf0c80-587e-11eb-9b92-2d76452a878c.png)
![image](https://user-images.githubusercontent.com/9097437/104828807-21230980-587e-11eb-9c54-b905d7d2279c.png)
ta3pks commented 3 years ago

options are supposed to be specified as nested maps one key at a time I guess this has nothing to do with LanguageClient-neovim afterall

martskins commented 3 years ago

I think the issue you are/were having is that the rust-analyzer. prefix on your options should not be included in this config section. The idea behind that not being necessary was that it was already clear that the initialization options were for rust-analyzer (or whatever server you were configuring), but maybe that's not clear or correct enough and it's worth changing it to require the full option name.

Essentially, what you want to have there is something like this instead:

...
"initializationOptions": {
  "procMacro.enable": v:true,
  "cargo.loadOutDirsFromCheck": v:true,
},
...
ta3pks commented 3 years ago

@martskins that doesnt work either

"initializatinonOptions":{
  "procMacro":{
    "enable":v:true
  }
}

dos work however