Skip to content

Commit

Permalink
Add user autocmds for ShowPreview and Autocomplete
Browse files Browse the repository at this point in the history
Also shift code blocks left
  • Loading branch information
natebosch committed Aug 5, 2017
1 parent ee7620f commit 92287c1
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
1 change: 1 addition & 0 deletions autoload/lsc/complete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions autoload/lsc/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 30 additions & 10 deletions doc/lsc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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*

Expand Down Expand Up @@ -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*
Expand All @@ -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*
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 92287c1

Please sign in to comment.