From 4ee28d312976e463a3373f6170cd5a0cdd1bcf3c Mon Sep 17 00:00:00 2001 From: w0rp Date: Mon, 20 May 2019 09:40:06 +0100 Subject: [PATCH] Fix #2515 - Send client capabilities to LSP servers --- autoload/ale/lsp.vim | 64 ++++++++++++++++++++++++- autoload/ale/lsp/message.vim | 7 ++- test/lsp/test_lsp_client_messages.vader | 2 +- test/lsp/test_lsp_startup.vader | 60 ++++++++++++++++++++++- 4 files changed, 126 insertions(+), 7 deletions(-) diff --git a/autoload/ale/lsp.vim b/autoload/ale/lsp.vim index 986e4c1b..017096cd 100644 --- a/autoload/ale/lsp.vim +++ b/autoload/ale/lsp.vim @@ -321,7 +321,69 @@ endfunction function! s:SendInitMessage(conn) abort let [l:init_id, l:init_data] = ale#lsp#CreateMessageData( - \ ale#lsp#message#Initialize(a:conn.root, a:conn.init_options), + \ ale#lsp#message#Initialize( + \ a:conn.root, + \ a:conn.init_options, + \ { + \ 'workspace': { + \ 'applyEdit': v:false, + \ 'didChangeConfiguration': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'symbol': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'workspaceFolders': v:false, + \ 'configuration': v:false, + \ }, + \ 'textDocument': { + \ 'synchronization': { + \ 'dynamicRegistration': v:false, + \ 'willSave': v:false, + \ 'willSaveWaitUntil': v:false, + \ 'didSave': v:true, + \ }, + \ 'completion': { + \ 'dynamicRegistration': v:false, + \ 'completionItem': { + \ 'snippetSupport': v:false, + \ 'commitCharactersSupport': v:false, + \ 'documentationFormat': ['plaintext'], + \ 'deprecatedSupport': v:false, + \ 'preselectSupport': v:false, + \ }, + \ 'contextSupport': v:false, + \ }, + \ 'hover': { + \ 'dynamicRegistration': v:false, + \ 'contentFormat': ['plaintext'], + \ }, + \ 'references': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'documentSymbol': { + \ 'dynamicRegistration': v:false, + \ 'hierarchicalDocumentSymbolSupport': v:false, + \ }, + \ 'definition': { + \ 'dynamicRegistration': v:false, + \ 'linkSupport': v:false, + \ }, + \ 'typeDefinition': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'publishDiagnostics': { + \ 'relatedInformation': v:true, + \ }, + \ 'codeAction': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'rename': { + \ 'dynamicRegistration': v:false, + \ }, + \ }, + \ }, + \ ), \) let a:conn.init_request_id = l:init_id call s:SendMessageData(a:conn, l:init_data) diff --git a/autoload/ale/lsp/message.vim b/autoload/ale/lsp/message.vim index 4ad94c4b..b6b14a22 100644 --- a/autoload/ale/lsp/message.vim +++ b/autoload/ale/lsp/message.vim @@ -28,14 +28,13 @@ function! ale#lsp#message#GetNextVersionID() abort return l:id endfunction -function! ale#lsp#message#Initialize(root_path, initialization_options) abort - " TODO: Define needed capabilities. +function! ale#lsp#message#Initialize(root_path, options, capabilities) abort " NOTE: rootPath is deprecated in favour of rootUri return [0, 'initialize', { \ 'processId': getpid(), \ 'rootPath': a:root_path, - \ 'capabilities': {}, - \ 'initializationOptions': a:initialization_options, + \ 'capabilities': a:capabilities, + \ 'initializationOptions': a:options, \ 'rootUri': ale#path#ToURI(a:root_path), \}] endfunction diff --git a/test/lsp/test_lsp_client_messages.vader b/test/lsp/test_lsp_client_messages.vader index 2abdf6ca..90a20832 100644 --- a/test/lsp/test_lsp_client_messages.vader +++ b/test/lsp/test_lsp_client_messages.vader @@ -20,7 +20,7 @@ Execute(ale#lsp#message#Initialize() should return correct messages): \ 'rootUri': 'file:///foo/bar', \ } \ ], - \ ale#lsp#message#Initialize('/foo/bar', {'foo': 'bar'}) + \ ale#lsp#message#Initialize('/foo/bar', {'foo': 'bar'}, {}) Execute(ale#lsp#message#Initialized() should return correct messages): AssertEqual [1, 'initialized', {}], ale#lsp#message#Initialized() diff --git a/test/lsp/test_lsp_startup.vader b/test/lsp/test_lsp_startup.vader index 028ec9b1..c29690bf 100644 --- a/test/lsp/test_lsp_startup.vader +++ b/test/lsp/test_lsp_startup.vader @@ -138,9 +138,67 @@ Before: \ 'params': { \ 'initializationOptions': {}, \ 'rootUri': ale#path#ToURI(a:root), - \ 'capabilities': {}, \ 'rootPath': a:root, \ 'processId': getpid(), + \ 'capabilities': { + \ 'workspace': { + \ 'applyEdit': v:false, + \ 'didChangeConfiguration': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'symbol': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'workspaceFolders': v:false, + \ 'configuration': v:false, + \ }, + \ 'textDocument': { + \ 'synchronization': { + \ 'dynamicRegistration': v:false, + \ 'willSave': v:false, + \ 'willSaveWaitUntil': v:false, + \ 'didSave': v:true, + \ }, + \ 'completion': { + \ 'dynamicRegistration': v:false, + \ 'completionItem': { + \ 'snippetSupport': v:false, + \ 'commitCharactersSupport': v:false, + \ 'documentationFormat': ['plaintext'], + \ 'deprecatedSupport': v:false, + \ 'preselectSupport': v:false, + \ }, + \ 'contextSupport': v:false, + \ }, + \ 'hover': { + \ 'dynamicRegistration': v:false, + \ 'contentFormat': ['plaintext'], + \ }, + \ 'references': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'documentSymbol': { + \ 'dynamicRegistration': v:false, + \ 'hierarchicalDocumentSymbolSupport': v:false, + \ }, + \ 'definition': { + \ 'dynamicRegistration': v:false, + \ 'linkSupport': v:false, + \ }, + \ 'typeDefinition': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'publishDiagnostics': { + \ 'relatedInformation': v:true, + \ }, + \ 'codeAction': { + \ 'dynamicRegistration': v:false, + \ }, + \ 'rename': { + \ 'dynamicRegistration': v:false, + \ }, + \ }, + \ }, \ }, \ }, \ ],