Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

a whole lot of things emacs and vim related

  • Loading branch information...
commit 276c4fe729f368eea1199197b3055f94af478a2d 1 parent 491ee1f
@dakrone authored
Showing with 2,110 additions and 1,164 deletions.
  1. +1 −0  .clojure/user.clj
  2. +31 −18 .emacs.d/init.el
  3. +1 −1  .irbrc
  4. +2 −1  .vim/.VimballRecord
  5. +314 −423 .vim/autoload/fuf.vim
  6. +25 −12 .vim/autoload/fuf/buffer.vim
  7. +12 −8 .vim/autoload/fuf/callbackfile.vim
  8. +11 −7 .vim/autoload/fuf/callbackitem.vim
  9. +11 −7 .vim/autoload/fuf/changelist.vim
  10. +15 −11 .vim/autoload/fuf/dir.vim
  11. +18 −16 .vim/autoload/fuf/file.vim
  12. +10 −6 .vim/autoload/fuf/givencmd.vim
  13. +10 −6 .vim/autoload/fuf/givendir.vim
  14. +9 −5 .vim/autoload/fuf/givenfile.vim
  15. +24 −28 .vim/autoload/fuf/help.vim
  16. +11 −7 .vim/autoload/fuf/jumplist.vim
  17. +11 −7 .vim/autoload/fuf/line.vim
  18. +16 −12 .vim/autoload/fuf/mrucmd.vim
  19. +98 −20 .vim/autoload/fuf/mrufile.vim
  20. +11 −7 .vim/autoload/fuf/quickfix.vim
  21. +22 −26 .vim/autoload/fuf/tag.vim
  22. +26 −29 .vim/autoload/fuf/taggedfile.vim
  23. +8 −4 .vim/autoload/xolox.vim
  24. +1 −1  .vim/doc/easytags.txt
  25. +393 −137 .vim/doc/fuf.jax
  26. +468 −147 .vim/doc/fuf.txt
  27. +43 −0 .vim/doc/supertab.txt
  28. +54 −17 .vim/doc/tags
  29. +43 −16 .vim/doc/tags-ja
  30. +40 −0 .vim/doc/twitvim.txt
  31. +125 −144 .vim/plugin/fuf.vim
  32. +3 −3 .vim/plugin/gist.vim
  33. +119 −16 .vim/plugin/supertab.vim
  34. +122 −22 .vim/plugin/twitvim.vim
  35. +2 −0  .zshrc
