This repository has been archived by the owner on Mar 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/tjdevries/nvim-langserver…
- Loading branch information
Showing
8 changed files
with
159 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
function! langserver#completion#callback(id, data, event) abort | ||
let l:parsed_data = langserver#callbacks#data(a:id, a:data, a:event) | ||
if l:parsed_data == {} | ||
return | ||
endif | ||
|
||
" {'isIncomplete': bool, 'items': [CompletionItems]} | ||
let l:completion_items = l:parsed_data['items'] | ||
|
||
endfunction | ||
|
||
function! langserver#completion#request(...) abort | ||
return langserver#client#send(langserver#util#get_lsp_id(), { | ||
\ 'method': 'textDocument/completion', | ||
\ 'params': langserver#util#get_text_document_position_params(), | ||
\ }) | ||
endfunction | ||
|
||
let s:CompletionItemKind = { | ||
\ 'Text': 1, | ||
\ 'Method': 2, | ||
\ 'Function': 3, | ||
\ 'Constructor': 4, | ||
\ 'Field': 5, | ||
\ 'Variable': 6, | ||
\ 'Class': 7, | ||
\ 'Interface': 8, | ||
\ 'Module': 9, | ||
\ 'Property': 10, | ||
\ 'Unit': 11, | ||
\ 'Value': 12, | ||
\ 'Enum': 13, | ||
\ 'Keyword': 14, | ||
\ 'Snippet': 15, | ||
\ 'Color': 16, | ||
\ 'File': 17, | ||
\ 'Reference': 18 | ||
\ } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
let s:unlocked_id = -1 | ||
|
||
function! s:dict_lock(job_id) dict | ||
if self.locked == v:false | ||
let self.locked = v:true | ||
let self.id = a:job_id | ||
return v:true | ||
else | ||
return v:false | ||
endif | ||
endfunction | ||
|
||
function! s:dict_unlock() dict | ||
let self.id = s:unlocked_id | ||
let self.locked = v:false | ||
endfunction | ||
|
||
function! s:get_id() dict | ||
return self.id | ||
endfunction | ||
|
||
function! s:take_lock(job_id) dict | ||
" If we're locked, kill the other job | ||
" And set ourselves to be the current job. | ||
if self.locked | ||
" TODO: Don't actually want to stop the whole server... | ||
" I just want to stop the current request. Maybe a send cancel request | ||
" would be good enough. We will see. | ||
" call langserver#job#stop(self.id) | ||
call self.unlock() | ||
endif | ||
|
||
call self.lock(a:job_id) | ||
endfunction | ||
|
||
function! langserver#lock#semaphore() abort | ||
let l:ret = { | ||
\ 'id': s:unlocked_id, | ||
\ 'locked': v:false, | ||
\ } | ||
let l:ret.lock = function('s:dict_lock') | ||
let l:ret.unlock = function('s:dict_unlock') | ||
let l:ret.get_id = function('s:get_id') | ||
let l:ret.take_lock = function('s:take_lock') | ||
return l:ret | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from .base import Base | ||
|
||
|
||
class Source(Base): | ||
def __init__(self, nvim): | ||
super(Source, self).__init__(nvim) | ||
|
||
self.nvim = nvim | ||
self.name = 'langserver' | ||
self.mark = '[LSP]' | ||
|
||
def on_event(self, context, filename=''): | ||
pass | ||
|
||
def gather_candidates(self, context): | ||
user_input = context['input'] | ||
filetype = context.get('filetype', '') | ||
complete_str = context['complete_str'] | ||
|
||
return [ | ||
{ | ||
'word': user_input + '_hello', | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Execute (Test Lock): | ||
let my_lock = langserver#lock#semaphore() | ||
|
||
AssertEqual v:false, my_lock.locked | ||
|
||
call my_lock.lock(1) | ||
AssertEqual v:true, my_lock.locked | ||
|
||
call my_lock.unlock() | ||
AssertEqual v:false, my_lock.locked | ||
|
||
AssertEqual -1, my_lock.get_id() | ||
|
||
call my_lock.lock(1) | ||
AssertEqual 1, my_lock.get_id() | ||
|
||
let set_result = my_lock.lock(2) | ||
AssertEqual v:false, set_result | ||
AssertEqual 1, my_lock.get_id() | ||
|
||
call my_lock.take_lock(2) | ||
AssertEqual 2, my_lock.get_id() |