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

Commit

Permalink
Add initial API
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdevries committed Nov 22, 2016
1 parent 443ba4f commit afacd8d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
9 changes: 9 additions & 0 deletions autoload/langserver/api/textDocument.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
""
function! langserver#api#textDocument#definition(request) abort
return langserver#goto#goto_defintion(
\ langserver#util#get_lsp_id(),
\ a:request.result.uri,
\ a:request.result.range,
\ {},
\ )
endfunction
11 changes: 11 additions & 0 deletions autoload/langserver/client.vim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ let s:lsp_text_document_sync_kind_incremental = 2

function! s:_on_lsp_stdout(id, data, event) abort
if has_key(s:lsp_clients, a:id)
" let s:lsp_clients[l:lsp_client_id] = {
" \ 'id': l:lsp_client_id,
" \ 'opts': a:opts,
" \ 'req_seq': 0,
" \ 'on_notifications': {},
" \ 'stdout': {
" \ 'max_buffer_size': l:max_buffer_size,
" \ 'buffer': '',
" \ 'next_token': s:lsp_token_type_contentlength,
" \ },
" \ }
let l:client = s:lsp_clients[a:id]

let l:client.stdout.buffer .= join(a:data, "\n")
Expand Down
7 changes: 5 additions & 2 deletions autoload/langserver/goto.vim
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ function! langserver#goto#goto_defintion(name, uri, range_dict, options) abort
" \ a:range_dict['start']['line'] + 1,
" \ a:range_dict['start']['character'] + 1,
" \ )
execute(printf('norm! %sG%s|',
let l:action = printf('norm! %sG%s|',
\ a:range_dict['start']['line'] + 1,
\ a:range_dict['start']['character'] + 1,
\ ))
\ )
execute(l:action)

return l:action
endfunction
42 changes: 42 additions & 0 deletions tests/test_goto.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

Given vim (Goto position):
let this = 'that'

" A comment here
" A comment there
" Here a comment, there a comment

" Everywhere a comment

Do (Move):
2j

Execute (Call goto):
let g:test_request = {
\ 'result': {
\ 'uri': 'file://' . expand('%'),
\ 'range': {
\ 'start': {'line': 0, 'character': 4},
\ 'end': {'line': 0, 'character': 8},
\ },
\ }}

Log g:test_request.result.uri

let cmd = langserver#api#textDocument#definition(g:test_request)
AssertEqual cmd, 'norm! 1G5|'

" I Would like to use these but it doesn't seem to work.
" Then (delete character):
" x

" Expect (Line to be deleted):
" let his = 'that'

" " A comment here
" " A comment there
" " Here a comment, there a comment

" " Everywhere a comment


0 comments on commit afacd8d

Please sign in to comment.