View
1  .clojure/user.clj
@@ -2,6 +2,7 @@
(use 'clojure.stacktrace)
(require '[clj-stacktrace.repl :as stacktrace])
+;(use 'cd-client.core)
; Use pprint, depending on what version of Clojure I'm in
(if (< (:minor *clojure-version*) 2)
View
49 .emacs.d/init.el
@@ -42,7 +42,7 @@
;; TODELETE: (require 'project-buffer-mode)
;; Command-enter -> fullscreen
-(global-set-key (kbd "M-RET") 'ns-toggle-fullscreen)
+(global-set-key (kbd "M-S-RET") 'ns-toggle-fullscreen)
; Dim parens
@@ -87,6 +87,18 @@
(match-end 1) "ƒ")
nil))))))
+;; use spaces instead of smart tabs for clojure-mode
+(eval-after-load 'clojure-mode '(setq-default indent-tabs-mode nil))
+
+;; Lazytest indention in clojure
+(eval-after-load 'clojure-mode
+ '(define-clojure-indent
+ (describe 'defun)
+ (testing 'defun)
+ (given 'defun)
+ (it 'defun)
+ (do-it 'defun)))
+
; This code makes % act like the buffer name, similar to Vim
(define-key minibuffer-local-map "%"
(function
@@ -351,7 +363,7 @@
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
-(setq journal-root-dir "/Users/zkim/Dropbox/org/")
+(setq journal-root-dir "/Users/hinmanm/Dropbox/org/")
(defun today-file-name () (concat journal-root-dir (format-time-string "%Y-%m-%d") ".org"))
(defun today-org ()
@@ -494,20 +506,20 @@
(require 'yaml-mode)
-(load-file "~/.emacs.d/plugins/cedet/common/cedet.el")
-(global-ede-mode t)
-(semantic-load-enable-minimum-features)
-(require 'semantic-ia)
+;(load-file "~/.emacs.d/plugins/cedet/common/cedet.el")
+;(global-ede-mode t)
+;(semantic-load-enable-minimum-features)
+;(require 'semantic-ia)
-(add-to-list 'load-path "~/.emacs.d/plugins/ecb240")
-(require 'ecb)
-(require 'ecb-autoloads)
-(setq ecb-tip-of-the-day nil)
+;(add-to-list 'load-path "~/.emacs.d/plugins/ecb240")
+;(require 'ecb)
+;(require 'ecb-autoloads)
+;(setq ecb-tip-of-the-day nil)
;(ecb-activate)
(setq inhibit-startup-screen t)
-(today-org)
-(setq initial-buffer-choice (today-file-name))
+;(today-org)
+;(setq initial-buffer-choice (today-file-name))
(custom-set-variables
;; custom-set-variables was added by Custom.
@@ -515,7 +527,8 @@
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(ecb-layout-window-sizes (quote (("left8" (0.24203821656050956 . 0.2857142857142857) (0.24203821656050956 . 0.22448979591836735) (0.24203821656050956 . 0.2857142857142857) (0.24203821656050956 . 0.1836734693877551)))))
- '(ecb-options-version "2.40"))
+ '(ecb-options-version "2.40")
+ '(org-agenda-files (quote ("~/Dropbox/org/2010-10-07.org"))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
@@ -546,8 +559,8 @@
(load-file "~/.emacs.d/.keys")
; Viper-mode
-(require 'viper)
-(setq viper-mode t)
-(setq viper-always t)
-(add-hook 'fundamental-mode-hook '(lambda () (viper-mode t)))
-(add-to-list 'viper-vi-state-mode-list 'help-mode)
+;(require 'viper)
+;(setq viper-mode t)
+;(setq viper-always t)
+;(add-hook 'fundamental-mode-hook '(lambda () (viper-mode t)))
+;(add-to-list 'viper-vi-state-mode-list 'help-mode)
View
2  .irbrc
@@ -9,4 +9,4 @@ end
MyIRB.start
# Enable purdy hirb output for ActiveRecord things
-Hirb::View.enable if rails?
+#Hirb::View.enable if rails?
View
3  .vim/.VimballRecord
@@ -10,7 +10,6 @@ rainbow.vba: call delete('/Users/hinmanm/.vim/after/syntax/c/rainbow.vim')
ctk(2).vba: call delete('/Users/hinmanm/.vim/plugin/ctk.vim')|call delete('/Users/hinmanm/.vim/doc/ctk.txt')|call delete('/Users/hinmanm/.vim/.compiler_info')
vimwiki_0_9_4.vba: call delete('/Users/hinmanm/.vim/autoload/vimwiki.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_lst.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_html.vim')|call delete('/Users/hinmanm/.vim/doc/vimwiki.txt')|call delete('/Users/hinmanm/.vim/ftplugin/vimwiki.vim')|call delete('/Users/hinmanm/.vim/indent/vimwiki.vim')|call delete('/Users/hinmanm/.vim/plugin/vimwiki.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki_default.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki_media.vim')
vimwiki_0_9_6.vba: call delete('/Users/hinmanm/.vim/syntax/vimwiki.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki_default.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki_media.vim')|call delete('/Users/hinmanm/.vim/ftplugin/vimwiki.vim')|call delete('/Users/hinmanm/.vim/plugin/vimwiki.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_html.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_lst.vim')|call delete('/Users/hinmanm/.vim/doc/vimwiki.txt')
-supertab.vba: call delete('/Users/hinmanm/.vim/doc/supertab.txt')|call delete('/Users/hinmanm/.vim/plugin/supertab.vim')
vimwiki-0-9-801.vba: call delete('/Users/hinmanm/.vim/autoload/vimwiki.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_html.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_lst.vim')|call delete('/Users/hinmanm/.vim/doc/vimwiki.txt')|call delete('/Users/hinmanm/.vim/ftplugin/vimwiki.vim')|call delete('/Users/hinmanm/.vim/plugin/vimwiki.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki_default.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki_media.vim')
ctk.vba: call delete('/Users/hinmanm/.vim/.compiler_info')|call delete('/Users/hinmanm/.vim/plugin/ctk.vim')|call delete('/Users/hinmanm/.vim/doc/ctk.txt')
markdown-1.1.0.vba: call delete('/Users/hinmanm/.vim/ftdetect/markdown.vim')|call delete('/Users/hinmanm/.vim/snippets/markdown.snippets')|call delete('/Users/hinmanm/.vim/syntax/markdown.vim')
@@ -28,3 +27,5 @@ twitvim-0.5.5.vba: call delete('/Users/hinmanm/.vim/plugin/twitvim.vim')|call de
vimwiki-1-1.vba: call delete('/Users/hinmanm/.vim/autoload/vimwiki.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_diary.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_html.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_lst.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_tbl.vim')|call delete('/Users/hinmanm/.vim/doc/vimwiki.txt')|call delete('/Users/hinmanm/.vim/ftplugin/vimwiki.vim')|call delete('/Users/hinmanm/.vim/plugin/vimwiki.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki_default.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki_media.vim')
vimwiki-1-1-1.vba: call delete('/Users/hinmanm/.vim/autoload/vimwiki.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_diary.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_html.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_lst.vim')|call delete('/Users/hinmanm/.vim/autoload/vimwiki_tbl.vim')|call delete('/Users/hinmanm/.vim/doc/vimwiki.txt')|call delete('/Users/hinmanm/.vim/ftplugin/vimwiki.vim')|call delete('/Users/hinmanm/.vim/plugin/vimwiki.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki_default.vim')|call delete('/Users/hinmanm/.vim/syntax/vimwiki_media.vim')
command-t-0.8.1.vba: call delete('/Users/hinmanm/.vim/ruby/command-t/controller.rb')|call delete('/Users/hinmanm/.vim/ruby/command-t/extconf.rb')|call delete('/Users/hinmanm/.vim/ruby/command-t/finder.rb')|call delete('/Users/hinmanm/.vim/ruby/command-t/match_window.rb')|call delete('/Users/hinmanm/.vim/ruby/command-t/prompt.rb')|call delete('/Users/hinmanm/.vim/ruby/command-t/scanner.rb')|call delete('/Users/hinmanm/.vim/ruby/command-t/settings.rb')|call delete('/Users/hinmanm/.vim/ruby/command-t/stub.rb')|call delete('/Users/hinmanm/.vim/ruby/command-t/vim/screen.rb')|call delete('/Users/hinmanm/.vim/ruby/command-t/vim/window.rb')|call delete('/Users/hinmanm/.vim/ruby/command-t/vim.rb')|call delete('/Users/hinmanm/.vim/ruby/command-t/ext.c')|call delete('/Users/hinmanm/.vim/ruby/command-t/match.c')|call delete('/Users/hinmanm/.vim/ruby/command-t/matcher.c')|call delete('/Users/hinmanm/.vim/ruby/command-t/ext.h')|call delete('/Users/hinmanm/.vim/ruby/command-t/match.h')|call delete('/Users/hinmanm/.vim/ruby/command-t/matcher.h')|call delete('/Users/hinmanm/.vim/ruby/command-t/ruby_compat.h')|call delete('/Users/hinmanm/.vim/ruby/command-t/depend')|call delete('/Users/hinmanm/.vim/doc/command-t.txt')|call delete('/Users/hinmanm/.vim/plugin/command-t.vim')
+supertab.vba: call delete('/Users/hinmanm/.vim/doc/supertab.txt')|call delete('/Users/hinmanm/.vim/plugin/supertab.vim')
+twitvim-0.5.6.vba: call delete('/Users/hinmanm/.vim/plugin/twitvim.vim')|call delete('/Users/hinmanm/.vim/doc/twitvim.txt')
View
737 .vim/autoload/fuf.vim
@@ -1,72 +1,29 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf = 1
" }}}1
"=============================================================================
" GLOBAL FUNCTIONS {{{1
-
-function fuf#getPathSeparator()
- return (!&shellslash && (has('win32') || has('win64')) ? '\' : '/')
-endfunction
-
-" Removes duplicates
-" this function doesn't change list of argument.
-function fuf#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
-
-" [ [0], [1,2], [3] ] -> [ 0, 1, 2, 3 ]
-" this function doesn't change list of argument.
-function fuf#concat(items)
- let result = []
- for l in a:items
- let result += l
- endfor
- return result
-endfunction
-
-" filter() with the maximum number of items
-" this function doesn't change list of argument.
-function fuf#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
+" returns list of paths.
+" An argument for glob() is normalized in order to avoid a bug on Windows.
+function fuf#glob(expr)
+ " Substitutes "\", because on Windows, "**\" doesn't include ".\",
+ " but "**/" include "./". I don't know why.
+ return split(glob(substitute(a:expr, '\', '/', 'g')), "\n")
endfunction
"
function fuf#countModifiedFiles(files, time)
- return len(filter(copy(a:files), 'getftime(v:val) > a:time'))
+ return len(filter(copy(a:files), 'getftime(expand(v:val)) > a:time'))
endfunction
"
@@ -85,9 +42,11 @@ endfunction
"
function fuf#updateMruList(mrulist, newItem, maxItem, exclude)
let result = copy(a:mrulist)
- let result = filter(result,'v:val.word != a:newItem.word')
+ let result = filter(result,'v:val.word !=# a:newItem.word')
let result = insert(result, a:newItem)
- let result = filter(result, 'v:val.word !~ a:exclude')
+ if len(a:exclude)
+ let result = filter(result, 'v:val.word !~ a:exclude')
+ endif
return result[0 : a:maxItem - 1]
endfunction
@@ -109,26 +68,12 @@ endfunction
" "foo/.../bar/...hoge" -> "foo/.../bar/../../hoge"
function fuf#expandTailDotSequenceToParentDir(pattern)
return substitute(a:pattern, '^\(.*[/\\]\)\?\zs\.\(\.\+\)\ze[^/\\]*$',
- \ '\=repeat(".." . fuf#getPathSeparator(), len(submatch(2)))', '')
+ \ '\=repeat(".." . l9#getPathSeparator(), len(submatch(2)))', '')
endfunction
"
-function fuf#hash224(str)
- let a = 0x00000800 " shift 11 bit
- let b = 0x001fffff " extract 11 bit
- 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
-
-"
-function fuf#formatPrompt(prompt, partialMatching)
- let indicator = (a:partialMatching ? '!' : '')
+function fuf#formatPrompt(prompt, partialMatching, otherString)
+ let indicator = escape((a:partialMatching ? '!' : '') . a:otherString, '\')
return substitute(a:prompt, '[]', indicator, 'g')
endfunction
@@ -139,11 +84,7 @@ function fuf#getFileLines(file)
if !empty(lines)
return lines
endif
- try
- return readfile(expand(a:file))
- catch /.*/
- endtry
- return []
+ return l9#readFile(a:file)
endfunction
"
@@ -181,28 +122,23 @@ function fuf#makePreviewLinesForFile(file, count, maxHeight)
endfunction
"
-function fuf#echoWithHl(msg, hl)
- execute "echohl " . a:hl
- echo a:msg
- echohl None
+function fuf#echoWarning(msg)
+ call l9#echoHl('WarningMsg', a:msg, '[fuf] ', 1)
endfunction
"
-function fuf#inputHl(prompt, text, hl)
- execute "echohl " . a:hl
- let s = input(a:prompt, a:text)
- echohl None
- return s
+function fuf#echoError(msg)
+ call l9#echoHl('ErrorMsg', a:msg, '[fuf] ', 1)
endfunction
"
function fuf#openBuffer(bufNr, mode, reuse)
- if a:reuse && ((a:mode == s:OPEN_TYPE_SPLIT &&
- \ s:moveToWindowOfBufferInCurrentTabPage(a:bufNr)) ||
- \ (a:mode == s:OPEN_TYPE_VSPLIT &&
- \ s:moveToWindowOfBufferInCurrentTabPage(a:bufNr)) ||
- \ (a:mode == s:OPEN_TYPE_TAB &&
- \ s:moveToWindowOfBufferInOtherTabPage(a:bufNr)))
+ if a:reuse && ((a:mode ==# s:OPEN_TYPE_SPLIT &&
+ \ l9#moveToBufferWindowInCurrentTabpage(a:bufNr)) ||
+ \ (a:mode ==# s:OPEN_TYPE_VSPLIT &&
+ \ l9#moveToBufferWindowInCurrentTabpage(a:bufNr)) ||
+ \ (a:mode ==# s:OPEN_TYPE_TAB &&
+ \ l9#moveToBufferWindowInOtherTabpage(a:bufNr)))
return
endif
execute printf({
@@ -275,8 +211,8 @@ endfunction
"
function fuf#makePathItem(fname, menu, appendsDirSuffix)
let pathPair = fuf#splitPath(a:fname)
- let dirSuffix = (a:appendsDirSuffix && isdirectory(a:fname)
- \ ? fuf#getPathSeparator()
+ let dirSuffix = (a:appendsDirSuffix && isdirectory(expand(a:fname))
+ \ ? l9#getPathSeparator()
\ : '')
return {
\ 'word' : a:fname . dirSuffix,
@@ -303,49 +239,6 @@ function fuf#makeNonPathItem(word, menu)
endfunction
"
-function s:interpretPrimaryPatternForPathTail(pattern)
- let pattern = fuf#expandTailDotSequenceToParentDir(a:pattern)
- let pairL = fuf#splitPath(s:toLowerForIgnoringCase(pattern))
- return {
- \ 'primary' : pattern,
- \ 'primaryForRank': pairL.tail,
- \ 'matchingPairs' : [['v:val.wordForPrimaryTail', pairL.tail],],
- \ }
-endfunction
-
-"
-function s:interpretPrimaryPatternForPath(pattern)
- let pattern = fuf#expandTailDotSequenceToParentDir(a:pattern)
- let patternL = s:toLowerForIgnoringCase(pattern)
- let pairL = fuf#splitPath(patternL)
- if g:fuf_splitPathMatching
- let matches = [
- \ ['v:val.wordForPrimaryHead', pairL.head],
- \ ['v:val.wordForPrimaryTail', pairL.tail],
- \ ]
- else
- let matches = [
- \ ['v:val.wordForPrimaryHead . v:val.wordForPrimaryTail', patternL],
- \ ]
- endif
- return {
- \ 'primary' : pattern,
- \ 'primaryForRank': pairL.tail,
- \ 'matchingPairs' : matches,
- \ }
-endfunction
-
-"
-function s:interpretPrimaryPatternForNonPath(pattern)
- let patternL = s:toLowerForIgnoringCase(a:pattern)
- return {
- \ 'primary' : a:pattern,
- \ 'primaryForRank': patternL,
- \ 'matchingPairs' : [['v:val.wordForPrimary', patternL],],
- \ }
-endfunction
-
-"
function fuf#makePatternSet(patternBase, interpreter, partialMatching)
let MakeMatchingExpr = function(a:partialMatching
\ ? 's:makePartialMatchingExpr'
@@ -363,11 +256,7 @@ endfunction
"
function fuf#enumExpandedDirsEntries(dir, exclude)
- " Substitutes "\" because on Windows, "**\" doesn't include ".\",
- " but "**/" include "./". I don't know why.
- let dirNormalized = substitute(a:dir, '\', '/', 'g')
- let entries = split(glob(dirNormalized . "*" ), "\n") +
- \ split(glob(dirNormalized . ".*"), "\n")
+ let entries = fuf#glob(a:dir . '*') + fuf#glob(a:dir . '.*')
" removes "*/." and "*/.."
call filter(entries, 'v:val !~ ''\v(^|[/\\])\.\.?$''')
call map(entries, 'fuf#makePathItem(v:val, "", 1)')
@@ -394,45 +283,101 @@ function fuf#setAbbrWithFormattedWord(item, abbrIndex)
if a:abbrIndex
let a:item.abbr = printf('%4d: ', a:item.index) . a:item.abbr
endif
- let a:item.abbr = s:snipTail(a:item.abbr, g:fuf_maxMenuWidth - lenMenu, s:ABBR_SNIP_MASK)
+ let a:item.abbr = l9#snipTail(a:item.abbr, g:fuf_maxMenuWidth - lenMenu, s:ABBR_SNIP_MASK)
return a:item
endfunction
"
-function fuf#defineLaunchCommand(CmdName, modeName, prefixInitialPattern)
- execute printf('command! -bang -narg=? %s call fuf#launch(%s, %s . <q-args>, len(<q-bang>))',
- \ a:CmdName, string(a:modeName), a:prefixInitialPattern)
+function s:onCommandPre()
+ for m in filter(copy(fuf#getModeNames()), 'fuf#{v:val}#requiresOnCommandPre()')
+ call fuf#{m}#onCommandPre(getcmdtype() . getcmdline())
+ endfor
+ " lets last entry become the newest in the history
+ call histadd(getcmdtype(), getcmdline())
+ " this is not mapped again (:help recursive_mapping)
+ return "\<CR>"
+endfunction
+
+"
+let s:modeNames = []
+
+"
+function fuf#addMode(modeName)
+ if count(g:fuf_modesDisable, a:modeName) > 0
+ return
+ endif
+ call add(s:modeNames, a:modeName)
+ call fuf#{a:modeName}#renewCache()
+ call fuf#{a:modeName}#onInit()
+ if fuf#{a:modeName}#requiresOnCommandPre()
+ " cnoremap has a problem, which doesn't expand cabbrev.
+ cmap <silent> <expr> <CR> <SID>onCommandPre()
+ endif
+endfunction
+
+"
+function fuf#getModeNames()
+ return s:modeNames
+endfunction
+
+"
+function fuf#defineLaunchCommand(CmdName, modeName, prefixInitialPattern, tempVars)
+ if empty(a:tempVars)
+ let preCmd = ''
+ else
+ let preCmd = printf('call l9#tempvariables#setList(%s, %s) | ',
+ \ string(s:TEMP_VARIABLES_GROUP), string(a:tempVars))
+ endif
+ execute printf('command! -range -bang -narg=? %s %s call fuf#launch(%s, %s . <q-args>, len(<q-bang>))',
+ \ a:CmdName, preCmd, string(a:modeName), a:prefixInitialPattern)
endfunction
"
function fuf#defineKeyMappingInHandler(key, func)
- " hacks to be able to use feedkeys().
- execute printf(
- \ 'inoremap <buffer> <silent> %s <C-r>=fuf#getRunningHandler().%s ? "" : ""<CR>',
- \ a:key, a:func)
+ " hacks to be able to use feedkeys().
+ execute printf(
+ \ 'inoremap <buffer> <silent> %s <C-r>=fuf#getRunningHandler().%s ? "" : ""<CR>',
+ \ a:key, a:func)
+endfunction
+
+"
+let s:oneTimeVariables = []
+
+"
+function fuf#setOneTimeVariables(...)
+ let s:oneTimeVariables += a:000
endfunction
"
function fuf#launch(modeName, initialPattern, partialMatching)
if exists('s:runningHandler')
- call fuf#echoWithHl('FuzzyFinder is running.', 'WarningMsg')
+ call fuf#echoWarning('FuzzyFinder is running.')
endif
- if count(g:fuf_modes, a:modeName) == 0
+ if count(fuf#getModeNames(), a:modeName) == 0
echoerr 'This mode is not available: ' . a:modeName
return
endif
let s:runningHandler = fuf#{a:modeName}#createHandler(copy(s:handlerBase))
- let s:runningHandler.info = fuf#loadInfoFile(s:runningHandler.getModeName())
+ let s:runningHandler.stats = fuf#loadDataFile(s:runningHandler.getModeName(), 'stats')
let s:runningHandler.partialMatching = a:partialMatching
let s:runningHandler.bufNrPrev = bufnr('%')
let s:runningHandler.lastCol = -1
+ let s:runningHandler.windowRestoringCommand = winrestcmd()
call s:runningHandler.onModeEnterPre()
- call s:setTemporaryGlobalOption('completeopt', 'menuone')
- call s:setTemporaryGlobalOption('ignorecase', 0)
+ " NOTE: updatetime is set, because in Buffer-Tag mode on Vim 7.3 on Windows,
+ " Vim keeps from triggering CursorMovedI for updatetime after system() is
+ " called. I don't know why.
+ call fuf#setOneTimeVariables(
+ \ ['&completeopt', 'menuone'],
+ \ ['&ignorecase', 0],
+ \ ['&updatetime', 10],
+ \ )
if s:runningHandler.getPreviewHeight() > 0
- call s:setTemporaryGlobalOption(
- \ 'cmdheight', s:runningHandler.getPreviewHeight() + 1)
+ call fuf#setOneTimeVariables(
+ \ ['&cmdheight', s:runningHandler.getPreviewHeight() + 1])
endif
+ call l9#tempvariables#setList(s:TEMP_VARIABLES_GROUP, s:oneTimeVariables)
+ let s:oneTimeVariables = []
call s:activateFufBuffer()
augroup FufLocal
autocmd!
@@ -440,18 +385,19 @@ function fuf#launch(modeName, initialPattern, partialMatching)
autocmd InsertLeave <buffer> nested call s:runningHandler.onInsertLeave()
augroup END
for [key, func] in [
- \ [ g:fuf_keyOpen , 'onCr(' . s:OPEN_TYPE_CURRENT . ', 0)' ],
- \ [ g:fuf_keyOpenSplit , 'onCr(' . s:OPEN_TYPE_SPLIT . ', 0)' ],
- \ [ g:fuf_keyOpenVsplit , 'onCr(' . s:OPEN_TYPE_VSPLIT . ', 0)' ],
- \ [ g:fuf_keyOpenTabpage , 'onCr(' . s:OPEN_TYPE_TAB . ', 0)' ],
- \ [ '<BS>' , 'onBs()' ],
- \ [ '<C-h>' , 'onBs()' ],
- \ [ g:fuf_keyPreview , 'onPreviewBase()' ],
- \ [ g:fuf_keyNextMode , 'onSwitchMode(+1)' ],
- \ [ g:fuf_keyPrevMode , 'onSwitchMode(-1)' ],
- \ [ g:fuf_keySwitchMatching, 'onSwitchMatching()' ],
- \ [ g:fuf_keyPrevPattern , 'onRecallPattern(+1)' ],
- \ [ g:fuf_keyNextPattern , 'onRecallPattern(-1)' ],
+ \ [ g:fuf_keyOpen , 'onCr(' . s:OPEN_TYPE_CURRENT . ')' ],
+ \ [ g:fuf_keyOpenSplit , 'onCr(' . s:OPEN_TYPE_SPLIT . ')' ],
+ \ [ g:fuf_keyOpenVsplit , 'onCr(' . s:OPEN_TYPE_VSPLIT . ')' ],
+ \ [ g:fuf_keyOpenTabpage , 'onCr(' . s:OPEN_TYPE_TAB . ')' ],
+ \ [ '<BS>' , 'onBs()' ],
+ \ [ '<C-h>' , 'onBs()' ],
+ \ [ '<C-w>' , 'onDeleteWord()' ],
+ \ [ g:fuf_keyPreview , 'onPreviewBase(1)' ],
+ \ [ g:fuf_keyNextMode , 'onSwitchMode(+1)' ],
+ \ [ g:fuf_keyPrevMode , 'onSwitchMode(-1)' ],
+ \ [ g:fuf_keySwitchMatching, 'onSwitchMatching()' ],
+ \ [ g:fuf_keyPrevPattern , 'onRecallPattern(+1)' ],
+ \ [ g:fuf_keyNextPattern , 'onRecallPattern(-1)' ],
\ ]
call fuf#defineKeyMappingInHandler(key, func)
endfor
@@ -464,54 +410,72 @@ function fuf#launch(modeName, initialPattern, partialMatching)
endfunction
"
-function fuf#loadInfoFile(modeName)
- try
- let lines = readfile(expand(g:fuf_infoFile))
- " compatibility check
- if count(lines, s:INFO_FILE_VERSION_LINE) == 0
- call s:warnOldInfoFile()
- let g:fuf_infoFile = ''
- throw 1
- endif
- catch /.*/
- let lines = []
- endtry
- let s:lastInfoMap = s:deserializeInfoMap(lines)
- if !exists('s:lastInfoMap[a:modeName]')
- let s:lastInfoMap[a:modeName] = {}
+function fuf#loadDataFile(modeName, dataName)
+ if !s:dataFileAvailable
+ return []
endif
- return extend(s:lastInfoMap[a:modeName], { 'data': [], 'stats': [] }, 'keep')
+ let lines = l9#readFile(l9#concatPaths([g:fuf_dataDir, a:modeName, a:dataName]))
+ return map(lines, 'eval(v:val)')
endfunction
-" if a:modeName is empty, a:info is treated as a map of information
-function fuf#saveInfoFile(modeName, info)
- if empty(a:modeName)
- let s:lastInfoMap = a:info
- else
- let s:lastInfoMap[a:modeName] = a:info
+"
+function fuf#saveDataFile(modeName, dataName, items)
+ if !s:dataFileAvailable
+ return -1
endif
- let lines = [ s:INFO_FILE_VERSION_LINE ] + s:serializeInfoMap(s:lastInfoMap)
- try
- call writefile(lines, expand(g:fuf_infoFile))
- catch /.*/
- endtry
-endfunction
-
-"
-function fuf#editInfoFile()
- new
- silent file `='[fuf-info]'`
- let s:bufNrInfo = bufnr('%')
- setlocal filetype=vim
- setlocal bufhidden=delete
- setlocal buftype=acwrite
- setlocal noswapfile
- augroup FufInfo
- autocmd!
- autocmd BufWriteCmd <buffer> call s:onBufWriteCmdInfoFile()
- augroup END
- execute '0read ' . expand(g:fuf_infoFile)
- setlocal nomodified
+ let lines = map(copy(a:items), 'string(v:val)')
+ return l9#writeFile(lines, l9#concatPaths([g:fuf_dataDir, a:modeName, a:dataName]))
+endfunction
+
+"
+function fuf#getDataFileTime(modeName, dataName)
+ if !s:dataFileAvailable
+ return -1
+ endif
+ return getftime(expand(l9#concatPaths([g:fuf_dataDir, a:modeName, a:dataName])))
+endfunction
+
+"
+function s:createDataBufferListener(dataFile)
+ let listener = { 'dataFile': a:dataFile }
+
+ function listener.onWrite(lines)
+ let [modeName, dataName] = split(self.dataFile, l9#getPathSeparator())
+ let items = map(filter(a:lines, '!empty(v:val)'), 'eval(v:val)')
+ call fuf#saveDataFile(modeName, dataName, items)
+ echo "Data files updated"
+ return 1
+ endfunction
+
+ return listener
+endfunction
+
+"
+function s:createEditDataListener()
+ let listener = {}
+
+ function listener.onComplete(dataFile, method)
+ let bufName = '[fuf-info]'
+ let lines = l9#readFile(l9#concatPaths([g:fuf_dataDir, a:dataFile]))
+ call l9#tempbuffer#openWritable(bufName, 'vim', lines, 0, 0, 0,
+ \ s:createDataBufferListener(a:dataFile))
+ endfunction
+
+ return listener
+endfunction
+
+"
+function s:getEditableDataFiles(modeName)
+ let dataFiles = fuf#{a:modeName}#getEditableDataNames()
+ call filter(dataFiles, 'fuf#getDataFileTime(a:modeName, v:val) != -1')
+ return map(dataFiles, 'l9#concatPaths([a:modeName, v:val])')
+endfunction
+
+"
+function fuf#editDataFile()
+ let dataFiles = map(copy(fuf#getModeNames()), 's:getEditableDataFiles(v:val)')
+ let dataFiles = l9#concat(dataFiles)
+ call fuf#callbackitem#launch('', 0, '>Mode>', s:createEditDataListener(), dataFiles, 0)
endfunction
"
@@ -528,22 +492,13 @@ endfunction
"=============================================================================
" LOCAL FUNCTIONS/VARIABLES {{{1
-let s:INFO_FILE_VERSION_LINE = "VERSION\t300"
+let s:TEMP_VARIABLES_GROUP = expand('<sfile>:p')
let s:ABBR_SNIP_MASK = '...'
let s:OPEN_TYPE_CURRENT = 1
let s:OPEN_TYPE_SPLIT = 2
let s:OPEN_TYPE_VSPLIT = 3
let s:OPEN_TYPE_TAB = 4
-" wildcard -> regexp
-function s:convertWildcardToRegexp(expr)
- let re = escape(a:expr, '\')
- for [pat, sub] in [ [ '*', '\\.\\*' ], [ '?', '\\.' ], [ '[', '\\[' ], ]
- let re = substitute(re, pat, sub, 'g')
- endfor
- return '\V' . re
-endfunction
-
" a:pattern: 'str' -> '\V\.\*s\.\*t\.\*r\.\*'
function s:makeFuzzyMatchingExpr(target, pattern)
let wi = ''
@@ -565,12 +520,16 @@ function s:makePartialMatchingExpr(target, pattern)
return 'stridx(' . a:target . ', ' . string(a:pattern) . ') >= 0'
endif
return a:target . ' =~# ' .
- \ string(s:convertWildcardToRegexp(a:pattern)) . patternMigemo
+ \ string(l9#convertWildcardToRegexp(a:pattern)) . patternMigemo
endfunction
"
function s:makeRefiningExpr(pattern)
- let expr = s:makePartialMatchingExpr('v:val.wordForRefining', a:pattern)
+ if g:fuf_fuzzyRefining
+ let expr = s:makeFuzzyMatchingExpr('v:val.wordForRefining', a:pattern)
+ else
+ let expr = s:makePartialMatchingExpr('v:val.wordForRefining', a:pattern)
+ endif
if a:pattern =~# '\D'
return expr
else
@@ -586,37 +545,47 @@ function s:makeAdditionalMigemoPattern(pattern)
return '\|\m' . substitute(migemo(a:pattern), '\\_s\*', '.*', 'g')
endfunction
-" Snips a:str and add a:mask if the length of a:str is more than a:len
-function s: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):]
+"
+function s:interpretPrimaryPatternForPathTail(pattern)
+ let pattern = fuf#expandTailDotSequenceToParentDir(a:pattern)
+ let pairL = fuf#splitPath(s:toLowerForIgnoringCase(pattern))
+ return {
+ \ 'primary' : pattern,
+ \ 'primaryForRank': pairL.tail,
+ \ 'matchingPairs' : [['v:val.wordForPrimaryTail', pairL.tail],],
+ \ }
endfunction
-" Snips a:str and add a:mask if the length of a:str is more than a:len
-function s:snipTail(str, len, mask)
- if a:len >= len(a:str)
- return a:str
- elseif a:len <= len(a:mask)
- return a:mask
+"
+function s:interpretPrimaryPatternForPath(pattern)
+ let pattern = fuf#expandTailDotSequenceToParentDir(a:pattern)
+ let patternL = s:toLowerForIgnoringCase(pattern)
+ let pairL = fuf#splitPath(patternL)
+ if g:fuf_splitPathMatching
+ let matches = [
+ \ ['v:val.wordForPrimaryHead', pairL.head],
+ \ ['v:val.wordForPrimaryTail', pairL.tail],
+ \ ]
+ else
+ let matches = [
+ \ ['v:val.wordForPrimaryHead . v:val.wordForPrimaryTail', patternL],
+ \ ]
endif
- return a:str[:a:len - 1 - len(a:mask)] . a:mask
+ return {
+ \ 'primary' : pattern,
+ \ 'primaryForRank': pairL.tail,
+ \ 'matchingPairs' : matches,
+ \ }
endfunction
-" Snips a:str and add a:mask if the length of a:str is more than a:len
-function s: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 :] : '')
+"
+function s:interpretPrimaryPatternForNonPath(pattern)
+ let patternL = s:toLowerForIgnoringCase(a:pattern)
+ return {
+ \ 'primary' : a:pattern,
+ \ 'primaryForRank': patternL,
+ \ 'matchingPairs' : [['v:val.wordForPrimary', patternL],],
+ \ }
endfunction
"
@@ -626,7 +595,7 @@ endfunction
"
function s:toLowerForIgnoringCase(str)
- return (g:fuf_ignoreCase ? tolower(a:str) : a:str)
+ return (g:fuf_ignoreCase ? tolower(a:str) : a:str)
endfunction
"
@@ -652,35 +621,34 @@ function s:evaluateLearningRank(word, stats)
return len(a:stats)
endfunction
-let g:s = ""
" range of return value is [0.0, 1.0]
function s:scoreSequentialMatching(word, pattern)
if empty(a:pattern)
- return 0.0
+ return str2float('0.0')
endif
let pos = stridx(a:word, a:pattern)
if pos < 0
- return 0.0
+ return str2float('0.0')
endif
let lenRest = len(a:word) - len(a:pattern) - pos
- return (pos == 0 ? 0.5 : 0.0) + 0.5 / (lenRest + 1)
+ return str2float(pos == 0 ? '0.5' : '0.0') + str2float('0.5') / (lenRest + 1)
endfunction
" range of return value is [0.0, 1.0]
function s:scoreBoundaryMatching(wordForBoundary, pattern, exprBoundary)
if empty(a:pattern)
- return 0.0
+ return str2float('0.0')
endif
if !eval(a:exprBoundary)
return 0
endif
- return 0.5 + 0.5 * s:scoreSequentialMatching(a:wordForBoundary, a:pattern)
+ return (s:scoreSequentialMatching(a:wordForBoundary, a:pattern) + 1) / 2
endfunction
"
function s:highlightPrompt(prompt)
syntax clear
- execute printf('syntax match %s /^\V%s/', g:fuf_promptHighlight, escape(a:prompt, '\'))
+ execute printf('syntax match %s /^\V%s/', g:fuf_promptHighlight, escape(a:prompt, '\/'))
endfunction
"
@@ -689,34 +657,6 @@ function s:highlightError()
syntax match Error /^.*$/
endfunction
-" returns 0 if the buffer is not found.
-function s:moveToWindowOfBufferInCurrentTabPage(bufNr)
- if 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
-
-" returns 0 if the buffer is not found.
-function s:moveToWindowOfBufferInOtherTabPage(bufNr)
- if !s:moveToOtherTabPageOpeningBuffer(a:bufNr)
- return 0
- endif
- return s:moveToWindowOfBufferInCurrentTabPage(a:bufNr)
-endfunction
-
"
function s:expandAbbrevMap(pattern, abbrevMap)
let result = [a:pattern]
@@ -727,7 +667,7 @@ function s:expandAbbrevMap(pattern, abbrevMap)
let result += map(copy(subs), 'substitute(expr, pattern, escape(v:val, ''\''), "g")')
endfor
endfor
- return fuf#unique(result)
+ return l9#unique(result)
endfunction
"
@@ -750,45 +690,19 @@ endfunction
"
function s:getSnippedHead(head, baseLen)
- return s:snipMid(a:head, len(a:head) + g:fuf_maxMenuWidth - a:baseLen, s:ABBR_SNIP_MASK)
+ return l9#snipMid(a:head, len(a:head) + g:fuf_maxMenuWidth - a:baseLen, s:ABBR_SNIP_MASK)
endfunction
"
function s:setAbbrWithFileAbbrData(item, snippedHeads)
let lenMenu = (exists('a:item.menu') ? len(a:item.menu) + 2 : 0)
let abbr = a:item.abbr.prefix . a:snippedHeads[a:item.abbr.key] . a:item.abbr.tail
- let a:item.abbr = s:snipTail(abbr, g:fuf_maxMenuWidth - lenMenu, s:ABBR_SNIP_MASK)
+ let a:item.abbr = l9#snipTail(abbr, g:fuf_maxMenuWidth - lenMenu, s:ABBR_SNIP_MASK)
return a:item
endfunction
-let s:bufNrFuf = -1
-
"
-function s:openFufBuffer()
- if !bufexists(s:bufNrFuf)
- topleft 1new
- silent file `='[fuf]'`
- let s:bufNrFuf = bufnr('%')
- elseif bufwinnr(s:bufNrFuf) == -1
- topleft 1split
- execute 'silent ' . s:bufNrFuf . 'buffer'
- delete _
- elseif bufwinnr(s:bufNrFuf) != bufwinnr('%')
- execute bufwinnr(s:bufNrFuf) . 'wincmd w'
- endif
-endfunction
-
-function s:setLocalOptionsForFufBuffer()
- setlocal filetype=fuf
- setlocal bufhidden=delete
- setlocal buftype=nofile
- setlocal noswapfile
- setlocal nobuflisted
- setlocal modifiable
- setlocal nocursorline " for highlighting
- setlocal nocursorcolumn " for highlighting
- setlocal omnifunc=fuf#onComplete
-endfunction
+let s:FUF_BUF_NAME = '[fuf]'
"
function s:activateFufBuffer()
@@ -796,10 +710,13 @@ function s:activateFufBuffer()
" if 'autochdir' was set on.
lcd .
let cwd = getcwd()
- call s:openFufBuffer()
+ call l9#tempbuffer#openScratch(s:FUF_BUF_NAME, 'fuf', [], 1, 0, 1, {})
+ resize 1 " for issue #21
" lcd ... : countermeasure against auto-cd script
lcd `=cwd`
- call s:setLocalOptionsForFufBuffer()
+ setlocal nocursorline " for highlighting
+ setlocal nocursorcolumn " for highlighting
+ setlocal omnifunc=fuf#onComplete
redraw " for 'lazyredraw'
if exists(':AcpLock')
AcpLock
@@ -815,73 +732,7 @@ function s:deactivateFufBuffer()
elseif exists(':AutoComplPopUnlock')
AutoComplPopUnlock
endif
- " must close after returning to previous window
- wincmd p
- execute s:bufNrFuf . 'bdelete'
-endfunction
-
-let s:originalGlobalOptions = {}
-
-"
-function s:setTemporaryGlobalOption(name, value)
- call extend(s:originalGlobalOptions, { a:name : eval('&' . a:name) }, 'keep')
- execute printf('let &%s = a:value', a:name)
-endfunction
-
-"
-function s:restoreTemporaryGlobalOptions()
- for [name, value] in items(s:originalGlobalOptions)
- execute printf('let &%s = value', name)
- endfor
- let s:originalGlobalOptions = {}
-endfunction
-
-"
-function s:warnOldInfoFile()
- call fuf#echoWithHl(printf("=================================================================\n" .
- \ " Sorry, but your information file for FuzzyFinder is no longer \n" .
- \ " compatible with this version of FuzzyFinder. Please remove \n" .
- \ " %-63s\n" .
- \ "=================================================================\n" ,
- \ '"' . expand(g:fuf_infoFile) . '".'),
- \ 'WarningMsg')
- echohl Question
- call input('Press Enter')
- echohl None
-endfunction
-
-"
-function s:serializeInfoMap(infoMap)
- let lines = []
- for [m, info] in items(a:infoMap)
- for [key, value] in items(info)
- let lines += map(copy(value), 'm . "\t" . key . "\t" . string(v:val)')
- endfor
- endfor
- return lines
-endfunction
-
-"
-function s:deserializeInfoMap(lines)
- let infoMap = {}
- for e in filter(map(a:lines, 'matchlist(v:val, ''^\v(\S+)\s+(\S+)\s+(.+)$'')'), '!empty(v:val)')
- if !exists('infoMap[e[1]]')
- let infoMap[e[1]] = {}
- endif
- if !exists('infoMap[e[1]][e[2]]')
- let infoMap[e[1]][e[2]] = []
- endif
- call add(infoMap[e[1]][e[2]], eval(e[3]))
- endfor
- return infoMap
-endfunction
-
-"
-function s:onBufWriteCmdInfoFile()
- call fuf#saveInfoFile('', s:deserializeInfoMap(getline(1, '$')))
- setlocal nomodified
- execute printf('%dbdelete! ', s:bufNrInfo)
- echo "Information file updated"
+ call l9#tempbuffer#close(s:FUF_BUF_NAME)
endfunction
" }}}1
@@ -899,9 +750,6 @@ let s:handlerBase = {}
" "
" s:handler.getPrompt()
"
-" " returns true if the mode deals with file paths.
-" s:handler.targetsPath()
-"
" "
" s:handler.getCompleteItems(patternSet)
"
@@ -929,9 +777,9 @@ endfunction
"
function s:handlerBase.addStat(pattern, word)
let stat = { 'pattern' : a:pattern, 'word' : a:word }
- call filter(self.info.stats, 'v:val !=# stat')
- call insert(self.info.stats, stat)
- let self.info.stats = self.info.stats[0 : g:fuf_learningLimit - 1]
+ call filter(self.stats, 'v:val !=# stat')
+ call insert(self.stats, stat)
+ let self.stats = self.stats[0 : g:fuf_learningLimit - 1]
endfunction
"
@@ -942,10 +790,10 @@ function s:handlerBase.getMatchingCompleteItems(patternBase)
let patternSet = self.makePatternSet(a:patternBase)
let exprBoundary = s:makeFuzzyMatchingExpr('a:wordForBoundary', patternSet.primaryForRank)
let stats = filter(
- \ copy(self.info.stats), 'v:val.pattern ==# patternSet.primaryForRank')
+ \ copy(self.stats), 'v:val.pattern ==# patternSet.primaryForRank')
let items = self.getCompleteItems(patternSet.primary)
" NOTE: In order to know an excess, plus 1 to limit number
- let items = fuf#filterWithLimit(
+ let items = l9#filterWithLimit(
\ items, patternSet.filteringExpr, g:fuf_enumeratingLimit + 1)
return map(items,
\ 's:setRanks(v:val, patternSet.primaryForRank, exprBoundary, stats)')
@@ -972,7 +820,11 @@ function s:handlerBase.onComplete(findstart, base)
call s:highlightError()
else
call sort(items, 'fuf#compareRanks')
- call feedkeys("\<C-p>\<Down>", 'n')
+ if g:fuf_autoPreview
+ call feedkeys("\<C-p>\<Down>\<C-r>=fuf#getRunningHandler().onPreviewBase(0) ? '' : ''\<CR>", 'n')
+ else
+ call feedkeys("\<C-p>\<Down>", 'n')
+ endif
let self.lastFirstWord = items[0].word
endif
return items
@@ -1017,33 +869,34 @@ endfunction
"
function s:handlerBase.onInsertLeave()
unlet s:runningHandler
- let lastPattern = self.removePrompt(getline('.'))
- call s:restoreTemporaryGlobalOptions()
+ let tempVars = l9#tempvariables#getList(s:TEMP_VARIABLES_GROUP)
+ call l9#tempvariables#end(s:TEMP_VARIABLES_GROUP)
call s:deactivateFufBuffer()
- call fuf#saveInfoFile(self.getModeName(), self.info)
+ call fuf#saveDataFile(self.getModeName(), 'stats', self.stats)
+ execute self.windowRestoringCommand
let fOpen = exists('s:reservedCommand')
if fOpen
call self.onOpen(s:reservedCommand[0], s:reservedCommand[1])
unlet s:reservedCommand
endif
call self.onModeLeavePost(fOpen)
- if exists('s:reservedMode')
- call fuf#launch(s:reservedMode, lastPattern, self.partialMatching)
- unlet s:reservedMode
+ if exists('self.reservedMode')
+ call l9#tempvariables#setList(s:TEMP_VARIABLES_GROUP, tempVars)
+ call fuf#launch(self.reservedMode, self.lastPattern, self.partialMatching)
endif
endfunction
"
-function s:handlerBase.onCr(openType, fCheckDir)
+function s:handlerBase.onCr(openType)
if pumvisible()
- call feedkeys(printf("\<C-y>\<C-r>=fuf#getRunningHandler().onCr(%d, %d) ? '' : ''\<CR>",
- \ a:openType, self.targetsPath()), 'n')
+ call feedkeys(printf("\<C-y>\<C-r>=fuf#getRunningHandler().onCr(%d) ? '' : ''\<CR>",
+ \ a:openType), 'n')
return
endif
if !empty(self.lastPattern)
call self.addStat(self.lastPattern, self.removePrompt(getline('.')))
endif
- if a:fCheckDir && getline('.') =~# '[/\\]$'
+ if !self.isOpenable(getline('.'))
" To clear i_<C-r> expression (fuf#getRunningHandler().onCr...)
echo ''
return
@@ -1054,24 +907,30 @@ endfunction
"
function s:handlerBase.onBs()
- let pattern = self.removePrompt(getline('.')[ : col('.') - 2])
- if empty(pattern)
- let numBs = 0
- elseif !g:fuf_smartBs
- let numBs = 1
- elseif pattern[-len(g:fuf_patternSeparator) : ] ==# g:fuf_patternSeparator
- let numBs = len(split(pattern, g:fuf_patternSeparator, 1)[-2])
- \ + len(g:fuf_patternSeparator)
- elseif self.targetsPath() && pattern[-1 : ] =~# '[/\\]'
- let numBs = len(matchstr(pattern, '[^/\\]*.$'))
- else
- let numBs = 1
+ call feedkeys((pumvisible() ? "\<C-e>\<BS>" : "\<BS>"), 'n')
+endfunction
+
+"
+function s:getLastBlockLength(pattern, patternIsPath)
+ let separatorPos = strridx(a:pattern, g:fuf_patternSeparator)
+ if separatorPos >= 0
+ return len(a:pattern) - separatorPos
+ endif
+ if a:patternIsPath && a:pattern =~# '[/\\].'
+ return len(matchstr(a:pattern, '[^/\\]*.$'))
endif
+ return len(a:pattern)
+endfunction
+
+"
+function s:handlerBase.onDeleteWord()
+ let pattern = self.removePrompt(getline('.')[ : col('.') - 2])
+ let numBs = s:getLastBlockLength(pattern, 1)
call feedkeys((pumvisible() ? "\<C-e>" : "") . repeat("\<BS>", numBs), 'n')
endfunction
"
-function s:handlerBase.onPreviewBase()
+function s:handlerBase.onPreviewBase(repeatable)
if self.getPreviewHeight() <= 0
return
elseif !pumvisible()
@@ -1084,7 +943,7 @@ function s:handlerBase.onPreviewBase()
let word = self.lastFirstWord
endif
redraw
- if exists('self.lastPreviewInfo') && self.lastPreviewInfo.word ==# word
+ if a:repeatable && exists('self.lastPreviewInfo') && self.lastPreviewInfo.word ==# word
let self.lastPreviewInfo.count += 1
else
let self.lastPreviewInfo = {'word': word, 'count': 0}
@@ -1092,20 +951,21 @@ function s:handlerBase.onPreviewBase()
let lines = self.makePreviewLines(word, self.lastPreviewInfo.count)
let lines = lines[: self.getPreviewHeight() - 1]
call map(lines, 'substitute(v:val, "\t", repeat(" ", &tabstop), "g")')
- call map(lines, 's:snipTail(v:val, &columns - 1, s:ABBR_SNIP_MASK)')
+ call map(lines, 'strtrans(v:val)')
+ call map(lines, 'l9#snipTail(v:val, &columns - 1, s:ABBR_SNIP_MASK)')
echo join(lines, "\n")
endfunction
"
function s:handlerBase.onSwitchMode(shift)
- let modes = copy(g:fuf_modes)
+ let modes = copy(fuf#getModeNames())
call map(modes, '{ "ranks": [ fuf#{v:val}#getSwitchOrder(), v:val ] }')
call filter(modes, 'v:val.ranks[0] >= 0')
call sort(modes, 'fuf#compareRanks')
- let s:reservedMode = self.getModeName()
+ let self.reservedMode = self.getModeName()
for i in range(len(modes))
if modes[i].ranks[1] ==# self.getModeName()
- let s:reservedMode = modes[(i + a:shift) % len(modes)].ranks[1]
+ let self.reservedMode = modes[(i + a:shift) % len(modes)].ranks[1]
break
endif
endfor
@@ -1123,7 +983,7 @@ endfunction
"
function s:handlerBase.onRecallPattern(shift)
- let patterns = map(copy(self.info.stats), 'v:val.pattern')
+ let patterns = map(copy(self.stats), 'v:val.pattern')
if !exists('self.indexRecall')
let self.indexRecall = -1
endif
@@ -1149,6 +1009,37 @@ augroup END
let s:bufferCursorPosMap = {}
+"
+let s:DATA_FILE_VERSION = 400
+
+"
+function s:checkDataFileCompatibility()
+ if empty(g:fuf_dataDir)
+ let s:dataFileAvailable = 0
+ return
+ endif
+ let versionPath = l9#concatPaths([g:fuf_dataDir, 'VERSION'])
+ let lines = l9#readFile(versionPath)
+ if empty(lines)
+ call l9#writeFile([s:DATA_FILE_VERSION], versionPath)
+ let s:dataFileAvailable = 1
+ elseif str2nr(lines[0]) == s:DATA_FILE_VERSION
+ let s:dataFileAvailable = 1
+ else
+ call fuf#echoWarning(printf(
+ \ "=======================================================\n" .
+ \ " Existing data files for FuzzyFinder is no longer \n" .
+ \ " compatible with this version of FuzzyFinder. Remove \n" .
+ \ " %-53s\n" .
+ \ "=======================================================\n" ,
+ \ string(g:fuf_dataDir)))
+ call l9#inputHl('Question', 'Press Enter')
+ let s:dataFileAvailable = 0
+ endif
+endfunction
+
+call s:checkDataFileCompatibility()
+
" }}}1
"=============================================================================
" vim: set fdm=marker:
View
37 .vim/autoload/fuf/buffer.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf_buffer') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf_buffer = 1
" }}}1
"=============================================================================
@@ -24,6 +23,11 @@ function fuf#buffer#getSwitchOrder()
endfunction
"
+function fuf#buffer#getEditableDataNames()
+ return []
+endfunction
+
+"
function fuf#buffer#renewCache()
endfunction
@@ -34,7 +38,7 @@ endfunction
"
function fuf#buffer#onInit()
- call fuf#defineLaunchCommand('FufBuffer', s:MODE_NAME, '""')
+ call fuf#defineLaunchCommand('FufBuffer', s:MODE_NAME, '""', [])
augroup fuf#buffer
autocmd!
autocmd BufEnter * call s:updateBufTimes()
@@ -47,6 +51,7 @@ endfunction
" LOCAL FUNCTIONS/VARIABLES {{{1
let s:MODE_NAME = expand('<sfile>:t:r')
+let s:OPEN_TYPE_DELETE = -1
let s:bufTimes = {}
@@ -59,7 +64,7 @@ endfunction
function s:makeItem(nr)
let fname = (empty(bufname(a:nr))
\ ? '[No Name]'
- \ : fnamemodify(bufname(a:nr), ':~:.'))
+ \ : 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
@@ -110,7 +115,7 @@ endfunction
"
function s:handler.getPrompt()
- return fuf#formatPrompt(g:fuf_buffer_prompt, self.partialMatching)
+ return fuf#formatPrompt(g:fuf_buffer_prompt, self.partialMatching, '')
endfunction
"
@@ -119,7 +124,7 @@ function s:handler.getPreviewHeight()
endfunction
"
-function s:handler.targetsPath()
+function s:handler.isOpenable(enteredPattern)
return 1
endfunction
@@ -147,7 +152,12 @@ 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)
+ 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
@@ -158,11 +168,14 @@ endfunction
"
function s:handler.onModeEnterPost()
- let self.items = map(filter(range(1, bufnr('$')),
- \ 'buflisted(v:val) && v:val != self.bufNrPrev'),
- \ 's:makeItem(v:val)')
+ 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 fuf#mapToSetSerialIndex(sort(self.items, 's:compareTimeDescending'), 1)
+ call sort(self.items, 's:compareTimeDescending')
+ call fuf#mapToSetSerialIndex(self.items, 1)
endif
let self.items = fuf#mapToSetAbbrWithSnippedWordAsPath(self.items)
endfunction
View
20 .vim/autoload/fuf/callbackfile.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf_callbackfile') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf_callbackfile = 1
" }}}1
"=============================================================================
@@ -24,6 +23,11 @@ function fuf#callbackfile#getSwitchOrder()
endfunction
"
+function fuf#callbackfile#getEditableDataNames()
+ return []
+endfunction
+
+"
function fuf#callbackfile#renewCache()
let s:cache = {}
endfunction
@@ -53,7 +57,7 @@ let s:MODE_NAME = expand('<sfile>:t:r')
"
function s:enumItems(dir)
- let key = getcwd() . s:exclude . "\n" . a: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)
@@ -78,7 +82,7 @@ endfunction
"
function s:handler.getPrompt()
- return fuf#formatPrompt(s:prompt, self.partialMatching)
+ return fuf#formatPrompt(s:prompt, self.partialMatching, '')
endfunction
"
@@ -87,8 +91,8 @@ function s:handler.getPreviewHeight()
endfunction
"
-function s:handler.targetsPath()
- return 1
+function s:handler.isOpenable(enteredPattern)
+ return a:enteredPattern =~# '[^/\\]$'
endfunction
"
@@ -123,7 +127,7 @@ endfunction
"
function s:handler.onModeLeavePost(opened)
- if !a:opened
+ if !a:opened && exists('s:listener.onAbort()')
call s:listener.onAbort()
endif
endfunction
View
18 .vim/autoload/fuf/callbackitem.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf_callbackitem') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf_callbackitem = 1
" }}}1
"=============================================================================
@@ -24,6 +23,11 @@ function fuf#callbackitem#getSwitchOrder()
endfunction
"
+function fuf#callbackitem#getEditableDataNames()
+ return []
+endfunction
+
+"
function fuf#callbackitem#renewCache()
endfunction
@@ -73,7 +77,7 @@ endfunction
"
function s:handler.getPrompt()
- return fuf#formatPrompt(s:prompt, self.partialMatching)
+ return fuf#formatPrompt(s:prompt, self.partialMatching, '')
endfunction
"
@@ -85,8 +89,8 @@ function s:handler.getPreviewHeight()
endfunction
"
-function s:handler.targetsPath()
- return s:forPath
+function s:handler.isOpenable(enteredPattern)
+ return 1
endfunction
"
@@ -125,7 +129,7 @@ endfunction
"
function s:handler.onModeLeavePost(opened)
- if !a:opened
+ if !a:opened && exists('s:listener.onAbort()')
call s:listener.onAbort()
endif
endfunction
View
18 .vim/autoload/fuf/changelist.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf_changelist') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf_changelist = 1
" }}}1
"=============================================================================
@@ -24,6 +23,11 @@ function fuf#changelist#getSwitchOrder()
endfunction
"
+function fuf#changelist#getEditableDataNames()
+ return []
+endfunction
+
+"
function fuf#changelist#renewCache()
endfunction
@@ -34,7 +38,7 @@ endfunction
"
function fuf#changelist#onInit()
- call fuf#defineLaunchCommand('FufChangeList', s:MODE_NAME, '""')
+ call fuf#defineLaunchCommand('FufChangeList', s:MODE_NAME, '""', [])
endfunction
" }}}1
@@ -91,7 +95,7 @@ endfunction
"
function s:handler.getPrompt()
- return fuf#formatPrompt(g:fuf_changelist_prompt, self.partialMatching)
+ return fuf#formatPrompt(g:fuf_changelist_prompt, self.partialMatching, '')
endfunction
"
@@ -100,8 +104,8 @@ function s:handler.getPreviewHeight()
endfunction
"
-function s:handler.targetsPath()
- return 0
+function s:handler.isOpenable(enteredPattern)
+ return 1
endfunction
"
View
26 .vim/autoload/fuf/dir.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf_dir') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf_dir = 1
" }}}1
"=============================================================================
@@ -24,6 +23,11 @@ function fuf#dir#getSwitchOrder()
endfunction
"
+function fuf#dir#getEditableDataNames()
+ return []
+endfunction
+
+"
function fuf#dir#renewCache()
let s:cache = {}
endfunction
@@ -35,9 +39,9 @@ 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''))]')
+ 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
@@ -48,7 +52,7 @@ let s:MODE_NAME = expand('<sfile>:t:r')
"
function s:enumItems(dir)
- let key = getcwd() . g:fuf_dir_exclude . "\n" . a: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 =~# ''[/\\]$''')
@@ -74,7 +78,7 @@ endfunction
"
function s:handler.getPrompt()
- return fuf#formatPrompt(g:fuf_dir_prompt, self.partialMatching)
+ return fuf#formatPrompt(g:fuf_dir_prompt, self.partialMatching, '')
endfunction
"
@@ -83,8 +87,8 @@ function s:handler.getPreviewHeight()
endfunction
"
-function s:handler.targetsPath()
- return 1
+function s:handler.isOpenable(enteredPattern)
+ return a:enteredPattern =~# '[^/\\]$'
endfunction
"
@@ -96,7 +100,7 @@ endfunction
"
function s:handler.makePreviewLines(word, count)
return fuf#makePreviewLinesAround(
- \ split(glob(fnamemodify(a:word, ':p') . '*'), "\n"),
+ \ fuf#glob(fnamemodify(a:word, ':p') . '*'),
\ [], a:count, self.getPreviewHeight())
return
endfunction
View
34 .vim/autoload/fuf/file.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf_file') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf_file = 1
" }}}1
"=============================================================================
@@ -24,6 +23,11 @@ function fuf#file#getSwitchOrder()
endfunction
"
+function fuf#file#getEditableDataNames()
+ return []
+endfunction
+
+"
function fuf#file#renewCache()
let s:cache = {}
endfunction
@@ -35,9 +39,9 @@ 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''))]')
+ 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
@@ -48,7 +52,7 @@ let s:MODE_NAME = expand('<sfile>:t:r')
"
function s:enumItems(dir)
- let key = getcwd() . g:fuf_file_exclude . "\n" . a: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)
@@ -58,15 +62,13 @@ function s:enumItems(dir)
endfunction
"
-function s:enumNonCurrentItems(dir, bufNr, cache)
+function s:enumNonCurrentItems(dir, bufNrPrev, cache)
let key = a:dir . 'AVOIDING EMPTY KEY'
if !exists('a:cache[key]')
- " NOTE: filtering should be done with
- " 'bufnr("^" . v:val.word . "$") != a:bufNr'.
- " But it takes a lot of time!
- let bufName = bufname(a:bufNr)
+ " 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 != bufName')
+ \ filter(copy(s:enumItems(a:dir)), 'v:val.word !=# bufNamePrev')
endif
return a:cache[key]
endfunction
@@ -84,7 +86,7 @@ endfunction
"
function s:handler.getPrompt()
- return fuf#formatPrompt(g:fuf_file_prompt, self.partialMatching)
+ return fuf#formatPrompt(g:fuf_file_prompt, self.partialMatching, '')
endfunction
"
@@ -93,8 +95,8 @@ function s:handler.getPreviewHeight()
endfunction
"
-function s:handler.targetsPath()
- return 1
+function s:handler.isOpenable(enteredPattern)
+ return a:enteredPattern =~# '[^/\\]$'
endfunction
"
View
16 .vim/autoload/fuf/givencmd.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf_givencmd') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf_givencmd = 1
" }}}1
"=============================================================================
@@ -24,6 +23,11 @@ function fuf#givencmd#getSwitchOrder()
endfunction
"
+function fuf#givencmd#getEditableDataNames()
+ return []
+endfunction
+
+"
function fuf#givencmd#renewCache()
endfunction
@@ -65,7 +69,7 @@ endfunction
"
function s:handler.getPrompt()
- return fuf#formatPrompt(s:prompt, self.partialMatching)
+ return fuf#formatPrompt(s:prompt, self.partialMatching, '')
endfunction
"
@@ -74,8 +78,8 @@ function s:handler.getPreviewHeight()
endfunction
"
-function s:handler.targetsPath()
- return 0
+function s:handler.isOpenable(enteredPattern)
+ return 1
endfunction
"
View
16 .vim/autoload/fuf/givendir.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf_givendir') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf_givendir = 1
" }}}1
"=============================================================================
@@ -24,6 +23,11 @@ function fuf#givendir#getSwitchOrder()
endfunction
"
+function fuf#givendir#getEditableDataNames()
+ return []
+endfunction
+
+"
function fuf#givendir#renewCache()
endfunction
@@ -65,7 +69,7 @@ endfunction
"
function s:handler.getPrompt()
- return fuf#formatPrompt(s:prompt, self.partialMatching)
+ return fuf#formatPrompt(s:prompt, self.partialMatching, '')
endfunction
"
@@ -74,7 +78,7 @@ function s:handler.getPreviewHeight()
endfunction
"
-function s:handler.targetsPath()
+function s:handler.isOpenable(enteredPattern)
return 1
endfunction
@@ -87,7 +91,7 @@ endfunction
"
function s:handler.makePreviewLines(word, count)
return fuf#makePreviewLinesAround(
- \ split(glob(fnamemodify(a:word, ':p') . '*'), "\n"),
+ \ fuf#glob(fnamemodify(a:word, ':p') . '*'),
\ [], a:count, self.getPreviewHeight())
return
endfunction
View
14 .vim/autoload/fuf/givenfile.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf_givenfile') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf_givenfile = 1
" }}}1
"=============================================================================
@@ -24,6 +23,11 @@ function fuf#givenfile#getSwitchOrder()
endfunction
"
+function fuf#givenfile#getEditableDataNames()
+ return []
+endfunction
+
+"
function fuf#givenfile#renewCache()
endfunction
@@ -65,7 +69,7 @@ endfunction
"
function s:handler.getPrompt()
- return fuf#formatPrompt(s:prompt, self.partialMatching)
+ return fuf#formatPrompt(s:prompt, self.partialMatching, '')
endfunction
"
@@ -74,7 +78,7 @@ function s:handler.getPreviewHeight()
endfunction
"
-function s:handler.targetsPath()
+function s:handler.isOpenable(enteredPattern)
return 1
endfunction
View
52 .vim/autoload/fuf/help.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf_help') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf_help = 1
" }}}1
"=============================================================================
@@ -24,6 +23,11 @@ function fuf#help#getSwitchOrder()
endfunction
"
+function fuf#help#getEditableDataNames()
+ return []
+endfunction
+
+"
function fuf#help#renewCache()
let s:cache = {}
endfunction
@@ -35,8 +39,8 @@ endfunction
"
function fuf#help#onInit()
- call fuf#defineLaunchCommand('FufHelp' , s:MODE_NAME, '""')
- call fuf#defineLaunchCommand('FufHelpWithCursorWord', s:MODE_NAME, 'expand(''<cword>'')')
+ call fuf#defineLaunchCommand('FufHelp' , s:MODE_NAME, '""', [])
+ call fuf#defineLaunchCommand('FufHelpWithCursorWord', s:MODE_NAME, 'expand(''<cword>'')', [])
endfunction
" }}}1
@@ -47,7 +51,7 @@ let s:MODE_NAME = expand('<sfile>:t:r')
"
function s:getCurrentHelpTagFiles()
- let prefix = 'doc' . fuf#getPathSeparator()
+ 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")'))
@@ -65,7 +69,7 @@ function s:parseHelpTagEntry(line, tagFile)
else
let suffix = '@' . suffix
endif
- let dir = fnamemodify(a:tagFile, ':h') . fuf#getPathSeparator()
+ let dir = fnamemodify(a:tagFile, ':h') . l9#getPathSeparator()
return {
\ 'word' : elements[0] . suffix,
\ 'path' : dir . elements[1],
@@ -75,30 +79,22 @@ endfunction
"
function s:getHelpTagEntries(tagFile)
- let names = map(readfile(a:tagFile), 's:parseHelpTagEntry(v:val, a: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)
- if !empty(g:fuf_help_cache_dir)
- if !isdirectory(expand(g:fuf_help_cache_dir))
- call mkdir(expand(g:fuf_help_cache_dir), 'p')
- endif
- " NOTE: fnamemodify('a/b', ':p') returns 'a/b/' if the directory exists.
- let cacheFile = fnamemodify(g:fuf_help_cache_dir, ':p')
- \ . fuf#hash224(join(a:tagFiles, "\n"))
- if filereadable(cacheFile) && fuf#countModifiedFiles(a:tagFiles, getftime(cacheFile)) == 0
- return map(readfile(cacheFile), 'eval(v:val)')
- endif
+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 = fuf#unique(fuf#concat(map(copy(a:tagFiles), 's:getHelpTagEntries(v:val)')))
+ 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)')
- if !empty(g:fuf_help_cache_dir)
- call writefile(map(copy(items), 'string(v:val)'), cacheFile)
- endif
+ call fuf#saveDataFile(s:MODE_NAME, cacheName, items)
return items
endfunction
@@ -107,11 +103,11 @@ function s:enumHelpTags(tagFiles)
if !len(a:tagFiles)
return []
endif
- let key = join(a:tagFiles, "\n")
+ 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)
+ \ 'items' : s:parseHelpTagFiles(a:tagFiles, key)
\ }
endif
return s:cache[key].items
@@ -143,7 +139,7 @@ endfunction
"
function s:handler.getPrompt()
- return fuf#formatPrompt(g:fuf_help_prompt, self.partialMatching)
+ return fuf#formatPrompt(g:fuf_help_prompt, self.partialMatching, '')
endfunction
"
@@ -152,8 +148,8 @@ function s:handler.getPreviewHeight()
endfunction
"
-function s:handler.targetsPath()
- return 0
+function s:handler.isOpenable(enteredPattern)
+ return 1
endfunction
"
View
18 .vim/autoload/fuf/jumplist.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"
"=============================================================================
" LOAD GUARD {{{1
-if exists('g:loaded_autoload_fuf_jumplist') || v:version < 702
+if !l9#guardScriptLoading(expand('<sfile>:p'), 0, 0, [])
finish
endif
-let g:loaded_autoload_fuf_jumplist = 1
" }}}1
"=============================================================================
@@ -24,6 +23,11 @@ function fuf#jumplist#getSwitchOrder()
endfunction
"
+function fuf#jumplist#getEditableDataNames()
+ return []
+endfunction
+
+"
function fuf#jumplist#renewCache()
endfunction
@@ -34,7 +38,7 @@ endfunction
"
function fuf#jumplist#onInit()
- call fuf#defineLaunchCommand('FufJumpList', s:MODE_NAME, '""')
+ call fuf#defineLaunchCommand('FufJumpList', s:MODE_NAME, '""', [])
endfunction
" }}}1
@@ -101,7 +105,7 @@ endfunction
"
function s:handler.getPrompt()
- return fuf#formatPrompt(g:fuf_jumplist_prompt, self.partialMatching)
+ return fuf#formatPrompt(g:fuf_jumplist_prompt, self.partialMatching, '')
endfunction
"
@@ -110,8 +114,8 @@ function s:handler.getPreviewHeight()
endfunction
"
-function s:handler.targetsPath()
- return 0
+function s:handler.isOpenable(enteredPattern)
+ return 1
endfunction
"
View
18 .vim/autoload/fuf/line.vim
@@ -1,13 +1,12 @@
"=============================================================================
-" Copyright (c) 2007-2009 Takeshi NISHIDA
+" Copyright (c) 2007-2010 Takeshi NISHIDA
"