Created
February 19, 2022 17:02
-
-
Save puremourning/6fcdf05b82aaec30fc8274c3b6ad97ff to your computer and use it in GitHub Desktop.
YCM: Show definition of symbol under cursor in preview window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! s:ShowGoToInPreviewWindow( result ) | |
if has_key( a:result, 'error' ) | |
echom a:result.error | |
return | |
endif | |
if type( a:result ) == v:t_list | |
echom 'Too many definitions' | |
return | |
endif | |
execute 'pedit' '+' .. a:result.line_num a:result.filepath | |
endfunction | |
function! s:PreviewGoTo( cmd ) | |
call youcompleteme#GetRawCommandResponseAsync( | |
\ function( 's:ShowGoToInPreviewWindow' ), | |
\ a:cmd ) | |
endfunction | |
nnoremap <silent> <plug>(YCMPEditDefinition) | |
\ :<C-u>call <SID>PreviewGoTo( 'GoToDefinition' )<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment