mirror of
https://github.com/gryf/.vim.git
synced 2026-03-19 02:23:33 +01:00
Removed bundle_consider, and plugins: buffergator and fuzzyfinder (+l9). Give
a try to ctrlp plugin.
This commit is contained in:
@@ -1,268 +0,0 @@
|
||||
*buffergator.txt* Buffer indexing and navigation plugin.
|
||||
|
||||
===============================================================================
|
||||
*buffergator* *buffergator-contents*
|
||||
CONTENTS~
|
||||
|
||||
1. Introduction ........................... |buffergator-introduction|
|
||||
2. Commands ............................... |buffergator-commands|
|
||||
3. Key Mappings (Global) .................. |buffergator-global-keys|
|
||||
4. Key Mappings (Buffer Catalog) .......... |buffergator-buffer-keys|
|
||||
5. Key Mappings (Tab Page Catalog) ........ |buffergator-tabpage-keys|
|
||||
5. Options and Settings ................... |buffergator-options|
|
||||
|
||||
===============================================================================
|
||||
*buffergator-introduction*
|
||||
INTRODUCTION~
|
||||
|
||||
Buffergator is a plugin for listing, navigating between, and selecting buffers
|
||||
to edit. Upon invocation (using the command, ":BuffergatorOpen" or
|
||||
"BuffergatorToggle", or the provided key mapping, "<Leader>b"), a "catalog" of
|
||||
listed buffers are displayed in a separate new window split (vertical or
|
||||
horizontal, based on user options; default = vertical). From this "buffer
|
||||
catalog", a buffer can be selected and opened in an existing window, a new
|
||||
window split (vertical or horizontal), or a new tab page.
|
||||
|
||||
Selected buffers can be "previewed", i.e. opened in a window or tab page, but
|
||||
with focus remaining in the buffer catalog. Even better, you can "walk" up and
|
||||
down the list of buffers shown in the catalog by using <C-N> (or <SPACE>) /
|
||||
<C-P> (or <C-SPACE>). These keys select the next/previous buffer in succession,
|
||||
respectively, opening it for preview without leaving the buffer catalog
|
||||
viewer.
|
||||
|
||||
Buffergator also provides a way to list tab pages and buffers associated with
|
||||
windows in tab pages (the "tab page catalog", which can be invoked using the
|
||||
command ":BuffergatorTabsOpen" or the provided key mapping, "<Leader>t").
|
||||
|
||||
By default, Buffergator provides global key maps that invoke its main
|
||||
commands: "<Leader>b" to open and "<Leader>B" to close the buffer catalog, and
|
||||
"<Leader>t" to open and "<Leader>T" to close the tab page catalog. If you
|
||||
prefer to map other keys, or do not want any keys mapped at all, set
|
||||
"g:buffergator_suppress_keymaps" to 1 in your $VIMRUNTIME.
|
||||
|
||||
===============================================================================
|
||||
*buffergator-commands*
|
||||
COMMANDS~
|
||||
|
||||
These following commands are provided globally by Buffergator:
|
||||
|
||||
:BuffergatorOpen
|
||||
Open the buffer catalog, or go to it if it is already open.
|
||||
|
||||
:BuffergatorClose
|
||||
Close the buffer catalog if it is already open.
|
||||
|
||||
:BuffergatorToggle
|
||||
Open the buffer catalog if it is closed, or close it if
|
||||
it is already open.
|
||||
|
||||
:BuffergatorTabsOpen
|
||||
Open the tab page catalog, or go to it if it is already open.
|
||||
|
||||
:BuffergatorTabsClose
|
||||
Close the tab page catalog if it is already open.
|
||||
|
||||
:BuffergatorTabsToggle
|
||||
Open the tab page catalog if it is closed, or close it if
|
||||
it is already open.
|
||||
|
||||
===============================================================================
|
||||
*buffergator-global-keys*
|
||||
KEY MAPPINGS (GLOBAL)~
|
||||
|
||||
Unless "g:buffergator_suppress_keymaps" is set to 1, then the following
|
||||
key mappings are defined:
|
||||
|
||||
<Leader>b Invokes ":BuffergatorOpen": open the buffer catalog, or go
|
||||
to it if it is already open.
|
||||
|
||||
<Leader>B Invokes ":BuffergatorClose": close the buffer catalog.
|
||||
|
||||
<Leader>t Invokes ":BuffergatorTabsOpen": open the tab page catalog,
|
||||
or go to it if it is already open.
|
||||
|
||||
<Leader>T Invokes ":BuffergatorTabsClose": close the tab page
|
||||
catalog.
|
||||
|
||||
===============================================================================
|
||||
*buffergator-buffer-keys*
|
||||
KEY MAPPINGS (BUFFER CATALOG)~
|
||||
|
||||
Invoking Buffergator results in the listed buffers being displayed in a
|
||||
special Buffergator window, which is referred to as a "buffer catalog viewer".
|
||||
The following key mappings are available when in the viewer.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Catalog Management~
|
||||
|
||||
cs Cycle through sort regimes.
|
||||
cd Cycle through display regimes.
|
||||
r Update (rebuild/refresh) index.
|
||||
d Delete the selected buffer.
|
||||
D Unconditionally delete the selected buffer.
|
||||
x Wipe the selected buffer.
|
||||
X Unconditionally wipe the selected buffer.
|
||||
q Quit the index/catalog window.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Open Selected Buffer~
|
||||
|
||||
The following keys all open the currently-selected buffer and switch focus to
|
||||
it. If the key presses are preceded by a number, then the buffer with that
|
||||
number will be selected and opened instead of the current buffer. The catalog
|
||||
buffer will be closed if 'g:buffergator_autodismiss_on_select' evaluates to
|
||||
true; otherwise it will be kept open.
|
||||
|
||||
<CR>, o Open the currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), in previous window.
|
||||
s Open the currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), in a new vertical
|
||||
split.
|
||||
i Open the currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), in a new split.
|
||||
t Open the currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), in a new tab page.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Preview Selected Buffer~
|
||||
|
||||
The following keys all open the currently-selected buffer, but retain focus on
|
||||
the catalog viewer. If the key presses are preceded by a number, than the
|
||||
buffer with that number will be opened.
|
||||
|
||||
O, go Preview the currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), in the previous
|
||||
window.
|
||||
S, gs Preview the currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), is a new vertical
|
||||
split.
|
||||
I, gi Preview the currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), in a new split
|
||||
T Preview the currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), in a new tab
|
||||
page.
|
||||
<SPACE>, <C-N> Go to the next buffer entry (or, if [count] is
|
||||
given, buffer with number [count]), and preview it in the
|
||||
previous window.
|
||||
<C-SPACE>, <C-P> Go to the previous buffer entry (or, if [count] is
|
||||
given, buffer with number [count]), and preview it in the
|
||||
previous window.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Go to Existing Viewport Showing Buffer~
|
||||
|
||||
The following keys will try to find the selected buffer in an existing
|
||||
viewport (whether on the current tab page or another). If the key presses are
|
||||
preceded by a number, then the buffer with that number will be the target
|
||||
buffer.
|
||||
|
||||
eo If currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), is showing in an existing
|
||||
viewport on this or any other tab page, go it it;
|
||||
otherwise show it in the previous window.
|
||||
es If currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), is showing in an existing
|
||||
viewport on this or any other tab page, go it it;
|
||||
otherwise show it in a new vertical split.
|
||||
ei If currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), is showing in an existing
|
||||
viewport on this or any other tab page, go it it;
|
||||
otherwise show it in a new horizontal split.
|
||||
et If currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), is showing in an existing
|
||||
viewport on this or any other tab page, go it it;
|
||||
otherwise show it in a new tab page.
|
||||
E If currently-selected buffer (or, if [count] is
|
||||
given, buffer with number [count]), is showing in an existing
|
||||
viewport on this or any other tab page, go it it;
|
||||
otherwise do nothing.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Window Control~
|
||||
|
||||
A Zoom/unzoom window, expanding to full height (if
|
||||
horizontally split) or full width (if vertically split)
|
||||
|
||||
===============================================================================
|
||||
*buffergator-tabpage-keys*
|
||||
KEY MAPPINGS (TAB PAGE CATALOG)~
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Catalog Management~
|
||||
|
||||
cd Cycle through display regimes.
|
||||
r Update (rebuild/refresh) index.
|
||||
q Quit the index/catalog window.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Open Selected Tab Page or Tab Page Window~
|
||||
|
||||
The following keys all open the currently-selected tab page or window.
|
||||
|
||||
<CR>, o Open the currently-selected tab page or window.
|
||||
<SPACE> Select the next tab page entry.
|
||||
<C-SPACE> Select the previous tab page entry.
|
||||
<C-N> Select the next tab page window entry.
|
||||
<C-P> Select the previous tab page window entry.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Window Control~
|
||||
|
||||
A Zoom/unzoom window, expanding to full height (if
|
||||
horizontally split) or full width (if vertically split)
|
||||
|
||||
|
||||
===============================================================================
|
||||
*buffergator-options*
|
||||
OPTIONS AND SETTINGS~
|
||||
|
||||
The following options can be used to customize the behavior of this plugin:
|
||||
|
||||
g:buffergator_viewport_split_policy~
|
||||
Default: "L"
|
||||
Determines how a new Buffergator window will be opened. Can be one of the
|
||||
following values:
|
||||
"L" : vertical left (full screen height)
|
||||
"R" : vertical right (full screen height)
|
||||
"T" : horizontal top (full screen width)
|
||||
"B" : horizontal bottom (full screen width)
|
||||
|
||||
g:buffergator_autodismiss_on_select~
|
||||
Default: 1
|
||||
If true, then selection an entry with <CR> will close the catalog. Otherwise,
|
||||
catalog stays open. Default is 1.
|
||||
|
||||
g:buffergator_autoexpand_on_split~
|
||||
Default: 1
|
||||
If true and running in GUI mode, then the application screen will be expanded
|
||||
to accommodate the Buffergator window.
|
||||
|
||||
g:buffergator_split_size~
|
||||
Default: 40
|
||||
If greater than 0, this will be the width of the Buffergator window in any
|
||||
vertical splitting mode, or its height in any horizontal splitting mode.
|
||||
|
||||
g:buffergator_sort_regime~
|
||||
Default: "bufnum"
|
||||
Sets the default sort regime for buffer listing:
|
||||
"bufnum" : sort by buffer number [default]
|
||||
"basename": sort by buffer file basename (followed by directory)
|
||||
"filepath": sort by full buffer filepath
|
||||
"extension": sort by buffer filename extension (followed by full
|
||||
filepath)
|
||||
"mru": sort by most recently used
|
||||
|
||||
g:buffergator_display_regime~
|
||||
Default: "basename"
|
||||
Sets the default sort regime for buffer listing:
|
||||
"basename": display buffer basename first,
|
||||
followed by directory [default]
|
||||
"filepath": display full buffer filepath
|
||||
"bufname": display buffer name
|
||||
|
||||
g:buffergator_suppress_keymaps~
|
||||
Default: 0
|
||||
If true, then Buffergator will not automatically map "<Leader>b" to
|
||||
open the Buffergator catalog and "<Leader>B" to close it.
|
||||
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,163 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#bookmarkdir#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmarkdir#getSwitchOrder()
|
||||
return g:fuf_bookmarkdir_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmarkdir#getEditableDataNames()
|
||||
return ['items']
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmarkdir#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmarkdir#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmarkdir#onInit()
|
||||
call fuf#defineLaunchCommand('FufBookmarkDir', s:MODE_NAME, '""', [])
|
||||
command! -bang -narg=? FufBookmarkDirAdd call s:bookmark(<q-args>)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
let s:OPEN_TYPE_DELETE = -1
|
||||
|
||||
"
|
||||
function s:bookmark(word)
|
||||
let item = {
|
||||
\ 'time' : localtime(),
|
||||
\ }
|
||||
|
||||
let item.path = l9#inputHl('Question', '[fuf] Directory to bookmark:',
|
||||
\ fnamemodify(getcwd(), ':p:~'), 'dir')
|
||||
if item.path !~ '\S'
|
||||
call fuf#echoWarning('Canceled')
|
||||
return
|
||||
endif
|
||||
let item.word = l9#inputHl('Question', '[fuf] Bookmark as:',
|
||||
\ fnamemodify(getcwd(), ':p:~'))
|
||||
if item.word !~ '\S'
|
||||
call fuf#echoWarning('Canceled')
|
||||
return
|
||||
endif
|
||||
let items = fuf#loadDataFile(s:MODE_NAME, 'items')
|
||||
call insert(items, item)
|
||||
call fuf#saveDataFile(s:MODE_NAME, 'items', items)
|
||||
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_bookmarkdir_prompt, self.partialMatching, '')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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)
|
||||
if a:mode ==# s:OPEN_TYPE_DELETE
|
||||
let items = fuf#loadDataFile(s:MODE_NAME, 'items')
|
||||
call filter(items, 'v:val.word !=# a:word')
|
||||
call fuf#saveDataFile(s:MODE_NAME, 'items', items)
|
||||
let self.reservedMode = self.getModeName()
|
||||
return
|
||||
else
|
||||
let item = s:findItem(fuf#loadDataFile(s:MODE_NAME, 'items'), a:word)
|
||||
if !empty(item)
|
||||
execute ':cd ' . fnameescape(item.path)
|
||||
endif
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
call fuf#defineKeyMappingInHandler(g:fuf_bookmarkdir_keyDelete,
|
||||
\ 'onCr(' . s:OPEN_TYPE_DELETE . ')')
|
||||
let self.items = fuf#loadDataFile(s:MODE_NAME, 'items')
|
||||
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:
|
||||
@@ -1,199 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#bookmarkfile#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmarkfile#getSwitchOrder()
|
||||
return g:fuf_bookmarkfile_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmarkfile#getEditableDataNames()
|
||||
return ['items']
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmarkfile#renewCache()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmarkfile#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#bookmarkfile#onInit()
|
||||
call fuf#defineLaunchCommand('FufBookmarkFile', s:MODE_NAME, '""', [])
|
||||
command! -bang -narg=? FufBookmarkFileAdd call s:bookmarkHere(<q-args>)
|
||||
command! -bang -narg=0 -range FufBookmarkFileAddAsSelectedText call s:bookmarkHere(l9#getSelectedText())
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
let s:OPEN_TYPE_DELETE = -1
|
||||
|
||||
" 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_bookmarkfile_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#echoWarning('Can''t bookmark this buffer.')
|
||||
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 = l9#inputHl('Question', '[fuf] Bookmark as:', item.word)
|
||||
if item.word !~ '\S'
|
||||
call fuf#echoWarning('Canceled')
|
||||
return
|
||||
endif
|
||||
let items = fuf#loadDataFile(s:MODE_NAME, 'items')
|
||||
call insert(items, item)
|
||||
call fuf#saveDataFile(s:MODE_NAME, 'items', items)
|
||||
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_bookmarkfile_prompt, self.partialMatching, '')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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(fuf#loadDataFile(s:MODE_NAME, 'items'), 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
|
||||
let items = fuf#loadDataFile(s:MODE_NAME, 'items')
|
||||
call filter(items, 'v:val.word !=# a:word')
|
||||
call fuf#saveDataFile(s:MODE_NAME, 'items', items)
|
||||
let self.reservedMode = self.getModeName()
|
||||
return
|
||||
else
|
||||
let item = s:findItem(fuf#loadDataFile(s:MODE_NAME, 'items'), 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_bookmarkfile_keyDelete,
|
||||
\ 'onCr(' . s:OPEN_TYPE_DELETE . ')')
|
||||
let self.items = fuf#loadDataFile(s:MODE_NAME, 'items')
|
||||
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:
|
||||
@@ -1,189 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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:OPEN_TYPE_DELETE = -1
|
||||
|
||||
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), ':p:~:.'))
|
||||
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.isOpenable(enteredPattern)
|
||||
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)
|
||||
" do nothing
|
||||
elseif a:mode ==# s:OPEN_TYPE_DELETE
|
||||
execute item.bufNr . 'bdelete'
|
||||
let self.reservedMode = self.getModeName()
|
||||
else
|
||||
call fuf#openBuffer(item.bufNr, a:mode, g:fuf_reuseWindow)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
call fuf#defineKeyMappingInHandler(g:fuf_buffer_keyDelete,
|
||||
\ 'onCr(' . s:OPEN_TYPE_DELETE . ')')
|
||||
let self.items = range(1, bufnr('$'))
|
||||
call filter(self.items, 'buflisted(v:val) && v:val != self.bufNrPrev && v:val != bufnr("%")')
|
||||
call map(self.items, 's:makeItem(v:val)')
|
||||
if g:fuf_buffer_mruOrder
|
||||
call sort(self.items, 's:compareTimeDescending')
|
||||
call fuf#mapToSetSerialIndex(self.items, 1)
|
||||
endif
|
||||
let self.items = fuf#mapToSetAbbrWithSnippedWordAsPath(self.items)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
@@ -1,300 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#buffertag#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#buffertag#getSwitchOrder()
|
||||
return g:fuf_buffertag_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#buffertag#getEditableDataNames()
|
||||
return []
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#buffertag#renewCache()
|
||||
let s:tagItemsCache = {}
|
||||
let s:tagDataCache = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#buffertag#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#buffertag#onInit()
|
||||
call fuf#defineLaunchCommand('FufBufferTag', s:MODE_NAME, '""',
|
||||
\ [['g:fuf_buffertag_forAll', 0]])
|
||||
call fuf#defineLaunchCommand('FufBufferTagAll', s:MODE_NAME, '""',
|
||||
\ [['g:fuf_buffertag_forAll', 1]])
|
||||
call fuf#defineLaunchCommand('FufBufferTagWithCursorWord', s:MODE_NAME,
|
||||
\ 'expand(''<cword>'')', [['g:fuf_buffertag_forAll', 0]])
|
||||
call fuf#defineLaunchCommand('FufBufferTagAllWithCursorWord', s:MODE_NAME,
|
||||
\ 'expand(''<cword>'')', [['g:fuf_buffertag_forAll', 1]])
|
||||
call fuf#defineLaunchCommand('FufBufferTagWithSelectedText', s:MODE_NAME,
|
||||
\ 'l9#getSelectedText()', [['g:fuf_buffertag_forAll', 0]])
|
||||
call fuf#defineLaunchCommand('FufBufferTagAllWithSelectedText', s:MODE_NAME,
|
||||
\ 'l9#getSelectedText()', [['g:fuf_buffertag_forAll', 1]])
|
||||
call l9#defineVariableDefault('g:fuf_buffertag_forAll', 0) " private option
|
||||
" the following settings originate from taglist.vim
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__asm' , '--language-force=asm --asm-types=dlmt')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__aspperl' , '--language-force=asp --asp-types=fsv')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__aspvbs' , '--language-force=asp --asp-types=fsv')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__awk' , '--language-force=awk --awk-types=f')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__beta' , '--language-force=beta --beta-types=fsv')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__c' , '--language-force=c --c-types=dgsutvf')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__cpp' , '--language-force=c++ --c++-types=nvdtcgsuf')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__cs' , '--language-force=c# --c#-types=dtncEgsipm')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__cobol' , '--language-force=cobol --cobol-types=dfgpPs')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__eiffel' , '--language-force=eiffel --eiffel-types=cf')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__erlang' , '--language-force=erlang --erlang-types=drmf')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__expect' , '--language-force=tcl --tcl-types=cfp')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__fortran' , '--language-force=fortran --fortran-types=pbceiklmntvfs')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__html' , '--language-force=html --html-types=af')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__java' , '--language-force=java --java-types=pcifm')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__javascript', '--language-force=javascript --javascript-types=f')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__lisp' , '--language-force=lisp --lisp-types=f')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__lua' , '--language-force=lua --lua-types=f')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__make' , '--language-force=make --make-types=m')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__pascal' , '--language-force=pascal --pascal-types=fp')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__perl' , '--language-force=perl --perl-types=clps')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__php' , '--language-force=php --php-types=cdvf')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__python' , '--language-force=python --python-types=cmf')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__rexx' , '--language-force=rexx --rexx-types=s')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__ruby' , '--language-force=ruby --ruby-types=cfFm')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__scheme' , '--language-force=scheme --scheme-types=sf')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__sh' , '--language-force=sh --sh-types=f')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__csh' , '--language-force=sh --sh-types=f')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__zsh' , '--language-force=sh --sh-types=f')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__slang' , '--language-force=slang --slang-types=nf')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__sml' , '--language-force=sml --sml-types=ecsrtvf')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__sql' , '--language-force=sql --sql-types=cFPrstTvfp')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__tcl' , '--language-force=tcl --tcl-types=cfmp')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__vera' , '--language-force=vera --vera-types=cdefgmpPtTvx')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__verilog' , '--language-force=verilog --verilog-types=mcPertwpvf')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__vim' , '--language-force=vim --vim-types=avf')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag__yacc' , '--language-force=yacc --yacc-types=l')
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:parseTagLine(line)
|
||||
" tag W:\Win32\SRC7\NCSIM\NCVW32\CUBEFACE.H /^#define CUBEFACE_H$/;" macro line:4
|
||||
let fields = matchlist(a:line, '\v^([^\t]+)\t(.+)\t\/\^(.+)\$\/\;\"\t(.+)\tline\:(\d+)')
|
||||
if empty(fields)
|
||||
return {}
|
||||
endif
|
||||
return {
|
||||
\ 'tag' : fields[1],
|
||||
\ 'fname' : fields[2],
|
||||
\ 'pattern': fields[3],
|
||||
\ 'kind' : fields[4],
|
||||
\ 'lnum' : str2nr(fields[5]),
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
"
|
||||
let s:TEMP_VARIABLES_GROUP = expand('<sfile>:p')
|
||||
|
||||
"
|
||||
function s:getFileType(bufNr)
|
||||
let ft = getbufvar(a:bufNr, '&filetype')
|
||||
if !empty(ft) || bufloaded(a:bufNr)
|
||||
return ft
|
||||
endif
|
||||
let ft = getbufvar(a:bufNr, 'fuf_buffertag_filetype')
|
||||
if !empty(ft)
|
||||
return ft
|
||||
endif
|
||||
call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP, '&eventignore', 'FileType')
|
||||
call l9#tempvariables#set(s:TEMP_VARIABLES_GROUP, '&filetype', &filetype)
|
||||
" from taglist.vim
|
||||
execute 'doautocmd filetypedetect BufRead ' . bufname(a:bufNr)
|
||||
let ft = &filetype
|
||||
call l9#tempvariables#end(s:TEMP_VARIABLES_GROUP)
|
||||
call setbufvar(a:bufNr, 'fuf_buffertag_filetype', ft)
|
||||
return ft
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:makeCtagsCmd(bufNr)
|
||||
let ft = s:getFileType(a:bufNr)
|
||||
if !exists('g:fuf_buffertag__{ft}')
|
||||
return ''
|
||||
endif
|
||||
"
|
||||
let cmd = join([g:fuf_buffertag_ctagsPath,
|
||||
\ '-f - --sort=no --excmd=pattern --fields=nKs',
|
||||
\ g:fuf_buffertag__{ft},
|
||||
\ shellescape(fnamemodify(bufname(a:bufNr), ':p'))])
|
||||
return cmd
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getTagItems(bufNr)
|
||||
let cmd = s:makeCtagsCmd(a:bufNr)
|
||||
if empty(cmd)
|
||||
return []
|
||||
elseif !exists('s:tagItemsCache[cmd]') ||
|
||||
\ s:tagItemsCache[cmd].time < getftime(expand(bufname(a:bufNr)))
|
||||
let items = split(system(cmd), "\n")
|
||||
if v:shell_error
|
||||
call fuf#echoError([cmd] + items)
|
||||
throw "Command error"
|
||||
endif
|
||||
call map(items, 's:parseTagLine(v:val)')
|
||||
call filter(items, '!empty(v:val)')
|
||||
let s:tagItemsCache[cmd] = {
|
||||
\ 'time' : localtime(),
|
||||
\ 'items' : items,
|
||||
\ }
|
||||
endif
|
||||
return s:tagItemsCache[cmd].items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:makeItem(tag, itemMap)
|
||||
let menu = fnamemodify(a:itemMap[a:tag][0].fname, ':t')
|
||||
\ . ' [' . a:itemMap[a:tag][0].kind . ']'
|
||||
if len(a:itemMap[a:tag]) > 1
|
||||
let menu .= ' (' . len(a:itemMap[a:tag]) . ')'
|
||||
endif
|
||||
let item = fuf#makeNonPathItem(a:tag, menu)
|
||||
return item
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getTagData(bufNrs)
|
||||
let key = join([0] + sort(copy(a:bufNrs)), "\n")
|
||||
let bufNames = map(copy(a:bufNrs), 'bufname(v:val)')
|
||||
if !exists('s:tagDataCache[key]') ||
|
||||
\ fuf#countModifiedFiles(bufNames, s:tagDataCache[key].time) > 0
|
||||
let itemMap = {}
|
||||
for item in l9#concat(map(copy(a:bufNrs), 's:getTagItems(v:val)'))
|
||||
if !exists('itemMap[item.tag]')
|
||||
let itemMap[item.tag] = []
|
||||
endif
|
||||
call add(itemMap[item.tag], item)
|
||||
endfor
|
||||
let items = sort(keys(itemMap))
|
||||
call map(items, 's:makeItem(v:val, itemMap)')
|
||||
call fuf#mapToSetSerialIndex(items, 1)
|
||||
call map(items, 'fuf#setAbbrWithFormattedWord(v:val, 1)')
|
||||
let s:tagDataCache[key] = {
|
||||
\ 'time' : localtime(),
|
||||
\ 'itemMap': itemMap,
|
||||
\ 'items' : items,
|
||||
\ }
|
||||
endif
|
||||
return [s:tagDataCache[key].items, s:tagDataCache[key].itemMap]
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:jumpToTag(item, mode)
|
||||
call fuf#openFile(a:item.fname, a:mode, g:fuf_reuseWindow)
|
||||
call cursor(a:item.lnum, 1)
|
||||
normal! zvzz
|
||||
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_buffertag_prompt, self.partialMatching, '')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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)
|
||||
if !exists('self.itemMap[a:word][0]')
|
||||
call fuf#echoError('Definition not found:' . a:word)
|
||||
return
|
||||
elseif len(self.itemMap[a:word]) == 1
|
||||
let i = 0
|
||||
else
|
||||
let list = map(fuf#mapToSetSerialIndex(copy(self.itemMap[a:word]), 1),
|
||||
\ 'printf(" %2d: %s|%d| [%s] %s",v:val.index, fnamemodify(v:val.fname, ":~:."), v:val.lnum, v:val.kind, v:val.pattern)')
|
||||
let i = inputlist(['Select a definition of "' . a:word . '":'] + list) - 1
|
||||
endif
|
||||
if 0 <= i && i < len(self.itemMap[a:word])
|
||||
call s:jumpToTag(self.itemMap[a:word][i], a:mode)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
if g:fuf_buffertag_forAll
|
||||
let bufNrs = filter(range(1, bufnr('$')), 'buflisted(v:val)')
|
||||
else
|
||||
let bufNrs = [self.bufNrPrev]
|
||||
endif
|
||||
let [self.items, self.itemMap] = s:getTagData(bufNrs)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
@@ -1,137 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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() . g:fuf_ignoreCase . 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.isOpenable(enteredPattern)
|
||||
return a:enteredPattern =~# '[^/\\]$'
|
||||
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 && exists('s:listener.onAbort()')
|
||||
call s:listener.onAbort()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
@@ -1,139 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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 && exists('s:listener.onAbort()')
|
||||
call s:listener.onAbort()
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
@@ -1,172 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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:
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GLOBAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function fuf#coveragefile#createHandler(base)
|
||||
return a:base.concretize(copy(s:handler))
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#coveragefile#getSwitchOrder()
|
||||
return g:fuf_coveragefile_switchOrder
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#coveragefile#getEditableDataNames()
|
||||
return ['coverages']
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#coveragefile#renewCache()
|
||||
let s:cache = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#coveragefile#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#coveragefile#onInit()
|
||||
call fuf#defineLaunchCommand('FufCoverageFile', s:MODE_NAME, '""', [])
|
||||
call l9#defineVariableDefault('g:fuf_coveragefile_name', '') " private option
|
||||
command! -bang -narg=0 FufCoverageFileRegister call s:registerCoverage()
|
||||
command! -bang -narg=? FufCoverageFileChange call s:changeCoverage(<q-args>)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
|
||||
"
|
||||
function s:enumItems()
|
||||
let key = join([getcwd(), g:fuf_ignoreCase, g:fuf_coveragefile_exclude,
|
||||
\ g:fuf_coveragefile_globPatterns], "\n")
|
||||
if !exists('s:cache[key]')
|
||||
let s:cache[key] = l9#concat(map(copy(g:fuf_coveragefile_globPatterns),
|
||||
\ 'fuf#glob(v:val)'))
|
||||
call filter(s:cache[key], 'filereadable(v:val)') " filter out directories
|
||||
call map(s:cache[key], 'fuf#makePathItem(fnamemodify(v:val, ":~:."), "", 0)')
|
||||
if len(g:fuf_coveragefile_exclude)
|
||||
call filter(s:cache[key], 'v:val.word !~ g:fuf_coveragefile_exclude')
|
||||
endif
|
||||
call fuf#mapToSetSerialIndex(s:cache[key], 1)
|
||||
call fuf#mapToSetAbbrWithSnippedWordAsPath(s:cache[key])
|
||||
endif
|
||||
return s:cache[key]
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:registerCoverage()
|
||||
let patterns = []
|
||||
while 1
|
||||
let pattern = l9#inputHl('Question', '[fuf] Glob pattern for coverage (<Esc> and end):',
|
||||
\ '', 'file')
|
||||
if pattern !~ '\S'
|
||||
break
|
||||
endif
|
||||
call add(patterns, pattern)
|
||||
endwhile
|
||||
if empty(patterns)
|
||||
call fuf#echoWarning('Canceled')
|
||||
return
|
||||
endif
|
||||
echo '[fuf] patterns: ' . string(patterns)
|
||||
let name = l9#inputHl('Question', '[fuf] Coverage name:')
|
||||
if name !~ '\S'
|
||||
call fuf#echoWarning('Canceled')
|
||||
return
|
||||
endif
|
||||
let coverages = fuf#loadDataFile(s:MODE_NAME, 'coverages')
|
||||
call insert(coverages, {'name': name, 'patterns': patterns})
|
||||
call fuf#saveDataFile(s:MODE_NAME, 'coverages', coverages)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:createChangeCoverageListener()
|
||||
let listener = {}
|
||||
|
||||
function listener.onComplete(name, method)
|
||||
call s:changeCoverage(a:name)
|
||||
endfunction
|
||||
|
||||
return listener
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:changeCoverage(name)
|
||||
let coverages = fuf#loadDataFile(s:MODE_NAME, 'coverages')
|
||||
if a:name !~ '\S'
|
||||
let names = map(copy(coverages), 'v:val.name')
|
||||
call fuf#callbackitem#launch('', 0, '>Coverage>', s:createChangeCoverageListener(), names, 0)
|
||||
return
|
||||
else
|
||||
let name = a:name
|
||||
endif
|
||||
call filter(coverages, 'v:val.name ==# name')
|
||||
if empty(coverages)
|
||||
call fuf#echoError('Coverage not found: ' . name)
|
||||
return
|
||||
endif
|
||||
call fuf#setOneTimeVariables(
|
||||
\ ['g:fuf_coveragefile_globPatterns', coverages[0].patterns],
|
||||
\ ['g:fuf_coveragefile_name' , a:name]
|
||||
\ )
|
||||
FufCoverageFile
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
let nameString = (empty(g:fuf_coveragefile_name) ? ''
|
||||
\ : '[' . g:fuf_coveragefile_name . ']')
|
||||
return fuf#formatPrompt(g:fuf_coveragefile_prompt, self.partialMatching,
|
||||
\ nameString)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.isOpenable(enteredPattern)
|
||||
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()
|
||||
" NOTE: Comparing filenames is faster than bufnr('^' . fname . '$')
|
||||
let bufNamePrev = fnamemodify(bufname(self.bufNrPrev), ':~:.')
|
||||
let self.items = copy(s:enumItems())
|
||||
call filter(self.items, 'v:val.word !=# bufNamePrev')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
@@ -1,132 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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_ignoreCase . 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.isOpenable(enteredPattern)
|
||||
return a:enteredPattern =~# '[^/\\]$'
|
||||
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(
|
||||
\ fuf#glob(fnamemodify(a:word, ':p') . '*'),
|
||||
\ [], 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:
|
||||
@@ -1,139 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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 = join([getcwd(), g:fuf_ignoreCase, g:fuf_file_exclude, a:dir], "\n")
|
||||
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, bufNrPrev, cache)
|
||||
let key = a:dir . 'AVOIDING EMPTY KEY'
|
||||
if !exists('a:cache[key]')
|
||||
" NOTE: Comparing filenames is faster than bufnr('^' . fname . '$')
|
||||
let bufNamePrev = bufname(a:bufNrPrev)
|
||||
let a:cache[key] =
|
||||
\ filter(copy(s:enumItems(a:dir)), 'v:val.word !=# bufNamePrev')
|
||||
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.isOpenable(enteredPattern)
|
||||
return a:enteredPattern =~# '[^/\\]$'
|
||||
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:
|
||||
@@ -1,123 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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:
|
||||
@@ -1,123 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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.isOpenable(enteredPattern)
|
||||
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(
|
||||
\ fuf#glob(fnamemodify(a:word, ':p') . '*'),
|
||||
\ [], 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:
|
||||
@@ -1,121 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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.isOpenable(enteredPattern)
|
||||
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:
|
||||
@@ -1,198 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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' . l9#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') . l9#getPathSeparator()
|
||||
return {
|
||||
\ 'word' : elements[0] . suffix,
|
||||
\ 'path' : dir . elements[1],
|
||||
\ 'pattern': elements[2][1:],
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:getHelpTagEntries(tagFile)
|
||||
let names = map(l9#readFile(a:tagFile), 's:parseHelpTagEntry(v:val, a:tagFile)')
|
||||
return filter(names, '!empty(v:val)')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:parseHelpTagFiles(tagFiles, key)
|
||||
let cacheName = 'cache-' . l9#hash224(a:key)
|
||||
let cacheTime = fuf#getDataFileTime(s:MODE_NAME, cacheName)
|
||||
if cacheTime != -1 && fuf#countModifiedFiles(a:tagFiles, cacheTime) == 0
|
||||
return fuf#loadDataFile(s:MODE_NAME, cacheName)
|
||||
endif
|
||||
let items = l9#unique(l9#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)')
|
||||
call fuf#saveDataFile(s:MODE_NAME, cacheName, items)
|
||||
return items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:enumHelpTags(tagFiles)
|
||||
if !len(a:tagFiles)
|
||||
return []
|
||||
endif
|
||||
let key = join([g:fuf_ignoreCase] + 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, key)
|
||||
\ }
|
||||
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.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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:
|
||||
@@ -1,182 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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:
|
||||
|
||||
@@ -1,135 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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:
|
||||
@@ -1,134 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return ['items']
|
||||
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 items = fuf#loadDataFile(s:MODE_NAME, 'items')
|
||||
let items = fuf#updateMruList(
|
||||
\ items, { 'word' : a:cmd, 'time' : localtime() },
|
||||
\ g:fuf_mrucmd_maxItem, g:fuf_mrucmd_exclude)
|
||||
call fuf#saveDataFile(s:MODE_NAME, 'items', 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_mrucmd_prompt, self.partialMatching, '')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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 = fuf#loadDataFile(s:MODE_NAME, 'items')
|
||||
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:
|
||||
@@ -1,234 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return ['items', 'itemdirs']
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrufile#renewCache()
|
||||
let s:cache = {}
|
||||
let s:aroundCache = {}
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrufile#requiresOnCommandPre()
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
"
|
||||
function fuf#mrufile#onInit()
|
||||
call fuf#defineLaunchCommand('FufMruFile', s:MODE_NAME, '""', [])
|
||||
call fuf#defineLaunchCommand('FufMruFileInCwd', s:MODE_NAME,
|
||||
\ '""', [['g:fuf_mrufile_underCwd', 1]])
|
||||
call l9#defineVariableDefault('g:fuf_mrufile_underCwd', 0) " private option
|
||||
call l9#defineVariableDefault('g:fuf_mrufile_searchAroundLevel', -1) " private option
|
||||
augroup fuf#mrufile
|
||||
autocmd!
|
||||
autocmd BufEnter * call s:updateData()
|
||||
autocmd BufWritePost * call s:updateData()
|
||||
augroup END
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS/VARIABLES {{{1
|
||||
|
||||
let s:MODE_NAME = expand('<sfile>:t:r')
|
||||
let s:OPEN_TYPE_EXPAND = -1
|
||||
|
||||
"
|
||||
function s:updateData()
|
||||
if !empty(&buftype) || !filereadable(expand('%'))
|
||||
return
|
||||
endif
|
||||
let items = fuf#loadDataFile(s:MODE_NAME, 'items')
|
||||
let items = fuf#updateMruList(
|
||||
\ items, { 'word' : expand('%:p'), 'time' : localtime() },
|
||||
\ g:fuf_mrufile_maxItem, g:fuf_mrufile_exclude)
|
||||
call fuf#saveDataFile(s:MODE_NAME, 'items', items)
|
||||
call s:removeItemFromCache(expand('%:p'))
|
||||
let itemDirs = fuf#loadDataFile(s:MODE_NAME, 'itemdirs')
|
||||
let itemDirs = fuf#updateMruList(
|
||||
\ itemDirs, { 'word' : expand('%:p:h') },
|
||||
\ g:fuf_mrufile_maxItemDir, g:fuf_mrufile_exclude)
|
||||
call fuf#saveDataFile(s:MODE_NAME, 'itemdirs', itemDirs)
|
||||
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, ':p:~'), strftime(g:fuf_timeFormat, a:item.time), 0)
|
||||
else
|
||||
let s:cache[a:item.word] = {}
|
||||
endif
|
||||
endif
|
||||
return s:cache[a:item.word]
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:expandSearchDir(dir, level)
|
||||
let dirs = [a:dir]
|
||||
let dirPrev = a:dir
|
||||
for i in range(a:level)
|
||||
let dirPrev = l9#concatPaths([dirPrev, '*'])
|
||||
call add(dirs, dirPrev)
|
||||
endfor
|
||||
let dirPrev = a:dir
|
||||
for i in range(a:level)
|
||||
let dirPrevPrev = dirPrev
|
||||
let dirPrev = fnamemodify(dirPrev, ':h')
|
||||
if dirPrevPrev ==# dirPrev
|
||||
break
|
||||
endif
|
||||
call add(dirs, dirPrev)
|
||||
endfor
|
||||
return dirs
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:listAroundFiles(dir)
|
||||
if !exists('s:aroundCache[a:dir]')
|
||||
let s:aroundCache[a:dir] = [a:dir] +
|
||||
\ fuf#glob(l9#concatPaths([a:dir, '*' ])) +
|
||||
\ fuf#glob(l9#concatPaths([a:dir, '.*']))
|
||||
call filter(s:aroundCache[a:dir], 'filereadable(v:val)')
|
||||
call map(s:aroundCache[a:dir], 'fuf#makePathItem(fnamemodify(v:val, ":~"), "", 0)')
|
||||
if len(g:fuf_mrufile_exclude)
|
||||
call filter(s:aroundCache[a:dir], 'v:val.word !~ g:fuf_mrufile_exclude')
|
||||
endif
|
||||
endif
|
||||
return s:aroundCache[a:dir]
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" s:handler {{{1
|
||||
|
||||
let s:handler = {}
|
||||
|
||||
"
|
||||
function s:handler.getModeName()
|
||||
return s:MODE_NAME
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPrompt()
|
||||
let cwdString = (g:fuf_mrufile_underCwd ? '[CWD]' : '')
|
||||
let levelString = (g:fuf_mrufile_searchAroundLevel < 0 ? ''
|
||||
\ : '[Around:' . g:fuf_mrufile_searchAroundLevel . ']')
|
||||
return fuf#formatPrompt(g:fuf_mrufile_prompt, self.partialMatching, cwdString . levelString)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.getPreviewHeight()
|
||||
return g:fuf_previewHeight
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.isOpenable(enteredPattern)
|
||||
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)
|
||||
if a:mode ==# s:OPEN_TYPE_EXPAND
|
||||
let nextLevel = (self.searchAroundLevel < 0 ? 0 : self.searchAroundLevel + 1)
|
||||
call fuf#setOneTimeVariables(['g:fuf_mrufile_searchAroundLevel', nextLevel])
|
||||
let self.reservedMode = self.getModeName()
|
||||
return
|
||||
else
|
||||
call fuf#openFile(a:word, a:mode, g:fuf_reuseWindow)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPre()
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeEnterPost()
|
||||
let self.searchAroundLevel = g:fuf_mrufile_searchAroundLevel
|
||||
call fuf#defineKeyMappingInHandler(g:fuf_mrufile_keyExpand,
|
||||
\ 'onCr(' . s:OPEN_TYPE_EXPAND . ')')
|
||||
if self.searchAroundLevel < 0
|
||||
let self.items = fuf#loadDataFile(s:MODE_NAME, 'items')
|
||||
call map(self.items, 's:formatItemUsingCache(v:val)')
|
||||
else
|
||||
let self.items = fuf#loadDataFile(s:MODE_NAME, 'itemdirs')
|
||||
call map(self.items, 's:expandSearchDir(v:val.word, g:fuf_mrufile_searchAroundLevel)')
|
||||
let self.items = l9#concat(self.items)
|
||||
let self.items = l9#unique(self.items)
|
||||
call map(self.items, 's:listAroundFiles(v:val)')
|
||||
let self.items = l9#concat(self.items)
|
||||
endif
|
||||
" NOTE: Comparing filenames is faster than bufnr('^' . fname . '$')
|
||||
let bufNamePrev = fnamemodify(bufname(self.bufNrPrev), ':p:~')
|
||||
call filter(self.items, '!empty(v:val) && v:val.word !=# bufNamePrev')
|
||||
if g:fuf_mrufile_underCwd
|
||||
let cwd = fnamemodify(getcwd(), ':p:~')
|
||||
call filter(self.items, 'stridx(v:val.word, cwd) == 0')
|
||||
endif
|
||||
call fuf#mapToSetSerialIndex(self.items, 1)
|
||||
call fuf#mapToSetAbbrWithSnippedWordAsPath(self.items)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
@@ -1,154 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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:
|
||||
|
||||
@@ -1,178 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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(l9#readFile(a:tagFile), 'matchstr(v:val, ''^[^!\t][^\t]*'')')
|
||||
return filter(names, 'v:val =~# ''\S''')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:parseTagFiles(tagFiles, key)
|
||||
let cacheName = 'cache-' . l9#hash224(a:key)
|
||||
let cacheTime = fuf#getDataFileTime(s:MODE_NAME, cacheName)
|
||||
if cacheTime != -1 && fuf#countModifiedFiles(a:tagFiles, cacheTime) == 0
|
||||
return fuf#loadDataFile(s:MODE_NAME, cacheName)
|
||||
endif
|
||||
let items = l9#unique(l9#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)')
|
||||
call fuf#saveDataFile(s:MODE_NAME, cacheName, items)
|
||||
return items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:enumTags(tagFiles)
|
||||
if !len(a:tagFiles)
|
||||
return []
|
||||
endif
|
||||
let key = join([g:fuf_ignoreCase] + 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, key)
|
||||
\ }
|
||||
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.isOpenable(enteredPattern)
|
||||
return 1
|
||||
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:
|
||||
@@ -1,159 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}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#getEditableDataNames()
|
||||
return []
|
||||
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(l9#readFile(a:tagfile), 'matchstr(v:val, ''^[^!\t][^\t]*\t\zs[^\t]\+'')')
|
||||
call map(l9#readFile(a:tagfile), 'fnamemodify(v:val, ":p")')
|
||||
cd -
|
||||
call map(l9#readFile(a:tagfile), 'fnamemodify(v:val, ":~:.")')
|
||||
return filter(result, 'v:val =~# ''[^/\\ ]$''')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:parseTagFiles(tagFiles, key)
|
||||
let cacheName = 'cache-' . l9#hash224(a:key)
|
||||
let cacheTime = fuf#getDataFileTime(s:MODE_NAME, cacheName)
|
||||
if cacheTime != -1 && fuf#countModifiedFiles(a:tagFiles, cacheTime) == 0
|
||||
return fuf#loadDataFile(s:MODE_NAME, cacheName)
|
||||
endif
|
||||
let items = l9#unique(l9#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)
|
||||
call fuf#saveDataFile(s:MODE_NAME, cacheName, items)
|
||||
return items
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:enumTaggedFiles(tagFiles)
|
||||
if !len(a:tagFiles)
|
||||
return []
|
||||
endif
|
||||
let key = join([getcwd(), g:fuf_ignoreCase] + 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, key)
|
||||
\ }
|
||||
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.isOpenable(enteredPattern)
|
||||
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: Comparing filenames is faster than bufnr('^' . fname . '$')
|
||||
let bufNamePrev = fnamemodify(bufname(self.bufNrPrev), ':p:~:.')
|
||||
" NOTE: Don't do this in onModeEnterPre()
|
||||
" because that should return in a short time.
|
||||
let self.items = copy(s:enumTaggedFiles(self.tagFiles))
|
||||
call filter(self.items, 'v:val.word !=# bufNamePrev')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:handler.onModeLeavePost(opened)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,158 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2007-2010 Takeshi NISHIDA
|
||||
"
|
||||
" GetLatestVimScripts: 1984 1 :AutoInstall: FuzzyFinder
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
try
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 702, 101, [])
|
||||
finish
|
||||
endif
|
||||
catch /E117/
|
||||
echoerr '***** L9 library must be installed! *****'
|
||||
finish
|
||||
endtry
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LOCAL FUNCTIONS {{{1
|
||||
|
||||
"
|
||||
function s:initialize()
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_modesDisable' , [ 'mrufile', 'mrucmd', ])
|
||||
call l9#defineVariableDefault('g:fuf_keyOpen' , '<CR>')
|
||||
call l9#defineVariableDefault('g:fuf_keyOpenSplit' , '<C-j>')
|
||||
call l9#defineVariableDefault('g:fuf_keyOpenVsplit' , '<C-k>')
|
||||
call l9#defineVariableDefault('g:fuf_keyOpenTabpage' , '<C-l>')
|
||||
call l9#defineVariableDefault('g:fuf_keyPreview' , '<C-@>')
|
||||
call l9#defineVariableDefault('g:fuf_keyNextMode' , '<C-t>')
|
||||
call l9#defineVariableDefault('g:fuf_keyPrevMode' , '<C-y>')
|
||||
call l9#defineVariableDefault('g:fuf_keyPrevPattern' , '<C-s>')
|
||||
call l9#defineVariableDefault('g:fuf_keyNextPattern' , '<C-_>')
|
||||
call l9#defineVariableDefault('g:fuf_keySwitchMatching', '<C-\><C-\>')
|
||||
call l9#defineVariableDefault('g:fuf_dataDir' , '~/.vim-fuf-data')
|
||||
call l9#defineVariableDefault('g:fuf_abbrevMap' , {})
|
||||
call l9#defineVariableDefault('g:fuf_patternSeparator' , ';')
|
||||
call l9#defineVariableDefault('g:fuf_promptHighlight' , 'Question')
|
||||
call l9#defineVariableDefault('g:fuf_ignoreCase' , 1)
|
||||
call l9#defineVariableDefault('g:fuf_splitPathMatching', 1)
|
||||
call l9#defineVariableDefault('g:fuf_fuzzyRefining' , 0)
|
||||
call l9#defineVariableDefault('g:fuf_smartBs' , 1)
|
||||
call l9#defineVariableDefault('g:fuf_reuseWindow' , 1)
|
||||
call l9#defineVariableDefault('g:fuf_timeFormat' , '(%Y-%m-%d %H:%M:%S)')
|
||||
call l9#defineVariableDefault('g:fuf_learningLimit' , 100)
|
||||
call l9#defineVariableDefault('g:fuf_enumeratingLimit' , 50)
|
||||
call l9#defineVariableDefault('g:fuf_maxMenuWidth' , 78)
|
||||
call l9#defineVariableDefault('g:fuf_previewHeight' , 0)
|
||||
call l9#defineVariableDefault('g:fuf_autoPreview' , 0)
|
||||
call l9#defineVariableDefault('g:fuf_useMigemo' , 0)
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_buffer_prompt' , '>Buffer[]>')
|
||||
call l9#defineVariableDefault('g:fuf_buffer_switchOrder', 10)
|
||||
call l9#defineVariableDefault('g:fuf_buffer_mruOrder' , 1)
|
||||
call l9#defineVariableDefault('g:fuf_buffer_keyDelete' , '<C-]>')
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_file_prompt' , '>File[]>')
|
||||
call l9#defineVariableDefault('g:fuf_file_switchOrder', 20)
|
||||
call l9#defineVariableDefault('g:fuf_file_exclude' , '\v\~$|\.(o|exe|dll|bak|orig|sw[po])$|(^|[/\\])\.(hg|git|bzr)($|[/\\])')
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_coveragefile_prompt' , '>CoverageFile[]>')
|
||||
call l9#defineVariableDefault('g:fuf_coveragefile_switchOrder', 30)
|
||||
call l9#defineVariableDefault('g:fuf_coveragefile_exclude' , '\v\~$|\.(o|exe|dll|bak|orig|sw[po])$|(^|[/\\])\.(hg|git|bzr)($|[/\\])')
|
||||
call l9#defineVariableDefault('g:fuf_coveragefile_globPatterns', ['**/.*', '**/*'])
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_dir_prompt' , '>Dir[]>')
|
||||
call l9#defineVariableDefault('g:fuf_dir_switchOrder', 40)
|
||||
call l9#defineVariableDefault('g:fuf_dir_exclude' , '\v(^|[/\\])\.(hg|git|bzr)($|[/\\])')
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_mrufile_prompt' , '>MRU-File[]>')
|
||||
call l9#defineVariableDefault('g:fuf_mrufile_switchOrder', 50)
|
||||
call l9#defineVariableDefault('g:fuf_mrufile_exclude' , '\v\~$|\.(o|exe|dll|bak|orig|sw[po])$|^(\/\/|\\\\|\/mnt\/|\/media\/)')
|
||||
call l9#defineVariableDefault('g:fuf_mrufile_maxItem' , 200)
|
||||
call l9#defineVariableDefault('g:fuf_mrufile_maxItemDir' , 50)
|
||||
call l9#defineVariableDefault('g:fuf_mrufile_keyExpand' , '<C-]>')
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_mrucmd_prompt' , '>MRU-Cmd[]>')
|
||||
call l9#defineVariableDefault('g:fuf_mrucmd_switchOrder', 60)
|
||||
call l9#defineVariableDefault('g:fuf_mrucmd_exclude' , '^$')
|
||||
call l9#defineVariableDefault('g:fuf_mrucmd_maxItem' , 200)
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_bookmarkfile_prompt' , '>Bookmark-File[]>')
|
||||
call l9#defineVariableDefault('g:fuf_bookmarkfile_switchOrder', 70)
|
||||
call l9#defineVariableDefault('g:fuf_bookmarkfile_searchRange', 400)
|
||||
call l9#defineVariableDefault('g:fuf_bookmarkfile_keyDelete' , '<C-]>')
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_bookmarkdir_prompt' , '>Bookmark-Dir[]>')
|
||||
call l9#defineVariableDefault('g:fuf_bookmarkdir_switchOrder', 80)
|
||||
call l9#defineVariableDefault('g:fuf_bookmarkdir_keyDelete' , '<C-]>')
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_tag_prompt' , '>Tag[]>')
|
||||
call l9#defineVariableDefault('g:fuf_tag_switchOrder', 90)
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_buffertag_prompt' , '>Buffer-Tag[]>')
|
||||
call l9#defineVariableDefault('g:fuf_buffertag_switchOrder', 100)
|
||||
call l9#defineVariableDefault('g:fuf_buffertag_ctagsPath' , 'ctags')
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_taggedfile_prompt' , '>Tagged-File[]>')
|
||||
call l9#defineVariableDefault('g:fuf_taggedfile_switchOrder', 110)
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_jumplist_prompt' , '>Jump-List[]>')
|
||||
call l9#defineVariableDefault('g:fuf_jumplist_switchOrder', 120)
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_changelist_prompt' , '>Change-List[]>')
|
||||
call l9#defineVariableDefault('g:fuf_changelist_switchOrder', 130)
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_quickfix_prompt' , '>Quickfix[]>')
|
||||
call l9#defineVariableDefault('g:fuf_quickfix_switchOrder', 140)
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_line_prompt' , '>Line[]>')
|
||||
call l9#defineVariableDefault('g:fuf_line_switchOrder', 150)
|
||||
"---------------------------------------------------------------------------
|
||||
call l9#defineVariableDefault('g:fuf_help_prompt' , '>Help[]>')
|
||||
call l9#defineVariableDefault('g:fuf_help_switchOrder', 160)
|
||||
"---------------------------------------------------------------------------
|
||||
command! -bang -narg=0 FufEditDataFile call fuf#editDataFile()
|
||||
command! -bang -narg=0 FufRenewCache call s:renewCachesOfAllModes()
|
||||
"---------------------------------------------------------------------------
|
||||
call fuf#addMode('buffer')
|
||||
call fuf#addMode('file')
|
||||
call fuf#addMode('coveragefile')
|
||||
call fuf#addMode('dir')
|
||||
call fuf#addMode('mrufile')
|
||||
call fuf#addMode('mrucmd')
|
||||
call fuf#addMode('bookmarkfile')
|
||||
call fuf#addMode('bookmarkdir')
|
||||
call fuf#addMode('tag')
|
||||
call fuf#addMode('buffertag')
|
||||
call fuf#addMode('taggedfile')
|
||||
call fuf#addMode('jumplist')
|
||||
call fuf#addMode('changelist')
|
||||
call fuf#addMode('quickfix')
|
||||
call fuf#addMode('line')
|
||||
call fuf#addMode('help')
|
||||
call fuf#addMode('givenfile')
|
||||
call fuf#addMode('givendir')
|
||||
call fuf#addMode('givencmd')
|
||||
call fuf#addMode('callbackfile')
|
||||
call fuf#addMode('callbackitem')
|
||||
"---------------------------------------------------------------------------
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:renewCachesOfAllModes()
|
||||
for m in fuf#getModeNames()
|
||||
call fuf#{m}#renewCache()
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" INITIALIZATION {{{1
|
||||
|
||||
call s:initialize()
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
8
bundle/git_ctrlp/.gitignore
vendored
Normal file
8
bundle/git_ctrlp/.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
.hgignore
|
||||
*.markdown
|
||||
*.zip
|
||||
wiki.md
|
||||
note.txt
|
||||
tags
|
||||
.hg/*
|
||||
tmp/*
|
||||
1519
bundle/git_ctrlp/autoload/ctrlp.vim
Normal file
1519
bundle/git_ctrlp/autoload/ctrlp.vim
Normal file
File diff suppressed because it is too large
Load Diff
234
bundle/git_ctrlp/autoload/ctrlp/buffertag.vim
Normal file
234
bundle/git_ctrlp/autoload/ctrlp/buffertag.vim
Normal file
@@ -0,0 +1,234 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/buffertag.vim
|
||||
" Description: Buffer Tag extension
|
||||
" Maintainer: Kien Nguyen <github.com/kien>
|
||||
" Credits: Much of the code was taken from tagbar.vim by Jan Larres, plus
|
||||
" a few lines from taglist.vim by Yegappan Lakshmanan and from
|
||||
" buffertag.vim by Takeshi Nishida.
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_buftag') && g:loaded_ctrlp_buftag
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_buftag = 1
|
||||
|
||||
let s:buftag_var = {
|
||||
\ 'init': 'ctrlp#buffertag#init(s:crfile)',
|
||||
\ 'accept': 'ctrlp#buffertag#accept',
|
||||
\ 'lname': 'buffer tags',
|
||||
\ 'sname': 'bft',
|
||||
\ 'exit': 'ctrlp#buffertag#exit()',
|
||||
\ 'type': 'tabs',
|
||||
\ }
|
||||
|
||||
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
||||
\ ? add(g:ctrlp_ext_vars, s:buftag_var) : [s:buftag_var]
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
|
||||
fu! s:opts()
|
||||
let opts = {
|
||||
\ 'g:ctrlp_buftag_systemenc': ['s:enc', &enc],
|
||||
\ 'g:ctrlp_buftag_ctags_bin': ['s:bin', ''],
|
||||
\ 'g:ctrlp_buftag_types': ['s:usr_types', ''],
|
||||
\ }
|
||||
for [ke, va] in items(opts)
|
||||
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1])
|
||||
endfo
|
||||
endf
|
||||
cal s:opts()
|
||||
|
||||
fu! s:bins()
|
||||
let bins = [
|
||||
\ 'ctags-exuberant',
|
||||
\ 'exuberant-ctags',
|
||||
\ 'exctags',
|
||||
\ '/usr/local/bin/ctags',
|
||||
\ '/opt/local/bin/ctags',
|
||||
\ 'ctags',
|
||||
\ 'ctags.exe',
|
||||
\ 'tags',
|
||||
\ ]
|
||||
if empty(s:bin)
|
||||
for bin in bins | if executable(bin)
|
||||
let s:bin = bin
|
||||
brea
|
||||
en | endfo
|
||||
el
|
||||
let s:bin = expand(s:bin, 1)
|
||||
en
|
||||
endf
|
||||
cal s:bins()
|
||||
|
||||
" s:types {{{2
|
||||
let s:types = {
|
||||
\ 'asm' : '%sasm%sasm%sdlmt',
|
||||
\ 'aspperl': '%sasp%sasp%sfsv',
|
||||
\ 'aspvbs' : '%sasp%sasp%sfsv',
|
||||
\ 'awk' : '%sawk%sawk%sf',
|
||||
\ 'beta' : '%sbeta%sbeta%sfsv',
|
||||
\ 'c' : '%sc%sc%sdgsutvf',
|
||||
\ 'cpp' : '%sc++%sc++%snvdtcgsuf',
|
||||
\ 'cs' : '%sc#%sc#%sdtncEgsipm',
|
||||
\ 'cobol' : '%scobol%scobol%sdfgpPs',
|
||||
\ 'eiffel' : '%seiffel%seiffel%scf',
|
||||
\ 'erlang' : '%serlang%serlang%sdrmf',
|
||||
\ 'expect' : '%stcl%stcl%scfp',
|
||||
\ 'fortran': '%sfortran%sfortran%spbceiklmntvfs',
|
||||
\ 'html' : '%shtml%shtml%saf',
|
||||
\ 'java' : '%sjava%sjava%spcifm',
|
||||
\ 'javascript': '%sjavascript%sjavascript%sf',
|
||||
\ 'lisp' : '%slisp%slisp%sf',
|
||||
\ 'lua' : '%slua%slua%sf',
|
||||
\ 'make' : '%smake%smake%sm',
|
||||
\ 'pascal' : '%spascal%spascal%sfp',
|
||||
\ 'perl' : '%sperl%sperl%sclps',
|
||||
\ 'php' : '%sphp%sphp%scdvf',
|
||||
\ 'python' : '%spython%spython%scmf',
|
||||
\ 'rexx' : '%srexx%srexx%ss',
|
||||
\ 'ruby' : '%sruby%sruby%scfFm',
|
||||
\ 'scheme' : '%sscheme%sscheme%ssf',
|
||||
\ 'sh' : '%ssh%ssh%sf',
|
||||
\ 'csh' : '%ssh%ssh%sf',
|
||||
\ 'zsh' : '%ssh%ssh%sf',
|
||||
\ 'slang' : '%sslang%sslang%snf',
|
||||
\ 'sml' : '%ssml%ssml%secsrtvf',
|
||||
\ 'sql' : '%ssql%ssql%scFPrstTvfp',
|
||||
\ 'tcl' : '%stcl%stcl%scfmp',
|
||||
\ 'vera' : '%svera%svera%scdefgmpPtTvx',
|
||||
\ 'verilog': '%sverilog%sverilog%smcPertwpvf',
|
||||
\ 'vim' : '%svim%svim%savf',
|
||||
\ 'yacc' : '%syacc%syacc%sl',
|
||||
\ }
|
||||
|
||||
cal map(s:types, 'printf(v:val, "--language-force=", " --", "-types=")')
|
||||
|
||||
if executable('jsctags')
|
||||
cal extend(s:types, { 'javascript': { 'args': '-f -', 'bin': 'jsctags' } })
|
||||
en
|
||||
|
||||
if type(s:usr_types) == 4
|
||||
cal extend(s:types, s:usr_types)
|
||||
en
|
||||
" Utilities {{{1
|
||||
fu! s:validfile(fname, ftype)
|
||||
if ( !empty(a:fname) || !empty(a:ftype) ) && filereadable(a:fname)
|
||||
\ && index(keys(s:types), a:ftype) >= 0 | retu 1 | en
|
||||
retu 0
|
||||
endf
|
||||
|
||||
fu! s:exectags(cmd)
|
||||
if exists('+ssl')
|
||||
let [ssl, &ssl] = [&ssl, 0]
|
||||
en
|
||||
if &sh =~ 'cmd\.exe'
|
||||
let [sxq, &sxq, shcf, &shcf] = [&sxq, '"', &shcf, '/s /c']
|
||||
en
|
||||
let output = system(a:cmd)
|
||||
if &sh =~ 'cmd\.exe'
|
||||
let [&sxq, &shcf] = [sxq, shcf]
|
||||
en
|
||||
if exists('+ssl')
|
||||
let &ssl = ssl
|
||||
en
|
||||
retu output
|
||||
endf
|
||||
|
||||
fu! s:exectagsonfile(fname, ftype)
|
||||
let [ags, ft] = ['-f - --sort=no --excmd=pattern --fields=nKs ', a:ftype]
|
||||
if type(s:types[ft]) == 1
|
||||
let ags .= s:types[ft]
|
||||
let bin = s:bin
|
||||
elsei type(s:types[ft]) == 4
|
||||
let ags = s:types[ft]['args']
|
||||
let bin = expand(s:types[ft]['bin'], 1)
|
||||
en
|
||||
if empty(bin) | retu '' | en
|
||||
let cmd = s:esctagscmd(bin, ags, a:fname)
|
||||
if empty(cmd) | retu '' | en
|
||||
let output = s:exectags(cmd)
|
||||
if v:shell_error || output =~ 'Warning: cannot open' | retu '' | en
|
||||
retu output
|
||||
endf
|
||||
|
||||
fu! s:esctagscmd(bin, args, ...)
|
||||
if exists('+ssl')
|
||||
let [ssl, &ssl] = [&ssl, 0]
|
||||
en
|
||||
let fname = a:0 == 1 ? shellescape(a:1) : ''
|
||||
let cmd = shellescape(a:bin).' '.a:args.' '.fname
|
||||
if exists('+ssl')
|
||||
let &ssl = ssl
|
||||
en
|
||||
if has('iconv')
|
||||
let last = s:enc != &enc ? s:enc : !empty($LANG) ? $LANG : &enc
|
||||
let cmd = iconv(cmd, &enc, last)
|
||||
en
|
||||
retu cmd
|
||||
endf
|
||||
|
||||
fu! s:process(fname, ftype)
|
||||
if !s:validfile(a:fname, a:ftype) | retu [] | endif
|
||||
let ftime = getftime(a:fname)
|
||||
if has_key(g:ctrlp_buftags, a:fname)
|
||||
\ && g:ctrlp_buftags[a:fname]['time'] >= ftime
|
||||
let lines = g:ctrlp_buftags[a:fname]['lines']
|
||||
el
|
||||
let data = s:exectagsonfile(a:fname, a:ftype)
|
||||
let [raw, lines] = [split(data, '\n\+'), []]
|
||||
for line in raw | if len(split(line, ';"')) == 2
|
||||
let parsed_line = s:parseline(line)
|
||||
if parsed_line != ''
|
||||
cal add(lines, parsed_line)
|
||||
en
|
||||
en | endfo
|
||||
let cache = { a:fname : { 'time': ftime, 'lines': lines } }
|
||||
cal extend(g:ctrlp_buftags, cache)
|
||||
en
|
||||
retu lines
|
||||
endf
|
||||
|
||||
fu! s:parseline(line)
|
||||
let eval = '\v^([^\t]+)\t(.+)\t\/\^(.+)\$\/\;\"\t(.+)\tline(no)?\:(\d+)'
|
||||
let vals = matchlist(a:line, eval)
|
||||
if empty(vals) | retu '' | en
|
||||
let [bufnr, bufname] = [bufnr('^'.vals[2].'$'), fnamemodify(vals[2], ':p:t')]
|
||||
retu vals[1].' '.vals[4].'|'.bufnr.':'.bufname.'|'.vals[6].'| '.vals[3]
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#buffertag#init(fname)
|
||||
let fname = exists('s:bufname') ? s:bufname : a:fname
|
||||
let bufs = exists('s:btmode') && s:btmode ? ctrlp#allbufs() : [fname]
|
||||
let lines = []
|
||||
for each in bufs
|
||||
let tftype = get(split(getbufvar(each, '&ft'), '\.'), 0, '')
|
||||
cal extend(lines, s:process(each, tftype))
|
||||
endfo
|
||||
if !hlexists('CtrlPTabExtra')
|
||||
hi link CtrlPTabExtra Comment
|
||||
en
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
||||
retu lines
|
||||
endf
|
||||
|
||||
fu! ctrlp#buffertag#accept(mode, str)
|
||||
let vals = matchlist(a:str, '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|')
|
||||
let [bufnm, linenr] = [fnamemodify(bufname(str2nr(vals[1])), ':p'), vals[2]]
|
||||
cal ctrlp#acceptfile(a:mode, bufnm, linenr)
|
||||
endf
|
||||
|
||||
fu! ctrlp#buffertag#cmd(mode, ...)
|
||||
let s:btmode = a:mode
|
||||
if a:0 && !empty(a:1)
|
||||
let s:bufname = fnamemodify(a:1, ':p')
|
||||
en
|
||||
retu s:id
|
||||
endf
|
||||
|
||||
fu! ctrlp#buffertag#exit()
|
||||
unl! s:btmode s:bufname
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
93
bundle/git_ctrlp/autoload/ctrlp/dir.vim
Normal file
93
bundle/git_ctrlp/autoload/ctrlp/dir.vim
Normal file
@@ -0,0 +1,93 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/dir.vim
|
||||
" Description: Directory extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_dir') && g:loaded_ctrlp_dir
|
||||
fini
|
||||
en
|
||||
let [g:loaded_ctrlp_dir, g:ctrlp_newdir] = [1, 0]
|
||||
|
||||
let s:ars = [
|
||||
\ 's:maxdepth',
|
||||
\ 's:maxfiles',
|
||||
\ 's:compare_lim',
|
||||
\ 's:glob',
|
||||
\ ]
|
||||
|
||||
let s:dir_var = {
|
||||
\ 'init': 'ctrlp#dir#init('.join(s:ars, ', ').')',
|
||||
\ 'accept': 'ctrlp#dir#accept',
|
||||
\ 'lname': 'dirs',
|
||||
\ 'sname': 'dir',
|
||||
\ 'type': 'path',
|
||||
\ }
|
||||
|
||||
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
||||
\ ? add(g:ctrlp_ext_vars, s:dir_var) : [s:dir_var]
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
" Utilities {{{1
|
||||
fu! s:globdirs(dirs, depth)
|
||||
let entries = split(globpath(a:dirs, s:glob), "\n")
|
||||
let [dirs, depth] = [ctrlp#dirnfile(entries)[0], a:depth + 1]
|
||||
cal extend(g:ctrlp_alldirs, dirs)
|
||||
if !empty(dirs) && !s:max(len(g:ctrlp_alldirs), s:maxfiles)
|
||||
\ && depth <= s:maxdepth
|
||||
sil! cal ctrlp#progress(len(g:ctrlp_alldirs))
|
||||
cal s:globdirs(join(dirs, ','), depth)
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:max(len, max)
|
||||
retu a:max && a:len > a:max ? 1 : 0
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#dir#init(...)
|
||||
let s:cwd = getcwd()
|
||||
for each in range(len(s:ars))
|
||||
exe 'let' s:ars[each] '=' string(eval('a:'.(each + 1)))
|
||||
endfo
|
||||
let cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().s:dir_var['sname']
|
||||
let cafile = cadir.ctrlp#utils#lash().ctrlp#utils#cachefile(s:dir_var['sname'])
|
||||
if g:ctrlp_newdir || !filereadable(cafile)
|
||||
let g:ctrlp_alldirs = []
|
||||
cal s:globdirs(s:cwd, 0)
|
||||
cal ctrlp#rmbasedir(g:ctrlp_alldirs)
|
||||
let read_cache = 0
|
||||
if len(g:ctrlp_alldirs) <= s:compare_lim
|
||||
cal sort(g:ctrlp_alldirs, 'ctrlp#complen')
|
||||
en
|
||||
el
|
||||
let g:ctrlp_alldirs = ctrlp#utils#readfile(cafile)
|
||||
let read_cache = 1
|
||||
en
|
||||
if !read_cache
|
||||
cal ctrlp#utils#writecache(g:ctrlp_alldirs, cadir, cafile)
|
||||
let g:ctrlp_newdir = 0
|
||||
en
|
||||
retu g:ctrlp_alldirs
|
||||
endf
|
||||
|
||||
fu! ctrlp#dir#accept(mode, str)
|
||||
let path = a:mode == 'h' ? getcwd() : s:cwd.ctrlp#utils#lash().a:str
|
||||
if a:mode =~ 't\|v\|h'
|
||||
cal ctrlp#exit()
|
||||
en
|
||||
cal ctrlp#setdir(path, a:mode =~ 't\|h' ? 'chd!' : 'lc!')
|
||||
if a:mode == 'e'
|
||||
sil! cal ctrlp#statusline()
|
||||
cal ctrlp#setlines(s:id)
|
||||
cal ctrlp#recordhist()
|
||||
cal ctrlp#prtclear()
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#dir#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
67
bundle/git_ctrlp/autoload/ctrlp/line.vim
Normal file
67
bundle/git_ctrlp/autoload/ctrlp/line.vim
Normal file
@@ -0,0 +1,67 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/line.vim
|
||||
" Description: Line extension - Find a line in any buffer
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" User Configuration {{{1
|
||||
" Enable:
|
||||
" let g:ctrlp_extensions += ['line']
|
||||
" Create A Command:
|
||||
" com! CtrlPLine cal ctrlp#init(ctrlp#line#id())
|
||||
"}}}
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_line') && g:loaded_ctrlp_line
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_line = 1
|
||||
|
||||
let s:line_var = {
|
||||
\ 'init': 'ctrlp#line#init()',
|
||||
\ 'accept': 'ctrlp#line#accept',
|
||||
\ 'lname': 'lines',
|
||||
\ 'sname': 'lns',
|
||||
\ 'type': 'tabe',
|
||||
\ }
|
||||
|
||||
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
||||
\ ? add(g:ctrlp_ext_vars, s:line_var) : [s:line_var]
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
" Public {{{1
|
||||
fu! ctrlp#line#init()
|
||||
let [bufs, lines] = [ctrlp#allbufs(), []]
|
||||
for each in bufs
|
||||
let from_file = readfile(each)
|
||||
cal map(from_file, 'tr(v:val, '' '', '' '')')
|
||||
let [id, len_ff, bufnr] = [1, len(from_file), bufnr('^'.each.'$')]
|
||||
wh id <= len_ff
|
||||
let from_file[id-1] .= ' #:'.bufnr.':'.id
|
||||
let id += 1
|
||||
endw
|
||||
cal filter(from_file, 'v:val !~ ''^\s*\t#:\d\+:\d\+$''')
|
||||
cal extend(lines, from_file)
|
||||
endfo
|
||||
if !hlexists('CtrlPTabExtra')
|
||||
hi link CtrlPTabExtra Comment
|
||||
en
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
||||
retu lines
|
||||
endf
|
||||
|
||||
fu! ctrlp#line#accept(mode, str)
|
||||
let info = get(split(a:str, '\t#:\ze\d\+:\d\+$'), 1, 0)
|
||||
let bufnr = str2nr(get(split(info, ':'), 0, 0))
|
||||
let linenr = get(split(info, ':'), 1, 0)
|
||||
if bufnr
|
||||
cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'), linenr)
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#line#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
92
bundle/git_ctrlp/autoload/ctrlp/mrufiles.vim
Normal file
92
bundle/git_ctrlp/autoload/ctrlp/mrufiles.vim
Normal file
@@ -0,0 +1,92 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/mrufiles.vim
|
||||
" Description: Most Recently Used Files extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Static variables {{{1
|
||||
fu! ctrlp#mrufiles#opts()
|
||||
let opts = {
|
||||
\ 'g:ctrlp_mruf_max': ['s:max', 250],
|
||||
\ 'g:ctrlp_mruf_include': ['s:in', ''],
|
||||
\ 'g:ctrlp_mruf_exclude': ['s:ex', ''],
|
||||
\ 'g:ctrlp_mruf_case_sensitive': ['s:csen', 1],
|
||||
\ 'g:ctrlp_mruf_relative': ['s:re', 0],
|
||||
\ 'g:ctrlp_mruf_last_entered': ['s:mre', 0],
|
||||
\ }
|
||||
for [ke, va] in items(opts)
|
||||
exe 'let' va[0] '=' string(exists(ke) ? eval(ke) : va[1])
|
||||
endfo
|
||||
let s:csen = s:csen ? '#' : '?'
|
||||
endf
|
||||
cal ctrlp#mrufiles#opts()
|
||||
fu! ctrlp#mrufiles#list(bufnr, ...) "{{{1
|
||||
if s:locked | retu | en
|
||||
let bufnr = a:bufnr + 0
|
||||
if bufnr > 0
|
||||
let fn = fnamemodify(bufname(bufnr), ':p')
|
||||
let fn = exists('+ssl') ? tr(fn, '/', '\') : fn
|
||||
if empty(fn) || !empty(&bt) || ( !empty(s:in) && fn !~# s:in )
|
||||
\ || ( !empty(s:ex) && fn =~# s:ex ) || !filereadable(fn)
|
||||
retu
|
||||
en
|
||||
en
|
||||
if !exists('s:cadir') || !exists('s:cafile')
|
||||
let s:cadir = ctrlp#utils#cachedir().ctrlp#utils#lash().'mru'
|
||||
let s:cafile = s:cadir.ctrlp#utils#lash().'cache.txt'
|
||||
en
|
||||
if a:0 && a:1 == 2
|
||||
cal ctrlp#utils#writecache([], s:cadir, s:cafile)
|
||||
retu []
|
||||
en
|
||||
" Get the list
|
||||
let mrufs = ctrlp#utils#readfile(s:cafile)
|
||||
" Remove non-existent files
|
||||
if a:0 && a:1 == 1
|
||||
cal filter(mrufs, '!empty(ctrlp#utils#glob(v:val, 1)) && !s:excl(v:val)')
|
||||
if exists('+ssl')
|
||||
cal map(mrufs, 'tr(v:val, ''/'', ''\'')')
|
||||
cal filter(mrufs, 'count(mrufs, v:val) == 1')
|
||||
en
|
||||
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
|
||||
en
|
||||
" Return the list with the active buffer removed
|
||||
if bufnr == -1
|
||||
let crf = fnamemodify(bufname(winbufnr(winnr('#'))), ':p')
|
||||
let crf = exists('+ssl') ? tr(crf, '/', '\') : crf
|
||||
let mrufs = empty(crf) ? mrufs : filter(mrufs, 'v:val !='.s:csen.' crf')
|
||||
if s:re
|
||||
let cwd = exists('+ssl') ? tr(getcwd(), '/', '\') : getcwd()
|
||||
cal filter(mrufs, '!stridx(v:val, cwd)')
|
||||
en
|
||||
cal map(mrufs, 'fnamemodify(v:val, '':.'')')
|
||||
retu mrufs
|
||||
en
|
||||
" Remove old entry
|
||||
cal filter(mrufs, 'v:val !='.s:csen.' fn')
|
||||
" Insert new one
|
||||
cal insert(mrufs, fn)
|
||||
" Remove oldest entry or entries
|
||||
if len(mrufs) > s:max | cal remove(mrufs, s:max, -1) | en
|
||||
cal ctrlp#utils#writecache(mrufs, s:cadir, s:cafile)
|
||||
endf "}}}
|
||||
fu! s:excl(fn) "{{{
|
||||
retu !empty(s:ex) && a:fn =~# s:ex
|
||||
endf "}}}
|
||||
fu! ctrlp#mrufiles#init() "{{{1
|
||||
let s:locked = 0
|
||||
aug CtrlPMRUF
|
||||
au!
|
||||
au BufReadPost,BufNewFile,BufWritePost *
|
||||
\ cal ctrlp#mrufiles#list(expand('<abuf>', 1))
|
||||
if s:mre
|
||||
au BufEnter,BufUnload *
|
||||
\ cal ctrlp#mrufiles#list(expand('<abuf>', 1))
|
||||
en
|
||||
au QuickFixCmdPre *vimgrep* let s:locked = 1
|
||||
au QuickFixCmdPost *vimgrep* let s:locked = 0
|
||||
aug END
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
58
bundle/git_ctrlp/autoload/ctrlp/quickfix.vim
Normal file
58
bundle/git_ctrlp/autoload/ctrlp/quickfix.vim
Normal file
@@ -0,0 +1,58 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/quickfix.vim
|
||||
" Description: Quickfix extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_quickfix') && g:loaded_ctrlp_quickfix
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_quickfix = 1
|
||||
|
||||
let s:var_qf = {
|
||||
\ 'init': 'ctrlp#quickfix#init()',
|
||||
\ 'accept': 'ctrlp#quickfix#accept',
|
||||
\ 'lname': 'quickfix',
|
||||
\ 'sname': 'qfx',
|
||||
\ 'type': 'line',
|
||||
\ }
|
||||
|
||||
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
||||
\ ? add(g:ctrlp_ext_vars, s:var_qf) : [s:var_qf]
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
|
||||
fu! s:lineout(dict)
|
||||
retu printf('%s|%d:%d| %s', bufname(a:dict['bufnr']), a:dict['lnum'],
|
||||
\ a:dict['col'], matchstr(a:dict['text'], '\s*\zs.*\S'))
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#quickfix#init()
|
||||
let g:ctrlp_nolimit = 1
|
||||
if !hlexists('CtrlPqfLineCol')
|
||||
hi link CtrlPqfLineCol Search
|
||||
en
|
||||
sy match CtrlPqfLineCol '|\zs\d\+:\d\+\ze|'
|
||||
retu map(getqflist(), 's:lineout(v:val)')
|
||||
endf
|
||||
|
||||
fu! ctrlp#quickfix#accept(mode, str)
|
||||
let items = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|')
|
||||
let [md, filpath] = [a:mode, fnamemodify(items[1], ':p')]
|
||||
if empty(filpath) | retu | en
|
||||
cal ctrlp#exit()
|
||||
let cmd = md == 't' ? 'tabe' : md == 'h' ? 'new' : md == 'v' ? 'vne'
|
||||
\ : ctrlp#normcmd('e')
|
||||
let cmd = cmd == 'e' && &modified ? 'hid e' : cmd
|
||||
exe cmd ctrlp#fnesc(filpath)
|
||||
cal cursor(items[2], items[3])
|
||||
sil! norm! zvzz
|
||||
endf
|
||||
|
||||
fu! ctrlp#quickfix#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
51
bundle/git_ctrlp/autoload/ctrlp/rtscript.vim
Normal file
51
bundle/git_ctrlp/autoload/ctrlp/rtscript.vim
Normal file
@@ -0,0 +1,51 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/rtscript.vim
|
||||
" Description: Runtime scripts extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_rtscript') && g:loaded_ctrlp_rtscript
|
||||
fini
|
||||
en
|
||||
let [g:loaded_ctrlp_rtscript, g:ctrlp_newrts] = [1, 0]
|
||||
|
||||
let s:rtscript_var = {
|
||||
\ 'init': 'ctrlp#rtscript#init()',
|
||||
\ 'accept': 'ctrlp#acceptfile',
|
||||
\ 'lname': 'runtime scripts',
|
||||
\ 'sname': 'rts',
|
||||
\ 'type': 'path',
|
||||
\ }
|
||||
|
||||
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
||||
\ ? add(g:ctrlp_ext_vars, s:rtscript_var) : [s:rtscript_var]
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
" Public {{{1
|
||||
fu! ctrlp#rtscript#init()
|
||||
if g:ctrlp_newrts
|
||||
\ || !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[0] == &rtp )
|
||||
sil! cal ctrlp#progress('Indexing...')
|
||||
let entries = split(globpath(&rtp, '**/*.*'), "\n")
|
||||
cal filter(entries, 'count(entries, v:val) == 1')
|
||||
let [entries, echoed] = [ctrlp#dirnfile(entries)[1], 1]
|
||||
el
|
||||
let [entries, results] = g:ctrlp_rtscache[2:3]
|
||||
en
|
||||
let cwd = getcwd()
|
||||
if g:ctrlp_newrts
|
||||
\ || !( exists('g:ctrlp_rtscache') && g:ctrlp_rtscache[:1] == [&rtp, cwd] )
|
||||
if !exists('echoed') | sil! cal ctrlp#progress('Processing...') | en
|
||||
let results = map(copy(entries), 'fnamemodify(v:val, '':.'')')
|
||||
en
|
||||
let [g:ctrlp_rtscache, g:ctrlp_newrts] = [[&rtp, cwd, entries, results], 0]
|
||||
retu results
|
||||
endf
|
||||
|
||||
fu! ctrlp#rtscript#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
111
bundle/git_ctrlp/autoload/ctrlp/tag.vim
Normal file
111
bundle/git_ctrlp/autoload/ctrlp/tag.vim
Normal file
@@ -0,0 +1,111 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/tag.vim
|
||||
" Description: Tag file extension
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Init {{{1
|
||||
if exists('g:loaded_ctrlp_tag') && g:loaded_ctrlp_tag
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_tag = 1
|
||||
|
||||
let s:tag_var = {
|
||||
\ 'init': 'ctrlp#tag#init(s:tagfiles)',
|
||||
\ 'accept': 'ctrlp#tag#accept',
|
||||
\ 'lname': 'tags',
|
||||
\ 'sname': 'tag',
|
||||
\ 'type': 'tabs',
|
||||
\ }
|
||||
|
||||
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
||||
\ ? add(g:ctrlp_ext_vars, s:tag_var) : [s:tag_var]
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
" Utilities {{{1
|
||||
fu! s:nodup(items)
|
||||
let dict = {}
|
||||
for each in a:items
|
||||
cal extend(dict, { each : 0 })
|
||||
endfo
|
||||
retu keys(dict)
|
||||
endf
|
||||
|
||||
fu! s:findcount(str)
|
||||
let [tg, fname] = split(a:str, '\t\+\ze[^\t]\+$')
|
||||
let [fname, tgs] = [expand(fname, 1), taglist('^'.tg.'$')]
|
||||
if empty(tgs) | retu [1, 1] | en
|
||||
let [fnd, ct, pos] = [0, 0, 0]
|
||||
for each in tgs
|
||||
let ct += 1
|
||||
let fulname = fnamemodify(each["filename"], ':p')
|
||||
if stridx(fulname, fname) >= 0
|
||||
\ && strlen(fname) + stridx(fulname, fname) == strlen(fulname)
|
||||
let fnd += 1
|
||||
let pos = ct
|
||||
en
|
||||
if fnd > 1 | brea | en
|
||||
endfo
|
||||
retu [fnd, pos]
|
||||
endf
|
||||
|
||||
fu! s:filter(tags)
|
||||
let [nr, alltags] = [0, a:tags]
|
||||
wh 0 < 1
|
||||
if alltags[nr] =~ '^!' && alltags[nr] !~ '^!_TAG_'
|
||||
let nr += 1
|
||||
con
|
||||
en
|
||||
if alltags[nr] =~ '^!_TAG_' && len(alltags) > nr
|
||||
cal remove(alltags, nr)
|
||||
el
|
||||
brea
|
||||
en
|
||||
endw
|
||||
retu alltags
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#tag#init(tagfiles)
|
||||
if empty(a:tagfiles) | retu [] | en
|
||||
let [tagfiles, g:ctrlp_alltags] = [sort(s:nodup(a:tagfiles)), []]
|
||||
for each in tagfiles
|
||||
let alltags = s:filter(ctrlp#utils#readfile(each))
|
||||
cal extend(g:ctrlp_alltags, alltags)
|
||||
endfo
|
||||
if !hlexists('CtrlPTabExtra')
|
||||
hi link CtrlPTabExtra Comment
|
||||
en
|
||||
sy match CtrlPTabExtra '\zs\t.*\ze$'
|
||||
retu g:ctrlp_alltags
|
||||
endf
|
||||
|
||||
fu! ctrlp#tag#accept(mode, str)
|
||||
cal ctrlp#exit()
|
||||
let str = matchstr(a:str, '^[^\t]\+\t\+[^\t]\+\ze\t')
|
||||
let [md, tg] = [a:mode, split(str, '^[^\t]\+\zs\t')[0]]
|
||||
let fnd = s:findcount(str)
|
||||
let cmds = {
|
||||
\ 't': ['tab sp', 'tab stj'],
|
||||
\ 'h': ['sp', 'stj'],
|
||||
\ 'v': ['vs', 'vert stj'],
|
||||
\ 'e': ['', 'tj'],
|
||||
\ }
|
||||
let cmd = fnd[0] == 1 ? cmds[md][0] : cmds[md][1]
|
||||
let cmd = cmd == 'tj' && &modified ? 'hid '.cmd : cmd
|
||||
let cmd = cmd =~ '^tab' ? tabpagenr('$').cmd : cmd
|
||||
if fnd[0] == 1
|
||||
if cmd != ''
|
||||
exe cmd
|
||||
en
|
||||
exe fnd[1].'ta' tg
|
||||
el
|
||||
exe cmd tg
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#tag#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
123
bundle/git_ctrlp/autoload/ctrlp/undo.vim
Normal file
123
bundle/git_ctrlp/autoload/ctrlp/undo.vim
Normal file
@@ -0,0 +1,123 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/undo.vim
|
||||
" Description: Undo extension - Browse undo history (requires Vim 7.3.005+)
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" User Configuration {{{1
|
||||
" Enable:
|
||||
" let g:ctrlp_extensions += ['undo']
|
||||
" Create A Command:
|
||||
" com! CtrlPUndo cal ctrlp#init(ctrlp#undo#id())
|
||||
"}}}
|
||||
|
||||
" Init {{{1
|
||||
if ( exists('g:loaded_ctrlp_undo') && g:loaded_ctrlp_undo )
|
||||
\ || !( v:version > 702 && has('patch005') )
|
||||
fini
|
||||
en
|
||||
let g:loaded_ctrlp_undo = 1
|
||||
|
||||
let s:undo_var = {
|
||||
\ 'init': 'ctrlp#undo#init(s:undotree)',
|
||||
\ 'accept': 'ctrlp#undo#accept',
|
||||
\ 'lname': 'undo',
|
||||
\ 'sname': 'udo',
|
||||
\ 'type': 'line',
|
||||
\ }
|
||||
|
||||
let g:ctrlp_ext_vars = exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
|
||||
\ ? add(g:ctrlp_ext_vars, s:undo_var) : [s:undo_var]
|
||||
|
||||
let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
|
||||
" Utilities {{{1
|
||||
fu! s:flatten(tree)
|
||||
let flatdict = {}
|
||||
for each in a:tree
|
||||
cal extend(flatdict, { each['seq'] : each['time'] })
|
||||
if has_key(each, 'alt')
|
||||
cal extend(flatdict, s:flatten(each['alt']))
|
||||
en
|
||||
endfo
|
||||
retu flatdict
|
||||
endf
|
||||
|
||||
fu! s:humantime(nr)
|
||||
let elapsed = localtime() - a:nr
|
||||
let mins = elapsed / 60
|
||||
let hrs = elapsed / 3600
|
||||
let days = elapsed / 86400
|
||||
let wks = elapsed / 604800
|
||||
let mons = elapsed / 2592000
|
||||
let yrs = elapsed / 31536000
|
||||
let text = [
|
||||
\ ' second ago',
|
||||
\ ' seconds ago',
|
||||
\ ' minutes ago',
|
||||
\ ' hours ago',
|
||||
\ ' days ago',
|
||||
\ ' weeks ago',
|
||||
\ ' months ago',
|
||||
\ ' years ago',
|
||||
\ ]
|
||||
if yrs > 1
|
||||
retu yrs.text[7]
|
||||
elsei mons > 1
|
||||
retu mons.text[6]
|
||||
elsei wks > 1
|
||||
retu wks.text[5]
|
||||
elsei days > 1
|
||||
retu days.text[4]
|
||||
elsei hrs > 1
|
||||
retu hrs.text[3]
|
||||
elsei mins > 1
|
||||
retu mins.text[2]
|
||||
elsei elapsed == 1
|
||||
retu elapsed.text[0]
|
||||
elsei elapsed < 120
|
||||
retu elapsed.text[1]
|
||||
en
|
||||
endf
|
||||
|
||||
fu! s:syntax()
|
||||
for [ke, va] in items({'T': 'Directory', 'Br': 'Comment', 'Nr': 'String'})
|
||||
if !hlexists('CtrlPUndo'.ke)
|
||||
exe 'hi link CtrlPUndo'.ke va
|
||||
en
|
||||
endfo
|
||||
sy match CtrlPUndoT '\d\+ \zs[^ ]\+\ze'
|
||||
sy match CtrlPUndoBr '\[\|\]'
|
||||
sy match CtrlPUndoNr '\[\d\+\]$' contains=CtrlPUndoBr
|
||||
endf
|
||||
|
||||
fu! s:dict2list(dict)
|
||||
let dict = map(a:dict, 's:humantime(v:val)')
|
||||
retu map(keys(dict), 'eval(''[v:val, dict[v:val]]'')')
|
||||
endf
|
||||
|
||||
fu! s:compval(...)
|
||||
retu a:2[0] - a:1[0]
|
||||
endf
|
||||
" Public {{{1
|
||||
fu! ctrlp#undo#init(undo)
|
||||
let entries = a:undo['entries']
|
||||
if empty(entries) | retu [] | en
|
||||
cal s:syntax()
|
||||
let g:ctrlp_nolimit = 1
|
||||
let entries = sort(s:dict2list(s:flatten(entries)), 's:compval')
|
||||
retu map(entries, 'v:val[1]." [".v:val[0]."]"')
|
||||
endf
|
||||
|
||||
fu! ctrlp#undo#accept(mode, str)
|
||||
let undon = matchstr(a:str, '\[\zs\d\+\ze\]')
|
||||
if empty(undon) | retu | en
|
||||
cal ctrlp#exit()
|
||||
exe 'u' undon
|
||||
endf
|
||||
|
||||
fu! ctrlp#undo#id()
|
||||
retu s:id
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
75
bundle/git_ctrlp/autoload/ctrlp/utils.vim
Normal file
75
bundle/git_ctrlp/autoload/ctrlp/utils.vim
Normal file
@@ -0,0 +1,75 @@
|
||||
" =============================================================================
|
||||
" File: autoload/ctrlp/utils.vim
|
||||
" Description: Utilities
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
|
||||
" Static variables {{{1
|
||||
fu! ctrlp#utils#lash()
|
||||
retu &ssl || !exists('+ssl') ? '/' : '\'
|
||||
endf
|
||||
let s:lash = ctrlp#utils#lash()
|
||||
|
||||
fu! s:lash(...)
|
||||
retu match(a:0 ? a:1 : getcwd(), '[\/]$') < 0 ? s:lash : ''
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#opts()
|
||||
let usrhome = $HOME.s:lash($HOME)
|
||||
let cahome = exists('$XDG_CACHE_HOME') ? $XDG_CACHE_HOME : usrhome.'.cache'
|
||||
let s:cache_dir = isdirectory(usrhome.'.ctrlp_cache')
|
||||
\ ? usrhome.'.ctrlp_cache' : cahome.s:lash(cahome).'ctrlp'
|
||||
if exists('g:ctrlp_cache_dir')
|
||||
let s:cache_dir = expand(g:ctrlp_cache_dir, 1)
|
||||
if isdirectory(s:cache_dir.s:lash(s:cache_dir).'.ctrlp_cache')
|
||||
let s:cache_dir = s:cache_dir.s:lash(s:cache_dir).'.ctrlp_cache'
|
||||
en
|
||||
en
|
||||
endf
|
||||
cal ctrlp#utils#opts()
|
||||
" Files and Directories {{{1
|
||||
fu! ctrlp#utils#cachedir()
|
||||
retu s:cache_dir
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#cachefile(...)
|
||||
let tail = a:0 ? '.'.a:1 : ''
|
||||
let cache_file = substitute(getcwd(), '\([\/]\|^\a\zs:\)', '%', 'g').tail.'.txt'
|
||||
retu a:0 ? cache_file : s:cache_dir.s:lash(s:cache_dir).cache_file
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#readfile(file)
|
||||
if filereadable(a:file)
|
||||
let data = readfile(a:file)
|
||||
if empty(data) || type(data) != 3
|
||||
unl data
|
||||
let data = []
|
||||
en
|
||||
retu data
|
||||
en
|
||||
retu []
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#mkdir(dir)
|
||||
if exists('*mkdir') && !isdirectory(a:dir)
|
||||
sil! cal mkdir(a:dir, 'p')
|
||||
en
|
||||
retu a:dir
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#writecache(lines, ...)
|
||||
if isdirectory(ctrlp#utils#mkdir(a:0 ? a:1 : s:cache_dir))
|
||||
sil! cal writefile(a:lines, a:0 >= 2 ? a:2 : ctrlp#utils#cachefile())
|
||||
if !a:0
|
||||
let g:ctrlp_newcache = 0
|
||||
en
|
||||
en
|
||||
endf
|
||||
|
||||
fu! ctrlp#utils#glob(...)
|
||||
let cond = v:version > 702 || ( v:version == 702 && has('patch051') )
|
||||
retu call('glob', cond ? a:000 : [a:1])
|
||||
endf
|
||||
"}}}
|
||||
|
||||
" vim:fen:fdm=marker:fmr={{{,}}}:fdl=0:fdc=1:ts=2:sw=2:sts=2
|
||||
860
bundle/git_ctrlp/doc/ctrlp.txt
Normal file
860
bundle/git_ctrlp/doc/ctrlp.txt
Normal file
@@ -0,0 +1,860 @@
|
||||
*ctrlp.txt* Fuzzy file, buffer, mru and tag finder. v1.7.1
|
||||
*CtrlP* *ControlP* *'ctrlp'* *'ctrl-p'*
|
||||
===============================================================================
|
||||
# #
|
||||
# :::::::: ::::::::::: ::::::::: ::: ::::::::: #
|
||||
# :+: :+: :+: :+: :+: :+: :+: :+: #
|
||||
# +:+ +:+ +:+ +:+ +:+ +:+ +:+ #
|
||||
# +#+ +#+ +#++:++#: +#+ +#++:++#+ #
|
||||
# +#+ +#+ +#+ +#+ +#+ +#+ #
|
||||
# #+# #+# #+# #+# #+# #+# #+# #
|
||||
# ######## ### ### ### ########## ### #
|
||||
# #
|
||||
===============================================================================
|
||||
CONTENTS *ctrlp-contents*
|
||||
|
||||
1. Intro........................................|ctrlp-intro|
|
||||
2. Options......................................|ctrlp-options|
|
||||
3. Commands.....................................|ctrlp-commands|
|
||||
4. Mappings.....................................|ctrlp-mappings|
|
||||
5. Input Formats................................|ctrlp-input-formats|
|
||||
6. Extensions...................................|ctrlp-extensions|
|
||||
|
||||
===============================================================================
|
||||
1. Intro *ctrlp-intro*
|
||||
|
||||
Full path fuzzy file, buffer, mru and tag finder with an intuitive interface.
|
||||
Written in pure Vimscript for MacVim and Vim version 7.0+. Has full support for
|
||||
Vim’s |regexp| as search pattern, built-in MRU files monitoring, project’s root
|
||||
finder, and more.
|
||||
|
||||
To enable optional extensions (tag, dir, rtscript...), see |ctrlp-extensions|.
|
||||
|
||||
===============================================================================
|
||||
2. Options *ctrlp-options*
|
||||
|
||||
Below are the available options and their default values:~
|
||||
|
||||
*'g:ctrlp_map'*
|
||||
Use this option to change the mapping to invoke |CtrlP| in |Normal| mode: >
|
||||
let g:ctrlp_map = '<c-p>'
|
||||
<
|
||||
|
||||
*'g:ctrlp_cmd'*
|
||||
Set the default opening command to use when pressing the above mapping: >
|
||||
let g:ctrlp_cmd = 'CtrlP'
|
||||
<
|
||||
|
||||
*'g:loaded_ctrlp'*
|
||||
Use this to disable the plugin completely: >
|
||||
let g:loaded_ctrlp = 1
|
||||
<
|
||||
|
||||
*'g:ctrlp_by_filename'*
|
||||
Set this to 1 to set search by filename (not full path) as the default: >
|
||||
let g:ctrlp_by_filename = 0
|
||||
<
|
||||
|
||||
*'g:ctrlp_regexp_search'*
|
||||
Set this to 1 to set |regexp| search as the default: >
|
||||
let g:ctrlp_regexp_search = 0
|
||||
<
|
||||
|
||||
*'g:ctrlp_match_window_bottom'*
|
||||
Set this to 0 to show the match window at the top of the screen: >
|
||||
let g:ctrlp_match_window_bottom = 1
|
||||
<
|
||||
|
||||
*'g:ctrlp_match_window_reversed'*
|
||||
Change the listing order of the matched files in the match window. The default
|
||||
setting (1) is from bottom to top: >
|
||||
let g:ctrlp_match_window_reversed = 1
|
||||
<
|
||||
|
||||
*'g:ctrlp_max_height'*
|
||||
Set the maximum height of the match window: >
|
||||
let g:ctrlp_max_height = 10
|
||||
<
|
||||
|
||||
*'g:ctrlp_jump_to_buffer'*
|
||||
When opening a file with <cr> or <c-t>, if the file's already opened somewhere
|
||||
|CtrlP| will try to jump to it instead of opening a new instance: >
|
||||
let g:ctrlp_jump_to_buffer = 2
|
||||
<
|
||||
1 - only jump to the buffer if it’s opened in the current tab.
|
||||
2 - jump tab as well if the buffer's opened in another tab.
|
||||
0 - disable this feature.
|
||||
|
||||
*'g:ctrlp_working_path_mode'*
|
||||
When starting up, |CtrlP| sets its local working directory according to this
|
||||
variable: >
|
||||
let g:ctrlp_working_path_mode = 2
|
||||
<
|
||||
1 - the parent directory of the current file.
|
||||
2 - the nearest ancestor that contains one of these directories/files:
|
||||
.git/
|
||||
.hg/
|
||||
.bzr/
|
||||
_darcs/
|
||||
root.dir
|
||||
0 - don’t manage working directory.
|
||||
|
||||
*'g:ctrlp_root_markers'*
|
||||
Use this to set your own root markers in addition to the default ones. Your
|
||||
markers will take precedence: >
|
||||
let g:ctrlp_root_markers = ['']
|
||||
<
|
||||
These markers (builtins and yours) will serve as identifiers for the '/' and
|
||||
'\' special inputs (section 5.e).
|
||||
|
||||
*'g:ctrlp_use_caching'*
|
||||
Set this to 0 to disable per-session caching. When disabled, caching will still
|
||||
be enabled for directories that have more than 4000 files: >
|
||||
let g:ctrlp_use_caching = 1
|
||||
<
|
||||
Note: you can quickly purge the cache by pressing <F5> while inside |CtrlP|.
|
||||
|
||||
*'g:ctrlp_clear_cache_on_exit'*
|
||||
Set this to 0 to enable cross-session caching by not deleting the cache files
|
||||
upon exiting Vim: >
|
||||
let g:ctrlp_clear_cache_on_exit = 1
|
||||
<
|
||||
|
||||
*'g:ctrlp_cache_dir'*
|
||||
Set the directory to store the cache files: >
|
||||
let g:ctrlp_cache_dir = $HOME.'/.cache/ctrlp'
|
||||
<
|
||||
|
||||
*'g:ctrlp_prompt_mappings'*
|
||||
Use this to customize the mappings inside |CtrlP|’s prompt to your liking. You
|
||||
only need to keep the lines that you’ve changed the values (inside []): >
|
||||
let g:ctrlp_prompt_mappings = {
|
||||
\ 'PrtBS()': ['<bs>', '<c-]>'],
|
||||
\ 'PrtDelete()': ['<del>'],
|
||||
\ 'PrtDeleteWord()': ['<c-w>'],
|
||||
\ 'PrtClear()': ['<c-u>'],
|
||||
\ 'PrtSelectMove("j")': ['<c-j>', '<down>'],
|
||||
\ 'PrtSelectMove("k")': ['<c-k>', '<up>'],
|
||||
\ 'PrtHistory(-1)': ['<c-n>'],
|
||||
\ 'PrtHistory(1)': ['<c-p>'],
|
||||
\ 'AcceptSelection("e")': ['<cr>', '<2-LeftMouse>'],
|
||||
\ 'AcceptSelection("h")': ['<c-x>', '<c-cr>', '<c-s>'],
|
||||
\ 'AcceptSelection("t")': ['<c-t>', '<MiddleMouse>'],
|
||||
\ 'AcceptSelection("v")': ['<c-v>', '<RightMouse>'],
|
||||
\ 'ToggleFocus()': ['<s-tab>'],
|
||||
\ 'ToggleRegex()': ['<c-r>'],
|
||||
\ 'ToggleByFname()': ['<c-d>'],
|
||||
\ 'ToggleType(1)': ['<c-f>', '<c-up>'],
|
||||
\ 'ToggleType(-1)': ['<c-b>', '<c-down>'],
|
||||
\ 'PrtExpandDir()': ['<tab>'],
|
||||
\ 'PrtInsert("w")': ['<F2>', '<insert>'],
|
||||
\ 'PrtInsert("s")': ['<F3>'],
|
||||
\ 'PrtInsert("v")': ['<F4>'],
|
||||
\ 'PrtInsert("+")': ['<F6>'],
|
||||
\ 'PrtCurStart()': ['<c-a>'],
|
||||
\ 'PrtCurEnd()': ['<c-e>'],
|
||||
\ 'PrtCurLeft()': ['<c-h>', '<left>', '<c-^>'],
|
||||
\ 'PrtCurRight()': ['<c-l>', '<right>'],
|
||||
\ 'PrtClearCache()': ['<F5>'],
|
||||
\ 'PrtDeleteMRU()': ['<F7>'],
|
||||
\ 'CreateNewFile()': ['<c-y>'],
|
||||
\ 'MarkToOpen()': ['<c-z>'],
|
||||
\ 'OpenMulti()': ['<c-o>'],
|
||||
\ 'PrtExit()': ['<esc>', '<c-c>', '<c-g>'],
|
||||
\ }
|
||||
<
|
||||
Note: In some terminals, it’s not possible to remap <c-h> without also changing
|
||||
<bs> (|key-codes|). So if pressing <bs> moves the cursor to the left instead of
|
||||
deleting a char for you, add this to your |vimrc| to change the default <c-h>
|
||||
mapping: >
|
||||
let g:ctrlp_prompt_mappings = {
|
||||
\ 'PrtBS()': ['<bs>', '<c-]>', '<c-h>'],
|
||||
\ 'PrtCurLeft()': ['<left>', '<c-^>'],
|
||||
\ }
|
||||
<
|
||||
|
||||
*'g:ctrlp_mruf_max'*
|
||||
Specify the number of recently opened files you want |CtrlP| to remember: >
|
||||
let g:ctrlp_mruf_max = 250
|
||||
<
|
||||
|
||||
*'g:ctrlp_mruf_exclude'*
|
||||
Files you don’t want |CtrlP| to remember. Use |regexp| to specify the patterns:
|
||||
>
|
||||
let g:ctrlp_mruf_exclude = ''
|
||||
<
|
||||
Examples: >
|
||||
let g:ctrlp_mruf_exclude = '/tmp/.*\|/temp/.*' " MacOSX/Linux
|
||||
let g:ctrlp_mruf_exclude = '^C:\\dev\\tmp\\.*' " Windows
|
||||
<
|
||||
|
||||
*'g:ctrlp_mruf_include'*
|
||||
And if you want |CtrlP| to only remember some files, specify them here: >
|
||||
let g:ctrlp_mruf_include = ''
|
||||
<
|
||||
Example: >
|
||||
let g:ctrlp_mruf_include = '\.py$\|\.rb$'
|
||||
<
|
||||
|
||||
*'g:ctrlp_mruf_relative'*
|
||||
Set this to 1 to show only MRU files in the current working directory: >
|
||||
let g:ctrlp_mruf_relative = 0
|
||||
<
|
||||
|
||||
*'g:ctrlp_mruf_case_sensitive'*
|
||||
Match this with your file system case-sensitivity setting to avoid duplicate
|
||||
MRU entries: >
|
||||
let g:ctrlp_mruf_case_sensitive = 1
|
||||
<
|
||||
|
||||
*'g:ctrlp_mruf_last_entered'*
|
||||
Set to 1 to sort the MRU file list to most-recently-entered-buffer order: >
|
||||
let g:ctrlp_mruf_last_entered = 0
|
||||
<
|
||||
|
||||
*'g:ctrlp_dotfiles'*
|
||||
Set this to 0 if you don’t want |CtrlP| to search for dotfiles and dotdirs: >
|
||||
let g:ctrlp_dotfiles = 1
|
||||
<
|
||||
You can use |'wildignore'| to exclude anything from the search.
|
||||
Examples: >
|
||||
" Excluding version control directories
|
||||
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Linux/MacOSX
|
||||
set wildignore+=.git\*,.hg\*,.svn\* " Windows
|
||||
<
|
||||
Note #1: the `*/` in front of each directory glob is required.
|
||||
|
||||
Note #2: |wildignore| influences the result of |expand()|, |globpath()| and
|
||||
|glob()| which many plugins use to find stuff on the system (e.g. fugitive.vim
|
||||
looks for .git/, some other plugins look for external .exe tools on Windows).
|
||||
So be a little mindful of what you put in your |wildignore|.
|
||||
|
||||
*'g:ctrlp_custom_ignore'*
|
||||
In addition to |'wildignore'|, use this for files and directories you want only
|
||||
|CtrlP| to not show. Use |regexp| to specify the patterns: >
|
||||
let g:ctrlp_custom_ignore = ''
|
||||
<
|
||||
Examples: >
|
||||
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
|
||||
let g:ctrlp_custom_ignore = {
|
||||
\ 'dir': '\.git$\|\.hg$\|\.svn$',
|
||||
\ 'file': '\.exe$\|\.so$\|\.dll$',
|
||||
\ 'link': 'SOME_BAD_SYMBOLIC_LINKS',
|
||||
\ }
|
||||
<
|
||||
|
||||
*'g:ctrlp_highlight_match'*
|
||||
Use this to enable/disable highlighting of the matched patterns and to specify
|
||||
the highlight group that’ll be used: >
|
||||
let g:ctrlp_highlight_match = [1, 'Identifier']
|
||||
<
|
||||
|
||||
*'g:ctrlp_max_files'*
|
||||
The maximum number of files to scan, set to 0 for no limit: >
|
||||
let g:ctrlp_max_files = 10000
|
||||
<
|
||||
|
||||
*'g:ctrlp_max_depth'*
|
||||
The maximum depth of a directory tree to recurse into: >
|
||||
let g:ctrlp_max_depth = 40
|
||||
<
|
||||
Note: the larger these values, the more memory Vim uses.
|
||||
|
||||
*'g:ctrlp_user_command'*
|
||||
Specify an external tool to use for listing files instead of using Vim’s
|
||||
|globpath()|. Use %s in place of the target directory: >
|
||||
let g:ctrlp_user_command = ''
|
||||
<
|
||||
Examples: >
|
||||
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
|
||||
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
|
||||
<
|
||||
You can also use 'grep', 'findstr' or something else to filter the results.
|
||||
Examples: >
|
||||
let g:ctrlp_user_command = 'find %s -type f | grep (?!tmp/.*)'
|
||||
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d | findstr .*\.py$'
|
||||
<
|
||||
Use a version control listing command when inside a repository, this is faster
|
||||
when scanning large projects: >
|
||||
let g:ctrlp_user_command = [root_marker, listing_command, fallback_command]
|
||||
let g:ctrlp_user_command = {
|
||||
\ 'types': {
|
||||
\ 1: [root_marker_1, listing_command_1],
|
||||
\ n: [root_marker_n, listing_command_n],
|
||||
\ },
|
||||
\ 'fallback': fallback_command
|
||||
\ }
|
||||
<
|
||||
Examples: >
|
||||
let g:ctrlp_user_command = ['.git/', 'cd %s && git ls-files']
|
||||
let g:ctrlp_user_command = ['.hg/', 'hg --cwd %s locate -I .']
|
||||
let g:ctrlp_user_command = {
|
||||
\ 'types': {
|
||||
\ 1: ['.git/', 'cd %s && git ls-files'],
|
||||
\ 2: ['.hg/', 'hg --cwd %s locate -I .'],
|
||||
\ },
|
||||
\ 'fallback': 'find %s -type f'
|
||||
\ }
|
||||
<
|
||||
If the fallback_command is empty or not defined, |globpath()| will then be used
|
||||
when searching outside a repo.
|
||||
|
||||
*'g:ctrlp_max_history'*
|
||||
The maximum number of input strings you want |CtrlP| to remember. The default
|
||||
value mirrors Vim’s global |'history'| option: >
|
||||
let g:ctrlp_max_history = &history
|
||||
<
|
||||
Set to 0 to disable prompt’s history. Browse the history with <c-n> and <c-p>.
|
||||
|
||||
*'g:ctrlp_open_new_file'*
|
||||
Use this option to specify how the newly created file is to be opened when
|
||||
pressing <c-y>:
|
||||
t - in a new tab
|
||||
h - in a new horizontal split
|
||||
v - in a new vertical split
|
||||
r - in the current window
|
||||
>
|
||||
let g:ctrlp_open_new_file = 'v'
|
||||
<
|
||||
|
||||
*'g:ctrlp_open_multi'*
|
||||
If non-zero, this will enable opening multiple files with <c-z> and <c-o>: >
|
||||
let g:ctrlp_open_multi = '1v'
|
||||
<
|
||||
For the number:
|
||||
- If bigger than 1, it’ll be used as the maximum number of windows or tabs to
|
||||
create when opening the files (the rest will be hidden buffers).
|
||||
- If is 1, <c-o> will open all files, each in a new window or new tab.
|
||||
- If no number is given, only the first file will be opened in a window,
|
||||
either new window or reused, and the rest will be hidden buffers.
|
||||
For the letters:
|
||||
t - each in a new tab
|
||||
h - each in a new horizontal split
|
||||
v - each in a new vertical split
|
||||
Reuse the current window:
|
||||
tr,
|
||||
hr,
|
||||
vr - open the first file in the current window, then the remaining files in
|
||||
new splits or new tabs just like with t, h, v.
|
||||
|
||||
*'g:ctrlp_arg_map'*
|
||||
When this is set to 1, the <c-o> and <c-y> mappings will accept one extra key
|
||||
as an argument to override their default behavior: >
|
||||
let g:ctrlp_arg_map = 0
|
||||
<
|
||||
Pressing <c-o> or <c-y> will then prompt for a keypress. The key can be:
|
||||
t - open in tab(s)
|
||||
h - open in horizontal split(s)
|
||||
v - open in vertical split(s)
|
||||
r - open in current window (for <c-y> only)
|
||||
<esc>, <c-c> - cancel and go back to the prompt.
|
||||
Any other key - use the behavior specified with |g:ctrlp_open_new_file| and
|
||||
|g:ctrlp_open_multi|.
|
||||
|
||||
*'g:ctrlp_dont_split'*
|
||||
When opening a file with <cr>, |CtrlP| avoids opening it in windows created by
|
||||
plugins, help and quickfix. Use this to setup some exceptions: >
|
||||
let g:ctrlp_dont_split = 'netrw'
|
||||
<
|
||||
Acceptable values are partial names or filetypes of the special buffers. Use
|
||||
|regexp| to specify the pattern. Example: >
|
||||
let g:ctrlp_dont_split = 'netrw\|help\|quickfix'
|
||||
<
|
||||
|
||||
*'g:ctrlp_follow_symlinks'*
|
||||
Set this to 1 to follow symbolic links when listing files: >
|
||||
let g:ctrlp_follow_symlinks = 0
|
||||
<
|
||||
When enabled, looped internal symlinks will be ignored to avoid duplicates.
|
||||
|
||||
*'g:ctrlp_lazy_update'*
|
||||
Set this to 1 to enable the lazy-update feature: only update the match window
|
||||
after typing’s been stopped for a certain amount of time: >
|
||||
let g:ctrlp_lazy_update = 0
|
||||
<
|
||||
If is 1, update after 250ms. If bigger than 1, the number will be used as the
|
||||
delay time in milliseconds.
|
||||
|
||||
*'g:ctrlp_use_migemo'*
|
||||
Set this to 1 to use Migemo Pattern for Japanese filenames. Migemo Search only
|
||||
works in |regexp| mode. To split the pattern, separate words with space: >
|
||||
let g:ctrlp_use_migemo = 0
|
||||
<
|
||||
|
||||
*'g:ctrlp_status_func'*
|
||||
Use this to customize the statuslines for the |CtrlP| window: >
|
||||
let g:ctrlp_status_func = {}
|
||||
<
|
||||
Example: >
|
||||
let g:ctrlp_status_func = {
|
||||
\ 'main': 'Function_Name_1',
|
||||
\ 'prog': 'Function_Name_2',
|
||||
\ }
|
||||
<
|
||||
See https://gist.github.com/1610859 for a working example.
|
||||
|
||||
===============================================================================
|
||||
3. Commands *ctrlp-commands*
|
||||
|
||||
*:CtrlP*
|
||||
:CtrlP [starting-directory]
|
||||
Open |CtrlP| in find file mode.
|
||||
|
||||
If no argument is given, the value of |g:ctrlp_working_path_mode| will be
|
||||
used to determine the starting directory.
|
||||
You can use <tab> to auto-complete the [starting-directory] when typing it.
|
||||
|
||||
*:CtrlPBuffer*
|
||||
:CtrlPBuffer
|
||||
Open |CtrlP| in find buffer mode.
|
||||
|
||||
*:CtrlPMRU*
|
||||
:CtrlPMRU
|
||||
Open |CtrlP| in find Most-Recently-Used file mode.
|
||||
|
||||
*:ClearCtrlPCache*
|
||||
:ClearCtrlPCache
|
||||
Flush the cache for the current working directory. The same as pressing <F5>
|
||||
inside |CtrlP|.
|
||||
You can also enable/disable caching with the option |g:ctrlp_use_caching|.
|
||||
|
||||
*:ClearAllCtrlPCaches*
|
||||
:ClearAllCtrlPCaches
|
||||
Delete all the cache files saved in |g:ctrlp_cache_dir|.
|
||||
|
||||
*:ResetCtrlP*
|
||||
:ResetCtrlP
|
||||
Reset all options and take in new values of the option variables.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
The following commands ignore the current value of |g:ctrlp_working_path_mode|:
|
||||
|
||||
:CtrlPCurWD *:CtrlPCurWD*
|
||||
This acts like |:CtrlP| with |path_mode| = 0
|
||||
|
||||
:CtrlPCurFile *:CtrlPCurFile*
|
||||
This acts like |:CtrlP| with |path_mode| = 1
|
||||
|
||||
:CtrlPRoot *:CtrlPRoot*
|
||||
This acts like |:CtrlP| with |path_mode| = 2
|
||||
|
||||
===============================================================================
|
||||
4. Mappings *ctrlp-mappings*
|
||||
|
||||
*'ctrlp-<c-p>'*
|
||||
<c-p>
|
||||
Default |Normal| mode mapping to open the |CtrlP| prompt in find file mode.
|
||||
|
||||
Once inside the prompt:~
|
||||
|
||||
<c-r> *'ctrlp-fullregexp'*
|
||||
Toggle between the string mode (section 5.a & b) and full |regexp| mode.
|
||||
(note: in full |regexp| mode, the prompt’s base is 'r>>' instead of '>>>')
|
||||
|
||||
See also |input-formats| (guide) and |g:ctrlp_regexp_search| (option).
|
||||
|
||||
<c-d>
|
||||
Toggle between full-path search and filename only search.
|
||||
(note: in filename mode, the prompt’s base is '>d>' instead of '>>>')
|
||||
|
||||
<c-f>, 'forward'
|
||||
<c-up>
|
||||
Scroll to the 'next' search mode in the sequence.
|
||||
|
||||
<c-b>, 'backward'
|
||||
<c-down>
|
||||
Scroll to the 'previous' search mode in the sequence.
|
||||
|
||||
<tab>
|
||||
Auto-complete directory names under the current working directory inside
|
||||
the prompt.
|
||||
|
||||
<s-tab>
|
||||
Toggle the focus between the match window and the prompt.
|
||||
|
||||
<c-j>,
|
||||
<down>
|
||||
Move selection down.
|
||||
|
||||
<c-k>,
|
||||
<up>
|
||||
Move selection up.
|
||||
|
||||
<c-a>
|
||||
Move the cursor to the 'start' of the prompt.
|
||||
|
||||
<c-e>
|
||||
Move the cursor to the 'end' of the prompt.
|
||||
|
||||
<c-h>,
|
||||
<left>,
|
||||
<c-^>
|
||||
Move the cursor one character to the 'left'.
|
||||
|
||||
<c-l>,
|
||||
<right>
|
||||
Move the cursor one character to the 'right'.
|
||||
|
||||
<c-]>,
|
||||
<bs>
|
||||
Delete the preceding character.
|
||||
|
||||
<del>
|
||||
Delete the current character.
|
||||
|
||||
<c-w>
|
||||
Delete a preceding inner word.
|
||||
|
||||
<c-u>
|
||||
Clear the input field.
|
||||
|
||||
<cr>
|
||||
Open selected file in the active window if possible.
|
||||
|
||||
<c-t>
|
||||
Open selected file in a new 'tab' after the last tabpage.
|
||||
|
||||
<c-v>
|
||||
Open selected file in a 'vertical' split.
|
||||
|
||||
<c-cr>,
|
||||
<c-s>,
|
||||
<c-x>
|
||||
Open selected file in a 'horizontal' split.
|
||||
|
||||
<c-y>
|
||||
Create a new file and its parent directories.
|
||||
|
||||
<c-n>
|
||||
Next string in the prompt’s history.
|
||||
|
||||
<c-p>
|
||||
Previous string in the prompt’s history.
|
||||
|
||||
<c-z>
|
||||
- Mark/unmark a file to be opened with <c-o>.
|
||||
- Mark/unmark a file to create a new file in its directory using <c-y>.
|
||||
|
||||
<c-o>
|
||||
Open files marked by <c-z>.
|
||||
|
||||
<F5>
|
||||
- Refresh the match window and purge the cache for the current directory.
|
||||
- Remove deleted files from MRU list.
|
||||
|
||||
<F7>
|
||||
Clear MRU list.
|
||||
|
||||
<insert>
|
||||
Insert the word under the cursor (in the active buffer) into the prompt.
|
||||
|
||||
<esc>,
|
||||
<c-c>,
|
||||
<c-g>
|
||||
Exit |CtrlP|.
|
||||
<c-c> can also be used to stop the scan if it’s taking too long.
|
||||
|
||||
Choose your own mappings with |g:ctrlp_prompt_mappings|.
|
||||
|
||||
When inside the match window (press <s-tab> to switch):~
|
||||
|
||||
a-z
|
||||
0-9
|
||||
~^-=;`',.+!@#$%&_(){}[]
|
||||
Cycle through the lines with the first letter (of paths or filenames) that
|
||||
matches that key.
|
||||
|
||||
===============================================================================
|
||||
5. Input Formats *ctrlp-input-formats*
|
||||
|
||||
Formats for inputting in the prompt:~
|
||||
|
||||
a) Simple string.
|
||||
e.g. 'abc' is understood internally as 'a[^a]\{-}b[^b]\{-}c'
|
||||
|
||||
b) Vim |regexp|. If the input string contains '*' or '|', it’ll be treated as
|
||||
a Vim’s |regexp| |pattern| without any modification.
|
||||
e.g. 'abc\d*efg' will be read as 'abc\d*efg'.
|
||||
|
||||
See also |ctrlp-fullregexp| (keymap) and |g:ctrlp_regexp_search| (option).
|
||||
|
||||
c) End the string with a colon ':' followed by a Vim command to execute that
|
||||
command after opening the file. If you need to use ':' literally, escape it
|
||||
with a backslash: '\:'. When opening multiple files, the command will be
|
||||
executed on each opening file.
|
||||
e.g. 'abc:45' will open the selected file and jump to line 45.
|
||||
'abc:/my\:string' will open the selected file and jump to the first
|
||||
instance of 'my:function'.
|
||||
'abc:+setf\ myfiletype|50' will open the selected file and set its
|
||||
filetype to 'myfiletype', then jump to line 50.
|
||||
'abc:diffthis' will open the selected file and run |:diffthis| on the
|
||||
first 4 files.
|
||||
|
||||
See also Vim’s |++opt| and |+cmd|.
|
||||
|
||||
d) Type exactly two dots '..' at the start of the prompt and press enter to go
|
||||
backward in the directory tree by 1 level. If the parent directory is
|
||||
large, this might be slow.
|
||||
|
||||
e) Similarly, submit '/' or '\' to find and go to the project’s root. If the
|
||||
project is large, using a VCS listing command to look for files might help
|
||||
speeding up the intial scan (see |g:ctrlp_user_command| for more details).
|
||||
|
||||
f) Type the name of a non-existent file and press <c-y> to create it. Mark a
|
||||
file with <c-z> to create the new file in the same directory as the marked
|
||||
file.
|
||||
e.g. 'parentdir/newfile.txt' will create a directory named 'parentdir' as
|
||||
well as 'newfile.txt'.
|
||||
If 'some/old/dirs/oldfile.txt' is marked with <c-z>, then 'parentdir'
|
||||
and 'newfile.txt' will be created in 'some/old/dirs'. The final path
|
||||
will then be 'some/old/dirs/parentdir/newfile.txt'.
|
||||
Use '\' in place of '/' on Windows (if |'ssl'| is not set).
|
||||
|
||||
g) Submit ? to open this help file.
|
||||
|
||||
===============================================================================
|
||||
6. Extensions *g:ctrlp-extensions*
|
||||
|
||||
Extensions are optional. To enable an extension, add its name to the variable
|
||||
g:ctrlp_extensions: >
|
||||
let g:ctrlp_extensions = ['tag', 'buffertag', 'quickfix', 'dir', 'rtscript']
|
||||
<
|
||||
The order of the items will be the order they appear on the statusline and when
|
||||
using <c-f>, <c-b>.
|
||||
|
||||
Available extensions:~
|
||||
|
||||
*:CtrlPTag*
|
||||
* Tag mode:~
|
||||
- Name: 'tag'
|
||||
- Command: ':CtrlPTag'
|
||||
- Search for a tag within a generated central tags file, and jump to the
|
||||
definition. Use the Vim’s option |'tags'| to specify the names and the
|
||||
locations of the tags file(s). Example: `set tags+=tags/help,doc/tags`
|
||||
|
||||
*:CtrlPBufTag*
|
||||
*:CtrlPBufTagAll*
|
||||
* Buffer Tag mode:~
|
||||
- Name: 'buffertag'
|
||||
- Commands: ':CtrlPBufTag [buffer-name]',
|
||||
':CtrlPBufTagAll'.
|
||||
- Search for a tag within the current buffer or all buffers and jump to the
|
||||
definition. Requires |exuberant_ctags| or compatible programs.
|
||||
|
||||
*:CtrlPQuickfix*
|
||||
* Quickfix mode:~
|
||||
- Name: 'quickfix'
|
||||
- Command: ':CtrlPQuickfix'
|
||||
- Search for an entry in the current quickfix errors and jump to it.
|
||||
|
||||
*:CtrlPDir*
|
||||
* Directory mode:~
|
||||
- Name: 'dir'
|
||||
- Command: ':CtrlPDir [starting-directory]'
|
||||
- Search for a directory and change the working directory to it.
|
||||
- Mappings:
|
||||
+ <cr> change the local working directory for |CtrlP| and keep it open.
|
||||
+ <c-t> change the global working directory (exit).
|
||||
+ <c-v> change the local working directory for the current window (exit).
|
||||
+ <c-x> change the global working directory to |CtrlP|’s current local
|
||||
working directory (exit).
|
||||
|
||||
*:CtrlPRTS*
|
||||
* Runtime script mode:~
|
||||
- Name: 'rtscript'
|
||||
- Command: ':CtrlPRTS'
|
||||
- Search for files (vimscripts, docs, snippets...) in runtimepath.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Buffer Tag mode options:~
|
||||
|
||||
*'g:ctrlp_buftag_ctags_bin'*
|
||||
If ctags isn’t in your $PATH, use this to set its location: >
|
||||
let g:ctrlp_buftag_ctags_bin = ''
|
||||
<
|
||||
|
||||
*'g:ctrlp_buftag_systemenc'*
|
||||
Match this with your OS’s encoding (not Vim’s). The default value mirrors Vim’s
|
||||
global |'encoding'| option: >
|
||||
let g:ctrlp_buftag_systemenc = &encoding
|
||||
<
|
||||
|
||||
*'g:ctrlp_buftag_types'*
|
||||
Use this to set the arguments for ctags, jsctags... for a given filetype: >
|
||||
let g:ctrlp_buftag_types = ''
|
||||
<
|
||||
Examples: >
|
||||
let g:ctrlp_buftag_types = {
|
||||
\ 'erlang' : '--language-force=erlang --erlang-types=drmf',
|
||||
\ 'javascript' : {
|
||||
\ 'bin': 'jsctags',
|
||||
\ 'args': '-f -',
|
||||
\ },
|
||||
\ }
|
||||
<
|
||||
|
||||
===============================================================================
|
||||
CUSTOMIZATION *ctrlp-customization*
|
||||
|
||||
Highlighting:~
|
||||
* For the |CtrlP| buffer:
|
||||
CtrlPNoEntries : the message when no match is found (Error)
|
||||
CtrlPMatch : the matched pattern (Identifier)
|
||||
CtrlPLinePre : the line prefix '>' in the match window
|
||||
CtrlPPrtBase : the prompt’s base (Comment)
|
||||
CtrlPPrtText : the prompt’s text (|hl-Normal|)
|
||||
CtrlPPrtCursor : the prompt’s cursor when moving over the text (Constant)
|
||||
|
||||
* In extensions:
|
||||
CtrlPTabExtra : the part of each line that’s not matched against (Comment)
|
||||
CtrlPqfLineCol : the line and column numbers in quickfix mode (|hl-Search|)
|
||||
CtrlPUndoT : the elapsed time in undo mode (|hl-Directory|)
|
||||
CtrlPUndoBr : the square brackets [] in undo mode (Comment)
|
||||
CtrlPUndoNr : the undo number inside [] in undo mode (String)
|
||||
|
||||
Statuslines:~
|
||||
* Highlight groups:
|
||||
CtrlPMode1 : 'prt' or 'win', also for 'regex' (Character)
|
||||
CtrlPMode2 : 'file' or 'path', also for the local working dir (|hl-LineNr|)
|
||||
CtrlPStats : the scanning status (Function)
|
||||
|
||||
For rebuilding the statuslines, see |g:ctrlp_status_func|.
|
||||
|
||||
===============================================================================
|
||||
CREDITS *ctrlp-credits*
|
||||
|
||||
Developed by Kien Nguyen <github.com/kien>.
|
||||
|
||||
Project’s homepage: http://kien.github.com/ctrlp.vim
|
||||
Git repository: https://github.com/kien/ctrlp.vim
|
||||
Mercurial repository: https://bitbucket.org/kien/ctrlp.vim
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Thanks to everyone that has submitted ideas, bug reports or helped debugging on
|
||||
gibhub, bitbucket, and through email.
|
||||
|
||||
Special thanks:~
|
||||
|
||||
* Woojong Koh <github.com/wjkoh>
|
||||
Forked and suggested the support for VCS listing commands.
|
||||
|
||||
* Yasuhiro Matsumoto <github.com/mattn>
|
||||
Added option to use Migemo for Japanese filenames.
|
||||
|
||||
* Kyo Nagashima <github.com/hail2u>
|
||||
Made some enhancements to file opening mappings.
|
||||
|
||||
* Piet Delport <github.com/pjdelport>
|
||||
Changed the default cache directory to meet XDG spec.
|
||||
|
||||
* Kent Sibilev <github.com/datanoise>
|
||||
Debugged and made various patches.
|
||||
|
||||
* Simon Ruderich
|
||||
* Ken Earley <github.com/kenearley>
|
||||
* Zak Johnson <github.com/zakj>
|
||||
* Diego Viola <github.com/diegoviola>
|
||||
* Thibault Duplessis <github.com/ornicar>
|
||||
* Tacahiroy <github.com/tacahiroy>
|
||||
Bugfixes/Corrections.
|
||||
|
||||
===============================================================================
|
||||
CHANGELOG *ctrlp-changelog*
|
||||
|
||||
+ New option: |g:ctrlp_mruf_last_entered| change MRU to recently-entered.
|
||||
|
||||
Before 2012/01/15~
|
||||
|
||||
+ New mapping: Switch <tab> and <s-tab>. <tab> is now used for completion
|
||||
of directory names under the current working directory.
|
||||
+ New options: |g:ctrlp_arg_map| for <c-y>, <c-o> to accept an argument.
|
||||
|g:ctrlp_status_func| custom statusline.
|
||||
|g:ctrlp_mruf_relative| show only MRU files inside cwd.
|
||||
+ Extend |g:ctrlp_open_multi| with new optional values: tr, hr, vr.
|
||||
+ Extend |g:ctrlp_custom_ignore| to specifically filter dir, file and link.
|
||||
|
||||
Before 2012/01/05~
|
||||
|
||||
+ New feature: Buffer Tag extension.
|
||||
+ New commands: |:CtrlPBufTag|, |:CtrlPBufTagAll|.
|
||||
+ New options: |g:ctrlp_cmd|,
|
||||
|g:ctrlp_custom_ignore|
|
||||
|
||||
Before 2011/11/30~
|
||||
|
||||
+ New features: Tag, Quickfix and Directory extensions.
|
||||
+ New commands: |:CtrlPTag|, |:CtrlPQuickfix|, |:CtrlPDir|.
|
||||
+ New options: |g:ctrlp_use_migemo|,
|
||||
|g:ctrlp_lazy_update|,
|
||||
|g:ctrlp_follow_symlinks|
|
||||
|
||||
Before 2011/11/13~
|
||||
|
||||
+ New special input: '/' and '\' find root (section 5.e)
|
||||
+ Remove ctrlp#SetWorkingPath().
|
||||
+ Remove |g:ctrlp_mru_files|, make MRU permanent.
|
||||
+ Extend |g:ctrlp_open_multi|, add new ways to open files.
|
||||
+ New option: |g:ctrlp_dont_split|,
|
||||
|g:ctrlp_mruf_case_sensitive|
|
||||
|
||||
Before 2011/10/30~
|
||||
|
||||
+ New feature: Support for custom extensions.
|
||||
<F5> also removes non-existent files from MRU list.
|
||||
+ New option: |g:ctrlp_jump_to_buffer|
|
||||
|
||||
Before 2011/10/12~
|
||||
|
||||
+ New features: Open multiple files.
|
||||
Pass Vim’s |++opt| and |+cmd| to the opening file
|
||||
(section 5.c)
|
||||
Auto-complete each dir for |:CtrlP| [starting-directory]
|
||||
+ New mappings: <c-z> mark/unmark a file to be opened with <c-o>.
|
||||
<c-o> open all marked files.
|
||||
+ New option: |g:ctrlp_open_multi|
|
||||
+ Remove |g:ctrlp_persistent_input|, |g:ctrlp_live_update| and <c-^>.
|
||||
|
||||
Before 2011/09/29~
|
||||
|
||||
+ New mappings: <c-n>, <c-p> next/prev string in the input history.
|
||||
<c-y> create a new file and its parent dirs.
|
||||
+ New options: |g:ctrlp_open_new_file|,
|
||||
|g:ctrlp_max_history|
|
||||
+ Added a new open-in-horizontal-split mapping: <c-x>
|
||||
|
||||
Before 2011/09/19~
|
||||
|
||||
+ New command: |ResetCtrlP|
|
||||
+ New options: |g:ctrlp_max_files|,
|
||||
|g:ctrlp_max_depth|,
|
||||
|g:ctrlp_live_update|
|
||||
+ New mapping: <c-^>
|
||||
|
||||
Before 2011/09/12~
|
||||
|
||||
+ Ability to cycle through matched lines in the match window.
|
||||
+ Extend the behavior of |g:ctrlp_persistent_input|
|
||||
+ Extend the behavior of |:CtrlP|
|
||||
+ New options: |g:ctrlp_dotfiles|,
|
||||
|g:ctrlp_clear_cache_on_exit|,
|
||||
|g:ctrlp_highlight_match|,
|
||||
|g:ctrlp_user_command|
|
||||
+ New special input: '..' (section 5.d)
|
||||
+ New mapping: <F5>.
|
||||
+ New commands: |:CtrlPCurWD|,
|
||||
|:CtrlPCurFile|,
|
||||
|:CtrlPRoot|
|
||||
|
||||
+ New feature: Search in most recently used (MRU) files
|
||||
+ New mapping: <c-b>.
|
||||
+ Extended the behavior of <c-f>.
|
||||
+ New options: |g:ctrlp_mru_files|,
|
||||
|g:ctrlp_mruf_max|,
|
||||
|g:ctrlp_mruf_exclude|,
|
||||
|g:ctrlp_mruf_include|
|
||||
+ New command: |:CtrlPMRUFiles|
|
||||
|
||||
First public release: 2011/09/06~
|
||||
|
||||
===============================================================================
|
||||
vim:ft=help:et:ts=2:sw=2:sts=2:norl
|
||||
64
bundle/git_ctrlp/plugin/ctrlp.vim
Normal file
64
bundle/git_ctrlp/plugin/ctrlp.vim
Normal file
@@ -0,0 +1,64 @@
|
||||
" =============================================================================
|
||||
" File: plugin/ctrlp.vim
|
||||
" Description: Fuzzy file, buffer, mru and tag finder.
|
||||
" Author: Kien Nguyen <github.com/kien>
|
||||
" =============================================================================
|
||||
" GetLatestVimScripts: 3736 1 :AutoInstall: ctrlp.zip
|
||||
|
||||
if ( exists('g:loaded_ctrlp') && g:loaded_ctrlp ) || v:version < 700 || &cp
|
||||
fini
|
||||
en
|
||||
let [g:loaded_ctrlp, g:ctrlp_lines, g:ctrlp_allfiles] = [1, [], []]
|
||||
|
||||
if !exists('g:ctrlp_map') | let g:ctrlp_map = '<c-p>' | en
|
||||
if !exists('g:ctrlp_cmd') | let g:ctrlp_cmd = 'CtrlP' | en
|
||||
|
||||
com! -n=? -com=dir CtrlP cal ctrlp#init(0, <q-args>)
|
||||
|
||||
com! CtrlPBuffer cal ctrlp#init(1)
|
||||
com! CtrlPMRUFiles cal ctrlp#init(2)
|
||||
|
||||
com! ClearCtrlPCache cal ctrlp#clr()
|
||||
com! ClearAllCtrlPCaches cal ctrlp#clra()
|
||||
com! ResetCtrlP cal ctrlp#reset()
|
||||
|
||||
com! CtrlPCurWD cal ctrlp#init(0, 0)
|
||||
com! CtrlPCurFile cal ctrlp#init(0, 1)
|
||||
com! CtrlPRoot cal ctrlp#init(0, 2)
|
||||
|
||||
if g:ctrlp_map != ''
|
||||
exe 'nn <silent>' g:ctrlp_map ':<c-u>'.g:ctrlp_cmd.'<cr>'
|
||||
en
|
||||
|
||||
cal ctrlp#mrufiles#init()
|
||||
|
||||
if !exists('g:ctrlp_extensions') | fini | en
|
||||
|
||||
let s:ext = g:ctrlp_extensions
|
||||
|
||||
if index(s:ext, 'tag') >= 0
|
||||
let g:ctrlp_alltags = []
|
||||
com! CtrlPTag cal ctrlp#init(ctrlp#tag#id())
|
||||
en
|
||||
|
||||
if index(s:ext, 'quickfix') >= 0
|
||||
com! CtrlPQuickfix cal ctrlp#init(ctrlp#quickfix#id())
|
||||
en
|
||||
|
||||
if index(s:ext, 'dir') >= 0
|
||||
let g:ctrlp_alldirs = []
|
||||
com! -n=? -com=dir CtrlPDir cal ctrlp#init(ctrlp#dir#id(), <q-args>)
|
||||
en
|
||||
|
||||
if index(s:ext, 'buffertag') >= 0
|
||||
let g:ctrlp_buftags = {}
|
||||
com! -n=? -com=buffer CtrlPBufTag
|
||||
\ cal ctrlp#init(ctrlp#buffertag#cmd(0, <q-args>))
|
||||
com! CtrlPBufTagAll cal ctrlp#init(ctrlp#buffertag#cmd(1))
|
||||
en
|
||||
|
||||
if index(s:ext, 'rtscript') >= 0
|
||||
com! CtrlPRTS cal ctrlp#init(ctrlp#rtscript#id())
|
||||
en
|
||||
|
||||
unl s:ext
|
||||
79
bundle/git_ctrlp/readme.md
Normal file
79
bundle/git_ctrlp/readme.md
Normal file
@@ -0,0 +1,79 @@
|
||||
# ctrlp.vim
|
||||
Full path fuzzy __file__, __buffer__, __mru__ and __tag__ finder for Vim.
|
||||
|
||||
* Written in pure Vimscript for MacVim and Vim 7.0+.
|
||||
* Full support for Vim’s regexp as search pattern.
|
||||
* Built-in Most Recently Used (MRU) files monitoring.
|
||||
* Built-in project’s root finder.
|
||||
* Open Multiple Files.
|
||||
* [Extensible][3].
|
||||
|
||||
![ctrlp][1]
|
||||
|
||||
## Basic Usage
|
||||
* Press `<c-p>` or run `:CtrlP` to invoke CtrlP in find file mode.
|
||||
* Or run `:CtrlPBuffer` or `:CtrlPMRU` to invoke CtrlP in buffer or MRU mode.
|
||||
|
||||
Once CtrlP is open:
|
||||
|
||||
* Press `<c-f>` and `<c-b>` to switch between find file, buffer, and MRU file modes.
|
||||
* Press `<c-d>` to switch to filename only search instead of full path.
|
||||
* Press `<F5>` to purge the cache for the current directory and get new files.
|
||||
* Use `*` or `|` in the prompt to submit the string as a Vim’s regexp pattern.
|
||||
* Or press `<c-r>` to switch to regexp mode.
|
||||
* End the input string with a colon `:` followed by a command to execute after opening the file.
|
||||
e.g. `abc:45` will open the file matched the pattern and jump to line 45.
|
||||
* Submit two dots `..` as the input string to go backward the directory tree by 1 level.
|
||||
* Use `<c-y>` to create a new file and its parent dirs.
|
||||
* Use `<c-z>` to mark/unmark files and `<c-o>` to open them.
|
||||
|
||||
## Basic Options
|
||||
* Change the mapping to invoke CtrlP:
|
||||
|
||||
```vim
|
||||
let g:ctrlp_map = '<c-p>'
|
||||
```
|
||||
|
||||
* When CtrlP is invoked, it automatically sets the working directory according to this variable:
|
||||
|
||||
```vim
|
||||
let g:ctrlp_working_path_mode = 2
|
||||
```
|
||||
|
||||
0 - don’t manage working directory.
|
||||
1 - the parent directory of the current file.
|
||||
2 - the nearest ancestor that contains one of these directories or files:
|
||||
|
||||
.git/
|
||||
.hg/
|
||||
.bzr/
|
||||
_darcs/
|
||||
root.dir
|
||||
|
||||
* If you want to exclude directories or files from the search, you can use the Vim’s option `wildignore`
|
||||
and/or the option `g:ctrlp_custom_ignore`. Examples:
|
||||
|
||||
```vim
|
||||
set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " for Linux/MacOSX
|
||||
set wildignore+=.git\*,.hg\*,.svn\* " for Windows
|
||||
|
||||
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$'
|
||||
let g:ctrlp_custom_ignore = {
|
||||
\ 'dir': '\.git$\|\.hg$\|\.svn$',
|
||||
\ 'file': '\.exe$\|\.so$\|\.dll$',
|
||||
\ 'link': 'some_bad_symbolic_links',
|
||||
\ }
|
||||
```
|
||||
|
||||
* Use a custom file listing command with:
|
||||
|
||||
```vim
|
||||
let g:ctrlp_user_command = 'find %s -type f' " MacOSX/Linux
|
||||
let g:ctrlp_user_command = 'dir %s /-n /b /s /a-d' " Windows
|
||||
```
|
||||
|
||||
_Check [the docs][2] for more mappings, commands and options._
|
||||
|
||||
[1]: http://i.imgur.com/yIynr.png
|
||||
[2]: https://github.com/kien/ctrlp.vim/blob/master/doc/ctrlp.txt
|
||||
[3]: https://github.com/kien/ctrlp.vim/tree/extensions
|
||||
@@ -1,8 +1,8 @@
|
||||
let current_file = expand('%:p')
|
||||
|
||||
if match(current_file, '\cicard') < 0
|
||||
source $HOME/.vim/indent/python_pep8.vim
|
||||
ru! indent/python_pep8.vim
|
||||
else
|
||||
let g:pep8_exclude=['W191']
|
||||
source $VIMRUNTIME/indent/python.vim
|
||||
ru! indent/python.vim
|
||||
endif
|
||||
|
||||
@@ -1,570 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (c) 2009-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if exists('g:loaded_autoload_l9')
|
||||
finish
|
||||
endif
|
||||
let g:loaded_autoload_l9 = 1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" COMPATIBILITY TEST {{{1
|
||||
|
||||
"
|
||||
let s:L9_VERSION_CURRENT = 101
|
||||
let s:L9_VERSION_PASSABLE = 101
|
||||
|
||||
" returns true if given version is compatible.
|
||||
function l9#isCompatible(ver)
|
||||
return
|
||||
endfunction
|
||||
|
||||
let s:VERSION_FACTOR = str2float('0.01')
|
||||
|
||||
" returns false if the caller script should finish.
|
||||
" a:vimVersion: if 0, don't check vim version
|
||||
" a:l9Version: same rule as v:version
|
||||
function l9#guardScriptLoading(path, vimVersion, l9Version, exprs)
|
||||
let loadedVarName = 'g:loaded_' . substitute(a:path, '\W', '_', 'g')
|
||||
if exists(loadedVarName)
|
||||
return 0
|
||||
elseif a:vimVersion > 0 && a:vimVersion > v:version
|
||||
echoerr a:path . ' requires Vim version ' . string(a:vimVersion * s:VERSION_FACTOR)
|
||||
return 0
|
||||
elseif a:l9Version > 0 && (a:l9Version > s:L9_VERSION_CURRENT ||
|
||||
\ a:l9Version < s:L9_VERSION_PASSABLE)
|
||||
echoerr a:path . ' requires L9 library version ' . string(a:l9Version * s:VERSION_FACTOR)
|
||||
return 0
|
||||
endif
|
||||
for expr in a:exprs
|
||||
if !eval(expr)
|
||||
echoerr a:path . ' requires: ' . expr
|
||||
return 0
|
||||
endif
|
||||
endfor
|
||||
let {loadedVarName} = 1
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#getVersion()
|
||||
return s:L9_VERSION_CURRENT
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LIST {{{1
|
||||
|
||||
" Removes duplicates (unstable)
|
||||
" This function doesn't change the list of argument.
|
||||
function l9#unique(items)
|
||||
let sorted = sort(a:items)
|
||||
if len(sorted) < 2
|
||||
return sorted
|
||||
endif
|
||||
let last = remove(sorted, 0)
|
||||
let result = [last]
|
||||
for item in sorted
|
||||
if item != last
|
||||
call add(result, item)
|
||||
let last = item
|
||||
endif
|
||||
endfor
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" Removes duplicates (stable)
|
||||
" This function doesn't change the list of argument.
|
||||
function l9#uniqueStably(items)
|
||||
let result = []
|
||||
for item in a:items
|
||||
if count(result, item, &ignorecase) == 0
|
||||
call add(result, item)
|
||||
endif
|
||||
endfor
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" [ [0], [1,2], [3] ] -> [ 0, 1, 2, 3 ]
|
||||
" This function doesn't change the list of argument.
|
||||
function l9#concat(items)
|
||||
let result = []
|
||||
for l in a:items
|
||||
let result += l
|
||||
endfor
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" [ [0,1,2], [3,4], [5,6,7,8] ] -> [ [0,3,5],[1,4,6] ]
|
||||
" This function doesn't change the list of argument.
|
||||
function l9#zip(items)
|
||||
let result = []
|
||||
for i in range(min(map(copy(a:items), 'len(v:val)')))
|
||||
call add(result, map(copy(a:items), 'v:val[i]'))
|
||||
endfor
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" filter() with the maximum number of items
|
||||
" This function doesn't change the list of argument.
|
||||
function l9#filterWithLimit(items, expr, limit)
|
||||
if a:limit <= 0
|
||||
return filter(copy(a:items), a:expr)
|
||||
endif
|
||||
let result = []
|
||||
let stride = a:limit * 3 / 2 " x1.5
|
||||
for i in range(0, len(a:items) - 1, stride)
|
||||
let result += filter(a:items[i : i + stride - 1], a:expr)
|
||||
if len(result) >= a:limit
|
||||
return remove(result, 0, a:limit - 1)
|
||||
endif
|
||||
endfor
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" Removes if a:expr is evaluated as non-zero and returns removed items.
|
||||
" This function change the list of argument.
|
||||
function l9#removeIf(items, expr)
|
||||
let removed = filter(copy(a:items), a:expr)
|
||||
call filter(a:items, '!( ' . a:expr . ')')
|
||||
return removed
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" NUMERIC {{{1
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" STRING {{{1
|
||||
|
||||
" Snips a:str and add a:mask if the length of a:str is more than a:len
|
||||
function l9#snipHead(str, len, mask)
|
||||
if a:len >= len(a:str)
|
||||
return a:str
|
||||
elseif a:len <= len(a:mask)
|
||||
return a:mask
|
||||
endif
|
||||
return a:mask . a:str[-a:len + len(a:mask):]
|
||||
endfunction
|
||||
|
||||
" Snips a:str and add a:mask if the length of a:str is more than a:len
|
||||
function l9#snipTail(str, len, mask)
|
||||
if a:len >= len(a:str)
|
||||
return a:str
|
||||
elseif a:len <= len(a:mask)
|
||||
return a:mask
|
||||
endif
|
||||
return a:str[:a:len - 1 - len(a:mask)] . a:mask
|
||||
endfunction
|
||||
|
||||
" Snips a:str and add a:mask if the length of a:str is more than a:len
|
||||
function l9#snipMid(str, len, mask)
|
||||
if a:len >= len(a:str)
|
||||
return a:str
|
||||
elseif a:len <= len(a:mask)
|
||||
return a:mask
|
||||
endif
|
||||
let len_head = (a:len - len(a:mask)) / 2
|
||||
let len_tail = a:len - len(a:mask) - len_head
|
||||
return (len_head > 0 ? a:str[: len_head - 1] : '') . a:mask .
|
||||
\ (len_tail > 0 ? a:str[-len_tail :] : '')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#hash224(str)
|
||||
let a = 0x00000800 " shift 11 bit (if unsigned)
|
||||
let b = 0x001fffff " extract 11 bit (if unsigned)
|
||||
let nHash = 7
|
||||
let hashes = repeat([0], nHash)
|
||||
for i in range(len(a:str))
|
||||
let iHash = i % nHash
|
||||
let hashes[iHash] = hashes[iHash] * a + hashes[iHash] / b
|
||||
let hashes[iHash] += char2nr(a:str[i])
|
||||
endfor
|
||||
return join(map(hashes, 'printf("%08x", v:val)'), '')
|
||||
endfunction
|
||||
|
||||
" wildcard -> regexp
|
||||
function l9#convertWildcardToRegexp(expr)
|
||||
let re = escape(a:expr, '\')
|
||||
for [pat, sub] in [ [ '*', '\\.\\*' ], [ '?', '\\.' ], [ '[', '\\[' ], ]
|
||||
let re = substitute(re, pat, sub, 'g')
|
||||
endfor
|
||||
return '\V' . re
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" LINES {{{1
|
||||
|
||||
" Removes from the line matching with a:begin first to the line matching with
|
||||
" a:end next and returns removed lines.
|
||||
" If matching range is not found, returns []
|
||||
function l9#removeLinesBetween(lines, begin, end)
|
||||
for i in range(len(a:lines) - 1)
|
||||
if a:lines[i] =~ a:begin
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
for j in range(i + 1, len(a:lines) - 1)
|
||||
if a:lines[j] =~ a:end
|
||||
let g:l0 += [a:lines[i : j]]
|
||||
return remove(a:lines, i, j)
|
||||
endif
|
||||
endfor
|
||||
return []
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" PATH {{{1
|
||||
|
||||
" returns the path separator charactor.
|
||||
function l9#getPathSeparator()
|
||||
return (!&shellslash && (has('win32') || has('win64')) ? '\' : '/')
|
||||
endfunction
|
||||
|
||||
" [ 'a', 'b/', '/c' ] -> 'a/b/c'
|
||||
function l9#concatPaths(paths)
|
||||
let result = ''
|
||||
for p in a:paths
|
||||
if empty(p)
|
||||
continue
|
||||
elseif empty(result)
|
||||
let result = p
|
||||
else
|
||||
let result = substitute(result, '[/\\]$', '', '') . l9#getPathSeparator()
|
||||
\ . substitute(p, '^[/\\]', '', '')
|
||||
endif
|
||||
endfor
|
||||
return result
|
||||
endfunction
|
||||
|
||||
" path: '/a/b/c/d', dir: '/a/b' => 'c/d'
|
||||
function l9#modifyPathRelativeToDir(path, dir)
|
||||
let pathFull = fnamemodify(a:path, ':p')
|
||||
let dirFull = fnamemodify(a:dir, ':p')
|
||||
if len(pathFull) < len(dirFull) || pathFull[:len(dirFull) - 1] !=# dirFull
|
||||
return pathFull
|
||||
endif
|
||||
return pathFull[len(dirFull):]
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" FILE {{{1
|
||||
|
||||
" Almost same as readfile().
|
||||
function l9#readFile(...)
|
||||
let args = copy(a:000)
|
||||
let args[0] = expand(args[0])
|
||||
try
|
||||
return call('readfile', args)
|
||||
catch
|
||||
endtry
|
||||
return []
|
||||
endfunction
|
||||
|
||||
" Almost same as writefile().
|
||||
function l9#writeFile(...)
|
||||
let args = copy(a:000)
|
||||
let args[1] = expand(args[1])
|
||||
let dir = fnamemodify(args[1], ':h')
|
||||
try
|
||||
if !isdirectory(dir)
|
||||
call mkdir(dir, 'p')
|
||||
endif
|
||||
return call('writefile', args)
|
||||
catch
|
||||
endtry
|
||||
return -1 " -1 is error code.
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" BUFFER {{{1
|
||||
|
||||
" :wall/:wall! wrapper. Useful for writing readonly buffers.
|
||||
function l9#writeAll()
|
||||
try
|
||||
silent update " NOTE: avoiding a problem with a buftype=acwrite buffer.
|
||||
silent wall
|
||||
catch /^Vim/ " E45, E505
|
||||
if l9#inputHl('Question', v:exception . "\nWrite readonly files? (Y/N) : ", 'Y') ==? 'y'
|
||||
redraw
|
||||
:wall!
|
||||
endif
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" Loads given files with :edit command
|
||||
function l9#loadFilesToBuffers(files)
|
||||
for file in filter(copy(a:files), '!bufloaded(v:val)')
|
||||
execute 'edit ' . fnameescape(file)
|
||||
if !exists('bufNrFirst')
|
||||
let bufNrFirst = bufnr('%')
|
||||
endif
|
||||
endfor
|
||||
if exists('bufNrFirst')
|
||||
execute bufNrFirst . 'buffer'
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Deletes all buffers except given files with :bdelete command
|
||||
function l9#deleteAllBuffersExcept(files)
|
||||
let bufNrExcepts = map(copy(a:files), 'bufnr("^" . v:val . "$")')
|
||||
for bufNr in filter(range(1, bufnr('$')), 'bufloaded(v:val)')
|
||||
if count(bufNrExcepts, bufNr) == 0
|
||||
execute bufNr . 'bdelete'
|
||||
endif
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" WINDOW {{{1
|
||||
|
||||
" move current window to next tabpage.
|
||||
function l9#shiftWinNextTabpage()
|
||||
if tabpagenr('$') < 2
|
||||
return
|
||||
endif
|
||||
let bufnr = bufnr('%')
|
||||
tabnext
|
||||
execute bufnr . 'sbuffer'
|
||||
tabprevious
|
||||
if winnr('$') > 1
|
||||
close
|
||||
tabnext
|
||||
else
|
||||
close " if tabpage is closed, next tabpage will become current
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" move current window to previous tabpage.
|
||||
function l9#shiftWinPrevTabpage()
|
||||
if tabpagenr('$') < 2
|
||||
return
|
||||
endif
|
||||
let bufnr = bufnr('%')
|
||||
tabprevious
|
||||
execute bufnr . 'sbuffer'
|
||||
tabnext
|
||||
close
|
||||
tabprevious
|
||||
endfunction
|
||||
|
||||
" move to a window containing specified buffer.
|
||||
" returns 0 if the buffer is not found.
|
||||
function l9#moveToBufferWindowInCurrentTabpage(bufNr)
|
||||
if bufnr('%') == a:bufNr
|
||||
return 1
|
||||
elseif count(tabpagebuflist(), a:bufNr) == 0
|
||||
return 0
|
||||
endif
|
||||
execute bufwinnr(a:bufNr) . 'wincmd w'
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" returns 0 if the buffer is not found.
|
||||
function s:moveToOtherTabpageOpeningBuffer(bufNr)
|
||||
for tabNr in range(1, tabpagenr('$'))
|
||||
if tabNr != tabpagenr() && count(tabpagebuflist(tabNr), a:bufNr) > 0
|
||||
execute 'tabnext ' . tabNr
|
||||
return 1
|
||||
endif
|
||||
endfor
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
" move to a window containing specified buffer.
|
||||
" returns 0 if the buffer is not found.
|
||||
function l9#moveToBufferWindowInOtherTabpage(bufNr)
|
||||
if !s:moveToOtherTabpageOpeningBuffer(a:bufNr)
|
||||
return 0
|
||||
endif
|
||||
return l9#moveToBufferWindowInCurrentTabpage(a:bufNr)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" COMMAND LINE {{{1
|
||||
|
||||
" echo/echomsg with highlighting.
|
||||
function l9#echoHl(hl, msg, prefix, addingHistory)
|
||||
let echoCmd = (a:addingHistory ? 'echomsg' : 'echo')
|
||||
execute "echohl " . a:hl
|
||||
try
|
||||
for l in (type(a:msg) == type([]) ? a:msg : split(a:msg, "\n"))
|
||||
execute echoCmd . ' a:prefix . l'
|
||||
endfor
|
||||
finally
|
||||
echohl None
|
||||
endtry
|
||||
endfunction
|
||||
|
||||
" input() with highlighting.
|
||||
" This function can take list as {completion} argument.
|
||||
function l9#inputHl(hl, ...)
|
||||
execute "echohl " . a:hl
|
||||
try
|
||||
let args = copy(a:000)
|
||||
if len(args) > 2 && type(args[2]) == type([])
|
||||
let s:candidatesForInputHl = args[2]
|
||||
let args[2] = 'custom,l9#completeForInputHl'
|
||||
endif
|
||||
let s = call('input', args)
|
||||
unlet! s:candidatesForInputHl
|
||||
finally
|
||||
echohl None
|
||||
endtry
|
||||
redraw " needed to show following echo to next line.
|
||||
return s
|
||||
endfunction
|
||||
|
||||
" only called by l9#inputHl() for completion.
|
||||
function l9#completeForInputHl(lead, line, pos)
|
||||
return join(s:candidatesForInputHl, "\n")
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" VISUAL MODE {{{1
|
||||
|
||||
" returns last selected text in Visual mode.
|
||||
function l9#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
|
||||
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" EVAL {{{1
|
||||
|
||||
" loads given text as Vim script with :source command
|
||||
function l9#loadScript(text)
|
||||
let lines = (type(a:text) == type([]) ? a:text : split(a:text, "\n"))
|
||||
let fname = tempname()
|
||||
call writefile(lines, fname)
|
||||
source `=fname`
|
||||
call delete(fname)
|
||||
endfunction
|
||||
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" VARIABLES {{{1
|
||||
|
||||
"
|
||||
function l9#defineVariableDefault(name, default)
|
||||
if !exists(a:name)
|
||||
let {a:name} = a:default
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GREP {{{1
|
||||
|
||||
" Execute :vimgrep and opens the quickfix window if matches are found.
|
||||
"
|
||||
" a:pattern: search pattern. If ommitted, last search pattern (@/) is used.
|
||||
" a:files: List of files
|
||||
function l9#grepFiles(pattern, files)
|
||||
let target = join(map(a:files, 'escape(v:val, " ")'), ' ')
|
||||
let pattern = (a:pattern[0] ==# '/' ? a:pattern[1:] : a:pattern)
|
||||
let pattern = (empty(pattern) ? @/ : pattern)
|
||||
try
|
||||
execute printf('vimgrep/%s/j %s', pattern, target)
|
||||
catch /^Vim/
|
||||
call setqflist([])
|
||||
endtry
|
||||
call l9#quickfix#sort()
|
||||
call l9#quickfix#openIfNotEmpty(1, 0)
|
||||
endfunction
|
||||
|
||||
" Execute :vimgrep for buffers using l9#grepFiles()
|
||||
" See also: :L9GrepBuffer :L9GrepBufferAll
|
||||
function l9#grepBuffers(pattern, bufNrs)
|
||||
let files = map(filter(a:bufNrs, 'bufloaded(v:val)'), 'bufname(v:val)')
|
||||
call l9#grepFiles(a:pattern, files)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" SIGN {{{1
|
||||
|
||||
" Highlights lines using :sign define and :sign place.
|
||||
"
|
||||
" a:linehl, a:text, a:texthl: See |signs|. Ignored if empty string.
|
||||
" a:locations: List of [{buffer number}, {line number}] for highlighting
|
||||
function l9#placeSign(linehl, text, texthl, locations)
|
||||
let argLinehl = (empty(a:linehl) ? '' : 'linehl=' . a:linehl)
|
||||
let argText = (empty(a:text) ? '' : 'text=' . a:text)
|
||||
let argTexthl = (empty(a:texthl) ? '' : 'texthl=' . a:texthl)
|
||||
let name = 'l9--' . a:linehl . '--' . a:text . '--' . a:texthl
|
||||
execute printf('sign define %s linehl=%s text=%s texthl=%s',
|
||||
\ name, a:linehl, a:text, a:texthl)
|
||||
for [bufNr, lnum] in a:locations
|
||||
execute printf('sign place 1 line=%d name=%s buffer=%d', lnum, name, bufNr)
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" NOTIFY EXTERNALLY {{{1
|
||||
|
||||
" Notify a message using an external program.
|
||||
" Currently supports Balloonly, Screen, and Tmux.
|
||||
function l9#notifyExternally(msg)
|
||||
return l9#notifyBalloonly(a:msg)
|
||||
\ || l9#notifyScreen(a:msg)
|
||||
\ || l9#notifyTmux(a:msg)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#notifyBalloonly(msg)
|
||||
if !(has('win32') || has('win64')) || !executable(g:l9_balloonly)
|
||||
return 0
|
||||
endif
|
||||
execute 'silent !start ' . shellescape(g:l9_balloonly) . ' 4000 "l9" ' . shellescape(a:msg)
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#notifyScreen(msg)
|
||||
if !has('unix') || has('gui_running') || $WINDOW !~ '\d' || !executable('screen')
|
||||
return 0
|
||||
endif
|
||||
call system('screen -X wall ' . shellescape('l9: ' . a:msg))
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#notifyTmux(msg)
|
||||
if !has('unix') || has('gui_running') || empty($TMUX) || !executable('tmux')
|
||||
return 0
|
||||
endif
|
||||
call system('tmux display-message ' . shellescape('l9: ' . a:msg))
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
@@ -1,92 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
from __future__ import with_statement
|
||||
import vim
|
||||
import os
|
||||
import subprocess
|
||||
import threading
|
||||
import Queue
|
||||
|
||||
|
||||
class Asyncer:
|
||||
|
||||
def __init__(self):
|
||||
self._workers = {}
|
||||
|
||||
def execute(self, var_key, var_command, var_cwd, var_input, var_appends):
|
||||
key = vim.eval(var_key)
|
||||
command = vim.eval(var_command)
|
||||
cwd = vim.eval(var_cwd)
|
||||
input = vim.eval(var_input)
|
||||
appends = vim.eval(var_appends)
|
||||
if key not in self._workers:
|
||||
self._workers[key] = Worker()
|
||||
self._workers[key].start()
|
||||
self._workers[key].put(Executor(command, cwd, input, appends))
|
||||
|
||||
def print_output(self, var_key):
|
||||
key = vim.eval(var_key)
|
||||
if key not in self._workers:
|
||||
return
|
||||
for l in self._workers[key].copy_outputs():
|
||||
print l,
|
||||
|
||||
def print_worker_keys(self):
|
||||
for k in self._workers.keys():
|
||||
print k
|
||||
|
||||
def print_active_worker_keys(self):
|
||||
for k in self._workers.keys():
|
||||
print k
|
||||
|
||||
|
||||
class Worker(threading.Thread):
|
||||
|
||||
def __init__(self):
|
||||
threading.Thread.__init__(self)
|
||||
self._queue = Queue.Queue()
|
||||
self._lines = []
|
||||
self._lock = threading.Lock()
|
||||
|
||||
def run(self):
|
||||
while True:
|
||||
self._queue.get().execute(self)
|
||||
self._queue.task_done()
|
||||
|
||||
def put(self, executor):
|
||||
self._queue.put(executor)
|
||||
|
||||
def clear_outputs(self):
|
||||
with self._lock:
|
||||
self._lines = []
|
||||
|
||||
def record_output(self, line):
|
||||
with self._lock:
|
||||
self._lines.append(line)
|
||||
|
||||
def copy_outputs(self):
|
||||
with self._lock:
|
||||
return self._lines[:]
|
||||
|
||||
|
||||
class Executor:
|
||||
|
||||
def __init__(self, command, cwd, input, appends):
|
||||
self._command = command
|
||||
self._cwd = cwd
|
||||
self._input = input
|
||||
self._appends = appends
|
||||
|
||||
def execute(self, worker):
|
||||
if not self._appends:
|
||||
worker.clear_outputs()
|
||||
os.chdir(self._cwd)
|
||||
p = subprocess.Popen(self._command, shell=True, stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
p.stdin.write(self._input)
|
||||
line = p.stdout.readline()
|
||||
while line:
|
||||
worker.record_output(line)
|
||||
line = p.stdout.readline()
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (C) 2009-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, ['has("python")'])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" ASYNC EXECUTE {{{1
|
||||
|
||||
"
|
||||
function s:checkKey(key)
|
||||
if a:key =~ '\n' || a:key !~ '\S'
|
||||
throw "Asyncer: Invalid key: " . a:key
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#async#execute(key, cmd, cwd, input, appends)
|
||||
call s:checkKey(a:key)
|
||||
python asyncer.execute('a:key', 'a:cmd', 'a:cwd', 'a:input', 'a:appends')
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#async#read(key)
|
||||
call s:checkKey(a:key)
|
||||
redir => result
|
||||
silent python asyncer.print_output('a:key')
|
||||
redir END
|
||||
" NOTE: "\n" is somehow inserted by redir.
|
||||
return (result[0] ==# "\n" ? result[1:] : result)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#async#listWorkers()
|
||||
redir => result
|
||||
silent python asyncer.print_worker_keys()
|
||||
redir END
|
||||
return split(result, "\n")
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#async#listActiveWorkers()
|
||||
redir => result
|
||||
silent python asyncer.print_active_worker_keys()
|
||||
redir END
|
||||
return split(result, "\n")
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" INITIALIZATION {{{1
|
||||
|
||||
let s:ASYNC_PY_PATH = fnamemodify(expand('<sfile>:p:h'), ':p') . 'async.py'
|
||||
|
||||
pyfile `=s:ASYNC_PY_PATH`
|
||||
python asyncer = Asyncer()
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (C) 2009-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" QUICKFIX {{{1
|
||||
|
||||
" Returns non-zero if quickfix window is opened.
|
||||
function l9#quickfix#isWindowOpened()
|
||||
return count(map(range(1, winnr('$')), 'getwinvar(v:val, "&buftype")'), 'quickfix') > 0
|
||||
endfunction
|
||||
|
||||
" Opens quickfix window if quickfix is not empty, and echo the number of errors.
|
||||
"
|
||||
" a:onlyRecognized: if non-zero, opens only if quickfix has recognized errors.
|
||||
" a:holdCursor: if non-zero, the cursor won't move to quickfix window.
|
||||
function l9#quickfix#openIfNotEmpty(onlyRecognized, holdCursor)
|
||||
let numErrors = len(filter(getqflist(), 'v:val.valid'))
|
||||
let numOthers = len(getqflist()) - numErrors
|
||||
if numErrors > 0 || (!a:onlyRecognized && numOthers > 0)
|
||||
copen
|
||||
if a:holdCursor
|
||||
wincmd p
|
||||
endif
|
||||
else
|
||||
cclose
|
||||
endif
|
||||
redraw
|
||||
if numOthers > 0
|
||||
echo printf('Quickfix: %d(+%d)', numErrors, numOthers)
|
||||
else
|
||||
echo printf('Quickfix: %d', numErrors)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Toggles Quickfix window
|
||||
function l9#quickfix#toggleWindow()
|
||||
if l9#quickfix#isWindowOpened()
|
||||
cclose
|
||||
else
|
||||
call l9#quickfix#openIfNotEmpty(0, 0)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" Creates quickfix list form given lines and opens the quickfix window if
|
||||
" errors exists.
|
||||
"
|
||||
" a:lines:
|
||||
" a:jump: if non-zero, jump to the first error.
|
||||
function l9#quickfix#setMakeResult(lines)
|
||||
cexpr a:lines
|
||||
call l9#quickfix#openIfNotEmpty(0, 1)
|
||||
endfunction
|
||||
|
||||
" Compares quickfix entries for sorting.
|
||||
function l9#quickfix#compareEntries(e0, e1)
|
||||
if a:e0.bufnr != a:e1.bufnr
|
||||
let i0 = bufname(a:e0.bufnr)
|
||||
let i1 = bufname(a:e1.bufnr)
|
||||
elseif a:e0.lnum != a:e1.lnum
|
||||
let i0 = a:e0.lnum
|
||||
let i1 = a:e1.lnum
|
||||
elseif a:e0.col != a:e1.col
|
||||
let i0 = a:e0.col
|
||||
let i1 = a:e1.col
|
||||
else
|
||||
return 0
|
||||
endif
|
||||
return (i0 > i1 ? +1 : -1)
|
||||
endfunction
|
||||
|
||||
" Sorts quickfix
|
||||
function l9#quickfix#sort()
|
||||
call setqflist(sort(getqflist(), 'l9#quickfix#compareEntries'), 'r')
|
||||
endfunction
|
||||
|
||||
" Highlights Quickfix lines by :sign.
|
||||
" Inspired by errormarker plugin.
|
||||
"
|
||||
" You can customize the highlighting via L9ErrorLine and L9WarningLine
|
||||
" highlight groups.
|
||||
function l9#quickfix#placeSign()
|
||||
let warnings = []
|
||||
let errors = []
|
||||
for e in filter(getqflist(), 'v:val.valid')
|
||||
let warning = (e.type ==? 'w' || e.text =~? '^\s*warning:')
|
||||
call add((warning ? warnings : errors), [e.bufnr, e.lnum])
|
||||
endfor
|
||||
sign unplace *
|
||||
call l9#placeSign('L9WarningLine', '>>', '', warnings)
|
||||
call l9#placeSign('L9ErrorLine', '>>', '', errors)
|
||||
endfunction
|
||||
|
||||
highlight default L9ErrorLine ctermfg=white ctermbg=52 guibg=#5F0000
|
||||
highlight default L9WarningLine ctermfg=white ctermbg=17 guibg=#00005F
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (C) 2009-2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" TEMPORARY BUFFER {{{1
|
||||
|
||||
" each key is a buffer name.
|
||||
let s:dataMap = {}
|
||||
|
||||
"
|
||||
function s:onBufDelete(bufname)
|
||||
if exists('s:dataMap[a:bufname].listener.onClose')
|
||||
call s:dataMap[a:bufname].listener.onClose(s:dataMap[a:bufname].written)
|
||||
endif
|
||||
if bufnr('%') == s:dataMap[a:bufname].bufNr && winnr('#') != 0
|
||||
" if winnr('#') returns 0, "wincmd p" causes ringing the bell.
|
||||
wincmd p
|
||||
endif
|
||||
endfunction
|
||||
|
||||
"
|
||||
function s:onBufWriteCmd(bufname)
|
||||
if !exists('s:dataMap[a:bufname].listener.onWrite') ||
|
||||
\ s:dataMap[a:bufname].listener.onWrite(getline(1, '$'))
|
||||
setlocal nomodified
|
||||
let s:dataMap[a:bufname].written = 1
|
||||
call l9#tempbuffer#close(a:bufname)
|
||||
else
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" a:bufname:
|
||||
" a:height: Window height. If 0, default height is used.
|
||||
" If less than 0, the window becomes full-screen.
|
||||
" a:listener:
|
||||
" a:listener.onClose(written)
|
||||
function l9#tempbuffer#openScratch(bufname, filetype, lines, topleft, vertical, height, listener)
|
||||
let openCmdPrefix = (a:topleft ? 'topleft ' : '')
|
||||
\ . (a:vertical ? 'vertical ' : '')
|
||||
\ . (a:height > 0 ? a:height : '')
|
||||
if !exists('s:dataMap[a:bufname]') || !bufexists(s:dataMap[a:bufname].bufNr)
|
||||
execute openCmdPrefix . 'new'
|
||||
else
|
||||
call l9#tempbuffer#close(a:bufname)
|
||||
execute openCmdPrefix . 'split'
|
||||
execute 'silent ' . s:dataMap[a:bufname].bufNr . 'buffer'
|
||||
endif
|
||||
if a:height < 0
|
||||
only
|
||||
endif
|
||||
setlocal buflisted noswapfile bufhidden=delete modifiable noreadonly buftype=nofile
|
||||
let &l:filetype = a:filetype
|
||||
silent file `=a:bufname`
|
||||
call setline(1, a:lines)
|
||||
setlocal nomodified
|
||||
augroup L9TempBuffer
|
||||
autocmd! * <buffer>
|
||||
execute printf('autocmd BufDelete <buffer> call s:onBufDelete (%s)', string(a:bufname))
|
||||
execute printf('autocmd BufWriteCmd <buffer> nested call s:onBufWriteCmd(%s)', string(a:bufname))
|
||||
augroup END
|
||||
let s:dataMap[a:bufname] = {
|
||||
\ 'bufNr': bufnr('%'),
|
||||
\ 'written': 0,
|
||||
\ 'listener': a:listener,
|
||||
\ }
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#tempbuffer#openReadOnly(bufname, filetype, lines, topleft, vertical, height, listener)
|
||||
call l9#tempbuffer#openScratch(a:bufname, a:filetype, a:lines, a:topleft, a:vertical, a:height, a:listener)
|
||||
setlocal nomodifiable readonly
|
||||
endfunction
|
||||
|
||||
" a:listener:
|
||||
" a:listener.onClose(written)
|
||||
" a:listener.onWrite(lines)
|
||||
function l9#tempbuffer#openWritable(bufname, filetype, lines, topleft, vertical, height, listener)
|
||||
call l9#tempbuffer#openScratch(a:bufname, a:filetype, a:lines, a:topleft, a:vertical, a:height, a:listener)
|
||||
setlocal buftype=acwrite
|
||||
endfunction
|
||||
|
||||
" makes specified temp buffer current.
|
||||
function l9#tempbuffer#moveTo(bufname)
|
||||
return l9#moveToBufferWindowInCurrentTabpage(s:dataMap[a:bufname].bufNr) ||
|
||||
\ l9#moveToBufferWindowInOtherTabpage(s:dataMap[a:bufname].bufNr)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#tempbuffer#close(bufname)
|
||||
if !l9#tempbuffer#isOpen(a:bufname)
|
||||
return
|
||||
endif
|
||||
execute printf('%dbdelete!', s:dataMap[a:bufname].bufNr)
|
||||
endfunction
|
||||
|
||||
"
|
||||
function l9#tempbuffer#isOpen(bufname)
|
||||
return exists('s:dataMap[a:bufname]') && bufloaded(s:dataMap[a:bufname].bufNr)
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (C) 2010 Takeshi NISHIDA
|
||||
"
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" TEMPORARY VARIABLES {{{1
|
||||
|
||||
"
|
||||
let s:origMap = {}
|
||||
|
||||
" set temporary variables
|
||||
function l9#tempvariables#set(group, name, value)
|
||||
if !exists('s:origMap[a:group]')
|
||||
let s:origMap[a:group] = {}
|
||||
endif
|
||||
if !exists('s:origMap[a:group][a:name]')
|
||||
let s:origMap[a:group][a:name] = eval(a:name)
|
||||
endif
|
||||
execute 'let ' . a:name . ' = a:value'
|
||||
endfunction
|
||||
|
||||
" set temporary variables
|
||||
function l9#tempvariables#setList(group, variables)
|
||||
for [name, value] in a:variables
|
||||
call l9#tempvariables#set(a:group, name, value)
|
||||
unlet value " to avoid E706
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
" get temporary variables
|
||||
function l9#tempvariables#getList(group)
|
||||
if !exists('s:origMap[a:group]')
|
||||
return []
|
||||
endif
|
||||
return map(keys(s:origMap[a:group]), '[v:val, eval(v:val)]')
|
||||
endfunction
|
||||
|
||||
" restore original variables and clean up.
|
||||
function l9#tempvariables#end(group)
|
||||
if !exists('s:origMap[a:group]')
|
||||
return
|
||||
endif
|
||||
for [name, value] in items(s:origMap[a:group])
|
||||
execute 'let ' . name . ' = value'
|
||||
unlet value " to avoid E706
|
||||
endfor
|
||||
unlet s:origMap[a:group]
|
||||
endfunction
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
*l9.txt* Vim-script library
|
||||
|
||||
Copyright (c) 2009-2010 Takeshi NISHIDA
|
||||
|
||||
l9 *l9*
|
||||
|
||||
INTRODUCTION |l9-introduction|
|
||||
INSTALLATION |l9-installation|
|
||||
USAGE |l9-usage|
|
||||
CHANGELOG |l9-changelog|
|
||||
ABOUT |l9-about|
|
||||
|
||||
==============================================================================
|
||||
INTRODUCTION *l9-introduction*
|
||||
|
||||
l9 is a Vim-script library, which provides some utility functions and commands
|
||||
for programming in Vim.
|
||||
|
||||
==============================================================================
|
||||
INSTALLATION *l9-installation*
|
||||
|
||||
Put all files into your runtime directory. If you have the zip file, extract
|
||||
it to your runtime directory.
|
||||
|
||||
You should place the files as follows:
|
||||
>
|
||||
<your runtime directory>/plugin/l9.vim
|
||||
<your runtime directory>/doc/l9.txt
|
||||
...
|
||||
<
|
||||
If you are disgusted to make your runtime directory confused with a lot of
|
||||
plugins, put each of the plugins into a directory individually and just add
|
||||
the directory path to 'runtimepath'. It's easy to uninstall the plugin.
|
||||
|
||||
Then update your help tags files to enable fuzzyfinder help. See
|
||||
|add-local-help| for details.
|
||||
|
||||
==============================================================================
|
||||
USAGE *l9-usage*
|
||||
|
||||
See source code.
|
||||
|
||||
==============================================================================
|
||||
CHANGELOG *l9-changelog*
|
||||
|
||||
1.1:
|
||||
- Added l9#zip()
|
||||
- Added l9#tempvariables#getList()
|
||||
- Changed l9#guardScriptLoading()
|
||||
- Removed l9#tempvariables#swap()
|
||||
|
||||
1.0.1:
|
||||
- Fixed a bug that floating point numbers weren't evaluated correctly and
|
||||
caused errors on some non-English locales.
|
||||
|
||||
1.0:
|
||||
- First release.
|
||||
|
||||
|
||||
==============================================================================
|
||||
ABOUT *l9-about* *l9-contact* *l9-author*
|
||||
|
||||
Author: Takeshi NISHIDA <ns9tks@DELETE-ME.gmail.com>
|
||||
Licence: MIT Licence
|
||||
URL: http://www.vim.org/scripts/script.php?script_id=3252
|
||||
http://bitbucket.org/ns9tks/vim-l9/
|
||||
|
||||
Bugs/Issues/Suggestions/Improvements ~
|
||||
|
||||
Please submit to http://bitbucket.org/ns9tks/vim-l9/issues/ .
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
||||
@@ -1,108 +0,0 @@
|
||||
"=============================================================================
|
||||
" Copyright (C) 2009-2010 Takeshi NISHIDA
|
||||
"
|
||||
" GetLatestVimScripts: 3252 1 :AutoInstall: L9
|
||||
"=============================================================================
|
||||
" LOAD GUARD {{{1
|
||||
|
||||
if !l9#guardScriptLoading(expand('<sfile>:p'), 702, 0, [])
|
||||
finish
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" OPTIONS: {{{1
|
||||
|
||||
call l9#defineVariableDefault('g:l9_balloonly', 'balloonly.exe')
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" ASSERTION: {{{1
|
||||
|
||||
" This command has effect only if $L9_DEBUG is non-zero.
|
||||
" Used as follows:
|
||||
" L9Assert a:i > 0
|
||||
" This command can't interpret script-local variables directly.
|
||||
" NG: L9Assert s:a == 1
|
||||
" OK: execute 'L9Assert ' . s:a . ' == 1'
|
||||
"
|
||||
if $L9_DEBUG
|
||||
command -nargs=* L9Assert call eval((<args>) ? 0 : s:handleFailedAssersion(<q-args>))
|
||||
|
||||
function s:handleFailedAssersion(expr)
|
||||
echoerr '[L9Assert] Assersion failure: ' . a:expr
|
||||
if input('[L9Assert] Continue? (Y/N) ', 'Y') !=? 'Y'
|
||||
throw 'L9Assert ' . a:expr
|
||||
endif
|
||||
endfunction
|
||||
|
||||
else
|
||||
command -nargs=* L9Assert :
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" TIMER: {{{1
|
||||
|
||||
" These commands have effect only if $L9_TIMER is non-zero.
|
||||
" Used as follows:
|
||||
" L9Timer foo
|
||||
" ... (1)
|
||||
" L9Timer bar
|
||||
" ... (2)
|
||||
" L9TimerStop
|
||||
" ...
|
||||
" L9TimerDump <- shows each elapsed time of (1) and (2)
|
||||
"
|
||||
if $L9_TIMER
|
||||
command -nargs=1 L9Timer call s:timerBegin(<q-args>)
|
||||
command -nargs=0 L9TimerStop call s:timerStop()
|
||||
command -nargs=0 L9TimerDump call s:timerDump()
|
||||
|
||||
let s:timerData = []
|
||||
let s:timerTagMaxLen = 0
|
||||
|
||||
function s:timerBegin(tag)
|
||||
L9TimerStop
|
||||
let s:timerCurrent = {'tag': strftime('%c ') . a:tag . ' ', 'time': reltime()}
|
||||
let s:timerTagMaxLen = max([len(s:timerCurrent.tag), s:timerTagMaxLen])
|
||||
endfunction
|
||||
|
||||
function s:timerStop()
|
||||
if !exists('s:timerCurrent')
|
||||
return
|
||||
endif
|
||||
let s:timerCurrent.time = reltimestr(reltime(s:timerCurrent.time))
|
||||
call add(s:timerData, s:timerCurrent)
|
||||
unlet s:timerCurrent
|
||||
endfunction
|
||||
|
||||
function s:timerDump()
|
||||
L9TimerStop
|
||||
let lines = map(s:timerData, 'v:val.tag . repeat(" ", s:timerTagMaxLen - len(v:val.tag)) . v:val.time')
|
||||
call l9#tempbuffer#openReadOnly('[l9-timer]', '', lines, 0, 0, 0, {})
|
||||
let s:timerData = []
|
||||
let s:timerTagMaxLen = 0
|
||||
endfunction
|
||||
|
||||
else
|
||||
command -nargs=1 L9Timer :
|
||||
command -nargs=0 L9TimerStop :
|
||||
command -nargs=0 L9TimerDump :
|
||||
endif
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" GREP BUFFER: {{{1
|
||||
|
||||
" Grep for current buffer by l9#grepBuffers()
|
||||
" Used as :L9GrepBuffer/pattern
|
||||
command -nargs=? L9GrepBuffer call l9#grepBuffers(<q-args>, [bufnr('%')])
|
||||
|
||||
" Grep for all buffers by l9#grepBuffers()
|
||||
" Used as :L9GrepBufferAll/pattern
|
||||
command -nargs=? L9GrepBufferAll call l9#grepBuffers(<q-args>, range(1, bufnr('$')))
|
||||
|
||||
" }}}1
|
||||
"=============================================================================
|
||||
" vim: set fdm=marker:
|
||||
Reference in New Issue
Block a user