From f090ac2c7c9d4f34722b5060e1a41fa4cacb6dfe Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Thu, 17 Nov 2016 08:16:12 -0500 Subject: [PATCH] Add some logging and move document items --- autoload/langserver.vim | 30 +++--------------------- autoload/langserver/callbacks.vim | 2 ++ autoload/langserver/documents.vim | 38 ++++++++++++++++++++++++++----- 3 files changed, 37 insertions(+), 33 deletions(-) diff --git a/autoload/langserver.vim b/autoload/langserver.vim index e5921b4..ec90cc7 100644 --- a/autoload/langserver.vim +++ b/autoload/langserver.vim @@ -10,7 +10,7 @@ function! langserver#start(options) abort else let l:cmd = langserver#default#cmd() if l:cmd == [-1] - echom 'No valid langserver for ' . &filetype . '. Please modify `g:langserver_executables`' + call langserver#log#log('error', 'No valid langserver for ' . &filetype . '. Please modify `g:langserver_executables`', v:true) return endif endif @@ -30,7 +30,7 @@ function! langserver#start(options) abort endif if l:lsp_id > 0 - echom 'lsp server running' + call langserver#log#log('info', 'lsp server running') call langserver#client#send(l:lsp_id, { \ 'method': 'initialize', \ 'params': { @@ -39,34 +39,10 @@ function! langserver#start(options) abort \ }, \ }) else - echom 'failed to start lsp server' + call langserver#log#log('error', 'failed to start lsp server', v:true) endif let g:lsp_id_map[&filetype] = l:lsp_id return l:lsp_id endfunction - -"" -" Corresponds to: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didchangetextdocument-notification -function! langserver#didChangeTextDocument() abort - -endfunction - -"" -" Corresponds to: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didclosetextdocument-notification -function! langserver#didCloseTextDocument() abort - -endfunction - -"" -" Corresponds to: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didsavetextdocument-notification -function! langserver#didSaveTextDocument() abort - -endfunction - -"" -" Corresponds to: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didchangewatchedfiles-notification -function! langserver#didChangeWatchedFiles() abort - -endfunction diff --git a/autoload/langserver/callbacks.vim b/autoload/langserver/callbacks.vim index 7d4b7fd..0837296 100644 --- a/autoload/langserver/callbacks.vim +++ b/autoload/langserver/callbacks.vim @@ -38,6 +38,8 @@ function! langserver#callbacks#on_notification(id, data, event) abort call langserver#goto#callback(a:id, a:data, a:event) elseif l:last_topic ==? 'textDocument/hover' call langserver#hover#callback(a:id, a:data, a:event) + elseif l:last_topic ==? 'textDocument/didOpen' + call langserver#documents#callback_did_open(a:id, a:data, a:event) else call langserver#log#log('warning', 'LAST REQUEST: ' . l:last_topic, v:true) endif diff --git a/autoload/langserver/documents.vim b/autoload/langserver/documents.vim index d1ef90b..1c674d5 100644 --- a/autoload/langserver/documents.vim +++ b/autoload/langserver/documents.vim @@ -1,8 +1,12 @@ -function! s:on_did_open_request(id, data, event) abort - let l:parsed = langserver#util#parse_message(a:data) - let g:last_response = l:parsed +function! langserver#documents#callback_did_open(id, data, event) abort + call langserver#log#callback(a:id, a:data, a:event) - echom string(l:parsed) + if type(a:data) != type({}) + return + endif + + let g:last_response = a:data + call langserver#log#log('info', string(a:data)) endfunction "" @@ -18,8 +22,30 @@ function! langserver#documents#did_open() abort return langserver#client#send(langserver#util#get_lsp_id(), { \ 'method': 'textDocument/didOpen', \ 'params': langserver#util#get_text_document_identifier(l:server_name), - \ 'on_notification': function('s:on_did_open_request'), - \ 'on_stderr': function('s:on_did_open_request'), \ }) endfunction + +"" +" Corresponds to: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didchangetextdocument-notification +function! langserver#documents#did_change() abort + +endfunction + +"" +" Corresponds to: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didclosetextdocument-notification +function! langserver#documents#did_close() abort + +endfunction + +"" +" Corresponds to: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didsavetextdocument-notification +function! langserver#documents#did_save() abort + +endfunction + +"" +" Corresponds to: https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#didchangewatchedfiles-notification +function! langserver#documents#did_change_watched_files() abort + +endfunction