@@ -75,25 +75,64 @@ To use the language server with Vim's formatting operator |gq|, set 'formatexpr'
7575
76762.1 g:LanguageClient_serverCommands *g:LanguageClient_serverCommands*
7777
78- String to list map. Defines commands to start language server for specific
79- filetype. For example: >
78+ Dictionary to specify the servers to be used for each filetype. The keys are
79+ strings representing the filetypes and the values are either
80+ 1 - a list of strings that form a command
81+ 2 - a dictionary with keys name, command and initializationOptions, where:
82+ - name: is the name of the server, which should match the root node of the
83+ configuration options specified in the settings.json file for this server
84+ - command: is the same list of strings in option 1
85+ - initializationOptions: is an optional dictionary with options to be passed
86+ to the server. The values to be set here are highly dependent on each
87+ server so you should see the documentation for each server to find out
88+ what to configure in here (if anything). The options set in
89+ initializationOptions are merged with the default settings for each
90+ language server and with the workspace settings defined by the user in
91+ the files specified in the variable `LanguageClient_settingsPath'. The
92+ order in which these settings are merged is first the defualt settings,
93+ then the server settings configured in this section and lastly the
94+ contents of the files in the `LanguageClient_settingsPath` variable in
95+ the order in which they were listed.
96+
97+ For example: >
8098
8199 let g:LanguageClient_serverCommands = {
82100 \ 'rust': ['rustup', 'run', 'stable', 'rls'],
83- \ }
84-
85- In the example above, 'run' , 'stable' , and 'rls' are arguments to the
86- 'rustup' command line tool.
87-
88- Or tcp connection string to the server, >
101+ \ 'go': {
102+ \ 'name': 'gopls',
103+ \ 'command': ['gopls'],
104+ \ 'initializationOptions': {
105+ \ 'usePlaceholders': v:true,
106+ \ 'codelens': {
107+ \ 'generate': v:true,
108+ \ 'test': v:true,
109+ \ },
110+ \ },
111+ \ },
112+ \}
113+
114+ In the configuration for the rust filetype above, 'run' , 'stable' , and 'rls'
115+ are arguments to the 'rustup' command line tool. And in the configuration for
116+ the go filetype the server is configured to run the command `gopls` with no
117+ additional arguments, and with the initialization options set in the
118+ `initializationOptions` key.
119+
120+ You can also use a tcp connection to the server, for example: >
89121 let g:LanguageClient_serverCommands = {
90122 \ 'javascript': ['tcp://127.0.0.1:2089'],
91123 \ }
92124
93125 Note: environmental variables are not supported except home directory alias `~` .
94126
95127Default: {}
96- Valid Option: Map<String, List<String> | String>
128+
129+
130+
131+ Valid Option: Map<String, List<String> | {
132+ name: String
133+ command: List<String>
134+ initializationOptions?: Map<String, Any>
135+ }>
97136
981372.2 g:LanguageClient_diagnosticsDisplay *g:LanguageClient_diagnosticsDisplay*
99138
@@ -231,9 +270,34 @@ path this is relative to the workspace directory. If several paths are
231270provided, then the corresponding settings are merged with precedence going to
232271the last file.
233272
273+ The initialization options found in the files in this config are combined with
274+ the initialization options specified in the server command, if any. The former
275+ taking precedence over the latter.
276+
277+ Note that the key under which the initialization options for each server lives
278+ matches the key under which the server expects it's configuration. This is
279+ important for servers that can request configuration via a
280+ `workspace/configuration` request.
281+
282+ Previously, the initialization options lived under a `initializationOptions`
283+ key, which worked, but made answering that `workspace/configuration` request
284+ hard, since we couldn't really get the correct path to the setting the server
285+ requested. Since version 0.1.161 of this plugin, that key has been deprecated
286+ and you'll see a message saying that you should move off of it if your settings
287+ file includes an `initializationOptions` key.
288+
234289Example settings file content: >
235290 {
236- "rust.clippy_preference": "on"
291+ "gopls": {
292+ "usePlaceholders": true,
293+ "local": "github.com/my/pkg",
294+ },
295+ "rust-analyzer": {
296+ "inlayHints": {
297+ "enable": true,
298+ "chainingHints": true
299+ },
300+ },
237301 }
238302
239303 Default: ".vim/settings.json"
0 commit comments