xref: /vim-8.2.3635/runtime/ftplugin/gprof.vim (revision 34cc7d8c)
1" Language:     gprof
2" Maintainer:   Dominique Pelle <[email protected]>
3" Contributors: Doug Kearns <[email protected]>
4" Last Change:  2021 Sep 19
5
6" When cursor is on one line of the gprof call graph,
7" calling this function jumps to this function in the call graph.
8if exists("b:did_ftplugin")
9  finish
10endif
11let b:did_ftplugin=1
12
13func! <SID>GprofJumpToFunctionIndex()
14  let l:line = getline('.')
15  if l:line =~ '[\d\+\]$'
16    " We're in a line in the call graph.
17    norm! $y%
18    call search('^' . escape(@", '[]'), 'sw')
19    norm! zz
20  elseif l:line =~ '^\(\s*[0-9\.]\+\)\{3}\s\+'
21    " We're in line in the flat profile.
22    norm! 55|eby$
23    call search('^\[\d\+\].*\d\s\+' .  escape(@", '[]*.') . '\>', 'sW')
24    norm! zz
25  endif
26endfunc
27
28if !exists("no_plugin_maps") && !exists("no_gprof_maps")
29  " Pressing <C-]> on a line in the gprof flat profile or in
30  " the call graph, jumps to the corresponding function inside
31  " the flat profile.
32  map <buffer> <silent> <C-]> :call <SID>GprofJumpToFunctionIndex()<CR>
33  let b:undo_ftplugin = "silent! unmap <buffer> <C-]>"
34endif
35
36" vim:sw=2 fdm=indent
37