Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 1 | " Language: gprof |
| 2 | " Maintainer: Dominique Pelle <dominique.pelle@gmail.com> |
Bram Moolenaar | 56994d2 | 2021-04-17 16:31:09 +0200 | [diff] [blame] | 3 | " Last Change: 2021 Apr 08 |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 4 | |
| 5 | " When cursor is on one line of the gprof call graph, |
| 6 | " calling this function jumps to this function in the call graph. |
| 7 | if exists("b:did_ftplugin") |
| 8 | finish |
| 9 | endif |
| 10 | let b:did_ftplugin=1 |
| 11 | |
| 12 | fun! <SID>GprofJumpToFunctionIndex() |
| 13 | let l:line = getline('.') |
| 14 | if l:line =~ '[\d\+\]$' |
| 15 | " We're in a line in the call graph. |
Bram Moolenaar | ec7944a | 2013-06-12 21:29:15 +0200 | [diff] [blame] | 16 | norm! $y% |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 17 | call search('^' . escape(@", '[]'), 'sw') |
Bram Moolenaar | ec7944a | 2013-06-12 21:29:15 +0200 | [diff] [blame] | 18 | norm! zz |
Bram Moolenaar | 56994d2 | 2021-04-17 16:31:09 +0200 | [diff] [blame] | 19 | elseif l:line =~ '^\(\s*[0-9\.]\+\)\{3}\s\+' |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 20 | " We're in line in the flat profile. |
Bram Moolenaar | ec7944a | 2013-06-12 21:29:15 +0200 | [diff] [blame] | 21 | norm! 55|eby$ |
| 22 | call search('^\[\d\+\].*\d\s\+' . escape(@", '[]*.') . '\>', 'sW') |
| 23 | norm! zz |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 24 | endif |
| 25 | endfun |
| 26 | |
| 27 | " Pressing <C-]> on a line in the gprof flat profile or in |
| 28 | " the call graph, jumps to the corresponding function inside |
| 29 | " the flat profile. |
Bram Moolenaar | ec7944a | 2013-06-12 21:29:15 +0200 | [diff] [blame] | 30 | map <buffer> <silent> <C-]> :call <SID>GprofJumpToFunctionIndex()<CR> |
Bram Moolenaar | 543b7ef | 2013-06-01 14:50:56 +0200 | [diff] [blame] | 31 | |
| 32 | " vim:sw=2 fdm=indent |