Add to your config:
nmap <silent> <leader>h <plug>(YCMHover)
K for that, but only for buffers/filetypes, where it makes sense:
let s:lsp_ft_maps = 'gdscript,go,python'
augroup ycm_settings | au!
exe printf('au FileType %s call Ycm_mappings()', s:lsp_ft_maps)
func! Ycm_mappings() abort
nmap <silent><buffer> K <plug>(YCMHover)
nnoremap <silent><buffer> gd :YcmCompleter GoTo<CR>
This snippet creates an autocommand for filetypes listed in
s:lsp_ft_maps that runs
Ycm_mappings() function, that in turn creates buffer local mappings.
Buffer local mappings as name suggests are only available for a given buffer thus if you switch to another buffer where YCM doesn't have LSP functionality, original mappings would be in effect.
K is used by vim to show a man page of a keyword under cursor, and for
vim filetype (say your .vimrc), the same
K is used to show vim help. With the snippet, it is preserved for non-lsp related buffers and shows YCM hover for buffers listed in
The same is with
gd mapping -- it has original built-in functionality which this snippet overrides for some of filetypes.