@@ -78,11 +78,11 @@ To use the language server with Vim's formatting operator |gq|, set 'formatexpr'
7878Dictionary to specify the servers to be used for each filetype. The keys are
7979strings representing the filetypes and the values are either
8080 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
81+ 2 - a dictionary with the following keys :
82+ - name: the name of the server, which should match the root node of the
8383 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
84+ - command: the same list of strings in option 1
85+ - initializationOptions: an optional dictionary with options to be passed
8686 to the server. The values to be set here are highly dependent on each
8787 server so you should see the documentation for each server to find out
8888 what to configure in here (if anything). The options set in
@@ -93,6 +93,13 @@ strings representing the filetypes and the values are either
9393 then the server settings configured in this section and lastly the
9494 contents of the files in the `LanguageClient_settingsPath` variable in
9595 the order in which they were listed.
96+ - handlers: an optional dictionary of custom handlers to register for this
97+ server. The keys for this dictionary should be (LSP) method names, and
98+ the values should be vim functions to be executed upon receiving an event
99+ with that method. The function will be called with a single param which
100+ is the JSON-RPC message itself. Note that any events will only be handled
101+ once, so if you register a handler for an event, the function you specify
102+ will dictate all that happens with that event.
96103
97104For example: >
98105
@@ -108,14 +115,21 @@ For example: >
108115 \ 'test': v:true,
109116 \ },
110117 \ },
118+ \ 'handlers': {
119+ \ 'window/logMessage': 'LogMessage'
120+ \ }
111121 \ },
112122 \}
113123
114124 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.
125+ are arguments to the 'rustup' command line tool.
126+
127+ In the configuration for the go filetype the server is configured to run the
128+ command `gopls` with no additional arguments, and with the initialization
129+ options set in the `initializationOptions` key. Also, the go server is
130+ configured to run the vim function LogMessage upon receiving an event with
131+ method `window /logMessage` . Remember that both initializationOptions and
132+ handlers are optional, so you can omit specifying those if you wish.
119133
120134You can also use a tcp connection to the server, for example: >
121135 let g:LanguageClient_serverCommands = {
0 commit comments