mirror of
https://github.com/gryf/.vim.git
synced 2025-12-18 03:50:30 +01:00
Moja prawie współczesna konfiguracja. Dużo rzeczy :)
This commit is contained in:
211
autoload/fuf/bookmark.vim
Normal file
211
autoload/fuf/bookmark.vim
Normal file
@@ -0,0 +1,211 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_bookmark') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_bookmark = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#bookmark#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmark#getSwitchOrder()
|
||||
return g:fuf_bookmark_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmark#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmark#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmark#onInit()
|
||||
call fuf#defineLaunchCommand('FufBookmark', s:MODE_NAME, '""')
|
||||
command! -bang -narg=? FufAddBookmark call s:bookmarkHere(<q-args>)
|
||||
command! -bang -narg=0 -range FufAddBookmarkAsSelectedText call s:bookmarkHere(s:getSelectedText())
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
let s:OPEN_TYPE_DELETE = -1
|
||||
|
||||
"
|
||||
function s:getSelectedText()
|
||||
let reg_ = [@", getregtype('"')]
|
||||
let regA = [@a, getregtype('a')]
|
||||
if mode() =~# "[vV\<C-v>]"
|
||||
silent normal! "aygv
|
||||
else
|
||||
let pos = getpos('.')
|
||||
silent normal! gv"ay
|
||||
call setpos('.', pos)
|
||||
endif
|
||||
let text = @a
|
||||
call setreg('"', reg_[0], reg_[1])
|
||||
call setreg('a', regA[0], regA[1])
|
||||
return text
|
||||
endfunction
|
||||
|
||||
" opens a:path and jumps to the line matching to a:pattern from a:lnum within
|
||||
" a:range. if not found, jumps to a:lnum.
|
||||
function s:jumpToBookmark(path, mode, pattern, lnum)
|
||||
call fuf#openFile(a:path, a:mode, g:fuf_reuseWindow)
|
||||
call cursor(s:getMatchingLineNumber(getline(1, '$'), a:pattern, a:lnum), 0)
|
||||
normal! zvzz
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getMatchingLineNumber(lines, pattern, lnumBegin)
|
||||
let l = min([a:lnumBegin, len(a:lines)])
|
||||
for [l0, l1] in map(range(0, g:fuf_bookmark_searchRange),
|
||||
\ '[l + v:val, l - v:val]')
|
||||
if l0 <= len(a:lines) && a:lines[l0 - 1] =~# a:pattern
|
||||
return l0
|
||||
elseif l1 >= 0 && a:lines[l1 - 1] =~# a:pattern
|
||||
return l1
|
||||
endif
|
||||
endfor
|
||||
return l
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getLinePattern(lnum)
|
||||
return '\C\V\^' . escape(getline(a:lnum), '\') . '\$'
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:bookmarkHere(word)
|
||||
if !empty(&buftype) || expand('%') !~ '\S'
|
||||
call fuf#echoWithHl('Can''t bookmark this buffer.', 'WarningMsg')
|
||||
return
|
||||
endif
|
||||
let item = {
|
||||
\ 'word' : (a:word =~# '\S' ? substitute(a:word, '\n', ' ', 'g')
|
||||
\ : pathshorten(expand('%:p:~')) . '|' . line('.') . '| ' . getline('.')),
|
||||
\ 'path' : expand('%:p'),
|
||||
\ 'lnum' : line('.'),
|
||||
\ 'pattern' : s:getLinePattern(line('.')),
|
||||
\ 'time' : localtime(),
|
||||
\ }
|
||||
let item.word = fuf#inputHl('Bookmark as:', item.word, 'Question')
|
||||
if item.word !~ '\S'
|
||||
call fuf#echoWithHl('Canceled', 'WarningMsg')
|
||||
return
|
||||
endif
|
||||
let info = fuf#loadInfoFile(s:MODE_NAME)
|
||||
call insert(info.data, item)
|
||||
call fuf#saveInfoFile(s:MODE_NAME, info)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:findItem(items, word)
|
||||
for item in a:items
|
||||
if item.word ==# a:word
|
||||
return item
|
||||
endif
|
||||
endfor
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_bookmark_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForNonPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
let item = s:findItem(self.info.data, a:word)
|
||||
let lines = fuf#getFileLines(item.path)
|
||||
if empty(lines)
|
||||
return []
|
||||
endif
|
||||
let index = s:getMatchingLineNumber(lines, item.pattern, item.lnum) - 1
|
||||
return fuf#makePreviewLinesAround(
|
||||
\ lines, [index], a:count, self.getPreviewHeight())
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return self.items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
if a:mode == s:OPEN_TYPE_DELETE
|
||||
call filter(self.info.data, 'v:val.word !=# a:word')
|
||||
call fuf#saveInfoFile(s:MODE_NAME, self.info)
|
||||
call fuf#launch(s:MODE_NAME, self.lastPattern, self.partialMatching)
|
||||
return
|
||||
else
|
||||
let item = s:findItem(self.info.data, a:word)
|
||||
if !empty(item)
|
||||
call s:jumpToBookmark(item.path, a:mode, item.pattern, item.lnum)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
call fuf#defineKeyMappingInHandler(g:fuf_bookmark_keyDelete,
|
||||
\ 'onCr(' . s:OPEN_TYPE_DELETE . ', 0)')
|
||||
let self.items = copy(self.info.data)
|
||||
call map(self.items, 'fuf#makeNonPathItem(v:val.word, strftime(g:fuf_timeFormat, v:val.time))')
|
||||
call fuf#mapToSetSerialIndex(self.items, 1)
|
||||
call map(self.items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
176
autoload/fuf/buffer.vim
Normal file
176
autoload/fuf/buffer.vim
Normal file
@@ -0,0 +1,176 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_buffer') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_buffer = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#buffer#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#buffer#getSwitchOrder()
|
||||
return g:fuf_buffer_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#buffer#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#buffer#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#buffer#onInit()
|
||||
call fuf#defineLaunchCommand('FufBuffer', s:MODE_NAME, '""')
|
||||
augroup fuf#buffer
|
||||
autocmd!
|
||||
autocmd BufEnter * call s:updateBufTimes()
|
||||
autocmd BufWritePost * call s:updateBufTimes()
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
let s:bufTimes = {}
|
||||
|
||||
"
|
||||
function s:updateBufTimes()
|
||||
let s:bufTimes[bufnr('%')] = localtime()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:makeItem(nr)
|
||||
let fname = (empty(bufname(a:nr))
|
||||
\ ? '[No Name]'
|
||||
\ : fnamemodify(bufname(a:nr), ':~:.'))
|
||||
let time = (exists('s:bufTimes[a:nr]') ? s:bufTimes[a:nr] : 0)
|
||||
let item = fuf#makePathItem(fname, strftime(g:fuf_timeFormat, time), 0)
|
||||
let item.index = a:nr
|
||||
let item.bufNr = a:nr
|
||||
let item.time = time
|
||||
let item.abbrPrefix = s:getBufIndicator(a:nr) . ' '
|
||||
return item
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getBufIndicator(bufNr)
|
||||
if !getbufvar(a:bufNr, '&modifiable')
|
||||
return '[-]'
|
||||
elseif getbufvar(a:bufNr, '&modified')
|
||||
return '[+]'
|
||||
elseif getbufvar(a:bufNr, '&readonly')
|
||||
return '[R]'
|
||||
else
|
||||
return ' '
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:compareTimeDescending(i1, i2)
|
||||
return a:i1.time == a:i2.time ? 0 : a:i1.time > a:i2.time ? -1 : +1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:findItem(items, word)
|
||||
for item in a:items
|
||||
if item.word ==# a:word
|
||||
return item
|
||||
endif
|
||||
endfor
|
||||
return {}
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_buffer_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
let item = s:findItem(self.items, a:word)
|
||||
if empty(item)
|
||||
return []
|
||||
endif
|
||||
return fuf#makePreviewLinesForFile(item.bufNr, a:count, self.getPreviewHeight())
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return self.items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
" not use bufnr(a:word) in order to handle unnamed buffer
|
||||
let item = s:findItem(self.items, a:word)
|
||||
if !empty(item)
|
||||
call fuf#openBuffer(item.bufNr, a:mode, g:fuf_reuseWindow)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
let self.items = map(filter(range(1, bufnr('$')),
|
||||
\ 'buflisted(v:val) && v:val != self.bufNrPrev'),
|
||||
\ 's:makeItem(v:val)')
|
||||
if g:fuf_buffer_mruOrder
|
||||
call fuf#mapToSetSerialIndex(sort(self.items, 's:compareTimeDescending'), 1)
|
||||
endif
|
||||
let self.items = fuf#mapToSetAbbrWithSnippedWordAsPath(self.items)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
133
autoload/fuf/callbackfile.vim
Normal file
133
autoload/fuf/callbackfile.vim
Normal file
@@ -0,0 +1,133 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_callbackfile') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_callbackfile = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#callbackfile#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#callbackfile#getSwitchOrder()
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#callbackfile#renewCache()
|
||||
let s:cache = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#callbackfile#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#callbackfile#onInit()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#callbackfile#launch(initialPattern, partialMatching, prompt, exclude, listener)
|
||||
let s:prompt = (empty(a:prompt) ? '>' : a:prompt)
|
||||
let s:exclude = a:exclude
|
||||
let s:listener = a:listener
|
||||
call fuf#launch(s:MODE_NAME, a:initialPattern, a:partialMatching)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:enumItems(dir)
|
||||
let key = getcwd() . s:exclude . "\n" . a:dir
|
||||
if !exists('s:cache[key]')
|
||||
let s:cache[key] = fuf#enumExpandedDirsEntries(a:dir, s:exclude)
|
||||
if isdirectory(a:dir)
|
||||
call insert(s:cache[key], fuf#makePathItem(a:dir . '.', '', 0))
|
||||
endif
|
||||
call fuf#mapToSetSerialIndex(s:cache[key], 1)
|
||||
call fuf#mapToSetAbbrWithSnippedWordAsPath(s:cache[key])
|
||||
endif
|
||||
return s:cache[key]
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(s:prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForPathTail',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
return fuf#makePreviewLinesForFile(a:word, a:count, self.getPreviewHeight())
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
let items = copy(s:enumItems(fuf#splitPath(a:patternPrimary).head))
|
||||
return filter(items, 'bufnr("^" . v:val.word . "$") != self.bufNrPrev')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call s:listener.onComplete(a:word, a:mode)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
if !a:opened
|
||||
call s:listener.onAbort()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
135
autoload/fuf/callbackitem.vim
Normal file
135
autoload/fuf/callbackitem.vim
Normal file
@@ -0,0 +1,135 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_callbackitem') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_callbackitem = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#callbackitem#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#callbackitem#getSwitchOrder()
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#callbackitem#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#callbackitem#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#callbackitem#onInit()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#callbackitem#launch(initialPattern, partialMatching, prompt, listener, items, forPath)
|
||||
let s:prompt = (empty(a:prompt) ? '>' : a:prompt)
|
||||
let s:listener = a:listener
|
||||
let s:forPath = a:forPath
|
||||
let s:items = copy(a:items)
|
||||
if s:forPath
|
||||
call map(s:items, 'fuf#makePathItem(v:val, "", 1)')
|
||||
call fuf#mapToSetSerialIndex(s:items, 1)
|
||||
call fuf#mapToSetAbbrWithSnippedWordAsPath(s:items)
|
||||
else
|
||||
call map(s:items, 'fuf#makeNonPathItem(v:val, "")')
|
||||
call fuf#mapToSetSerialIndex(s:items, 1)
|
||||
call map(s:items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
|
||||
endif
|
||||
call fuf#launch(s:MODE_NAME, a:initialPattern, a:partialMatching)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(s:prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
if s:forPath
|
||||
return g:fuf_previewHeight
|
||||
endif
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return s:forPath
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
let parser = (s:forPath
|
||||
\ ? 's:interpretPrimaryPatternForPath'
|
||||
\ : 's:interpretPrimaryPatternForNonPath')
|
||||
return fuf#makePatternSet(a:patternBase, parser, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
if s:forPath
|
||||
return fuf#makePreviewLinesForFile(a:word, a:count, self.getPreviewHeight())
|
||||
endif
|
||||
return []
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return s:items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call s:listener.onComplete(a:word, a:mode)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
if !a:opened
|
||||
call s:listener.onAbort()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
168
autoload/fuf/changelist.vim
Normal file
168
autoload/fuf/changelist.vim
Normal file
@@ -0,0 +1,168 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_changelist') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_changelist = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#changelist#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#changelist#getSwitchOrder()
|
||||
return g:fuf_changelist_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#changelist#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#changelist#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#changelist#onInit()
|
||||
call fuf#defineLaunchCommand('FufChangeList', s:MODE_NAME, '""')
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:getChangesLines()
|
||||
redir => result
|
||||
:silent changes
|
||||
redir END
|
||||
return split(result, "\n")
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:parseChangesLine(line)
|
||||
" return matchlist(a:line, '^\(.\)\s\+\(\d\+\)\s\(.*\)$')
|
||||
let elements = matchlist(a:line, '\v^(.)\s*(\d+)\s+(\d+)\s+(\d+)\s*(.*)$')
|
||||
if empty(elements)
|
||||
return {}
|
||||
endif
|
||||
return {
|
||||
\ 'prefix': elements[1],
|
||||
\ 'count' : elements[2],
|
||||
\ 'lnum' : elements[3],
|
||||
\ 'text' : printf('|%d:%d|%s', elements[3], elements[4], elements[5]),
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:makeItem(line)
|
||||
let parsed = s:parseChangesLine(a:line)
|
||||
if empty(parsed)
|
||||
return {}
|
||||
endif
|
||||
let item = fuf#makeNonPathItem(parsed.text, '')
|
||||
let item.abbrPrefix = parsed.prefix
|
||||
let item.lnum = parsed.lnum
|
||||
return item
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_changelist_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForNonPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
let items = filter(copy(self.items), 'v:val.word ==# a:word')
|
||||
if empty(items)
|
||||
return []
|
||||
endif
|
||||
let lines = fuf#getFileLines(self.bufNrPrev)
|
||||
return fuf#makePreviewLinesAround(
|
||||
\ lines, [items[0].lnum - 1], a:count, self.getPreviewHeight())
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return self.items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call fuf#prejump(a:mode)
|
||||
let older = 0
|
||||
for line in reverse(s:getChangesLines())
|
||||
if stridx(line, '>') == 0
|
||||
let older = 1
|
||||
endif
|
||||
let parsed = s:parseChangesLine(line)
|
||||
if !empty(parsed) && parsed.text ==# a:word
|
||||
if parsed.count != 0
|
||||
execute 'normal! ' . parsed.count . (older ? 'g;' : 'g,') . 'zvzz'
|
||||
endif
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
let self.items = s:getChangesLines()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
call map(self.items, 's:makeItem(v:val)')
|
||||
call filter(self.items, '!empty(v:val)')
|
||||
call reverse(self.items)
|
||||
call fuf#mapToSetSerialIndex(self.items, 1)
|
||||
call map(self.items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
|
||||
128
autoload/fuf/dir.vim
Normal file
128
autoload/fuf/dir.vim
Normal file
@@ -0,0 +1,128 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_dir') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_dir = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#dir#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#dir#getSwitchOrder()
|
||||
return g:fuf_dir_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#dir#renewCache()
|
||||
let s:cache = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#dir#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#dir#onInit()
|
||||
call fuf#defineLaunchCommand('FufDir' , s:MODE_NAME, '""')
|
||||
call fuf#defineLaunchCommand('FufDirWithFullCwd' , s:MODE_NAME, 'fnamemodify(getcwd(), '':p'')')
|
||||
call fuf#defineLaunchCommand('FufDirWithCurrentBufferDir', s:MODE_NAME, 'expand(''%:~:.'')[:-1-len(expand(''%:~:.:t''))]')
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:enumItems(dir)
|
||||
let key = getcwd() . g:fuf_dir_exclude . "\n" . a:dir
|
||||
if !exists('s:cache[key]')
|
||||
let s:cache[key] = fuf#enumExpandedDirsEntries(a:dir, g:fuf_dir_exclude)
|
||||
call filter(s:cache[key], 'v:val.word =~# ''[/\\]$''')
|
||||
if isdirectory(a:dir)
|
||||
call insert(s:cache[key], fuf#makePathItem(a:dir . '.', '', 0))
|
||||
endif
|
||||
call fuf#mapToSetSerialIndex(s:cache[key], 1)
|
||||
call fuf#mapToSetAbbrWithSnippedWordAsPath(s:cache[key])
|
||||
endif
|
||||
return s:cache[key]
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_dir_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForPathTail',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
return fuf#makePreviewLinesAround(
|
||||
\ split(glob(fnamemodify(a:word, ':p') . '*'), "\n"),
|
||||
\ [], a:count, self.getPreviewHeight())
|
||||
return
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return s:enumItems(fuf#splitPath(a:patternPrimary).head)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
execute ':cd ' . fnameescape(a:word)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
137
autoload/fuf/file.vim
Normal file
137
autoload/fuf/file.vim
Normal file
@@ -0,0 +1,137 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_file') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_file = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#file#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#file#getSwitchOrder()
|
||||
return g:fuf_file_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#file#renewCache()
|
||||
let s:cache = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#file#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#file#onInit()
|
||||
call fuf#defineLaunchCommand('FufFile' , s:MODE_NAME, '""')
|
||||
call fuf#defineLaunchCommand('FufFileWithFullCwd' , s:MODE_NAME, 'fnamemodify(getcwd(), '':p'')')
|
||||
call fuf#defineLaunchCommand('FufFileWithCurrentBufferDir', s:MODE_NAME, 'expand(''%:~:.'')[:-1-len(expand(''%:~:.:t''))]')
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:enumItems(dir)
|
||||
let key = getcwd() . g:fuf_file_exclude . "\n" . a:dir
|
||||
if !exists('s:cache[key]')
|
||||
let s:cache[key] = fuf#enumExpandedDirsEntries(a:dir, g:fuf_file_exclude)
|
||||
call fuf#mapToSetSerialIndex(s:cache[key], 1)
|
||||
call fuf#mapToSetAbbrWithSnippedWordAsPath(s:cache[key])
|
||||
endif
|
||||
return s:cache[key]
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:enumNonCurrentItems(dir, bufNr, cache)
|
||||
let key = a:dir . 'AVOIDING EMPTY KEY'
|
||||
if !exists('a:cache[key]')
|
||||
" NOTE: filtering should be done with
|
||||
" 'bufnr("^" . v:val.word . "$") != a:bufNr'.
|
||||
" But it takes a lot of time!
|
||||
let bufName = bufname(a:bufNr)
|
||||
let a:cache[key] =
|
||||
\ filter(copy(s:enumItems(a:dir)), 'v:val.word != bufName')
|
||||
endif
|
||||
return a:cache[key]
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_file_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForPathTail',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
return fuf#makePreviewLinesForFile(a:word, a:count, self.getPreviewHeight())
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return s:enumNonCurrentItems(
|
||||
\ fuf#splitPath(a:patternPrimary).head, self.bufNrPrev, self.cache)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call fuf#openFile(a:word, a:mode, g:fuf_reuseWindow)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
let self.cache = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
119
autoload/fuf/givencmd.vim
Normal file
119
autoload/fuf/givencmd.vim
Normal file
@@ -0,0 +1,119 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_givencmd') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_givencmd = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#givencmd#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givencmd#getSwitchOrder()
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givencmd#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givencmd#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givencmd#onInit()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givencmd#launch(initialPattern, partialMatching, prompt, items)
|
||||
let s:prompt = (empty(a:prompt) ? '>' : a:prompt)
|
||||
let s:items = copy(a:items)
|
||||
call map(s:items, 'fuf#makeNonPathItem(v:val, "")')
|
||||
call fuf#mapToSetSerialIndex(s:items, 1)
|
||||
call map(s:items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
|
||||
call fuf#launch(s:MODE_NAME, a:initialPattern, a:partialMatching)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(s:prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForNonPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
return []
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return s:items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
if a:word[0] =~# '[:/?]'
|
||||
call histadd(a:word[0], a:word[1:])
|
||||
endif
|
||||
call feedkeys(a:word . "\<CR>", 'n')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
119
autoload/fuf/givendir.vim
Normal file
119
autoload/fuf/givendir.vim
Normal file
@@ -0,0 +1,119 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_givendir') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_givendir = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#givendir#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givendir#getSwitchOrder()
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givendir#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givendir#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givendir#onInit()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givendir#launch(initialPattern, partialMatching, prompt, items)
|
||||
let s:prompt = (empty(a:prompt) ? '>' : a:prompt)
|
||||
let s:items = map(copy(a:items), 'substitute(v:val, ''[/\\]\?$'', "", "")')
|
||||
let s:items = map(s:items, 'fuf#makePathItem(v:val, "", 0)')
|
||||
call fuf#mapToSetSerialIndex(s:items, 1)
|
||||
call fuf#mapToSetAbbrWithSnippedWordAsPath(s:items)
|
||||
call fuf#launch(s:MODE_NAME, a:initialPattern, a:partialMatching)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(s:prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
return fuf#makePreviewLinesAround(
|
||||
\ split(glob(fnamemodify(a:word, ':p') . '*'), "\n"),
|
||||
\ [], a:count, self.getPreviewHeight())
|
||||
return
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return s:items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
execute ':cd ' . fnameescape(a:word)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
117
autoload/fuf/givenfile.vim
Normal file
117
autoload/fuf/givenfile.vim
Normal file
@@ -0,0 +1,117 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_givenfile') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_givenfile = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#givenfile#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givenfile#getSwitchOrder()
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givenfile#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givenfile#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givenfile#onInit()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#givenfile#launch(initialPattern, partialMatching, prompt, items)
|
||||
let s:prompt = (empty(a:prompt) ? '>' : a:prompt)
|
||||
let s:items = map(copy(a:items), 'fuf#makePathItem(v:val, "", 0)')
|
||||
call fuf#mapToSetSerialIndex(s:items, 1)
|
||||
call map(s:items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
|
||||
call fuf#launch(s:MODE_NAME, a:initialPattern, a:partialMatching)
|
||||
endfunction
|
||||
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(s:prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
return fuf#makePreviewLinesForFile(a:word, a:count, self.getPreviewHeight())
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return s:items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call fuf#openFile(a:word, a:mode, g:fuf_reuseWindow)
|
||||
endfunction
|
||||
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
202
autoload/fuf/help.vim
Normal file
202
autoload/fuf/help.vim
Normal file
@@ -0,0 +1,202 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_help') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_help = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#help#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#help#getSwitchOrder()
|
||||
return g:fuf_help_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#help#renewCache()
|
||||
let s:cache = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#help#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#help#onInit()
|
||||
call fuf#defineLaunchCommand('FufHelp' , s:MODE_NAME, '""')
|
||||
call fuf#defineLaunchCommand('FufHelpWithCursorWord', s:MODE_NAME, 'expand(''<cword>'')')
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:getCurrentHelpTagFiles()
|
||||
let prefix = 'doc' . fuf#getPathSeparator()
|
||||
let tagFiles = split(globpath(&runtimepath, prefix . 'tags' ), "\n")
|
||||
\ + split(globpath(&runtimepath, prefix . 'tags-??'), "\n")
|
||||
return sort(map(tagFiles, 'fnamemodify(v:val, ":p")'))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:parseHelpTagEntry(line, tagFile)
|
||||
let elements = split(a:line, "\t")
|
||||
if len(elements) != 3 || elements[0][0] ==# '!'
|
||||
return {}
|
||||
endif
|
||||
let suffix = matchstr(a:tagFile, '-\zs..$')
|
||||
if empty(suffix)
|
||||
let suffix = '@en'
|
||||
else
|
||||
let suffix = '@' . suffix
|
||||
endif
|
||||
let dir = fnamemodify(a:tagFile, ':h') . fuf#getPathSeparator()
|
||||
return {
|
||||
\ 'word' : elements[0] . suffix,
|
||||
\ 'path' : dir . elements[1],
|
||||
\ 'pattern': elements[2][1:],
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getHelpTagEntries(tagFile)
|
||||
let names = map(readfile(a:tagFile), 's:parseHelpTagEntry(v:val, a:tagFile)')
|
||||
return filter(names, '!empty(v:val)')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:parseHelpTagFiles(tagFiles)
|
||||
if !empty(g:fuf_help_cache_dir)
|
||||
if !isdirectory(expand(g:fuf_help_cache_dir))
|
||||
call mkdir(expand(g:fuf_help_cache_dir), 'p')
|
||||
endif
|
||||
" NOTE: fnamemodify('a/b', ':p') returns 'a/b/' if the directory exists.
|
||||
let cacheFile = fnamemodify(g:fuf_help_cache_dir, ':p')
|
||||
\ . fuf#hash224(join(a:tagFiles, "\n"))
|
||||
if filereadable(cacheFile) && fuf#countModifiedFiles(a:tagFiles, getftime(cacheFile)) == 0
|
||||
return map(readfile(cacheFile), 'eval(v:val)')
|
||||
endif
|
||||
endif
|
||||
let items = fuf#unique(fuf#concat(map(copy(a:tagFiles), 's:getHelpTagEntries(v:val)')))
|
||||
let items = map(items, 'extend(v:val, fuf#makeNonPathItem(v:val.word, ""))')
|
||||
call fuf#mapToSetSerialIndex(items, 1)
|
||||
let items = map(items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
|
||||
if !empty(g:fuf_help_cache_dir)
|
||||
call writefile(map(copy(items), 'string(v:val)'), cacheFile)
|
||||
endif
|
||||
return items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:enumHelpTags(tagFiles)
|
||||
if !len(a:tagFiles)
|
||||
return []
|
||||
endif
|
||||
let key = join(a:tagFiles, "\n")
|
||||
if !exists('s:cache[key]') || fuf#countModifiedFiles(a:tagFiles, s:cache[key].time)
|
||||
let s:cache[key] = {
|
||||
\ 'time' : localtime(),
|
||||
\ 'items' : s:parseHelpTagFiles(a:tagFiles)
|
||||
\ }
|
||||
endif
|
||||
return s:cache[key].items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getMatchingIndex(lines, pattern)
|
||||
if empty(a:pattern)
|
||||
return -1
|
||||
endif
|
||||
for i in range(len(a:lines))
|
||||
if stridx(a:lines[i], a:pattern) >= 0
|
||||
return i
|
||||
endif
|
||||
endfor
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_help_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForNonPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
let items = filter(copy(s:enumHelpTags(self.tagFiles)), 'v:val.word ==# a:word')
|
||||
if empty(items)
|
||||
return []
|
||||
endif
|
||||
let lines = fuf#getFileLines(items[0].path)
|
||||
let index = s:getMatchingIndex(lines, items[0].pattern)
|
||||
return [items[0].path . ':'] + fuf#makePreviewLinesAround(
|
||||
\ lines, (index < 0 ? [] : [index]), a:count, self.getPreviewHeight() - 1)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return s:enumHelpTags(self.tagFiles)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call fuf#openHelp(a:word, a:mode)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
let self.tagFiles = s:getCurrentHelpTagFiles()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
178
autoload/fuf/jumplist.vim
Normal file
178
autoload/fuf/jumplist.vim
Normal file
@@ -0,0 +1,178 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_jumplist') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_jumplist = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#jumplist#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#jumplist#getSwitchOrder()
|
||||
return g:fuf_jumplist_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#jumplist#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#jumplist#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#jumplist#onInit()
|
||||
call fuf#defineLaunchCommand('FufJumpList', s:MODE_NAME, '""')
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:getJumpsLines()
|
||||
redir => result
|
||||
:silent jumps
|
||||
redir END
|
||||
return split(result, "\n")
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:parseJumpsLine(line, bufnrPrev)
|
||||
"return matchlist(a:line, '^\(.\)\s\+\(\d\+\)\s\(.*\)$')
|
||||
let elements = matchlist(a:line, '\v^(.)\s*(\d+)\s+(\d+)\s+(\d+)\s*(.*)$')
|
||||
if empty(elements)
|
||||
return {}
|
||||
endif
|
||||
let linePrevBuffer = join(getbufline(a:bufnrPrev, elements[3]))
|
||||
if stridx(linePrevBuffer, elements[5]) >= 0
|
||||
let fname = bufname(a:bufnrPrev)
|
||||
let text = elements[5]
|
||||
else
|
||||
let fname = elements[5]
|
||||
let text = join(getbufline('^' . elements[5] . '$', elements[3]))
|
||||
endif
|
||||
return {
|
||||
\ 'prefix': elements[1],
|
||||
\ 'count' : elements[2],
|
||||
\ 'lnum' : elements[3],
|
||||
\ 'fname' : fname,
|
||||
\ 'text' : printf('%s|%d:%d|%s', fname, elements[3], elements[4], text),
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:makeItem(line, bufnrPrev)
|
||||
let parsed = s:parseJumpsLine(a:line, a:bufnrPrev)
|
||||
if empty(parsed)
|
||||
return {}
|
||||
endif
|
||||
let item = fuf#makeNonPathItem(parsed.text, '')
|
||||
let item.abbrPrefix = parsed.prefix
|
||||
let item.lnum = parsed.lnum
|
||||
let item.fname = parsed.fname
|
||||
return item
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_jumplist_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForNonPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
let items = filter(copy(self.items), 'v:val.word ==# a:word')
|
||||
if empty(items)
|
||||
return []
|
||||
endif
|
||||
let lines = fuf#getFileLines(items[0].fname)
|
||||
return fuf#makePreviewLinesAround(
|
||||
\ lines, [items[0].lnum - 1], a:count, self.getPreviewHeight())
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return self.items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call fuf#prejump(a:mode)
|
||||
let older = 0
|
||||
for line in reverse(s:getJumpsLines())
|
||||
if stridx(line, '>') == 0
|
||||
let older = 1
|
||||
endif
|
||||
let parsed = s:parseJumpsLine(line, self.bufNrPrev)
|
||||
if !empty(parsed) && parsed.text ==# a:word
|
||||
if parsed.count != 0
|
||||
execute 'normal! ' . parsed.count . (older ? "\<C-o>" : "\<C-i>") . 'zvzz'
|
||||
endif
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
let self.items = s:getJumpsLines()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
call map(self.items, 's:makeItem(v:val, self.bufNrPrev)')
|
||||
call filter(self.items, '!empty(v:val)')
|
||||
call reverse(self.items)
|
||||
call fuf#mapToSetSerialIndex(self.items, 1)
|
||||
call map(self.items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
|
||||
131
autoload/fuf/line.vim
Normal file
131
autoload/fuf/line.vim
Normal file
@@ -0,0 +1,131 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_line') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_line = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#line#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#line#getSwitchOrder()
|
||||
return g:fuf_line_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#line#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#line#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#line#onInit()
|
||||
call fuf#defineLaunchCommand('FufLine', s:MODE_NAME, '""')
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
let s:OPEN_TYPE_DELETE = -1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_line_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForNonPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
let items = filter(copy(self.items), 'v:val.word ==# a:word')
|
||||
if empty(items)
|
||||
return []
|
||||
endif
|
||||
let lines = fuf#getFileLines(self.bufNrPrev)
|
||||
return fuf#makePreviewLinesAround(
|
||||
\ lines, [items[0].index - 1], a:count, self.getPreviewHeight())
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return self.items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call fuf#prejump(a:mode)
|
||||
call filter(self.items, 'v:val.word ==# a:word')
|
||||
if empty(self.items)
|
||||
return
|
||||
execute 'cc ' . self.items[0].index
|
||||
endif
|
||||
call cursor(self.items[0].index, 0)
|
||||
normal! zvzz
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
let tab = repeat(' ', getbufvar(self.bufNrPrev, '&tabstop'))
|
||||
let self.items = getbufline(self.bufNrPrev, 1, '$')
|
||||
let lnumFormat = '%' . len(string(len(self.items) + 1)) . 'd|'
|
||||
for i in range(len(self.items))
|
||||
let self.items[i] = printf(lnumFormat, i + 1)
|
||||
\ . substitute(self.items[i], "\t", tab, 'g')
|
||||
endfor
|
||||
call map(self.items, 'fuf#makeNonPathItem(v:val, "")')
|
||||
call fuf#mapToSetSerialIndex(self.items, 1)
|
||||
call map(self.items, 'fuf#setAbbrWithFormattedWord(v:val, 0)')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
130
autoload/fuf/mrucmd.vim
Normal file
130
autoload/fuf/mrucmd.vim
Normal file
@@ -0,0 +1,130 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_mrucmd') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_mrucmd = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#mrucmd#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrucmd#getSwitchOrder()
|
||||
return g:fuf_mrucmd_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrucmd#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrucmd#requiresOnCommandPre()
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrucmd#onInit()
|
||||
call fuf#defineLaunchCommand('FufMruCmd', s:MODE_NAME, '""')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrucmd#onCommandPre(cmd)
|
||||
if getcmdtype() =~# '^[:/?]'
|
||||
call s:updateInfo(a:cmd)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:updateInfo(cmd)
|
||||
let info = fuf#loadInfoFile(s:MODE_NAME)
|
||||
let info.data = fuf#updateMruList(
|
||||
\ info.data, { 'word' : a:cmd, 'time' : localtime() },
|
||||
\ g:fuf_mrucmd_maxItem, g:fuf_mrucmd_exclude)
|
||||
call fuf#saveInfoFile(s:MODE_NAME, info)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_mrucmd_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForNonPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
return []
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return self.items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call s:updateInfo(a:word)
|
||||
call histadd(a:word[0], a:word[1:])
|
||||
call feedkeys(a:word . "\<CR>", 'n')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
let self.items = copy(self.info.data)
|
||||
call map(self.items, 'fuf#makeNonPathItem(v:val.word, strftime(g:fuf_timeFormat, v:val.time))')
|
||||
call fuf#mapToSetSerialIndex(self.items, 1)
|
||||
call map(self.items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
156
autoload/fuf/mrufile.vim
Normal file
156
autoload/fuf/mrufile.vim
Normal file
@@ -0,0 +1,156 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_mrufile') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_mrufile = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#mrufile#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrufile#getSwitchOrder()
|
||||
return g:fuf_mrufile_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrufile#renewCache()
|
||||
let s:cache = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrufile#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrufile#onInit()
|
||||
call fuf#defineLaunchCommand('FufMruFile', s:MODE_NAME, '""')
|
||||
augroup fuf#mrufile
|
||||
autocmd!
|
||||
autocmd BufEnter * call s:updateInfo()
|
||||
autocmd BufWritePost * call s:updateInfo()
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:updateInfo()
|
||||
if !empty(&buftype) || !filereadable(expand('%'))
|
||||
return
|
||||
endif
|
||||
let info = fuf#loadInfoFile(s:MODE_NAME)
|
||||
let info.data = fuf#updateMruList(
|
||||
\ info.data, { 'word' : expand('%:p'), 'time' : localtime() },
|
||||
\ g:fuf_mrufile_maxItem, g:fuf_mrufile_exclude)
|
||||
call fuf#saveInfoFile(s:MODE_NAME, info)
|
||||
call s:removeItemFromCache(expand('%:p'))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:removeItemFromCache(word)
|
||||
for items in values(s:cache)
|
||||
if exists('items[a:word]')
|
||||
unlet items[a:word]
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" returns empty value if invalid item
|
||||
function s:formatItemUsingCache(item)
|
||||
if a:item.word !~ '\S'
|
||||
return {}
|
||||
endif
|
||||
if !exists('s:cache[a:item.word]')
|
||||
if filereadable(a:item.word)
|
||||
let s:cache[a:item.word] = fuf#makePathItem(
|
||||
\ fnamemodify(a:item.word, ':~'), strftime(g:fuf_timeFormat, a:item.time), 0)
|
||||
else
|
||||
let s:cache[a:item.word] = {}
|
||||
endif
|
||||
endif
|
||||
return s:cache[a:item.word]
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_mrufile_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
return fuf#makePreviewLinesForFile(a:word, a:count, self.getPreviewHeight())
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return self.items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call fuf#openFile(a:word, a:mode, g:fuf_reuseWindow)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
let self.items = copy(self.info.data)
|
||||
let self.items = map(self.items, 's:formatItemUsingCache(v:val)')
|
||||
let self.items = filter(self.items, '!empty(v:val) && bufnr("^" . v:val.word . "$") != self.bufNrPrev')
|
||||
let self.items = fuf#mapToSetSerialIndex(self.items, 1)
|
||||
let self.items = fuf#mapToSetAbbrWithSnippedWordAsPath(self.items)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
150
autoload/fuf/quickfix.vim
Normal file
150
autoload/fuf/quickfix.vim
Normal file
@@ -0,0 +1,150 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_quickfix') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_quickfix = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#quickfix#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#quickfix#getSwitchOrder()
|
||||
return g:fuf_quickfix_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#quickfix#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#quickfix#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#quickfix#onInit()
|
||||
call fuf#defineLaunchCommand('FufQuickfix', s:MODE_NAME, '""')
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:getJumpsLines()
|
||||
redir => result
|
||||
:silent jumps
|
||||
redir END
|
||||
return split(result, "\n")
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:parseJumpsLine(line)
|
||||
return matchlist(a:line, '^\(.\)\s\+\(\d\+\)\s\(.*\)$')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:makeItem(qfItem)
|
||||
if !a:qfItem.valid
|
||||
return {}
|
||||
endif
|
||||
let item = fuf#makeNonPathItem(
|
||||
\ printf('%s|%d:%d|%s', bufname(a:qfItem.bufnr), a:qfItem.lnum,
|
||||
\ a:qfItem.col, matchstr(a:qfItem.text, '\s*\zs.*\S'))
|
||||
\ , '')
|
||||
let item.bufnr = a:qfItem.bufnr
|
||||
let item.lnum = a:qfItem.lnum
|
||||
return item
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_quickfix_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForNonPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
let items = filter(copy(self.items), 'v:val.word ==# a:word')
|
||||
if empty(items)
|
||||
return []
|
||||
endif
|
||||
let lines = fuf#getFileLines(items[0].bufnr)
|
||||
return fuf#makePreviewLinesAround(
|
||||
\ lines, [items[0].lnum - 1], a:count, self.getPreviewHeight())
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return self.items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call fuf#prejump(a:mode)
|
||||
call filter(self.items, 'v:val.word ==# a:word')
|
||||
if !empty(self.items)
|
||||
execute 'cc ' . self.items[0].index
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
let self.items = getqflist()
|
||||
call map(self.items, 's:makeItem(v:val)')
|
||||
call fuf#mapToSetSerialIndex(self.items, 1)
|
||||
call filter(self.items, 'exists("v:val.word")')
|
||||
call map(self.items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
|
||||
182
autoload/fuf/tag.vim
Normal file
182
autoload/fuf/tag.vim
Normal file
@@ -0,0 +1,182 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_tag') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_tag = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#tag#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#tag#getSwitchOrder()
|
||||
return g:fuf_tag_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#tag#renewCache()
|
||||
let s:cache = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#tag#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#tag#onInit()
|
||||
call fuf#defineLaunchCommand('FufTag' , s:MODE_NAME, '""')
|
||||
call fuf#defineLaunchCommand('FufTagWithCursorWord', s:MODE_NAME, 'expand(''<cword>'')')
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:getTagNames(tagFile)
|
||||
let names = map(readfile(a:tagFile), 'matchstr(v:val, ''^[^!\t][^\t]*'')')
|
||||
return filter(names, 'v:val =~# ''\S''')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:parseTagFiles(tagFiles)
|
||||
if !empty(g:fuf_tag_cache_dir)
|
||||
if !isdirectory(expand(g:fuf_tag_cache_dir))
|
||||
call mkdir(expand(g:fuf_tag_cache_dir), 'p')
|
||||
endif
|
||||
" NOTE: fnamemodify('a/b', ':p') returns 'a/b/' if the directory exists.
|
||||
let cacheFile = fnamemodify(g:fuf_tag_cache_dir, ':p')
|
||||
\ . fuf#hash224(join(a:tagFiles, "\n"))
|
||||
if filereadable(cacheFile) && fuf#countModifiedFiles(a:tagFiles, getftime(cacheFile)) == 0
|
||||
return map(readfile(cacheFile), 'eval(v:val)')
|
||||
endif
|
||||
endif
|
||||
let items = fuf#unique(fuf#concat(map(copy(a:tagFiles), 's:getTagNames(v:val)')))
|
||||
let items = map(items, 'fuf#makeNonPathItem(v:val, "")')
|
||||
call fuf#mapToSetSerialIndex(items, 1)
|
||||
let items = map(items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
|
||||
if !empty(g:fuf_tag_cache_dir)
|
||||
call writefile(map(copy(items), 'string(v:val)'), cacheFile)
|
||||
endif
|
||||
return items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:enumTags(tagFiles)
|
||||
if !len(a:tagFiles)
|
||||
return []
|
||||
endif
|
||||
let key = join(a:tagFiles, "\n")
|
||||
if !exists('s:cache[key]') || fuf#countModifiedFiles(a:tagFiles, s:cache[key].time)
|
||||
let s:cache[key] = {
|
||||
\ 'time' : localtime(),
|
||||
\ 'items' : s:parseTagFiles(a:tagFiles)
|
||||
\ }
|
||||
endif
|
||||
return s:cache[key].items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getMatchingIndex(lines, cmd)
|
||||
if a:cmd !~# '\D'
|
||||
return str2nr(a:cmd)
|
||||
endif
|
||||
let pattern = matchstr(a:cmd, '^\/\^\zs.*\ze\$\/$')
|
||||
if empty(pattern)
|
||||
return -1
|
||||
endif
|
||||
for i in range(len(a:lines))
|
||||
if a:lines[i] ==# pattern
|
||||
return i
|
||||
endif
|
||||
endfor
|
||||
return -1
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_tag_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForNonPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
" 'cmd' is '/^hoge hoge$/' or line number
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
let tags = taglist('^' . a:word . '$')
|
||||
if empty(tags)
|
||||
return []
|
||||
endif
|
||||
let i = a:count % len(tags)
|
||||
let title = printf('(%d/%d) %s', i + 1, len(tags), tags[i].filename)
|
||||
let lines = fuf#getFileLines(tags[i].filename)
|
||||
let index = s:getMatchingIndex(lines, tags[i].cmd)
|
||||
return [title] + fuf#makePreviewLinesAround(
|
||||
\ lines, (index < 0 ? [] : [index]), 0, self.getPreviewHeight() - 1)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return s:enumTags(self.tagFiles)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call fuf#openTag(a:word, a:mode)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
let self.tagFiles = fuf#getCurrentTagFiles()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
let &l:tags = join(self.tagFiles, ',')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
let &l:tags = ''
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
162
autoload/fuf/taggedfile.vim
Normal file
162
autoload/fuf/taggedfile.vim
Normal file
@@ -0,0 +1,162 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2009 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_fuf_taggedfile') || v:version < 702
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_fuf_taggedfile = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#taggedfile#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#taggedfile#getSwitchOrder()
|
||||
return g:fuf_taggedfile_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#taggedfile#renewCache()
|
||||
let s:cache = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#taggedfile#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#taggedfile#onInit()
|
||||
call fuf#defineLaunchCommand('FufTaggedFile', s:MODE_NAME, '""')
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:getTaggedFileList(tagfile)
|
||||
execute 'cd ' . fnamemodify(a:tagfile, ':h')
|
||||
let result = map(readfile(a:tagfile), 'matchstr(v:val, ''^[^!\t][^\t]*\t\zs[^\t]\+'')')
|
||||
call map(readfile(a:tagfile), 'fnamemodify(v:val, ":p")')
|
||||
cd -
|
||||
call map(readfile(a:tagfile), 'fnamemodify(v:val, ":~:.")')
|
||||
return filter(result, 'v:val =~# ''[^/\\ ]$''')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:parseTagFiles(tagFiles)
|
||||
if !empty(g:fuf_taggedfile_cache_dir)
|
||||
if !isdirectory(expand(g:fuf_taggedfile_cache_dir))
|
||||
call mkdir(expand(g:fuf_taggedfile_cache_dir), 'p')
|
||||
endif
|
||||
" NOTE: fnamemodify('a/b', ':p') returns 'a/b/' if the directory exists.
|
||||
let cacheFile = fnamemodify(g:fuf_taggedfile_cache_dir, ':p')
|
||||
\ . fuf#hash224(join(a:tagFiles, "\n"))
|
||||
if filereadable(cacheFile) && fuf#countModifiedFiles(a:tagFiles, getftime(cacheFile)) == 0
|
||||
return map(readfile(cacheFile), 'eval(v:val)')
|
||||
endif
|
||||
endif
|
||||
let items = fuf#unique(fuf#concat(map(copy(a:tagFiles), 's:getTaggedFileList(v:val)')))
|
||||
call map(items, 'fuf#makePathItem(v:val, "", 0)')
|
||||
call fuf#mapToSetSerialIndex(items, 1)
|
||||
call fuf#mapToSetAbbrWithSnippedWordAsPath(items)
|
||||
if !empty(g:fuf_taggedfile_cache_dir)
|
||||
call writefile(map(copy(items), 'string(v:val)'), cacheFile)
|
||||
endif
|
||||
return items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:enumTaggedFiles(tagFiles)
|
||||
if !len(a:tagFiles)
|
||||
return []
|
||||
endif
|
||||
let key = join([getcwd()] + a:tagFiles, "\n")
|
||||
if !exists('s:cache[key]') || fuf#countModifiedFiles(a:tagFiles, s:cache[key].time)
|
||||
let s:cache[key] = {
|
||||
\ 'time' : localtime(),
|
||||
\ 'items' : s:parseTagFiles(a:tagFiles)
|
||||
\ }
|
||||
endif
|
||||
return s:cache[key].items
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
return fuf#formatPrompt(g:fuf_taggedfile_prompt, self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.targetsPath()
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePatternSet(patternBase)
|
||||
return fuf#makePatternSet(a:patternBase, 's:interpretPrimaryPatternForPath',
|
||||
\ self.partialMatching)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.makePreviewLines(word, count)
|
||||
return fuf#makePreviewLinesForFile(a:word, a:count, self.getPreviewHeight())
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getCompleteItems(patternPrimary)
|
||||
return self.items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onOpen(word, mode)
|
||||
call fuf#openFile(a:word, a:mode, g:fuf_reuseWindow)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
let self.tagFiles = fuf#getCurrentTagFiles()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
" NOTE: Don't do this in onModeEnterPre()
|
||||
" because that should return in a short time.
|
||||
let self.items =
|
||||
\ filter(copy(s:enumTaggedFiles(self.tagFiles)),
|
||||
\ 'bufnr("^" . v:val.word . "$") != self.bufNrPrev')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
Reference in New Issue
Block a user