Option to close preview after leaving insert mode
Added the `g:ycm_autoclose_preview_window_after_insertion` option (similar to `g:ycm_autoclose_preview_window_after_completion`). If set, the preview window is automatically closed when the user leaves insert mode.
This commit is contained in:
parent
6d6f53fdfe
commit
a2595d6f7e
15
README.md
15
README.md
@ -617,6 +617,18 @@ Default: `0`
|
||||
|
||||
let g:ycm_autoclose_preview_window_after_completion = 0
|
||||
|
||||
### The `g:ycm_autoclose_preview_window_after_insertion` option
|
||||
|
||||
When this option is set to `1`, YCM will auto-close the `preview` window after
|
||||
the user leaves insert mode. This option is irrelevant if
|
||||
`g:ycm_autoclose_preview_window_after_completion` is set or if no `preview`
|
||||
window is triggered. See the `g:ycm_add_preview_to_completeopt` option for more
|
||||
details.
|
||||
|
||||
Default: `0`
|
||||
|
||||
let g:ycm_autoclose_preview_window_after_insertion = 0
|
||||
|
||||
### The `g:ycm_max_diagnostics_to_display` option
|
||||
|
||||
This option controls the maximum number of diagnostics shown to the user when
|
||||
@ -787,7 +799,8 @@ types to write the function call.
|
||||
|
||||
If you would like this window to auto-close after you select a completion
|
||||
string, set the `g:ycm_autoclose_preview_window_after_completion` option to `1`
|
||||
in your `vimrc` file.
|
||||
in your `vimrc` file. Similarly, the `g:ycm_autoclose_preview_window_after_insertion`
|
||||
option can be set to close the `preview` window after leaving insert mode.
|
||||
|
||||
If you don't want this window to ever show up, add `set completeopt-=preview` to
|
||||
your `vimrc`. Also make sure that the `g:ycm_add_preview_to_completeopt` option
|
||||
|
@ -238,7 +238,9 @@ function! s:OnCursorMovedInsertMode()
|
||||
endif
|
||||
|
||||
call s:IdentifierFinishedOperations()
|
||||
if g:ycm_autoclose_preview_window_after_completion
|
||||
call s:ClosePreviewWindowIfNeeded()
|
||||
endif
|
||||
call s:InvokeCompletion()
|
||||
endfunction
|
||||
|
||||
@ -260,7 +262,10 @@ function! s:OnInsertLeave()
|
||||
let s:omnifunc_mode = 0
|
||||
call s:UpdateDiagnosticNotifications()
|
||||
py ycm_state.OnInsertLeave()
|
||||
if g:ycm_autoclose_preview_window_after_completion ||
|
||||
\ g:ycm_autoclose_preview_window_after_insertion
|
||||
call s:ClosePreviewWindowIfNeeded()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
@ -306,10 +311,6 @@ endfunction
|
||||
|
||||
|
||||
function! s:ClosePreviewWindowIfNeeded()
|
||||
if !g:ycm_autoclose_preview_window_after_completion
|
||||
return
|
||||
endif
|
||||
|
||||
if s:searched_and_results_found
|
||||
" This command does the actual closing of the preview window. If no preview
|
||||
" window is shown, nothing happens.
|
||||
|
@ -91,6 +91,9 @@ let g:ycm_collect_identifiers_from_comments_and_strings =
|
||||
let g:ycm_autoclose_preview_window_after_completion =
|
||||
\ get( g:, 'ycm_autoclose_preview_window_after_completion', 0 )
|
||||
|
||||
let g:ycm_autoclose_preview_window_after_insertion =
|
||||
\ get( g:, 'ycm_autoclose_preview_window_after_insertion', 0 )
|
||||
|
||||
let g:ycm_max_diagnostics_to_display =
|
||||
\ get( g:, 'ycm_max_diagnostics_to_display', 30 )
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user