-
Notifications
You must be signed in to change notification settings - Fork 14
/
cfi.vim
60 lines (43 loc) · 1.15 KB
/
cfi.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
" vim:foldmethod=marker:fen:
scriptencoding utf-8
if get(g:, 'cfi_disable') || get(g:, 'loaded_cfi_ftplugin_vim')
finish
endif
let g:loaded_cfi_ftplugin_vim = 1
" Saving 'cpoptions' {{{
let s:save_cpo = &cpo
set cpo&vim
" }}}
let s:BEGIN_PATTERN = '\C'.'^\s*'.'fu\%[nction]\>'.'!\='.'\s\+'.'\([^(]\+\)'.'('
let s:END_PATTERN = '\C'.'^\s*'.'endf\%[unction]\>'
let s:finder = cfi#create_finder('vim')
function! s:finder.get_func_name() "{{{
let NONE = ''
if self.phase !=# 1
return NONE
endif
let m = matchlist(getline('.'), s:BEGIN_PATTERN)
if empty(m)
return NONE
endif
return m[1]
endfunction "}}}
function! s:finder.find_begin() "{{{
let NONE = 0
let begin_lnum = search(s:BEGIN_PATTERN, 'bW')
if begin_lnum == 0
return NONE
endif
let self.is_ready = 1
return [line('.'), col('.')]
endfunction "}}}
function! s:finder.find_end() "{{{
let NONE = []
if searchpair(s:BEGIN_PATTERN, '', s:END_PATTERN, 'W') == 0
return NONE
endif
return [line('.'), col('.')]
endfunction "}}}
call cfi#register_finder('vim', s:finder)
unlet s:finder
let &cpo = s:save_cpo