diff --git a/CHANGELOG.md b/CHANGELOG.md index aa4bd313..25336eb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.2.5-dev + +- Add autocmds `LSCAutocomplete` before firing completion, and `LSCShowPreview` + after opening the preview window. + # 0.2.4 - Bug Fix: Handle completion items with empty detail. diff --git a/autoload/lsc/complete.vim b/autoload/lsc/complete.vim index 63f0b68f..f5cac8bb 100644 --- a/autoload/lsc/complete.vim +++ b/autoload/lsc/complete.vim @@ -131,6 +131,7 @@ function! s:SuggestCompletions(completion) abort endif setl completeopt-=longest setl completeopt+=menu,menuone,noinsert,noselect + if exists('#User#LSCAutocomplete') | doautocmd User LSCAutocomplete | endif call complete(start, suggestions) endfunction diff --git a/autoload/lsc/util.vim b/autoload/lsc/util.vim index 9196836f..bc8e546c 100644 --- a/autoload/lsc/util.vim +++ b/autoload/lsc/util.vim @@ -125,6 +125,7 @@ function! s:createOrJumpToPreview(line_count) abort let direction = '' endif execute direction.' '.string(want_height).'split __lsc_preview__' + if exists('#User#LSCShowPreview') | doautocmd User LSCShowPreview | endif endif set previewwindow set winfixheight diff --git a/doc/lsc.txt b/doc/lsc.txt index dd8ab12b..9beef830 100644 --- a/doc/lsc.txt +++ b/doc/lsc.txt @@ -21,15 +21,14 @@ value in this dict should be a string which corresponds to an executable in your "$PATH". If multiple filetypes are tracked by the same server they should be entered as separate keys with the same value. For example: > - let g:lsc_server_commands = { - \ 'dart': 'dart_language_server', - \ 'html': 'dart_language_server', - \} + let g:lsc_server_commands = { + \ 'dart': 'dart_language_server', + \ 'html': 'dart_language_server', + \} < lsc will communicate with each executable over stdin/stdout following the RPC protocol as specified. -> COMMANDS *lsc-commands* @@ -100,7 +99,7 @@ window to show more details for selected completion items. Close the window after completion with CTRL_W-z or disable with "set completeopt-=preview". To automatically close the preview window after completion use the following: > - autocmd CompleteDone * silent! pclose + autocmd CompleteDone * silent! pclose < *lsc-configure-hover* @@ -118,8 +117,8 @@ default "lscDiagnosticError" is linked to |hl-Error|, and the rest are linked to |hl-SpellBad|. Override this by setting or linking any of these highlight groups. For example: > - highlight lscDiagnosticError ctermbg=160 - highlight link lscDiagnosticWarning SpellCap + highlight lscDiagnosticError ctermbg=160 + highlight link lscDiagnosticWarning SpellCap < *lsc-configure-key-map* @@ -143,6 +142,27 @@ K `:LSClientShowHover` If "g:lsc_enable_autocomplete" is set to "v:false" then |completefunc| will be set to the vim-lsc completion function. +AUTOCMDS *lsc-autocmds* + + *autocmd-LSCAutocomplete* +Fires before triggering completion in auto-complete mode. Does not fire if +|g:lsc_enable_auto_complete| is false. For example, if windows normally split +above (set |nosplitbelow|) but the completion-menu preview window should split +below: +> + augroup completsplitbelow + autocmd User LSCAutocomplete setlocal splitbelow + autocmd CompleteDone * setlocal nosplitbelow + augroup END +< + *autocmd-LSCShowPreview* +Fires when LSC opens a new preview window during `:LSClientShowHover`. Does +not fire if an exist preview window was reused. For example if the hover +information should display full-height, 80 columns wide, at the left of the +screen instead of as a horizontal split: +> + autocmd User LSCShowPreview wincmd H | vertical resize 80 +< DEBUGGING TIPS *lsc-debugging* If you are having difficulty with integration with a particular language @@ -151,8 +171,8 @@ script to log stdin and stdout. For example if the server is normally started with "my_language_server", write a script like "my_languag_server_logged.sh" and point |g:lsc_server_commands| at this script. > - #!/bin/bash - tee in.log | my_language_server | tee out.log + #!/bin/bash + tee in.log | my_language_server | tee out.log < If a language server is following the protocol but does not work with vim-lsc, file an issue at https://github.com/natebosch/vim-lsc/issues