summaryrefslogtreecommitdiff
path: root/autoload/fuf/givendir.vim
blob: e654d85320b6e4d9192447ced85ea4728404bcbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
"=============================================================================
" 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: