autozimu / LanguageClient-neovim

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

Add support for server specific handlers #1177

Closed martskins closed 3 years ago

martskins commented 3 years ago

This PR adds support for server specific handlers that are specified via config. Other than enabling the user to run certain handlers for a specific server. Becase of this being via config, we can register the handlers before initialization, which ensures all events of that type are handled correctly.

An example configuration to use this would look like this:

let g:LanguageClient_serverCommands = {}
let g:LanguageClient_serverCommands.go =  {
            \ 'name': 'gopls',
            \ 'command': ['gopls'],
                        \ 'handlers': {
                        \  'window/logMessage': 'LogProgress'
                        \ }
            \}

Note that this is only possible with the newly introduced way of specifying a server command.

Closes #1176

martskins commented 3 years ago

@fanzeyi if you could try this one out and see if it solves your issue it would be great. I tested it locally and it seems to work just fine, but maybe I missed something for your use-case.