Skip to content

Instantly share code, notes, and snippets.

@puremourning
Created February 19, 2022 17:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save puremourning/6fcdf05b82aaec30fc8274c3b6ad97ff to your computer and use it in GitHub Desktop.
Save puremourning/6fcdf05b82aaec30fc8274c3b6ad97ff to your computer and use it in GitHub Desktop.
YCM: Show definition of symbol under cursor in preview window
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