blob: d8974bcc84bd24e6be9a153dc01ae76728eb8a66 [file] [log] [blame]
Bram Moolenaar34cc7d82021-09-21 20:09:51 +02001" Language: gprof
2" Maintainer: Dominique Pelle <dominique.pelle@gmail.com>
3" Contributors: Doug Kearns <dougkearns@gmail.com>
4" Last Change: 2021 Sep 19
Bram Moolenaar543b7ef2013-06-01 14:50:56 +02005
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
Bram Moolenaar34cc7d82021-09-21 20:09:51 +020013func! <SID>GprofJumpToFunctionIndex()
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020014 let l:line = getline('.')
15 if l:line =~ '[\d\+\]$'
16 " We're in a line in the call graph.
Bram Moolenaarec7944a2013-06-12 21:29:15 +020017 norm! $y%
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020018 call search('^' . escape(@", '[]'), 'sw')
Bram Moolenaarec7944a2013-06-12 21:29:15 +020019 norm! zz
Bram Moolenaar56994d22021-04-17 16:31:09 +020020 elseif l:line =~ '^\(\s*[0-9\.]\+\)\{3}\s\+'
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020021 " We're in line in the flat profile.
Bram Moolenaarec7944a2013-06-12 21:29:15 +020022 norm! 55|eby$
23 call search('^\[\d\+\].*\d\s\+' . escape(@", '[]*.') . '\>', 'sW')
24 norm! zz
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020025 endif
Bram Moolenaar34cc7d82021-09-21 20:09:51 +020026endfunc
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020027
Bram Moolenaar34cc7d82021-09-21 20:09:51 +020028if !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
Bram Moolenaar543b7ef2013-06-01 14:50:56 +020035
36" vim:sw=2 fdm=indent