aboutsummaryrefslogtreecommitdiff
path: root/autoload/hints/plugins.vim
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/hints/plugins.vim')
-rw-r--r--autoload/hints/plugins.vim59
1 files changed, 59 insertions, 0 deletions
diff --git a/autoload/hints/plugins.vim b/autoload/hints/plugins.vim
new file mode 100644
index 0000000..de8cc6c
--- /dev/null
+++ b/autoload/hints/plugins.vim
@@ -0,0 +1,59 @@
+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
+ 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
+
+call hints#plugins#registerFt("vim", s:vim_plugin)
+call hints#plugins#registerFt("java", s:java_plugin)
+
+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_line = ''
+endfunction
+
+let s:ISSPACE= '^\s*$'
+function! s:default_plugin.TagLine(linenr, line)
+ if self.last_line =~ s:ISSPACE && !(a:line =~ s:ISSPACE)
+ let self.last_line = a:line
+ return v:true
+ endif
+
+ let self.last_line = a:line
+ return v:false
+endfunction