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

Scripts update

Removed GetLatestVimScripts plugin (it's distributed with vim)
Added nice function for generating HTML from rst in rst/common.vim
Removd NERDtree (didn't used it at all)
Removed tasklist (same as above)
Removed eclim tools, leaved only buffer functionality
Small improvements in vimrc
This commit is contained in:
2010-08-29 19:58:17 +02:00
parent 51fd5661ec
commit 67fd7abec6
37 changed files with 1725 additions and 8138 deletions

View File

@@ -2,8 +2,8 @@
" FILE: "/home/wlee/.vim/plugin/DirDiff.vim" {{{
" LAST MODIFICATION: "Mon, 20 Oct 2008 09:04:59 -0500 (wlee)"
" HEADER MAINTAINED BY: N/A
" VERSION: 1.1.2
" (C) 2001-2006 by William Lee, <wl1012@yahoo.com>
" VERSION: 1.1.3
" (C) 2001-2010 by William Lee, <wl1012@yahoo.com>
" }}}
@@ -147,9 +147,12 @@
"
" Florian Delizy for the i18n diff patch
" Robert Webb for his sorting function
" Wu WeiWei for his Chinese diff patch
" Salman Halim, Yosuke Kimura, and others for their suggestions
"
" HISTORY:
" 1.1.3 - Applied the patch to 1.1.2 by Wu WeiWei in order to make diff
" that's localized in Chinese work.
" 1.1.2 - Applied the patch to 1.1.0 instead of 1.0.2. Please do not use
" 1.1.1
" 1.1.1 - Make it work with filename with spaces. (Thanks to Atte Kojo)
@@ -281,6 +284,11 @@ if !exists("g:DirDiffTextOnlyIn")
let g:DirDiffTextOnlyIn = "Only in "
endif
" String used for the English equivalent ": ")
if !exists("g:DirDiffTextOnlyInCenter")
let g:DirDiffTextOnlyInCenter = ": "
endif
" Set some script specific variables:
"
let s:DirDiffFirstDiffLine = 6
@@ -778,11 +786,11 @@ endfunction
"Returns the source (A or B) of the "Only" line
function! <SID>ParseOnlySrc(line)
return substitute(a:line, '^.*' . s:DirDiffDiffOnlyLine . '\[\(.\)\].*:.*', '\1', '')
return substitute(a:line, '^.*' . s:DirDiffDiffOnlyLine . '\[\(.\)\].*' . s:DirDiffDiffOnlyLineCenter . '.*', '\1', '')
endfunction
function! <SID>ParseOnlyFile(line)
let regex = '^.*' . s:DirDiffDiffOnlyLine . '\[.\]\(.*\): \(.*\)'
let regex = '^.*' . s:DirDiffDiffOnlyLine . '\[.\]\(.*\)' . s:DirDiffDiffOnlyLineCenter . '\(.*\)'
let root = substitute(a:line, regex , '\1', '')
let file = root . s:sep . substitute(a:line, regex , '\2', '')
return file
@@ -1006,6 +1014,7 @@ function! <SID>GetDiffStrings()
" what's set in the global variables
if (g:DirDiffDynamicDiffText == 0)
let s:DirDiffDiffOnlyLineCenter = g:DirDiffTextOnlyInCenter
let s:DirDiffDiffOnlyLine = g:DirDiffTextOnlyIn
let s:DirDiffDifferLine = g:DirDiffTextFiles
let s:DirDiffDifferAndLine = g:DirDiffTextAnd
@@ -1032,7 +1041,9 @@ function! <SID>GetDiffStrings()
"echo "First line: " . getline(1)
"echo "tmp1: " . tmp1
"echo "tmp1rx: " . tmp1rx
let s:DirDiffDiffOnlyLine = substitute( getline(1), tmp1rx . ".*$", "", '')
let regex = '\(^.*\)' . tmp1rx . '\(.*\)' . "test"
let s:DirDiffDiffOnlyLine = substitute( getline(1), regex, '\1', '')
let s:DirDiffDiffOnlyLineCenter = substitute( getline(1), regex, '\2', '')
"echo "DirDiff Only: " . s:DirDiffDiffOnlyLine
q
@@ -1067,4 +1078,12 @@ function! <SID>GetDiffStrings()
call <SID>Delete(tmp2)
call <SID>Delete(tmpdiff)
"avoid get diff text again
let g:DirDiffTextOnlyInCenter = s:DirDiffDiffOnlyLineCenter
let g:DirDiffTextOnlyIn = s:DirDiffDiffOnlyLine
let g:DirDiffTextFiles = s:DirDiffDifferLine
let g:DirDiffTextAnd = s:DirDiffDifferAndLine
let g:DirDiffTextDiffer = s:DirDiffDifferEndLine
let g:DirDiffDynamicDiffText = 0
endfunction

File diff suppressed because it is too large Load Diff

530
plugin/buffers.vim Normal file
View File

@@ -0,0 +1,530 @@
" ============================================================================
" File: buffers.vim
" Description: vim plugin that provides buffers helpers. Almost all of parts
" are taken from Eclim project <http://eclim.sourceforge.net>
" Maintainer: Roman 'gryf' Dobosz <gryf73@gmail.com>
" Last Change: 2010-08-28
" License: This program is free software: you can redistribute it and/or
" modify it under the terms of the GNU General Public License as
" published by the Free Software Foundation, either version 3 of
" the License, or (at your option) any later version.
"
" This program is distributed in the hope that it will be useful,
" but WITHOUT ANY WARRANTY; without even the implied warranty of
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" GNU General Public License for more details.
"
" You should have received a copy of the GNU General Public
" License along with this program. If not, see
" <http://www.gnu.org/licenses/>.
" ============================================================================
let s:Eclim_ver = '1.6.0'
" Eclim: {{{1
" files:
" - plugin/eclim.vim (global vars)
" - plugin/common.vim (commands)
" Global Variables {{{2
if has("signs")
if !exists("g:EclimSignLevel")
let g:EclimSignLevel = 5
endif
else
let g:EclimSignLevel = 0
endif
if !exists("g:EclimInfoHighlight")
let g:EclimInfoHighlight = "Statement"
endif
if !exists("g:EclimLogLevel")
let g:EclimLogLevel = 4
endif
if !exists("g:EclimTraceHighlight")
let g:EclimTraceHighlight = "Normal"
endif
if !exists("g:EclimDebugHighlight")
let g:EclimDebugHighlight = "Normal"
endif
if !exists("g:EclimInfoHighlight")
let g:EclimInfoHighlight = "Statement"
endif
if !exists("g:EclimWarningHighlight")
let g:EclimWarningHighlight = "WarningMsg"
endif
if !exists("g:EclimErrorHighlight")
let g:EclimErrorHighlight = "Error"
endif
if !exists("g:EclimFatalHighlight")
let g:EclimFatalHighlight = "Error"
endif
if !exists("g:EclimShowCurrentError")
let g:EclimShowCurrentError = 1
endif
if !exists("g:EclimShowCurrentErrorBalloon")
let g:EclimShowCurrentErrorBalloon = 1
endif
if !exists("g:EclimOpenQFLists")
let g:EclimOpenQFLists = 1
endif
" }}}
" Command Declarations {{{2
if !exists(":Buffers")
command Buffers :call s:Buffers()
endif
" }}}
" End Eclim: }}}
" Common Buffers: {{{1
" Global Variables {{{2
if !exists('g:EclimBuffersSort')
let g:EclimBuffersSort = 'file'
endif
if !exists('g:EclimBuffersSortDirection')
let g:EclimBuffersSortDirection = 'asc'
endif
if !exists('g:EclimBuffersDefaultAction')
let g:EclimBuffersDefaultAction = 'edit'
endif
if !exists('g:EclimOnlyExclude')
let g:EclimOnlyExclude =
\ '\(NERD_tree_*\|__Tag_List__\|command-line\)'
endif
" }}}
" Buffers() eclim/autoload/eclim/common/buffers.vim {{{2
" Like, :buffers, but opens a temporary buffer.
function! s:Buffers()
redir => list
silent exec 'buffers'
redir END
let buffers = []
let filelength = 0
for entry in split(list, '\n')
let buffer = {}
let buffer.status = substitute(entry, '\s*[0-9]\+\s\+\(.\{-}\)\s\+".*', '\1', '')
let buffer.path = substitute(entry, '.\{-}"\(.\{-}\)".*', '\1', '')
let buffer.path = fnamemodify(buffer.path, ':p')
let buffer.file = fnamemodify(buffer.path, ':p:t')
let buffer.dir = fnamemodify(buffer.path, ':p:h')
exec 'let buffer.bufnr = ' . substitute(entry, '\s*\([0-9]\+\).*', '\1', '')
exec 'let buffer.lnum = ' .
\ substitute(entry, '.*"\s\+line\s\+\([0-9]\+\).*', '\1', '')
call add(buffers, buffer)
if len(buffer.file) > filelength
let filelength = len(buffer.file)
endif
endfor
if g:EclimBuffersSort != ''
call sort(buffers, 'BufferCompare')
endif
let lines = []
for buffer in buffers
call add(lines, s:BufferEntryToLine(buffer, filelength))
endfor
call TempWindow('[buffers]', lines)
let b:eclim_buffers = buffers
setlocal modifiable noreadonly
call append(line('$'), ['', '" use ? to view help'])
setlocal nomodifiable readonly
let b:eclim_buffers = buffers
" syntax
set ft=eclim_buffers
hi link BufferActive Special
hi link BufferHidden Comment
syntax match BufferActive /+\?active\s\+\(\[RO\]\)\?/
syntax match BufferHidden /+\?hidden\s\+\(\[RO\]\)\?/
syntax match Comment /^".*/
" mappings
nnoremap <silent> <buffer> <cr> :call <SID>BufferOpen2(g:EclimBuffersDefaultAction)<cr>
nnoremap <silent> <buffer> E :call <SID>BufferOpen2('edit')<cr>
nnoremap <silent> <buffer> S :call <SID>BufferOpen2('split')<cr>
nnoremap <silent> <buffer> T :call <SID>BufferOpen('tablast \| tabnew')<cr>
nnoremap <silent> <buffer> D :call <SID>BufferDelete()<cr>
" assign to buffer var to get around weird vim issue passing list containing
" a string w/ a '<' in it on execution of mapping.
let b:buffers_help = [
\ '<cr> - open buffer with default action',
\ 'E - open with :edit',
\ 'S - open in a new split window',
\ 'T - open in a new tab',
\ 'D - delete the buffer',
\ ]
nnoremap <buffer> <silent> ?
\ :call BufferHelp(b:buffers_help, 'vertical', 40)<cr>
"augroup eclim_buffers
" autocmd!
" autocmd BufAdd,BufWinEnter,BufDelete,BufWinLeave *
" \ call eclim#common#buffers#BuffersUpdate()
" autocmd BufUnload <buffer> autocmd! eclim_buffers
"augroup END
endfunction " }}}
" BufferCompare(buffer1, buffer2) eclim/autoload/eclim/common/buffers.vim {{{2
function! BufferCompare(buffer1, buffer2)
exec 'let attr1 = a:buffer1.' . g:EclimBuffersSort
exec 'let attr2 = a:buffer2.' . g:EclimBuffersSort
let compare = attr1 == attr2 ? 0 : attr1 > attr2 ? 1 : -1
if g:EclimBuffersSortDirection == 'desc'
let compare = 0 - compare
endif
return compare
endfunction " }}}
" s:BufferDelete() {{{2
function! s:BufferDelete()
let line = line('.')
if line > len(b:eclim_buffers)
return
endif
let index = line - 1
setlocal modifiable
setlocal noreadonly
exec line . ',' . line . 'delete _'
setlocal nomodifiable
setlocal readonly
let buffer = b:eclim_buffers[index]
call remove(b:eclim_buffers, index)
exec 'bd ' . buffer.bufnr
endfunction " }}}
" s:BufferEntryToLine(buffer, filelength) eclim/autoload/eclim/common/buffers.vim {{{2
function! s:BufferEntryToLine(buffer, filelength)
let line = ''
let line .= a:buffer.status =~ '+' ? '+' : ' '
let line .= a:buffer.status =~ 'a' ? 'active' : 'hidden'
let line .= a:buffer.status =~ '[-=]' ? ' [RO] ' : ' '
let line .= a:buffer.file
let pad = a:filelength - len(a:buffer.file) + 2
while pad > 0
let line .= ' '
let pad -= 1
endwhile
let line .= a:buffer.dir
return line
endfunction " }}}
" s:BufferOpen(cmd) eclim/autoload/eclim/common/buffers.vim {{{2
function! s:BufferOpen(cmd)
let line = line('.')
if line > len(b:eclim_buffers)
return
endif
let file = bufname(b:eclim_buffers[line - 1].bufnr)
let winnr = b:winnr
close
exec winnr . 'winc w'
call GoToBufferWindowOrOpen(file, a:cmd)
endfunction " }}}
" End Common Buffers: }}}
" Util: {{{1
" Script Variables eclim/autoload/eclim/util.vim {{{2
let s:buffer_write_closing_commands = '^\s*\(' .
\ 'wq\|xa\|' .
\ '\d*w[nN]\|\d*wp\|' .
\ 'ZZ' .
\ '\)'
let s:bourne_shells = ['sh', 'bash', 'dash', 'ksh', 'zsh']
let s:c_shells = ['csh', 'tcsh']
let s:show_current_error_displaying = 0
" }}}
" DelayedCommand(command, [delay]) eclim/autoload/eclim/util.vim {{{2
" Executes a delayed command. Useful in cases where one would expect an
" autocommand event (WinEnter, etc) to fire, but doesn't, or you need a
" command to execute after other autocommands have finished.
" Note: Nesting is not supported. A delayed command cannot be invoke off
" another delayed command.
function! DelayedCommand(command, ...)
let uid = fnamemodify(tempname(), ':t:r')
if &updatetime > 1
exec 'let g:eclim_updatetime_save' . uid . ' = &updatetime'
endif
exec 'let g:eclim_delayed_command' . uid . ' = a:command'
let &updatetime = len(a:000) ? a:000[0] : 1
exec 'augroup delayed_command' . uid
exec 'autocmd CursorHold * ' .
\ ' if exists("g:eclim_updatetime_save' . uid . '") | ' .
\ ' let &updatetime = g:eclim_updatetime_save' . uid . ' | ' .
\ ' unlet g:eclim_updatetime_save' . uid . ' | ' .
\ ' endif | ' .
\ ' exec g:eclim_delayed_command' . uid . ' | ' .
\ ' unlet g:eclim_delayed_command' . uid . ' | ' .
\ ' autocmd! delayed_command' . uid
exec 'augroup END'
endfunction " }}}
" EscapeBufferName(name) eclim/autoload/eclim/util.vim {{{2
" Escapes the supplied buffer name so that it can be safely used by buf*
" functions.
function! EscapeBufferName(name)
let name = a:name
" escaping the space in cygwin could lead to the dos path error message that
" cygwin throws when a dos path is referenced.
if !has('win32unix')
let name = escape(a:name, ' ')
endif
return substitute(name, '\(.\{-}\)\[\(.\{-}\)\]\(.\{-}\)', '\1[[]\2[]]\3', 'g')
endfunction " }}}
" GoToBufferWindow(buf) eclim/autoload/eclim/util.vim {{{2
" Focuses the window containing the supplied buffer name or buffer number.
" Returns 1 if the window was found, 0 otherwise.
function! GoToBufferWindow(buf)
if type(a:buf) == 0
let winnr = bufwinnr(a:buf)
else
let name = EscapeBufferName(a:buf)
let winnr = bufwinnr(bufnr('^' . name))
endif
if winnr != -1
exec winnr . "winc w"
call DelayedCommand('doautocmd WinEnter')
return 1
endif
return 0
endfunction " }}}
" GoToBufferWindowOrOpen(name, cmd) eclim/autoload/eclim/util.vim {{{2
" Gives focus to the window containing the buffer for the supplied file, or if
" none, opens the file using the supplied command.
function! GoToBufferWindowOrOpen(name, cmd)
let name = EscapeBufferName(a:name)
let winnr = bufwinnr(bufnr('^' . name))
if winnr != -1
exec winnr . "winc w"
call DelayedCommand('doautocmd WinEnter')
else
let cmd = a:cmd
" if splitting and the buffer is a unamed empty buffer, then switch to an
" edit.
if cmd == 'split' && expand('%') == '' &&
\ !&modified && line('$') == 1 && getline(1) == ''
let cmd = 'edit'
endif
silent exec cmd . ' ' . escape(Simplify(a:name), ' ')
endif
endfunction " }}}
" GoToBufferWindowRegister(buf) eclim/autoload/eclim/util.vim {{{2
" Registers the autocmd for returning the user to the supplied buffer when the
" current buffer is closed.
function! GoToBufferWindowRegister(buf)
exec 'autocmd BufWinLeave <buffer> ' .
\ 'call GoToBufferWindow("' . escape(a:buf, '\') . '") | ' .
\ 'doautocmd BufEnter'
endfunction " }}}
" Simplify(file) eclim/autoload/eclim/util.vim {{{2
" Simply the supplied file to the shortest valid name.
function! Simplify(file)
let file = a:file
" Don't run simplify on url files, it will screw them up.
if file !~ '://'
let file = simplify(file)
endif
" replace all '\' chars with '/' except those escaping spaces.
let file = substitute(file, '\\\([^[:space:]]\)', '/\1', 'g')
let cwd = substitute(getcwd(), '\', '/', 'g')
if cwd !~ '/$'
let cwd .= '/'
endif
if file =~ '^' . cwd
let file = substitute(file, '^' . cwd, '', '')
endif
return file
endfunction " }}}
" TempWindow(name, lines, [readonly]) eclim/autoload/eclim/util.vim {{{2
" Opens a temp window w/ the given name and contents which is readonly unless
" specified otherwise.
function! TempWindow(name, lines, ...)
let filename = expand('%:p')
let winnr = winnr()
call TempWindowClear(a:name)
let name = EscapeBufferName(a:name)
if bufwinnr(name) == -1
silent! noautocmd exec "botright 10sview " . escape(a:name, ' ')
let b:eclim_temp_window = 1
setlocal nowrap
setlocal winfixheight
setlocal noswapfile
setlocal nobuflisted
setlocal buftype=nofile
setlocal bufhidden=delete
else
exec bufwinnr(name) . "winc w"
endif
setlocal modifiable
setlocal noreadonly
call append(1, a:lines)
retab
silent 1,1delete _
if len(a:000) == 0 || a:000[0]
setlocal nomodified
setlocal nomodifiable
setlocal readonly
endif
silent doautocmd BufEnter
" Store filename and window number so that plugins can use it if necessary.
if filename != expand('%:p')
let b:filename = filename
let b:winnr = winnr
augroup eclim_temp_window
autocmd! BufWinLeave <buffer>
call GoToBufferWindowRegister(b:filename)
augroup END
endif
endfunction " }}}
" TempWindowClear(name) eclim/autoload/eclim/util.vim {{{2
" Clears the contents of the temp window with the given name.
function! TempWindowClear(name)
let name = EscapeBufferName(a:name)
if bufwinnr(name) != -1
let curwinnr = winnr()
exec bufwinnr(name) . "winc w"
setlocal modifiable
setlocal noreadonly
silent 1,$delete _
exec curwinnr . "winc w"
endif
endfunction " }}}
" End Util: }}}
" Eclim Help: {{{1
" BufferHelp(lines, orientation, size) eclim/autoload/eclim/help.vim {{{
" Function to display a help window for the current buffer.
function! BufferHelp(lines, orientation, size)
let orig_bufnr = bufnr('%')
let name = expand('%')
if name =~ '^\W.*\W$'
let name = name[:-2] . ' Help' . name[len(name) - 1]
else
let name .= ' Help'
endif
let bname = EscapeBufferName(name)
let orient = a:orientation == 'vertical' ? 'v' : ''
if bufwinnr(bname) != -1
exec 'bd ' . bufnr(bname)
return
endif
silent! noautocmd exec a:size . orient . "new " . escape(name, ' ')
let b:eclim_temp_window = 1
setlocal nowrap winfixheight
setlocal noswapfile nobuflisted nonumber
setlocal buftype=nofile bufhidden=delete
nnoremap <buffer> <silent> ? :bd<cr>
setlocal modifiable noreadonly
silent 1,$delete _
call append(1, a:lines)
retab
silent 1,1delete _
if len(a:000) == 0 || a:000[0]
setlocal nomodified nomodifiable readonly
endif
let help_bufnr = bufnr('%')
augroup eclim_help_buffer
autocmd! BufWinLeave <buffer>
autocmd BufWinLeave <buffer> nested autocmd! eclim_help_buffer * <buffer>
exec 'autocmd BufWinLeave <buffer> nested ' .
\ 'autocmd! eclim_help_buffer * <buffer=' . orig_bufnr . '>'
exec 'autocmd! BufWinLeave <buffer=' . orig_bufnr . '>'
exec 'autocmd BufWinLeave <buffer=' . orig_bufnr . '> nested bd ' . help_bufnr
augroup END
return help_bufnr
endfunction " }}}
" }}}
" Gryfs Mods: {{{
" s:BufferOpen2(cmd) (gryf) {{{2
function! s:BufferOpen2(cmd)
let line = line('.')
if line > len(b:eclim_buffers)
return
endif
let bufnr = b:eclim_buffers[line - 1].bufnr
let winnr = b:winnr
close
exec winnr . 'winc w'
call s:GoToBufferWindowOrOpen2(bufnr, a:cmd)
endfunction " }}}
" GoToBufferWindowOrOpen2(nr, cmd) (gryf) {{{2
" modified function GoToBufferWindowOrOpen. instead of buffer name it accepts
" buffer number.
function! s:GoToBufferWindowOrOpen2(nr, cmd)
let winnr = bufwinnr(a:nr)
if winnr != -1
exec winnr . "winc w"
call DelayedCommand('doautocmd WinEnter')
else
if a:cmd == 'edit'
silent exec 'buffer ' . a:nr
elseif a:cmd == 'split'
silent exec 'sbuffer ' . a:nr
endif
endif
endfunction " }}}
" End Gryfs Mods: }}}
" vim:ft=vim:fdm=marker

File diff suppressed because it is too large Load Diff

View File

@@ -1,38 +0,0 @@
" ---------------------------------------------------------------------
" getscriptPlugin.vim
" Author: Charles E. Campbell, Jr.
" Date: Jan 07, 2008
" Installing: :help glvs-install
" Usage: :help glvs
"
" GetLatestVimScripts: 642 1 :AutoInstall: getscript.vim
"
" (Rom 15:11 WEB) Again, "Praise the Lord, all you Gentiles! Let
" all the peoples praise Him."
" ---------------------------------------------------------------------
" Initialization: {{{1
" if you're sourcing this file, surely you can't be
" expecting vim to be in its vi-compatible mode
if &cp || exists("g:loaded_getscriptPlugin")
if &verbose
echo "GetLatestVimScripts is not vi-compatible; not loaded (you need to set nocp)"
endif
finish
endif
let g:loaded_getscriptPlugin = "v29"
let s:keepcpo = &cpo
set cpo&vim
" ---------------------------------------------------------------------
" Public Interface: {{{1
com! -nargs=0 GetLatestVimScripts call getscript#GetLatestVimScripts()
com! -nargs=0 GetScripts call getscript#GetLatestVimScripts()
silent! com -nargs=0 GLVS call getscript#GetLatestVimScripts()
" ---------------------------------------------------------------------
" Restore Options: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
" ---------------------------------------------------------------------
" vim: ts=8 sts=2 fdm=marker nowrap

View File

@@ -21,12 +21,13 @@
" along with this program. If not, see <http://www.gnu.org/licenses/>.
"
" }}}
" eclim version: 1.6.0
"if exists('g:taglisttoo_loaded') ||
" \ (exists('g:taglisttoo_disabled') && g:taglisttoo_disabled)
" finish
"endif
"let g:taglisttoo_loaded = 1
if exists('g:taglisttoo_loaded') ||
\ (exists('g:taglisttoo_disabled') && g:taglisttoo_disabled)
finish
endif
let g:taglisttoo_loaded = 1
" Global Variables {{{
@@ -34,6 +35,21 @@ if !exists("g:TaglistEnabled")
let g:TaglistEnabled = 1
endif
" always set the taglist title since eclim references it in a few places.
if !exists('g:TagList_title')
let g:TagList_title = "__Tag_List__"
endif
if !g:TaglistEnabled
finish
endif
" disable if user has taglist installed on windows since we can't hook into
" taglist to fix the windows path separators to be java compatible.
if exists('loaded_taglist') && (has('win32') || has('win64') || has('win32unix'))
finish
endif
if !exists('g:Tlist_Ctags_Cmd')
if executable('exuberant-ctags')
let g:Tlist_Ctags_Cmd = 'exuberant-ctags'
@@ -46,11 +62,6 @@ if !exists('g:Tlist_Ctags_Cmd')
endif
endif
" always set the taglist title since eclim references it in a few places.
if !exists('g:TagList_title')
let g:TagList_title = "__Tag_List__"
endif
" no ctags found, no need to continue.
if !exists('g:Tlist_Ctags_Cmd')
finish
@@ -526,6 +537,18 @@ let s:tlist_def_html_settings = {
\ }
\ }
" java language
let s:tlist_format_java = 'FormatJava'
let s:tlist_def_java_settings = {
\ 'lang': 'java', 'tags': {
\ 'p': 'package',
\ 'c': 'class',
\ 'i': 'interface',
\ 'f': 'field',
\ 'm': 'method'
\ }
\ }
let s:tlist_format_javascript = 'FormatJavascript'
let s:tlist_def_javascript_settings = {
\ 'lang': 'javascript', 'tags': {
@@ -715,7 +738,8 @@ function! s:AutoOpen()
let buf_num = winbufnr(i)
while buf_num != -1
let filename = fnamemodify(bufname(buf_num), ':p')
if s:FileSupported(filename, getbufvar(buf_num, '&filetype'))
if !getbufvar(buf_num, '&diff') &&
\ s:FileSupported(filename, getbufvar(buf_num, '&filetype'))
let open_window = 1
break
endif
@@ -758,7 +782,7 @@ function! s:Taglist(...)
endif
if action == -1 || action == 1
call s:ProcessTags()
call s:ProcessTags(1)
call s:StartAutocmds()
augroup taglisttoo
@@ -791,13 +815,17 @@ function! s:Restore()
\ 'endif')
endfunction " }}}
" s:StartAutocmds() {{{
" s:StartAutocmds() eclim/autoload/eclim/taglist/taglisttoo.vim {{{
function! s:StartAutocmds()
augroup taglisttoo_file
autocmd!
autocmd BufEnter,BufWritePost *
autocmd BufEnter *
\ if bufwinnr(g:TagList_title) != -1 |
\ call s:ProcessTags() |
\ call s:ProcessTags(0) |
\ endif
autocmd BufWritePost *
\ if bufwinnr(g:TagList_title) != -1 |
\ call s:ProcessTags(1) |
\ endif
" bit of a hack to re-process tags if the filetype changes after the tags
" have been processed.
@@ -805,7 +833,7 @@ function! s:StartAutocmds()
\ if exists('b:ft') |
\ if b:ft != &ft |
\ if bufwinnr(g:TagList_title) != -1 |
\ call s:ProcessTags() |
\ call s:ProcessTags(1) |
\ endif |
\ endif |
\ else |
@@ -818,170 +846,20 @@ function! s:StartAutocmds()
augroup END
endfunction " }}}
" s:StopAutocmds() {{{
" s:StopAutocmds() eclim/autoload/eclim/taglist/taglisttoo.vim {{{
function! s:StopAutocmds()
augroup taglisttoo_file
autocmd!
augroup END
endfunction " }}}
" s:ProcessTags() {{{
function! s:ProcessTags()
" on insert completion prevent vim's jumping back and forth from the
" completion preview window from triggering a re-processing of tags
if pumvisible()
return
endif
let filename = expand('%:p')
if filename =~ s:taglisttoo_ignore || filename == ''
return
endif
let filewin = winnr()
let tags = []
if s:FileSupported(expand('%:p'), &ft)
if exists('g:tlist_{&ft}_settings')
let settings = g:tlist_{&ft}_settings
let types = join(keys(settings.tags), '')
else
let settings = s:tlist_def_{&ft}_settings
let types = join(keys(settings.tags), '')
endif
let file = substitute(expand('%:p'), '\', '/', 'g')
" support generated file contents (like viewing a .class file via jad)
let tempfile = ''
if !filereadable(file) || &buftype == 'nofile'
let tempfile = g:EclimTempDir . '/' . fnamemodify(file, ':t')
if tolower(file) != tolower(tempfile)
let tempfile = escape(tempfile, ' ')
exec 'write! ' . tempfile
let file = tempfile
endif
endif
try
let command = g:Tlist_Ctags_Cmd_Ctags
"if eclim#EclimAvailable() && !exists('g:EclimDisabled')
" let port = eclim#client#nailgun#GetNgPort()
" let command = substitute(g:Tlist_Ctags_Cmd_Eclim, '<port>', port, '')
"endif
let command .= ' -f - --format=2 --excmd=pattern ' .
\ '--fields=nks --sort=no --language-force=<lang> ' .
\ '--<lang>-types=<types> "<file>"'
let command = substitute(command, '<lang>', settings.lang, 'g')
let command = substitute(command, '<types>', types, 'g')
let command = substitute(command, '<file>', file, '')
if (has('win32') || has('win64')) && command =~ '^"'
let command .= ' "'
endif
let response = System(command)
finally
if tempfile != ''
call delete(tempfile)
endif
endtry
if v:shell_error
call EchoError('taglist failed with error code: ' . v:shell_error)
return
endif
let results = split(response, '\n')
if len(response) == 1 && response[0] == '0'
return
endif
while len(results) && results[0] =~ 'ctags.*: Warning:'
call remove(results, 0)
endwhile
let truncated = 0
if len(results)
" for some reason, vim may truncate the output of system, leading to only
" a partial taglist.
let values = s:ParseOutputLine(results[-1])
if len(values) < 5
let truncated = 1
endif
if g:Tlist_Sort_Type == 'name'
call sort(results)
endif
for result in results
let values = s:ParseOutputLine(result)
" filter false positives found in comments.
if values[-1] =~ 'line:[0-9]\+'
exec 'let lnum = ' . substitute(values[-1], 'line:\([0-9]\+\).*', '\1', '')
let line = getline(lnum)
let col = len(line) - len(substitute(line, '^\s*', '', '')) + 1
if synIDattr(synID(lnum, col, 1), "name") =~ '\([Cc]omment\|[Ss]tring\)'
continue
endif
endif
" exit if we run into apparent bug in vim that truncates the response
" from system()
if len(values) < 5
break
endif
call add(tags, values)
endfor
endif
if exists('s:tlist_format_{&ft}')
exec 'call s:Window(settings.tags, tags, ' .
\ s:tlist_format_{&ft} . '(settings.tags, tags))'
else
call s:Window(settings.tags, tags, s:FormatDefault(settings.tags, tags))
endif
" if vim truncated the output, then add a note in the taglist indicating
" the the list has been truncated.
if truncated
setlocal modifiable
call append(line('$'), '')
call append(line('$'), 'Warning: taglist truncated.')
setlocal nomodifiable
endif
" if the file buffer is no longer in the same window it was, then find its
" new location. Occurs when taglist first opens.
if winbufnr(filewin) != bufnr(filename)
let filewin = bufwinnr(filename)
endif
if filewin != -1
exec filewin . 'winc w'
endif
else
" if the file isn't supported, then don't open the taglist window if it
" isn't open already.
let winnum = bufwinnr(g:TagList_title)
if winnum != -1
call s:Window({}, tags, [[],[]])
winc p
endif
endif
call s:ShowCurrentTag()
endfunction " }}}
" s:CloseTaglist() {{{
" s:CloseTaglist() eclim/autoload/eclim/taglist/taglisttoo.vim {{{
function! s:CloseTaglist()
close
call s:Cleanup()
endfunction " }}}
" s:Cleanup() {{{
" s:Cleanup() eclim/autoload/eclim/taglist/taglisttoo.vim {{{
function! s:Cleanup()
augroup taglisttoo_file
autocmd!
@@ -992,14 +870,24 @@ function! s:Cleanup()
augroup END
endfunction " }}}
" s:ProcessTags() {{{
function! s:ProcessTags()
" s:ProcessTags(on_open_or_write) eclim/autoload/eclim/taglist/taglisttoo.vim {{{
function! s:ProcessTags(on_open_or_write)
" on insert completion prevent vim's jumping back and forth from the
" completion preview window from triggering a re-processing of tags
if pumvisible()
return
endif
" if we are entering a buffer whose taglist list is already loaded, then
" don't do anything.
if !a:on_open_or_write
let bufnr = bufnr(g:TagList_title)
let filebuf = getbufvar(bufnr, 'taglisttoo_file_bufnr')
if filebuf == bufnr('%')
return
endif
endif
let filename = expand('%:p')
if filename =~ s:taglisttoo_ignore || filename == ''
return
@@ -1031,10 +919,6 @@ function! s:ProcessTags()
try
let command = g:Tlist_Ctags_Cmd_Ctags
"if eclim#EclimAvailable() && !exists('g:EclimDisabled')
" let port = eclim#client#nailgun#GetNgPort()
" let command = substitute(g:Tlist_Ctags_Cmd_Eclim, '<port>', port, '')
"endif
let command .= ' -f - --format=2 --excmd=pattern ' .
\ '--fields=nks --sort=no --language-force=<lang> ' .
@@ -1077,10 +961,6 @@ function! s:ProcessTags()
let truncated = 1
endif
if g:Tlist_Sort_Type == 'name'
call sort(results)
endif
for result in results
let values = s:ParseOutputLine(result)
@@ -1108,6 +988,10 @@ function! s:ProcessTags()
exec 'call s:Window(settings.tags, tags, ' .
\ s:tlist_format_{&ft} . '(settings.tags, tags))'
else
if g:Tlist_Sort_Type == 'name'
call sort(tags)
endif
call s:Window(settings.tags, tags, s:FormatDefault(settings.tags, tags))
endif
@@ -1142,7 +1026,7 @@ function! s:ProcessTags()
call s:ShowCurrentTag()
endfunction " }}}
" s:ParseOutputLine(line) {{{
" s:ParseOutputLine(line) eclim/autoload/eclim/taglist/taglisttoo.vim {{{
function! s:ParseOutputLine(line)
let pre = substitute(a:line, '\(.\{-}\)\t\/\^.*', '\1', '')
let pattern = substitute(a:line, '.\{-}\(\/\^.*\$\/;"\).*', '\1', '')
@@ -1150,7 +1034,7 @@ function! s:ParseOutputLine(line)
return split(pre, '\t') + [pattern] + split(post, '\t')
endfunction " }}}
" s:FormatDefault(types, tags) {{{
" s:FormatDefault(types, tags) eclim/autoload/eclim/taglist/taglisttoo.vim {{{
" All format functions must return a two element list containing:
" result[0] - A list of length len(result[1]) where each value specifies the
" tag index such that result[0][line('.') - 1] == tag index for
@@ -1173,7 +1057,7 @@ function! s:FormatDefault(types, tags)
return [lines, content]
endfunction " }}}
" s:JumpToTag() {{{
" s:JumpToTag() eclim/autoload/eclim/taglist/taglisttoo.vim {{{
function! s:JumpToTag()
if line('.') > len(b:taglisttoo_content[0])
return
@@ -1203,7 +1087,7 @@ function! s:JumpToTag()
" account for my plugin which removes trailing spaces from the file
let pattern = escape(pattern, '.~*[]')
let pattern = substitute(pattern, '\s\+\$$', '\s*$', '')
let pattern = substitute(pattern, '\s\+\$$', '\\s*$', '')
if getline(lnum) =~ pattern
mark '
@@ -1248,7 +1132,7 @@ function! s:JumpToTag()
endif
endfunction " }}}
" s:Window(types, tags, content) {{{
" s:Window(types, tags, content) eclim/autoload/eclim/taglist/taglisttoo.vim {{{
function! s:Window(types, tags, content)
let filename = expand('%:t')
let file_bufnr = bufnr('%')
@@ -1309,7 +1193,7 @@ function! s:Window(types, tags, content)
let b:taglisttoo_file_bufnr = file_bufnr
endfunction " }}}
" s:ShowCurrentTag() {{{
" s:ShowCurrentTag() eclim/autoload/eclim/taglist/taglisttoo.vim {{{
function! s:ShowCurrentTag()
if s:FileSupported(expand('%:p'), &ft) && bufwinnr(g:TagList_title) != -1
let tags = getbufvar(g:TagList_title, 'taglisttoo_tags')
@@ -1350,7 +1234,7 @@ function! s:ShowCurrentTag()
endif
endfunction " }}}
" s:FileSupported(filename, ftype) {{{
" s:FileSupported(filename, ftype) eclim/autoload/eclim/taglist/taglisttoo.vim {{{
" Check whether tag listing is supported for the specified file
function! s:FileSupported(filename, ftype)
" Skip buffers with no names, buffers with filetype not set, and vimballs
@@ -1380,7 +1264,7 @@ function! s:FileSupported(filename, ftype)
return 1
endfunction " }}}
" s:GetTagLineNumber(tag) {{{
" s:GetTagLineNumber(tag) eclim/autoload/eclim/taglist/taglisttoo.vim {{{
function! s:GetTagLineNumber(tag)
if len(a:tag) > 4
return substitute(a:tag[4], '.*:\(.*\)', '\1', '')
@@ -1389,6 +1273,68 @@ function! s:GetTagLineNumber(tag)
endfunction " }}}
" FormatJava(types, tags) eclim/autoload/eclim/taglist/lang/java.vim {{{
function! FormatJava(types, tags)
let lines = []
let content = []
call add(content, expand('%:t'))
call add(lines, -1)
let package = filter(copy(a:tags), 'v:val[3] == "p"')
call s:FormatType(
\ a:tags, a:types['p'], package, lines, content, "\t")
let classes = filter(copy(a:tags), 'v:val[3] == "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:])
endif
for class in classes
call add(content, "")
call add(lines, -1)
let visibility = s:GetVisibility(class)
call add(content, "\t" . visibility . a:types['c'] . ' ' . class[0])
call add(lines, index(a:tags, class))
let fields = filter(copy(a:tags),
\ 'v:val[3] == "f" && len(v:val) > 5 && v:val[5] =~ "class:.*\\<" . class[0] . "$"')
call s:FormatType(
\ a:tags, a:types['f'], fields, lines, content, "\t\t")
let methods = filter(copy(a:tags),
\ 'v:val[3] == "m" && len(v:val) > 5 && v:val[5] =~ "class:.*\\<" . class[0] . "$"')
call s:FormatType(
\ a:tags, a:types['m'], methods, lines, content, "\t\t")
endfor
let interfaces = filter(copy(a:tags), 'v:val[3] == "i"')
if g:Tlist_Sort_Type == 'name'
call sort(interfaces)
endif
for interface in interfaces
call add(content, "")
call add(lines, -1)
let visibility = s:GetVisibility(interface)
call add(content, "\t" . visibility . a:types['i'] . ' ' . interface[0])
call add(lines, index(a:tags, interface))
let fields = filter(copy(a:tags),
\ 'v:val[3] == "f" && len(v:val) > 5 && v:val[5] =~ "interface:.*\\<" . interface[0] . "$"')
call s:FormatType(
\ a:tags, a:types['f'], fields, lines, content, "\t\t")
let methods = filter(copy(a:tags),
\ 'v:val[3] == "m" && len(v:val) > 5 && v:val[5] =~ "interface:.*\\<" . interface[0] . "$"')
call s:FormatType(
\ a:tags, a:types['m'], methods, lines, content, "\t\t")
endfor
return [lines, content]
endfunction " }}}
" FormatJavascript(types, tags) eclim/autoload/eclim/taglist/lang/javascript.vim {{{
function! FormatJavascript(types, tags)
let pos = getpos('.')
@@ -1415,13 +1361,24 @@ function! FormatJavascript(types, tags)
let object_end = searchpair('{', '', '}', 'W', 's:SkipComments()')
let methods = []
let indexes = []
let index = 0
for fct in members
if len(fct) > 3
exec 'let fct_line = ' . split(fct[4], ':')[1]
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 = []
@@ -1434,6 +1391,8 @@ function! FormatJavascript(types, tags)
call add(indexes, index)
elseif fct_line == object_start
call add(indexes, index)
elseif fct_line > object_end
break
endif
endif
let index += 1
@@ -1451,7 +1410,6 @@ function! FormatJavascript(types, tags)
call filter(parent_object.methods, 'index(methods, v:val) == -1')
endif
let object_bounds[string(object)] = [object_start, object_end]
call sort(methods)
call add(object_contents, {'object': object, 'methods': methods})
endif
endfor
@@ -1463,6 +1421,10 @@ function! FormatJavascript(types, tags)
\ a:tags, a:types['f'], functions, lines, content, "\t")
endif
if g:Tlist_Sort_Type == 'name'
call sort(object_contents, function('s:ObjectComparator'))
endif
for object_content in object_contents
call add(content, "")
call add(lines, -1)
@@ -1478,14 +1440,21 @@ function! FormatJavascript(types, tags)
return [lines, content]
endfunction " }}}
" s:ObjectComparator(o1, o2) eclim/autoload/eclim/taglist/lang/javascript.vim {{{
function s:ObjectComparator(o1, o2)
let n1 = a:o1['object'][0]
let n2 = a:o2['object'][0]
return n1 == n2 ? 0 : n1 > n2 ? 1 : -1
endfunction " }}}
" s:SkipComments() eclim/autoload/eclim/taglist/lang/javascript.vim {{{
function! s:SkipComments()
function s:SkipComments()
let synname = synIDattr(synID(line('.'), col('.'), 1), "name")
return synname =~ '\([Cc]omment\|[Ss]tring\)'
endfunction " }}}
" s:GetParentObject(objects, bounds, start, end) eclim/autoload/eclim/taglist/lang/javascript.vim {{{
function! s:GetParentObject(objects, bounds, start, end)
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
@@ -1509,6 +1478,10 @@ endfunction " }}}
" indent: The indentation to use on the display (string).
function! s:FormatType(tags, type, values, lines, content, indent)
if len(a:values) > 0
if g:Tlist_Sort_Type == 'name'
call sort(a:values)
endif
call add(a:content, a:indent . a:type)
call add(a:lines, -1)
@@ -1556,6 +1529,9 @@ function! FormatPhp(types, tags)
let class_contents = []
let classes = filter(copy(a:tags), 'v:val[3] == "c"')
if g:Tlist_Sort_Type == 'name'
call sort(classes)
endif
for class in classes
exec 'let object_start = ' . split(class[4], ':')[1]
call cursor(object_start, 1)
@@ -1585,6 +1561,9 @@ function! FormatPhp(types, tags)
let interface_contents = []
let interfaces = filter(copy(a:tags), 'v:val[3] == "i"')
if g:Tlist_Sort_Type == 'name'
call sort(interfaces)
endif
for interface in interfaces
exec 'let object_start = ' . split(interface[4], ':')[1]
call cursor(object_start, 1)
@@ -1657,6 +1636,10 @@ function! FormatPython(types, tags)
\ a:tags, a:types['f'], functions, lines, content, "\t")
let classes = filter(copy(a:tags), 'len(v:val) > 3 && v:val[3] == "c"')
if g:Tlist_Sort_Type == 'name'
call sort(classes)
endif
for class in classes
call add(content, "")
call add(lines, -1)
@@ -1665,10 +1648,8 @@ function! FormatPython(types, tags)
let members = filter(copy(a:tags),
\ 'len(v:val) > 5 && v:val[3] == "m" && v:val[5] == "class:" . class[0]')
for member in members
call add(content, "\t\t" . member[0])
call add(lines, index(a:tags, member))
endfor
call s:FormatType(
\ a:tags, a:types['m'], members, lines, content, "\t\t")
endfor
return [lines, content]
@@ -1871,13 +1852,25 @@ function! s:PreventCloseOnBufferDelete()
endif
endfor
if winnr('$') == numtoolwindows
let index = 1
let numtempwindows = 0
let tempbuffers = []
while index <= winnr('$')
let buf = winbufnr(index)
if buf != -1 && getbufvar(buf, 'eclim_temp_window') != ''
call add(tempbuffers, buf)
endif
let index += 1
endwhile
if winnr('$') == (numtoolwindows + len(tempbuffers))
let toolbuf = bufnr('%')
if g:VerticalToolWindowSide == 'right'
vertical topleft new
else
vertical botright new
endif
setlocal noreadonly modifiable
let winnum = winnr()
exec 'let bufnr = ' . expand('<abuf>')
@@ -1921,6 +1914,30 @@ function! s:PreventCloseOnBufferDelete()
exec bufwinnr(toolbuf) . 'winc w'
exec 'vertical resize ' . g:VerticalToolWindowWidth
" fix the position of the temp windows
if len(tempbuffers) > 0
for buf in tempbuffers
" open the buffer in the temp window position
botright 10new
exec 'buffer ' . buf
setlocal winfixheight
" close the old window
let winnr = winnr()
let index = 1
while index <= winnr('$')
if winbufnr(index) == buf && index != winnr
exec index . 'winc w'
close
winc p
break
endif
let index += 1
endwhile
endfor
endif
exec winnum . 'winc w'
endif
endfunction " }}}

View File

@@ -1,375 +0,0 @@
"------------------------------------------------------------------------------
" Name Of File: tasklist.vim
"
" Description: Vim plugin to search for a list of tokens and display a
" window with matches.
"
" Author: Juan Frias (juandfrias at gmail.com)
"
" Last Change: 2009 Apr 11
" Version: 1.0.1
"
" Copyright: Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this header
" is included with it.
"
" This script is to be distributed freely in the hope that it
" will be useful, but is provided 'as is' and without warranties
" as to performance of merchantability or any other warranties
" whether expressed or implied. Because of the various hardware
" and software environments into which this script may be put,
" no warranty of fitness for a particular purpose is offered.
"
" GOOD DATA PROCESSING PROCEDURE DICTATES THAT ANY SCRIPT BE
" THOROUGHLY TESTED WITH NON-CRITICAL DATA BEFORE RELYING ON IT.
"
" THE USER MUST ASSUME THE ENTIRE RISK OF USING THE SCRIPT.
"
" The author does not retain any liability on any damage caused
" through the use of this script.
"
" Install: 1. Read the section titled 'Options'
" 2. Setup any variables need in your vimrc file
" 3. Copy 'tasklist.vim' to your plugin directory.
"
" Mapped Keys: <Leader>t Display list.
"
" Usage: Start the script with the mapped key, a new window appears
" with the matches found, moving around the window will also
" update the position of the current document.
"
" The following keys are mapped to the results window:
"
" q - Quit, and restore original cursor position.
"
" e - Exit, and keep results window open note that
" movements on the result window will no longer be
" updated.
"
" <cr> - Quit and place the cursor on the selected line.
"
" Aknowledgments: Many thanks to Zhang Shuhan for taking the time to beta
" test and suggest many of the improvements and features
" found in the script. I don't think I would have
" implemented it wihout his help. Thanks!
"
"------------------------------------------------------------------------------
" Please send me any bugs you find, so I can keep the script up to date.
"------------------------------------------------------------------------------
" History: {{{1
"------------------------------------------------------------------------------
"
" 1.00 Initial version.
"
" User Options: {{{1
"------------------------------------------------------------------------------
"
" <Leader>t
" This is the default key map to view the task list.
" to overwrite use something like:
" map <leader>v <Plug>TaskList
" in your vimrc file
"
" g:tlWindowPosition
" This is specifies the position of the window to be opened. By
" default it will open at on top. To overwrite use:
" let g:tlWindowPosition = 1
" in your vimrc file, options are as follows:
" 0 = Open on top
" 1 = Open on the bottom
"
" g:tlTokenList
" This is the list of tokens to search for default is
" 'FIXME TODO XXX'. The results are groupped and displayed in the
" order that they appear. to overwrite use:
" let g:tlTokenList = ['TOKEN1', 'TOKEN2', 'TOKEN3']
" in your vimrc file
"
" g:tlRememberPosition
" If this is set to 1 then the script will try to get back to the
" position where it last was closed. By default it will find the line
" closest to the current cursor position.
" to overwrite use:
" let g:tlRememberPosition = 1
" in your vimrc file
"
" Global variables: {{{1
"------------------------------------------------------------------------------
" Load script once
"------------------------------------------------------------------------------
if exists("g:loaded_tasklist") || &cp
finish
endif
let g:loaded_tasklist = 1
" Set where the window opens
"------------------------------------------------------------------------------
if !exists('g:tlWindowPosition')
" 0 = Open at top
let g:tlWindowPosition = 0
endif
" Set the token list
"------------------------------------------------------------------------------
if !exists('g:tlTokenList')
" default list of tokens
let g:tlTokenList = ["FIXME", "TODO", "XXX"]
endif
" Remember position
"------------------------------------------------------------------------------
if !exists('g:tlRememberPosition')
" 0 = Donot remember, find closest match
let g:tlRememberPosition = 0
endif
" Script variables: {{{1
"------------------------------------------------------------------------------
" Function: Open Window {{{1
"--------------------------------------------------------------------------
function! s:OpenWindow(buffnr, lineno)
" Open results window and place items there.
if g:tlWindowPosition == 0
execute 'sp -TaskList_'.a:buffnr.'-'
else
execute 'botright sp -TaskList_'.a:buffnr.'-'
endif
let b:original_buffnr = a:buffnr
let b:original_line = a:lineno
set noswapfile
set modifiable
normal! "zPGddgg
set fde=getline(v:lnum)[0]=='L'
set foldmethod=expr
set foldlevel=0
normal! zR
" Resize line if too big.
let l:hits = line("$")
if l:hits < winheight(0)
sil! exe "resize ".l:hits
endif
" Clean up.
let @z = ""
set nomodified
endfunction
" Function: Search file {{{1
"--------------------------------------------------------------------------
function! s:SearchFile(hits, word)
" Search at the beginning and keep adding them to the register
let l:match_count = 0
normal! gg0
let l:max = strlen(line('$'))
let l:last_match = -1
let l:div = 0
while search(a:word, "Wc") > 0
let l:curr_line = line('.')
if l:last_match == l:curr_line
if l:curr_line == line('$')
break
endif
normal! j0
continue
endif
let l:last_match = l:curr_line
if foldlevel(l:curr_line) != 0
normal! 99zo
endif
if l:div == 0
if a:hits != 0
let @z = @z."\n"
endif
let l:div = 1
endif
normal! 0
let l:lineno = ' '.l:curr_line
let @z = @z.'Ln '.strpart(l:lineno, strlen(l:lineno) - l:max).': '
let l:text = getline(".")
let @z = @z.strpart(l:text, stridx(l:text, a:word))
let @z = @z."\n"
normal! $
let l:match_count = l:match_count + 1
endwhile
return l:match_count
endfunction
" Function: Get line number {{{1
"--------------------------------------------------------------------------
function! s:LineNumber()
let l:text = getline(".")
if strpart(l:text, 0, 5) == "File:"
return 0
endif
if strlen(l:text) == 0
return -1
endif
let l:num = matchstr(l:text, '[0-9]\+')
if l:num == ''
return -1
endif
return l:num
endfunction
" Function: Update document position {{{1
"--------------------------------------------------------------------------
function! s:UpdateDoc()
let l:line_hit = <sid>LineNumber()
match none
if l:line_hit == -1
redraw
return
endif
let l:buffnr = b:original_buffnr
exe 'match Search /\%'.line(".").'l.*/'
if line(".") < (line("$") - (winheight(0) / 2)) + 1
normal! zz
endif
execute bufwinnr(l:buffnr)." wincmd w"
match none
if l:line_hit == 0
normal! 1G
else
exe "normal! ".l:line_hit."Gzz"
exe 'match Search /\%'.line(".").'l.*/'
endif
execute bufwinnr('-TaskList_'.l:buffnr.'-')." wincmd w"
redraw
endfunction
" Function: Clean up on exit {{{1
"--------------------------------------------------------------------------
function! s:Exit(key)
call <sid>UpdateDoc()
match none
let l:original_line = b:original_line
let l:last_position = line('.')
if a:key == -1
nunmap <buffer> e
nunmap <buffer> q
nunmap <buffer> <cr>
execute bufwinnr(b:original_buffnr)." wincmd w"
else
bd!
endif
let b:last_position = l:last_position
if a:key == 0
exe "normal! ".l:original_line."G"
endif
match none
normal! zz
execute "set updatetime=".s:old_updatetime
endfunction
" Function: Check for screen update {{{1
"--------------------------------------------------------------------------
function! s:CheckForUpdate()
if stridx(expand("%:t"), '-TaskList_') == -1
return
endif
if b:selected_line != line(".")
call <sid>UpdateDoc()
let b:selected_line = line(".")
endif
endfunction
" Function: Start the search. {{{1
"--------------------------------------------------------------------------
function! s:TaskList()
let l:original_buffnr = bufnr('%')
let l:original_line = line(".")
" last position
if !exists('b:last_position')
let b:last_position = 1
endif
let l:last_position = b:last_position
" get file name
let @z = "File:".expand("%:p")."\n\n"
" search file
let l:index = 0
let l:count = 0
let l:hits = 0
while l:index < len(g:tlTokenList)
let l:search_word = g:tlTokenList[l:index]
let l:hits = s:SearchFile(l:hits, l:search_word)
let l:count = l:count + l:hits
let l:index = l:index + 1
endwhile
" Make sure we at least have one hit.
if l:count == 0
echohl Search
echo "tasklist.vim: No task information found."
echohl None
execute 'normal! '.l:original_line.'G'
return
endif
" display window
call s:OpenWindow(l:original_buffnr, l:original_line)
" restore the cursor position
if g:tlRememberPosition != 0
exec 'normal! '.l:last_position.'G'
else
normal! gg
endif
" Map exit keys
nnoremap <buffer> <silent> q :call <sid>Exit(0)<cr>
nnoremap <buffer> <silent> <cr> :call <sid>Exit(1)<cr>
nnoremap <buffer> <silent> e :call <sid>Exit(-1)<cr>
" Setup syntax highlight {{{
syntax match tasklistFileDivider /^File:.*$/
syntax match tasklistLineNumber /^Ln\s\+\d\+:/
highlight def link tasklistFileDivider Title
highlight def link tasklistLineNumber LineNr
highlight def link tasklistSearchWord Search
" }}}
" Save globals and change updatetime
let b:selected_line = line(".")
let s:old_updatetime = &updatetime
set updatetime=350
" update the doc and hook the CheckForUpdate function.
call <sid>UpdateDoc()
au! CursorHold <buffer> nested call <sid>CheckForUpdate()
endfunction
"}}}
" Command
command! TaskList call s:TaskList()
" Default key map
if !hasmapto('<Plug>TaskList')
map <unique> <Leader>T <Plug>TaskList
endif
" Key map to Command
nnoremap <unique> <script> <Plug>TaskList :TaskList<CR>
" vim:fdm=marker:tw=75:ff=unix:

View File

@@ -239,7 +239,7 @@ endfunction
" Function: s:bzrFunctions.Status(argList) {{{2
function! s:bzrFunctions.Status(argList)
let options = ['-S']
if len(a:argList) == 0
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})

View File

@@ -469,7 +469,7 @@ function! s:GenerateResultBufferName(command, originalBuffer, vcsType, statusTex
let bufferName .= ' ' . fileName
let counter = 0
let versionedBufferName = bufferName
while buflisted(versionedBufferName)
while bufexists(versionedBufferName)
let counter += 1
let versionedBufferName = bufferName . ' (' . counter . ')'
endwhile
@@ -489,7 +489,7 @@ function! s:GenerateResultBufferNameWithExtension(command, originalBuffer, vcsTy
let bufferName .= ' ' . fileName . VCSCommandGetOption('VCSCommandResultBufferNameExtension', '.vcs')
let counter = 0
let versionedBufferName = bufferName
while buflisted(versionedBufferName)
while bufexists(versionedBufferName)
let counter += 1
let versionedBufferName = '(' . counter . ') ' . bufferName
endwhile

View File

@@ -128,11 +128,11 @@ endfunction
" Function: s:gitFunctions.Commit(argList) {{{2
function! s:gitFunctions.Commit(argList)
let resultBuffer = s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
if resultBuffer == 0
try
return s:DoCommand('commit -F "' . a:argList[0] . '"', 'commit', '', {})
catch /\m^Version control command failed.*nothing\%( added\)\? to commit/
echomsg 'No commit needed.'
endif
return resultBuffer
endtry
endfunction
" Function: s:gitFunctions.Delete() {{{2

View File

@@ -105,7 +105,7 @@ endfunction
" Function: s:hgFunctions.Add() {{{2
function! s:hgFunctions.Add(argList)
return s:DoCommand(join(['add'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
return s:DoCommand(join(['add -v'] + a:argList, ' '), 'add', join(a:argList, ' '), {})
endfunction
" Function: s:hgFunctions.Annotate(argList) {{{2
@@ -132,10 +132,7 @@ endfunction
" Function: s:hgFunctions.Commit(argList) {{{2
function! s:hgFunctions.Commit(argList)
let resultBuffer = s:DoCommand('commit -l "' . a:argList[0] . '"', 'commit', '', {})
if resultBuffer == 0
echomsg 'No commit needed.'
endif
return s:DoCommand('commit -v -l "' . a:argList[0] . '"', 'commit', '', {})
endfunction
" Function: s:hgFunctions.Delete() {{{2
@@ -252,8 +249,8 @@ endfunction
" Function: s:hgFunctions.Status(argList) {{{2
function! s:hgFunctions.Status(argList)
let options = ['-u', '-v']
if len(a:argList) == 0
let options = ['-A', '-v']
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})

View File

@@ -237,7 +237,7 @@ endfunction
" Function: s:svkFunctions.Status(argList) {{{2
function! s:svkFunctions.Status(argList)
let options = ['-v']
if len(a:argList) == 0
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status'] + options, ' '), 'status', join(options, ' '), {})

View File

@@ -260,7 +260,7 @@ endfunction
" Function: s:svnFunctions.Status(argList) {{{2
function! s:svnFunctions.Status(argList)
let options = ['-u', '-v']
if len(a:argList) == 0
if len(a:argList) != 0
let options = a:argList
endif
return s:DoCommand(join(['status --non-interactive'] + options, ' '), 'status', join(options, ' '), {})

View File

@@ -72,7 +72,7 @@ function! s:setup_buffer_enter() "{{{
endif
if idx == -1
call add(g:vimwiki_list, {'path': path, 'ext': ext})
call add(g:vimwiki_list, {'path': path, 'ext': ext, 'temp': 1})
let g:vimwiki_current_idx = len(g:vimwiki_list) - 1
else
let g:vimwiki_current_idx = idx
@@ -81,52 +81,29 @@ function! s:setup_buffer_enter() "{{{
let b:vimwiki_idx = g:vimwiki_current_idx
endif
call s:setup_colors()
if &filetype != 'vimwiki'
setlocal ft=vimwiki
else
setlocal syntax=vimwiki
endif
" Update existed/non-existed links highlighting.
call vimwiki#highlight_links()
" Settings foldmethod, foldexpr and foldtext are local to window. Thus in a
" new tab with the same buffer folding is reset to vim defaults. So we
" insist vimwiki folding here.
" TODO: remove the same from ftplugin.
if g:vimwiki_folding == 1 && &fdm != 'expr'
setlocal fdm=expr
setlocal foldexpr=VimwikiFoldLevel(v:lnum)
setlocal foldtext=VimwikiFoldText()
endif
" And conceal level too.
if g:vimwiki_conceallevel && exists("+conceallevel")
let &conceallevel = g:vimwiki_conceallevel
endif
" Set up menu
if g:vimwiki_menu != ""
exe 'nmenu enable '.g:vimwiki_menu.'.Table'
endif
endfunction "}}}
function! s:setup_colors()"{{{
if g:vimwiki_hl_headers == 0
return
endif
if &background == 'light'
hi def VimwikiHeader1 guibg=bg guifg=#aa5858 gui=bold ctermfg=DarkRed
hi def VimwikiHeader2 guibg=bg guifg=#309010 gui=bold ctermfg=DarkGreen
hi def VimwikiHeader3 guibg=bg guifg=#1030a0 gui=bold ctermfg=DarkBlue
hi def VimwikiHeader4 guibg=bg guifg=#103040 gui=bold ctermfg=Black
hi def VimwikiHeader5 guibg=bg guifg=#001020 gui=bold ctermfg=Black
hi def VimwikiHeader6 guibg=bg guifg=#000000 gui=bold ctermfg=Black
else
hi def VimwikiHeader1 guibg=bg guifg=#e08090 gui=bold ctermfg=Red
hi def VimwikiHeader2 guibg=bg guifg=#80e090 gui=bold ctermfg=Green
hi def VimwikiHeader3 guibg=bg guifg=#6090e0 gui=bold ctermfg=Blue
hi def VimwikiHeader4 guibg=bg guifg=#c0c0f0 gui=bold ctermfg=White
hi def VimwikiHeader5 guibg=bg guifg=#e0e0f0 gui=bold ctermfg=White
hi def VimwikiHeader6 guibg=bg guifg=#f0f0f0 gui=bold ctermfg=White
endif
endfunction"}}}
" OPTION get/set functions {{{
" return value of option for current wiki or if second parameter exists for
" wiki with a given index.
@@ -201,11 +178,13 @@ let s:vimwiki_defaults.index = 'index'
let s:vimwiki_defaults.ext = '.wiki'
let s:vimwiki_defaults.maxhi = 1
let s:vimwiki_defaults.syntax = 'default'
let s:vimwiki_defaults.gohome = 'split'
let s:vimwiki_defaults.html_header = ''
let s:vimwiki_defaults.html_footer = ''
let s:vimwiki_defaults.nested_syntaxes = {}
let s:vimwiki_defaults.auto_export = 0
" is wiki temporary -- was added to g:vimwiki_list by opening arbitrary wiki
" file.
let s:vimwiki_defaults.temp = 0
" diary
let s:vimwiki_defaults.diary_rel_path = 'diary/'
@@ -265,9 +244,12 @@ call s:default('table_auto_fmt', 1)
call s:default('w32_dir_enc', '')
call s:default('CJK_length', 0)
call s:default('dir_link', '')
call s:default('file_exts', 'pdf,txt,doc,rtf,xls,php,zip,rar,7z,html,gz')
call s:default('valid_html_tags', 'b,i,s,u,sub,sup,kbd,br,hr')
call s:default('html_header_numbering', 0)
call s:default('html_header_numbering_sym', '')
call s:default('conceallevel', 3)
call s:default('current_idx', 0)
@@ -292,7 +274,8 @@ else
endif
let g:vimwiki_rxWeblink = '\%("[^"(]\+\((\([^)]\+\))\)\?":\)\?'.
\'\%(https\?\|ftp\|gopher\|telnet\|file\|notes\|ms-help\):'.
\'\%(\%(\%(//\)\|\%(\\\\\)\)\+[A-Za-z0-9:#@%/;,$~()_?+=.&\\\-]*\)'
\'\%(\%(\%(//\)\|\%(\\\\\)\)\+[A-Za-z0-9:#@%/;,$~()_?+=.&\\\-]*\)'.
\'[().,?]\@<!'
"}}}
" AUTOCOMMANDS for all known wiki extensions {{{
@@ -316,12 +299,13 @@ augroup vimwiki
for ext in keys(extensions)
exe 'autocmd BufEnter *'.ext.' call s:setup_buffer_enter()'
exe 'autocmd BufLeave,BufHidden *'.ext.' call s:setup_buffer_leave()'
exe 'autocmd BufNewFile,BufRead, *'.ext.' setf vimwiki'
" ColorScheme could have or could have not a
" VimwikiHeader1..VimwikiHeader6 highlight groups. We need to refresh
" syntax after colorscheme change.
exe 'autocmd ColorScheme *'.ext.' call s:setup_colors()'.
\ ' | set syntax=vimwiki'
exe 'autocmd ColorScheme *'.ext.' call vimwiki#setup_colors()'.
\ ' | call vimwiki#highlight_links()'
" Format tables when exit from insert mode. Do not use textwidth to
" autowrap tables.
@@ -334,11 +318,11 @@ augroup END
"}}}
" COMMANDS {{{
command! VimwikiUISelect call vimwiki#WikiUISelect()
command! -count VimwikiGoHome
\ call vimwiki#WikiGoHome(v:count1)
command! -count VimwikiTabGoHome tabedit <bar>
\ call vimwiki#WikiGoHome(v:count1)
command! VimwikiUISelect call vimwiki#ui_select()
command! -count VimwikiIndex
\ call vimwiki#goto_index(v:count1)
command! -count VimwikiTabIndex tabedit <bar>
\ call vimwiki#goto_index(v:count1)
command! -count VimwikiMakeDiaryNote
\ call vimwiki_diary#make_note(v:count1)
@@ -347,15 +331,15 @@ command! -count VimwikiTabMakeDiaryNote tabedit <bar>
"}}}
" MAPPINGS {{{
if !hasmapto('<Plug>VimwikiGoHome')
map <silent><unique> <Leader>ww <Plug>VimwikiGoHome
if !hasmapto('<Plug>VimwikiIndex')
map <silent><unique> <Leader>ww <Plug>VimwikiIndex
endif
noremap <unique><script> <Plug>VimwikiGoHome :VimwikiGoHome<CR>
noremap <unique><script> <Plug>VimwikiIndex :VimwikiIndex<CR>
if !hasmapto('<Plug>VimwikiTabGoHome')
map <silent><unique> <Leader>wt <Plug>VimwikiTabGoHome
if !hasmapto('<Plug>VimwikiTabIndex')
map <silent><unique> <Leader>wt <Plug>VimwikiTabIndex
endif
noremap <unique><script> <Plug>VimwikiTabGoHome :VimwikiTabGoHome<CR>
noremap <unique><script> <Plug>VimwikiTabIndex :VimwikiTabIndex<CR>
if !hasmapto('<Plug>VimwikiUISelect')
map <silent><unique> <Leader>ws <Plug>VimwikiUISelect
@@ -382,7 +366,7 @@ function! s:build_menu(topmenu)
let norm_path = fnamemodify(VimwikiGet('path', idx), ':h:t')
let norm_path = escape(norm_path, '\ ')
execute 'menu '.a:topmenu.'.Open\ index.'.norm_path.
\ ' :call vimwiki#WikiGoHome('.(idx + 1).')<CR>'
\ ' :call vimwiki#goto_index('.(idx + 1).')<CR>'
execute 'menu '.a:topmenu.'.Open/Create\ diary\ note.'.norm_path.
\ ' :call vimwiki_diary#make_note('.(idx + 1).')<CR>'
let idx += 1