Updated plugins
This commit is contained in:
1 parent
6711ae6453
commit
3aefdbd21a
244 files changed
+9486
-3395
No files matched your search
@@ -52,6 +52,7 @@ let s:should_complete_map = {
|
||||
\ 'lisp': s:lisp_regex,
|
||||
\ 'typescript': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|''$|"$',
|
||||
\ 'rust': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$',
|
||||
\ 'cpp': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$|\.$|::$|-\>$',
|
||||
\}
|
||||
|
||||
" Regular expressions for finding the start column to replace with completion.
|
||||
@@ -59,11 +60,13 @@ let s:omni_start_map = {
|
||||
\ '<default>': '\v[a-zA-Z$_][a-zA-Z$_0-9]*$',
|
||||
\}
|
||||
|
||||
" A map of exact characters for triggering LSP completions.
|
||||
" A map of exact characters for triggering LSP completions. Do not forget to
|
||||
" update self.input_patterns in ale.py in updating entries in this map.
|
||||
let s:trigger_character_map = {
|
||||
\ '<default>': ['.'],
|
||||
\ 'typescript': ['.', '''', '"'],
|
||||
\ 'rust': ['.', '::'],
|
||||
\ 'cpp': ['.', '::', '->'],
|
||||
\}
|
||||
|
||||
function! s:GetFiletypeValue(map, filetype) abort
|
||||
@@ -169,7 +172,7 @@ function! s:ReplaceCompletionOptions() abort
|
||||
let b:ale_old_omnifunc = &l:omnifunc
|
||||
endif
|
||||
|
||||
let &l:omnifunc = 'ale#completion#OmniFunc'
|
||||
let &l:omnifunc = 'ale#completion#AutomaticOmniFunc'
|
||||
endif
|
||||
|
||||
if l:source is# 'ale-automatic'
|
||||
@@ -215,19 +218,11 @@ function! ale#completion#GetCompletionPosition() abort
|
||||
return l:column - len(l:match) - 1
|
||||
endfunction
|
||||
|
||||
function! ale#completion#GetCompletionPositionForDeoplete(input) abort
|
||||
return match(a:input, '\k*$')
|
||||
endfunction
|
||||
|
||||
function! ale#completion#GetCompletionResult() abort
|
||||
" Parse a new response if there is one.
|
||||
if exists('b:ale_completion_response')
|
||||
\&& exists('b:ale_completion_parser')
|
||||
let l:response = b:ale_completion_response
|
||||
let l:parser = b:ale_completion_parser
|
||||
|
||||
unlet b:ale_completion_response
|
||||
unlet b:ale_completion_parser
|
||||
|
||||
let b:ale_completion_result = function(l:parser)(l:response)
|
||||
endif
|
||||
|
||||
if exists('b:ale_completion_result')
|
||||
return b:ale_completion_result
|
||||
endif
|
||||
@@ -235,7 +230,7 @@ function! ale#completion#GetCompletionResult() abort
|
||||
return v:null
|
||||
endfunction
|
||||
|
||||
function! ale#completion#OmniFunc(findstart, base) abort
|
||||
function! ale#completion#AutomaticOmniFunc(findstart, base) abort
|
||||
if a:findstart
|
||||
return ale#completion#GetCompletionPosition()
|
||||
else
|
||||
@@ -247,15 +242,20 @@ function! ale#completion#OmniFunc(findstart, base) abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#completion#Show(response, completion_parser) abort
|
||||
function! ale#completion#Show(result) abort
|
||||
if ale#util#Mode() isnot# 'i'
|
||||
return
|
||||
endif
|
||||
|
||||
" Set the list in the buffer, temporarily replace omnifunc with our
|
||||
" function, and then start omni-completion.
|
||||
let b:ale_completion_response = a:response
|
||||
let b:ale_completion_parser = a:completion_parser
|
||||
let b:ale_completion_result = a:result
|
||||
|
||||
" Don't try to open the completion menu if there's nothing to show.
|
||||
if empty(b:ale_completion_result)
|
||||
return
|
||||
endif
|
||||
|
||||
" Replace completion options shortly before opening the menu.
|
||||
call s:ReplaceCompletionOptions()
|
||||
|
||||
@@ -267,6 +267,14 @@ function! ale#completion#Show(response, completion_parser) abort
|
||||
\ {-> ale#util#FeedKeys("\<Plug>(ale_show_completion_menu)")}
|
||||
\)
|
||||
endif
|
||||
|
||||
if l:source is# 'ale-callback'
|
||||
call b:CompleteCallback(b:ale_completion_result)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! ale#completion#GetAllTriggers() abort
|
||||
return deepcopy(s:trigger_character_map)
|
||||
endfunction
|
||||
|
||||
function! s:CompletionStillValid(request_id) abort
|
||||
@@ -279,6 +287,8 @@ function! s:CompletionStillValid(request_id) abort
|
||||
\&& (
|
||||
\ b:ale_completion_info.column == l:column
|
||||
\ || b:ale_completion_info.source is# 'deoplete'
|
||||
\ || b:ale_completion_info.source is# 'ale-omnifunc'
|
||||
\ || b:ale_completion_info.source is# 'ale-callback'
|
||||
\)
|
||||
endfunction
|
||||
|
||||
@@ -474,8 +484,7 @@ function! ale#completion#HandleTSServerResponse(conn_id, response) abort
|
||||
endif
|
||||
elseif l:command is# 'completionEntryDetails'
|
||||
call ale#completion#Show(
|
||||
\ a:response,
|
||||
\ 'ale#completion#ParseTSServerCompletionEntryDetails',
|
||||
\ ale#completion#ParseTSServerCompletionEntryDetails(a:response),
|
||||
\)
|
||||
endif
|
||||
endfunction
|
||||
@@ -487,8 +496,7 @@ function! ale#completion#HandleLSPResponse(conn_id, response) abort
|
||||
endif
|
||||
|
||||
call ale#completion#Show(
|
||||
\ a:response,
|
||||
\ 'ale#completion#ParseLSPCompletions',
|
||||
\ ale#completion#ParseLSPCompletions(a:response),
|
||||
\)
|
||||
endfunction
|
||||
|
||||
@@ -529,10 +537,7 @@ function! s:OnReady(linter, lsp_details) abort
|
||||
let l:message = ale#lsp#message#Completion(
|
||||
\ l:buffer,
|
||||
\ b:ale_completion_info.line,
|
||||
\ min([
|
||||
\ b:ale_completion_info.line_length,
|
||||
\ b:ale_completion_info.column,
|
||||
\ ]) + 1,
|
||||
\ b:ale_completion_info.column,
|
||||
\ ale#completion#GetTriggerCharacter(&filetype, b:ale_completion_info.prefix),
|
||||
\)
|
||||
endif
|
||||
@@ -564,13 +569,26 @@ endfunction
|
||||
|
||||
" This function can be used to manually trigger autocomplete, even when
|
||||
" g:ale_completion_enabled is set to false
|
||||
function! ale#completion#GetCompletions(source) abort
|
||||
function! ale#completion#GetCompletions(...) abort
|
||||
let l:source = get(a:000, 0, '')
|
||||
let l:options = get(a:000, 1, {})
|
||||
|
||||
if len(a:000) > 2
|
||||
throw 'Too many arguments!'
|
||||
endif
|
||||
|
||||
let l:CompleteCallback = get(l:options, 'callback', v:null)
|
||||
|
||||
if l:CompleteCallback isnot v:null
|
||||
let b:CompleteCallback = l:CompleteCallback
|
||||
endif
|
||||
|
||||
let [l:line, l:column] = getpos('.')[1:2]
|
||||
|
||||
let l:prefix = ale#completion#GetPrefix(&filetype, l:line, l:column)
|
||||
|
||||
if a:source is# 'ale-automatic' && empty(l:prefix)
|
||||
return
|
||||
if l:source is# 'ale-automatic' && empty(l:prefix)
|
||||
return 0
|
||||
endif
|
||||
|
||||
let l:line_length = len(getline('.'))
|
||||
@@ -582,18 +600,47 @@ function! ale#completion#GetCompletions(source) abort
|
||||
\ 'prefix': l:prefix,
|
||||
\ 'conn_id': 0,
|
||||
\ 'request_id': 0,
|
||||
\ 'source': a:source,
|
||||
\ 'source': l:source,
|
||||
\}
|
||||
unlet! b:ale_completion_result
|
||||
|
||||
let l:buffer = bufnr('')
|
||||
let l:Callback = function('s:OnReady')
|
||||
|
||||
let l:started = 0
|
||||
|
||||
for l:linter in ale#linter#Get(&filetype)
|
||||
if !empty(l:linter.lsp)
|
||||
call ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback)
|
||||
if ale#lsp_linter#StartLSP(l:buffer, l:linter, l:Callback)
|
||||
let l:started = 1
|
||||
endif
|
||||
endif
|
||||
endfor
|
||||
|
||||
return l:started
|
||||
endfunction
|
||||
|
||||
function! ale#completion#OmniFunc(findstart, base) abort
|
||||
if a:findstart
|
||||
let l:started = ale#completion#GetCompletions('ale-omnifunc')
|
||||
|
||||
if !l:started
|
||||
" This is the special value for cancelling completions silently.
|
||||
" See :help complete-functions
|
||||
return -3
|
||||
endif
|
||||
|
||||
return ale#completion#GetCompletionPosition()
|
||||
else
|
||||
let l:result = ale#completion#GetCompletionResult()
|
||||
|
||||
while l:result is v:null && !complete_check()
|
||||
sleep 2ms
|
||||
let l:result = ale#completion#GetCompletionResult()
|
||||
endwhile
|
||||
|
||||
return l:result isnot v:null ? l:result : []
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:TimerHandler(...) abort
|
||||
|
||||
Reference in new issue
Block a user