#1162 Get LSP completions working reasonably well

This commit is contained in:
w0rp
2017-11-26 13:01:01 +00:00
parent b1a6abdda6
commit 8254e507d6
4 changed files with 36 additions and 17 deletions

View File

@@ -326,6 +326,14 @@ function! s:GetLSPCompletions(linter) abort
\ b:ale_completion_info.prefix,
\)
else
" Send a message saying the buffer has changed first, otherwise
" completions won't know what text is nearby.
call ale#lsp#Send(
\ l:id,
\ ale#lsp#message#DidChange(l:buffer),
\ l:root
\)
" For LSP completions, we need to clamp the column to the length of
" the line. python-language-server and perhaps others do not implement
" this correctly.
@@ -334,9 +342,9 @@ function! s:GetLSPCompletions(linter) abort
\ b:ale_completion_info.line,
\ min([
\ b:ale_completion_info.line_length,
\ b:ale_completion_info.column
\ b:ale_completion_info.column,
\ ]),
\ '',
\ ale#completion#GetTriggerCharacter(&filetype, b:ale_completion_info.prefix),
\)
endif

View File

@@ -95,7 +95,7 @@ function! ale#lsp#message#Completion(buffer, line, column, trigger_character) ab
\ 'textDocument': {
\ 'uri': ale#path#ToURI(expand('#' . a:buffer . ':p')),
\ },
\ 'position': {'line': a:line - 1, 'character': a:column - 1},
\ 'position': {'line': a:line - 1, 'character': a:column},
\}]
if !empty(a:trigger_character)