Youcompleteme: Have an option not to autoclose the quickfix window for GoTo* commands

Created on 15 Dec 2018  路  5Comments  路  Source: ycm-core/YouCompleteMe

Please consider having an option not to close the quickfix window for GoTo*commands that return lists. Especially for GoToReferences.

GoToReferences usually produces more than one result and as a user I would like to quickly browse through all of them. As far as I can tell, as soon I leave the resulting quickFix window, it gets closed. That makes jumping to the next found reference mode difficult.
As as workaround I use :copen to reopen the window. I would be interested if there are better workarounds too.

I think the responsible line for this autoclose is always true for handling GoTo* responses.

Most helpful comment

The above autocmd suggestion was an excellent idea. I had to make a tweak to get it to work for me though (not sure why, maybe a YCM update or Neovim difference or something).

autocmd User YcmQuickFixOpened autocmd! ycmquickfix WinLeave

All 5 comments

There are also :cnext, :cprevious, :cfirst and :clast that you can bind. For example, Tim Pope's unimpaired plugin has the following mappings:

nnoremap ]q     :cnext<CR>
nnoremap [q     :cprevious<CR>
nnoremap ]Q     :clast<CR>
nnoremap [Q     :cfirst<CR>

With those four, in the occasion I really need to see the actual list, I don't see it as a problem to type :cw<CR>.

It's possible to keep the window open by removing the WinLeave autocmd that automatically closes the window on the YcmQuickFixOpened event:

autocmd User YcmQuickFixOpened autocmd! WinLeave

Or one can temporarily :set eventignore=WinLeave and later reset it to an empty string.

@micbou Brilliant. Thank you for the great suggestion. That is exactly what I needed. With that YcmQuickFixOpened, you make the previously registered autocmd to close a NOOP.

The above autocmd suggestion was an excellent idea. I had to make a tweak to get it to work for me though (not sure why, maybe a YCM update or Neovim difference or something).

autocmd User YcmQuickFixOpened autocmd! ycmquickfix WinLeave
Was this page helpful?
0 / 5 - 0 ratings