1
0
mirror of https://github.com/gryf/.vim.git synced 2025-12-17 11:30:29 +01:00

Update of buffers plugin from Eclim project, update taglisttoo plugin

(https://github.com/ervandew/taglisttoo).
This commit is contained in:
2011-07-16 19:36:56 +02:00
parent 29b24ba1f6
commit bb181fa494
23 changed files with 3094 additions and 1924 deletions

View File

@@ -0,0 +1,233 @@
"""
Copyright (c) 2005 - 2011, Eric Van Dewoestine
All rights reserved.
Redistribution and use of this software in source and binary forms, with
or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the
following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the
following disclaimer in the documentation and/or other
materials provided with the distribution.
* Neither the name of Eric Van Dewoestine nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission of
Eric Van Dewoestine.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
import os
import re
import subprocess
import tempfile
import vim
def ctags(lang, types, filename):
ctags = vim.eval('g:Tlist_Ctags_Cmd')
startupinfo = None
if os.name == 'nt':
startupinfo = subprocess.STARTUPINFO()
if hasattr(subprocess, '_subprocess'):
startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
else:
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
stdoutfile = tempfile.TemporaryFile()
stderrfile = tempfile.TemporaryFile()
try:
process = subprocess.Popen(
[
ctags,
'-f', '-',
'--format=2',
'--excmd=pattern',
'--fields=nks',
'--sort=no',
'--language-force=%s' % lang,
'--%s-types=%s' % (lang, types),
filename,
],
stdout=stdoutfile,
stderr=stderrfile,
stdin=subprocess.PIPE,
startupinfo=startupinfo,
)
retcode = process.wait()
if retcode != 0:
stderrfile.seek(0)
return (retcode, stderrfile.read())
stdoutfile.seek(0)
return (retcode, stdoutfile.read())
finally:
stdoutfile.close()
stderrfile.close()
def jsctags(filename):
jsctags = vim.eval('g:Tlist_JSctags_Cmd')
startupinfo = None
if os.name == 'nt':
startupinfo = subprocess.STARTUPINFO()
if hasattr(subprocess, '_subprocess'):
startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW
else:
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
temp = tempfile.mkstemp()[1]
try:
process = subprocess.Popen(
[
jsctags,
'-o', temp,
filename,
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
startupinfo=startupinfo,
)
retcode = process.wait()
if retcode != 0:
return (retcode, process.communicate()[1].strip())
return (retcode, open(temp).read())
finally:
os.unlink(temp)
def parse(filename, patterns):
f = open(filename, 'r')
contents = f.read()
f.close()
for i, info in enumerate(patterns):
flags = re.DOTALL | re.MULTILINE
if len(info) > 3:
if info[3] == 'i':
flags |= re.IGNORECASE
info = info[:3]
patterns[i] = info
try:
info[1] = re.compile(info[1], flags)
except:
print 'Failed to parse pattern: %s' % info[1]
raise
offsets = FileOffsets.compile(filename)
results = []
for ptype, regex, group in patterns:
for match in regex.finditer(contents):
start = match.start()
end = match.end()
line = offsets.offsetToLineColumn(start)[0]
col = 1
if group.isdigit():
name = match.group(int(group))
else:
matched = contents[start:end]
name = regex.sub(group, matched)
first = offsets.getLineStart(line)
last = offsets.getLineEnd(offsets.offsetToLineColumn(end)[0])
pattern = contents[first:last]
# pattern cannot span lines
if '\n' in pattern:
lines = pattern.split('\n')
for i, l in enumerate(lines):
if name in l:
pattern = l
line += i
col = l.index(name) + 1
break
# still multiline, so just use the first one
if '\n' in pattern:
pattern = lines[0]
elif name in pattern:
col = pattern.index(name) + 1
# remove ctrl-Ms
pattern = pattern.replace('\r', '')
results.append({
'type': ptype,
'name': name,
'pattern': '^%s$' % pattern,
'line': line,
'column': col,
})
return results
class FileOffsets(object):
def __init__(self):
self.offsets = []
@staticmethod
def compile(filename):
offsets = FileOffsets()
offsets.compileOffsets(filename)
return offsets;
def compileOffsets(self, filename):
f = file(filename, 'r')
try:
self.offsets.append(0);
offset = 0;
for line in f:
offset += len(line)
self.offsets.append(offset)
finally:
f.close()
def offsetToLineColumn(self, offset):
if offset <= 0:
return [1, 1]
bot = -1
top = len(self.offsets) - 1
while (top - bot) > 1:
mid = (top + bot) / 2
if self.offsets[mid] < offset:
bot = mid
else:
top = mid
if self.offsets[top] > offset:
top -= 1
line = top + 1
column = 1 + offset - self.offsets[top]
return [line, column]
def getLineStart(self, line):
return self.offsets[line - 1]
def getLineEnd(self, line):
if len(self.offsets) == line:
return self.offsets[len(self.offsets) - 1]
return self.offsets[line] - 1;

Binary file not shown.

View File

@@ -0,0 +1,48 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Parse(file, settings) {{{
function! taglisttoo#lang#ant#Parse(file, settings)
return taglisttoo#util#Parse(a:file, [
\ ['p', "<project\\s+(?:[^>]*)name\\s*=\\s*['\"](.*?)['\"]", 1],
\ ['i', "<import\\s+(?:[^>]*)file\\s*=\\s*['\"](.*?)['\"]", 1],
\ ['t', "<target\\s+(?:[^>]*)name\\s*=\\s*['\"](.*?)['\"]", 1],
\ ['r', "<property\\s+(?:[^>]*)name\\s*=\\s*['\"](.*?)['\"]", 1],
\ ])
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,45 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Parse(file, settings) {{{
function! taglisttoo#lang#dtd#Parse(file, settings)
return taglisttoo#util#Parse(a:file, [
\ ['e', '^\s*<!ELEMENT\s+(.*?)(\s|\s*$)', 1],
\ ])
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,46 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Parse(file, settings) {{{
function! taglisttoo#lang#html#Parse(file, settings)
return taglisttoo#util#Parse(a:file, [
\ ['a', "<a\\s+[^>]*?name=['\"](.*?)['\"]", 1],
\ ['i', "<([a-z]*?)\\s+[^>]*?id=['\"](.*?)['\"]", '\1 \2'],
\ ])
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,47 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Parse(file, settings) {{{
function! taglisttoo#lang#htmldjango#Parse(file, settings)
return taglisttoo#util#Parse(a:file, [
\ ['a', "<a\\s+[^>]*?name=['\"](.*?)['\"]", 1],
\ ['i', "<([a-z]*?)\\s+[^>]*?id=['\"](.*?)['\"]", '\1 \2'],
\ ['b', '\{%?\s*block\s+(\w+)', 1],
\ ])
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,48 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Parse(file, settings) {{{
function! taglisttoo#lang#htmljinja#Parse(file, settings)
return taglisttoo#util#Parse(a:file, [
\ ['a', "<a\\s+[^>]*?name=['\"](.*?)['\"]", 1],
\ ['i', "<([a-z]*?)\\s+[^>]*?id=['\"](.*?)['\"]", '\1 \2'],
\ ['b', '\{%?\s*block\s+(\w+)', 1],
\ ['m', '\{%-?\s*macro\s+(\w+)\s*\(', 1],
\ ])
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,90 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Format(types, tags) {{{
function! taglisttoo#lang#java#Format(types, tags)
let formatter = taglisttoo#util#Formatter(a:tags)
call formatter.filename()
let package = filter(copy(a:tags), 'v:val.type == "p"')
call formatter.format(a:types['p'], package, '')
let classes = filter(copy(a:tags), 'v:val.type == "c"')
" sort classes alphabetically except for the primary containing class.
if len(classes) > 1 && g:Tlist_Sort_Type == 'name'
let classes = [classes[0]] + sort(classes[1:], 'taglisttoo#util#SortTags')
endif
for class in classes
call formatter.blank()
let visibility = taglisttoo#util#GetVisibility(class)
call formatter.heading(a:types['c'], class, '')
let fields = filter(copy(a:tags),
\ 'v:val.type == "f" && v:val.parent =~ "class:.*\\<" . class.name . "$"')
call formatter.format(a:types['f'], fields, "\t")
let methods = filter(copy(a:tags),
\ 'v:val.type == "m" && v:val.parent =~ "class:.*\\<" . class.name . "$"')
call formatter.format(a:types['m'], methods, "\t")
endfor
let interfaces = filter(copy(a:tags), 'v:val.type == "i"')
if g:Tlist_Sort_Type == 'name'
call sort(interfaces, 'taglisttoo#util#SortTags')
endif
for interface in interfaces
call formatter.blank()
let visibility = taglisttoo#util#GetVisibility(interface)
call formatter.heading(a:types['i'], interface, '')
let fields = filter(copy(a:tags),
\ 'v:val.type == "f" && v:val.parent =~ "interface:.*\\<" . interface.name . "$"')
call formatter.format(a:types['f'], fields, "\t")
let methods = filter(copy(a:tags),
\ 'v:val.type == "m" && v:val.parent =~ "interface:.*\\<" . interface.name . "$"')
call formatter.format(a:types['m'], methods, "\t")
endfor
return formatter
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,303 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2011, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Global Variabls {{{
if !exists('g:TaglistTooJSctags')
let g:TaglistTooJSctags = 1
endif
" }}}
function! taglisttoo#lang#javascript#Format(types, tags) " {{{
if !g:TaglistTooJSctags || !exists('g:Tlist_JSctags_Cmd')
return s:FormatRegexResults(a:types, a:tags)
endif
return s:FormatJSctagsResults(a:types, a:tags)
endfunction " }}}
function! s:FormatJSctagsResults(types, tags) " {{{
let formatter = taglisttoo#util#Formatter(a:tags)
call formatter.filename()
let functions = filter(copy(a:tags), 'v:val.type == "f" && v:val.namespace == ""')
if len(functions) > 0
call formatter.blank()
call formatter.format(a:types['f'], functions, '')
endif
let members = filter(copy(a:tags), 'v:val.name == "includeScript"')
let objects = filter(copy(a:tags), 'v:val.jstype == "Object"')
for object in objects
if object.namespace != ''
let object.name = object.namespace . '.' . object.name
endif
call formatter.blank()
call formatter.heading(a:types['o'], object, '')
let members = filter(copy(a:tags), 'v:val.type == "f" && v:val.namespace == object.name')
call formatter.format(a:types['f'], members, "\t")
endfor
return formatter
endfunction " }}}
function! s:FormatRegexResults(types, tags) " {{{
let pos = getpos('.')
let formatter = taglisttoo#util#Formatter(a:tags)
call formatter.filename()
let object_contents = []
let objects = filter(copy(a:tags), 'v:val.type == "o"')
let members = filter(copy(a:tags), 'v:val.type == "m"')
let functions = filter(copy(a:tags),
\ 'v:val.type == "f" && v:val.pattern =~ "\\<function\\>"')
let object_bounds = {}
for object in objects
let object_start = object.line
call cursor(object_start, 1)
while search('{', 'W') && s:SkipComments()
" no op
endwhile
let object_end = searchpair('{', '', '}', 'W', 's:SkipComments()')
let methods = []
let indexes = []
let index = 0
for fct in members
if len(fct) > 3
let fct_line = fct.line
if fct_line > object_start && fct_line < object_end
call add(methods, fct)
elseif fct_line > object_end
break
elseif fct_line < object_end
call add(indexes, index)
endif
endif
let index += 1
endfor
call reverse(indexes)
for i in indexes
call remove(members, i)
endfor
let indexes = []
let index = 0
for fct in functions
if len(fct) > 3
let fct_line = fct.line
if fct_line > object_start && fct_line < object_end
call add(methods, fct)
call add(indexes, index)
elseif fct_line == object_start
call add(indexes, index)
elseif fct_line > object_end
break
endif
endif
let index += 1
endfor
call reverse(indexes)
for i in indexes
call remove(functions, i)
endfor
if len(methods) > 0
let parent_object = s:GetParentObject(
\ object_contents, object_bounds, object_start, object_end)
" remove methods from the parent if necessary
if len(parent_object)
call filter(parent_object.methods, 'index(methods, v:val) == -1')
endif
let object_bounds[string(object)] = [object_start, object_end]
call add(object_contents, {'object': object, 'methods': methods})
endif
endfor
if len(functions) > 0
call formatter.blank()
call formatter.format(a:types['f'], functions, '')
endif
if g:Tlist_Sort_Type == 'name'
call sort(object_contents, function('s:ObjectComparator'))
endif
for object_content in object_contents
call formatter.blank()
call formatter.heading(a:types['o'], object_content.object, '')
call formatter.format(a:types['f'], object_content.methods, "\t")
endfor
call setpos('.', pos)
return formatter
endfunction " }}}
function! taglisttoo#lang#javascript#Parse(file, settings) " {{{
if g:TaglistTooJSctags && !exists('g:Tlist_JSctags_Cmd')
if executable('jsctags')
let g:Tlist_JSctags_Cmd = 'jsctags'
elseif executable('javascripttags')
let g:Tlist_JSctags_Cmd = 'javascripttags'
endif
endif
if !g:TaglistTooJSctags || !exists('g:Tlist_JSctags_Cmd')
return s:ParseRegex(a:file, a:settings)
endif
return s:ParseJSctags(a:file, a:settings)
endfunction " }}}
function! s:ParseJSctags(file, settings) " {{{
python << PYTHONEOF
retcode, result = taglisttoo.jsctags(vim.eval('a:file'))
vim.command('let retcode = %i' % retcode)
vim.command("let result = '%s'" % result.replace("'", "''"))
PYTHONEOF
if retcode
call s:EchoError('jsctags failed with error code: ' . retcode)
return
endif
if has('win32') || has('win64') || has('win32unix')
let result = substitute(result, "\<c-m>\n", '\n', 'g')
endif
let results = split(result, '\n')
while len(results) && results[0] =~ '^!_'
call remove(results, 0)
endwhile
let types = keys(a:settings.tags)
let parsed_results = []
for result in results
" some results use <lnum>G;" (e.g. 1956G;") as the pattern... skip those
" for now since taglist expects actual patterns.
if result !~ '\t\/\^'
continue
endif
let pre = substitute(result, '\(.\{-}\)\t\/\^.*', '\1', '')
let pattern = substitute(result, '.\{-}\(\/\^.*\/;"\).*', '\1', '')
let post = substitute(result, '.\{-}\/\^.*\/;"\t', '', '')
let [name, filename] = split(pre, '\t')
let parts = split(post, '\t')
let [type, line_str] = parts[:1]
exec 'let line = ' . substitute(line_str, 'lineno:', '', '')
let pattern = substitute(pattern, '^/\(.*\)/;"$', '\1', '')
let jstypes = filter(copy(parts), 'v:val =~ "^type:"')
let namespaces = filter(copy(parts), 'v:val =~ "^namespace:"')
let jstype = len(jstypes) ? substitute(jstypes[0], '^type:', '', '') : ''
let ns = len(namespaces) ? substitute(namespaces[0], '^namespace:', '', '') : ''
call add(parsed_results, {
\ 'type': type,
\ 'name': name,
\ 'pattern': pattern,
\ 'line': line,
\ 'namespace': ns,
\ 'jstype': jstype,
\ })
endfor
return parsed_results
endfunction " }}}
function! s:ParseRegex(file, settings) " {{{
let patterns = []
" Match Objects/Classes
call add(patterns, ['o', '([A-Za-z0-9_.]+)\s*=\s*\{(\s*[^}]|$)', 1])
" prototype.js has Object.extend to extend existing objects.
call add(patterns, ['o', '(?:var\s+)?\b([A-Z][A-Za-z0-9_.]+)\s*=\s*Object\.extend\s*\(', 1])
call add(patterns, ['o', '\bObject\.extend\s*\(\b([A-Z][A-Za-z0-9_.]+)\s*,\s*\{', 1])
" mootools uses 'new Class'
call add(patterns, ['o', '(?:var\s+)?\b([A-Z][A-Za-z0-9_.]+)\s*=\s*new\s+Class\s*\(', 1])
" firebug uses extend
call add(patterns, ['o', '(?:var\s+)?\b([A-Z][A-Za-z0-9_.]+)\s*=\s*extend\s*\(', 1])
" vimperator uses function MyClass ()
call add(patterns, ['o', 'function\s+\b([A-Z][A-Za-z0-9_.]+)\s*\(', 1])
" vimperator uses var = (function()
call add(patterns, ['o', '([A-Za-z0-9_.]+)\s*=\s*\(function\s*\(', 1])
" Match Functions
call add(patterns, ['f', '\bfunction\s+([a-zA-Z0-9_.\$]+?)\s*\(', 1])
call add(patterns, ['f', '([a-zA-Z0-9_.\$]+?)\s*=\s*function\s*\(', 1])
" Match Members
call add(patterns, ['m', '\b([a-zA-Z0-9_.\$]+?)\s*:\s*function\s*\(', 1])
return taglisttoo#util#Parse(a:file, patterns)
endfunction " }}}
function s:ObjectComparator(o1, o2) " {{{
let n1 = a:o1['object'].name
let n2 = a:o2['object'].name
return n1 == n2 ? 0 : n1 > n2 ? 1 : -1
endfunction " }}}
function s:SkipComments() " {{{
let synname = synIDattr(synID(line('.'), col('.'), 1), "name")
return synname =~? '\(comment\|string\)'
endfunction " }}}
function s:GetParentObject(objects, bounds, start, end) " {{{
for key in keys(a:bounds)
let range = a:bounds[key]
if range[0] < a:start && range[1] > a:end
for object_content in a:objects
if string(object_content.object) == key
return object_content
endif
endfor
break
endif
endfor
return {}
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,43 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Parse(file, settings) {{{
function! taglisttoo#lang#jproperties#Parse(file, settings)
return taglisttoo#util#Parse(a:file, [['p', '^\s*([^#]+?)\s*=', 1]])
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,48 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Parse(file, settings) {{{
function! taglisttoo#lang#log4j#Parse(file, settings)
return taglisttoo#util#Parse(a:file, [
\ ['a', "<appender\\s+[^>]*?name=['\"](.*?)['\"]", 1],
\ ['c', "<category\\s+[^>]*?name=['\"](.*?)['\"]", 1],
\ ['l', "<logger\\s+[^>]*?name=['\"](.*?)['\"]", 1],
\ ['r', "<(root)\\s*>", 1],
\ ])
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,142 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Format(types, tags) {{{
function! taglisttoo#lang#php#Format(types, tags)
let pos = getpos('.')
let formatter = taglisttoo#util#Formatter(a:tags)
call formatter.filename()
let top_functions = filter(copy(a:tags), 'v:val.type == "f"')
let class_contents = []
let classes = filter(copy(a:tags), 'v:val.type == "c"')
if g:Tlist_Sort_Type == 'name'
call sort(classes, 'taglisttoo#util#SortTags')
endif
for class in classes
let object_start = class.line
call cursor(object_start, 1)
call search('{', 'W')
let object_end = searchpair('{', '', '}', 'W')
let functions = []
let indexes = []
let index = 0
for fct in top_functions
if len(fct) > 3
let fct_line = fct.line
if fct_line > object_start && fct_line < object_end
call add(functions, fct)
call add(indexes, index)
endif
endif
let index += 1
endfor
call reverse(indexes)
for i in indexes
call remove(top_functions, i)
endfor
call add(class_contents, {'class': class, 'functions': functions})
endfor
let interface_contents = []
let interfaces = filter(copy(a:tags), 'v:val.type == "i"')
if g:Tlist_Sort_Type == 'name'
call sort(interfaces, 'taglisttoo#util#SortTags')
endif
for interface in interfaces
let object_start = interface.line
call cursor(object_start, 1)
call search('{', 'W')
let object_end = searchpair('{', '', '}', 'W')
let functions = []
let indexes = []
let index = 0
for fct in top_functions
if len(fct) > 3
let fct_line = fct.line
if fct_line > object_start && fct_line < object_end
call add(functions, fct)
call add(indexes, index)
endif
endif
let index += 1
endfor
call reverse(indexes)
for i in indexes
call remove(top_functions, i)
endfor
call add(interface_contents, {'interface': interface, 'functions': functions})
endfor
if len(top_functions) > 0
call formatter.blank()
call formatter.format(a:types['f'], top_functions, '')
endif
for class_content in class_contents
call formatter.blank()
call formatter.heading(a:types['c'], class_content.class, '')
call formatter.format(a:types['f'], class_content.functions, "\t")
endfor
for interface_content in interface_contents
call formatter.blank()
call formatter.heading(a:types['i'], interface_content.interface, '')
call formatter.format(a:types['f'], interface_content.functions, "\t")
endfor
call setpos('.', pos)
return formatter
endfunction " }}}
" Parse(file, settings) {{{
function! taglisttoo#lang#php#Parse(file, settings)
return taglisttoo#util#Parse(a:file, [
\ ['f', '\bfunction\s+([a-zA-Z0-9_]+)\s*\(', 1],
\ ['c', '\bclass\s+([a-zA-Z0-9_]+)', 1],
\ ['i', '\binterface\s+([a-zA-Z0-9_]+)', 1],
\ ])
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,66 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Format(types, tags) {{{
function! taglisttoo#lang#python#Format(types, tags)
let formatter = taglisttoo#util#Formatter(a:tags)
call formatter.filename()
let functions = filter(copy(a:tags), 'v:val.type == "f"')
if len(functions)
call formatter.blank()
call formatter.format(a:types['f'], functions, '')
endif
let classes = filter(copy(a:tags), 'v:val.type == "c"')
if g:Tlist_Sort_Type == 'name'
call sort(classes, 'taglisttoo#util#SortTags')
endif
for class in classes
call formatter.blank()
call formatter.heading(a:types['c'], class, '')
let members = filter(copy(a:tags),
\ 'v:val.type == "m" && v:val.parent == "class:" . class.name')
call formatter.format(a:types['m'], members, "\t")
endfor
return formatter
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,46 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Parse(file, settings) {{{
function! taglisttoo#lang#rst#Parse(file, settings)
return taglisttoo#util#Parse(a:file, [
\ ['a', '^\s*\.\.\s_((\\:|[^:])+):\s*\n', 1],
\ ['s', '^([^\n]+)\n[=^-]{4,}', 1],
\ ])
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,57 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Parse(file, settings) {{{
function! taglisttoo#lang#sql#Parse(file, settings)
return taglisttoo#util#Parse(a:file, [
\ ['g', 'create\s+(?:group|role)\s+([a-zA-Z0-9_.]+)', 1, 'i'],
\ ['u', 'create\s+user\s+([a-zA-Z0-9_.]+)', 1, 'i'],
\ ['p', 'create\s+(?:tablespace|dbspace)\s+([a-zA-Z0-9_.]+)', 1, 'i'],
\ ['s', 'create\s+schema\s+([a-zA-Z0-9_.]+)', 1, 'i'],
\ ['t', 'create\s+(?:temporary\s+)?table\s+(?:if\s+not\s+exists\s+)?[`]?([a-zA-Z0-9_.]+)[`]?', 1, 'i'],
\ ['v', 'create\s+(?:or\s+replace\s+)?view\s+([a-zA-Z0-9_.]+)', 1, 'i'],
\ ['q', 'create\s+sequence\s+([a-zA-Z0-9_.]+)', 1, 'i'],
\ ['x', 'create\s+(?:or\s+replace\s+)?trigger\s+([a-zA-Z0-9_.]+)', 1, 'i'],
\ ['f', 'create\s+(?:or\s+replace\s+)?function\s+([a-zA-Z0-9_.]+)', 1, 'i'],
\ ['c', 'create\s+(?:or\s+replace\s+)?procedure\s+([a-zA-Z0-9_.]+)', 1, 'i'],
\ ['r', "exec\\s+sp_addrole\\s+['\"]([a-zA-Z0-9_.]+)['\"]", 1, 'i'],
\ ['m', "exec\\s+sp_addlogin\\s+@loginname=['\"](.*?)['\"]", 1, 'i'],
\ ['z', 'alter\s+database.*add\s+filegroup\s+([a-zA-Z0-9_.]+)', 1, 'i'],
\ ])
endfunction " }}}
" vim:ft=vim:fdm=marker

View File

@@ -0,0 +1,46 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2010, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
" Parse(file, settings) {{{
function! taglisttoo#lang#xsd#Parse(file, settings)
return taglisttoo#util#Parse(a:file, [
\ ['e', "<(?:xs[d]?:)?element\\s+[^>]*?name=['\"](.*?)['\"]", 1],
\ ['t', "<(?:xs[d]?:)?complexType\\s+[^>]*?name=['\"](.*?)['\"]", 1],
\ ])
endfunction " }}}
" vim:ft=vim:fdm=marker

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,131 @@
" Author: Eric Van Dewoestine
"
" License: {{{
" Copyright (c) 2005 - 2011, Eric Van Dewoestine
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
" or without modification, are permitted provided that the following
" conditions are met:
"
" * Redistributions of source code must retain the above
" copyright notice, this list of conditions and the
" following disclaimer.
"
" * Redistributions in binary form must reproduce the above
" copyright notice, this list of conditions and the
" following disclaimer in the documentation and/or other
" materials provided with the distribution.
"
" * Neither the name of Eric Van Dewoestine nor the names of its
" contributors may be used to endorse or promote products derived from
" this software without specific prior written permission of
" Eric Van Dewoestine.
"
" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
" }}}
function! taglisttoo#util#Formatter(tags) " {{{
let formatter = {'lines': [], 'content': [], 'syntax': [], 'tags': a:tags}
function! formatter.filename() dict " {{{
call add(self.content, expand('%:t'))
call add(self.lines, -1)
endfunction " }}}
function! formatter.format(type, values, indent) dict " {{{
if len(a:values) > 0
if g:Tlist_Sort_Type == 'name'
call sort(a:values, 'taglisttoo#util#SortTags')
endif
call self.heading(a:type, {}, a:indent)
for value in a:values
let visibility = taglisttoo#util#GetVisibility(value)
call add(self.content, "\t" . a:indent . visibility . value.name)
call add(self.lines, index(self.tags, value))
endfor
endif
endfunction " }}}
function! formatter.heading(type, tag, indent) dict " {{{
if len(a:tag)
call add(self.lines, index(self.tags, a:tag))
call add(self.content, a:indent . a:type . ' ' . a:tag.name)
call add(self.syntax,
\ 'syn match TagListKeyword "^\s*' . a:type . '\%' . len(self.lines) . 'l"')
else
call add(self.lines, 'label')
call add(self.content, a:indent . a:type)
call add(self.syntax, 'syn match TagListKeyword "^.*\%' . len(self.lines) . 'l.*"')
endif
endfunction " }}}
function! formatter.blank() dict " {{{
call add(self.content, '')
call add(self.lines, -1)
endfunction " }}}
return formatter
endfunction " }}}
function! taglisttoo#util#GetVisibility(tag) " {{{
let pattern = a:tag.pattern
if pattern =~ '\<public\>'
if pattern =~ '\<static\>'
return '*'
endif
return '+'
elseif pattern =~ '\<protected\>'
return '#'
elseif pattern =~ '\<private\>'
return '-'
endif
return ''
endfunction " }}}
function! taglisttoo#util#Parse(file, patterns) " {{{
python << PYTHONEOF
filename = vim.eval('a:file')
patterns = vim.eval('a:patterns')
result = taglisttoo.parse(filename, patterns)
vim.command('let results = %s' % ('%r' % result).replace("\\'", "''"))
PYTHONEOF
let tags = []
if len(results)
for result in results
" filter false positives found in comments or strings
let lnum = result.line
let line = getline(lnum)
let col = len(line) - len(substitute(line, '^\s*', '', '')) + 1
if synIDattr(synID(lnum, col, 1), 'name') =~? '\(comment\|string\)' ||
\ synIDattr(synIDtrans(synID(lnum, col, 1)), 'name') =~? '\(comment\|string\)'
continue
endif
call add(tags, result)
endfor
endif
return tags
endfunction " }}}
function! taglisttoo#util#SortTags(tag1, tag2) " {{{
let name1 = tolower(a:tag1.name)
let name2 = tolower(a:tag2.name)
return name1 == name2 ? 0 : name1 > name2 ? 1 : -1
endfunction " }}}
" vim:ft=vim:fdm=marker