LanguageClient-neovim
LanguageClient-neovim copied to clipboard
workspace/configuration doesn't work for servers which don't send serverInfo
Describe the bug
If the server doesn't provide serverInfo
in InitializeResult
, the plugin will send an empty array instead of the initializationOptions
set by the user when the server requests workspace/configuration
.
Environment
- Vim 8.2.3450
- Plugin version 1cb8bb5 (current dev branch)
- Plugin's binary version 0.1.161
- Relevant vimrc settings:
let g:LanguageClient_serverCommands = {
\ 'yaml': {
\ 'name': 'yaml',
\ 'command': ['/path/to/yaml-language-server', '--stdio'],
\ 'initializationOptions': {
\ 'completion': v:true,
\ 'hover': v:true,
\ 'validate': v:true,
\ 'format': {
\ 'enable': v:true,
\ 'singleQuote': v:true,
\ 'bracketSpacing': v:true,
\ },
\ },
\ },
\}
- YAML language server 0.22.0
To Reproduce
- Use Vim to edit a YAML file with single-quoted strings. For example:
a: '123'
- Execute
call LanguageClient#textDocument_formatting()
Current behavior
Single quotes are changed to double quotes.
Expected behavior
Single quotes should not be changed. I have asked the plugin to tell the language server that I want single quotes, so the language server should not change it to double quotes.
Additional context
I am not sure if this is a correct patch, but at least it allows me to pass options to the YAML language server.
diff --git a/src/language_client.rs b/src/language_client.rs
index 0204c7c..e9bdcc9 100644
--- a/src/language_client.rs
+++ b/src/language_client.rs
@@ -973,11 +973,12 @@ impl LanguageClient {
let server_name = initialize_result
.server_info
.as_ref()
- .map(|info| info.name.clone());
- if let (Some(name), Some(options)) = (server_name, initialization_options) {
+ .map(|info| info.name.clone())
+ .unwrap_or(command.name());
+ if let Some(options) = initialization_options {
state.initialization_options = state
.initialization_options
- .combine(&json!({ name: options }));
+ .combine(&json!({ server_name: options }));
}
let capabilities: ServerCapabilities = initialize_result.capabilities.clone();