From 2f6eca0dc513d474765290f1a5a4c02aed549be0 Mon Sep 17 00:00:00 2001 From: Hugues Hiegel Date: Wed, 7 Nov 2018 10:34:07 +0100 Subject: Plein de trucs en vrac... J’ai honte.. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/fuf/dir.vim | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 autoload/fuf/dir.vim (limited to 'autoload/fuf/dir.vim') diff --git a/autoload/fuf/dir.vim b/autoload/fuf/dir.vim new file mode 100644 index 0000000..5316093 --- /dev/null +++ b/autoload/fuf/dir.vim @@ -0,0 +1,132 @@ +"============================================================================= +" Copyright (c) 2007-2010 Takeshi NISHIDA +" +"============================================================================= +" LOAD GUARD {{{1 + +if !l9#guardScriptLoading(expand(':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(':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: -- cgit v1.2.3