Last active
January 22, 2023 14:54
-
-
Save romainl/a11c6952f012f1dd32c26fad4fa82e43 to your computer and use it in GitHub Desktop.
Print declaration of word under the cursor
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! ShowDeclaration(global) abort | |
let pos = getpos('.') | |
if searchdecl(expand('<cword>'), a:global) == 0 | |
let line_of_declaration = line('.') | |
execute line_of_declaration . "#" | |
else | |
echo 'Sorry, no declaration found.' | |
endif | |
call cursor(pos[1], pos[2]) | |
endfunction | |
nnoremap sd :call ShowDeclaration(0)<CR> | |
nnoremap sD :call ShowDeclaration(1)<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment