blob: 645b07e1278665dcf277bd5322f8233d0883c112 (
plain) (
blame)
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
61
62
63
64
65
66
67
68
69
|
let s:ftplugins = {}
let s:default_plugin = {}
let s:vim_plugin = {}
function! s:vim_plugin.Before(file)
endfunction
function! s:vim_plugin.TagLine(linenr, line)
return a:line =~ '\<\(if\|function\|return\|end\w*\|while\|for\|let\|else\|try\)\>'
endfunction
let s:java_plugin = {}
function! s:java_plugin.Before(file) dict
let self.last_line = ''
endfunction
let s:WHITESPACE_OR_COMMENT='\(^\s*$\)\|\(^\s*//\)\|\(^\s*\*/\)'
function! s:java_plugin.TagLine(linenr, line) dict
return v:true
" if self.last_line =~ s:WHITESPACE_OR_COMMENT
" \ && !(a:line =~ s:WHITESPACE_OR_COMMENT)
" let self.last_line = a:line
" return v:true
" endif
" let self.last_line = a:line
" return
" \ a:line =~ '^\s*}$' ||
" \ a:line =~ '\<\(public\|private\|protected\|class\|static\|try\|while\|for\|if\|else\|catch\)\>'
endfunction
function! hints#plugins#registerFt(filetype, plugin) abort
let s:ftplugins[a:filetype] = a:plugin
endfunction
function! hints#plugins#getPluginForFiletype(filetype) abort
return get(s:ftplugins, a:filetype, s:default_plugin)
endfunction
function! hints#plugins#getDefaultPlugin() abort
return s:default_plugin
endfunction
function! s:default_plugin.Before(file)
let self.last_kind = 1
endfunction
let s:ISSPACE = '^\s*$'
let s:ISCOMMENT = '^\s*[-/#;"(]'
function! s:default_plugin.TagLine(linenr, line)
if a:line =~ s:ISSPACE
let kind = 1
elseif a:line =~ s:ISCOMMENT
let kind = 2
else
let kind = 3
endif
if self.last_kind != kind && kind != 1
let self.last_kind = kind
return v:true
endif
let self.last_kind = kind
return v:false
endfunction
call hints#plugins#registerFt("vim", s:vim_plugin)
call hints#plugins#registerFt("java", s:java_plugin)
|