Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

Commit

Permalink
Add some logging and move document items
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdevries committed Nov 17, 2016
1 parent 8c66aa6 commit f090ac2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 33 deletions.
30 changes: 3 additions & 27 deletions autoload/langserver.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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': {
Expand All @@ -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
2 changes: 2 additions & 0 deletions autoload/langserver/callbacks.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 32 additions & 6 deletions autoload/langserver/documents.vim
Original file line number Diff line number Diff line change
@@ -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

""
Expand All @@ -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

0 comments on commit f090ac2

Please sign in to comment.