diff --git a/README.md b/README.md index 79ff9f97..27c2fabd 100644 --- a/README.md +++ b/README.md @@ -555,6 +555,10 @@ You may want to map this command to a key; try putting `nnoremap Calling this command will fill Vim's `locationlist` with errors or warnings if any were detected in your file and then open it. +The `g:ycm_open_loclist_on_ycm_diags` option can be used to prevent the location +list from opening, but still have it filled with new diagnostic data. See the +_Options_ section for details. + ### The `:YcmShowDetailedDiagnostic` command This command shows the full diagnostic text when the user's cursor is on the @@ -890,6 +894,17 @@ Default: `0` let g:ycm_always_populate_location_list = 0 +### The `g:ycm_open_loclist_on_ycm_diags` option + +When this option is set, `:YcmDiags` will automatically open the location list +after forcing a compilation and filling the list with diagnostic data. + +See `:help location-list` in Vim to learn more about the location list. + +Default: `1` + + let g:ycm_open_loclist_on_ycm_diags = 1 + ### The `g:ycm_allow_changing_updatetime` option When this option is set to `1`, YCM will change the `updatetime` Vim option to diff --git a/autoload/youcompleteme.vim b/autoload/youcompleteme.vim index 5b61a56f..3bff54c3 100644 --- a/autoload/youcompleteme.vim +++ b/autoload/youcompleteme.vim @@ -787,7 +787,10 @@ function! s:ShowDiagnostics() \ 'ycm_state.GetDiagnosticsFromStoredRequest( qflist_format = True )' ) if !empty( diags ) call setloclist( 0, diags ) - lopen + + if g:ycm_open_loclist_on_ycm_diags + lopen + endif else echom "No warnings or errors detected" endif diff --git a/plugin/youcompleteme.vim b/plugin/youcompleteme.vim index 7a6f4632..bfdad8db 100644 --- a/plugin/youcompleteme.vim +++ b/plugin/youcompleteme.vim @@ -74,6 +74,9 @@ let g:loaded_youcompleteme = 1 let g:ycm_allow_changing_updatetime = \ get( g:, 'ycm_allow_changing_updatetime', 1 ) +let g:ycm_open_loclist_on_ycm_diags = + \ get( g:, 'ycm_open_loclist_on_ycm_diags', 1 ) + let g:ycm_add_preview_to_completeopt = \ get( g:, 'ycm_add_preview_to_completeopt', 0 )