-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathcontext.vim
More file actions
164 lines (142 loc) · 3.89 KB
/
Copy pathcontext.vim
File metadata and controls
164 lines (142 loc) · 3.89 KB
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
let s:pluginBuffer = -1
let s:pluginFolder = fnamemodify(resolve(expand('<sfile>:p')), ':h:h:h')
let s:configuration = {
\ "defaultSymbols": {
\ "unicode": {
\ "CS": "⌗",
\ "Sin": "•",
\ "All": "፨",
\ "Vis": "★",
\ "File": "○",
\ "Tabs": "▫",
\ "CTab": "▪",
\ "NTM": "⁺",
\ "WLoad": "⬆",
\ "WSave": "⬇",
\ "Zoom": "⌕",
\ "SLeft": "›",
\ "SRight": "‹",
\ "BM": "♥",
\ "Help": "?",
\ "IV": "☆",
\ "IA": "★",
\ "IM": "+",
\ "Dots": "…"
\ },
\ "ascii": {
\ "CS": "#",
\ "Sin": "SIN",
\ "All": "ALL",
\ "Vis": "VIS",
\ "File": "FILE",
\ "Tabs": "-",
\ "CTab": "+",
\ "NTM": "+",
\ "WLoad": "|*|",
\ "WSave": "[*]",
\ "Zoom": "*",
\ "SLeft": "[",
\ "SRight": "]",
\ "BM": "BM",
\ "Help": "?",
\ "IV": "-",
\ "IA": "*",
\ "IM": "+",
\ "Dots": "..."
\ }
\ },
\ "Height": 1,
\ "MaxHeight": 0,
\ "SetDefaultMapping": 1,
\ "DefaultMappingKey": "<C-Space>",
\ "Keys": {},
\ "Help": {},
\ "GlobCommand": "",
\ "UseTabline": 1,
\ "UseArrowsInTerm": 0,
\ "UseMouseAndArrowsInTerm": 0,
\ "StatuslineFunction": "ctrlspace#api#Statusline()",
\ "SaveWorkspaceOnExit": 0,
\ "SaveWorkspaceOnSwitch": 0,
\ "LoadLastWorkspaceOnStart": 0,
\ "CacheDir": expand($HOME),
\ "ProjectRootMarkers": [".git", ".hg", ".svn", ".bzr", "_darcs", "CVS"],
\ "UseUnicode": 1,
\ "IgnoredFiles": '\v(tmp|temp)[\/]',
\ "SearchTiming": 200,
\ "FileEngine": "auto",
\ }
function! s:init()
let s:conf = copy(s:configuration)
for name in keys(s:conf)
if exists("g:CtrlSpace" . name)
let s:conf[name] = g:{"CtrlSpace" . name}
endif
endfor
let s:conf.Symbols = copy(s:conf.UseUnicode ? s:conf.defaultSymbols.unicode : s:conf.defaultSymbols.ascii)
if exists("g:CtrlSpaceSymbols")
call extend(s:conf.Symbols, g:CtrlSpaceSymbols)
endif
let s:symbolSizes = {
\ "IAV": max([strwidth(s:conf.Symbols.IV), strwidth(s:conf.Symbols.IA)]),
\ "IM": strwidth(s:conf.Symbols.IM),
\ "Dots": strwidth(s:conf.Symbols.Dots)
\ }
if s:conf.FileEngine ==# "auto"
let s:conf.FileEngine = s:detectEngine()
endif
if !empty(s:conf.FileEngine)
let s:conf.FileEngineName = s:conf.FileEngine
let ebin = s:pluginFolder . "/bin/" . s:conf.FileEngine
let s:conf.FileEngine = executable(ebin) ? ebin : ""
endif
if empty(s:conf.FileEngine)
let s:conf.FileEngineName = "VIM"
endif
endfunction
function! s:detectEngine()
let [os, arch] = ["", ""]
if has("win32")
let os = "windows"
let arch = empty(system('set | find "ProgramFiles(x86)"')) ? "386" : "amd64"
else
let uname = system("uname -a")
for sys in ["darwin", "linux", "freebsd", "netbsd", "openbsd"]
if uname =~? sys
let os = sys
break
endif
endfor
if uname =~? "64"
let arch = "amd64"
elseif uname =~? "arm"
let arch = "arm"
else
let arch = "386"
endif
endif
if empty(os) || empty(arch)
return ""
endif
return join(["file_engine", os, arch], "_")
endfunction
call s:init()
function! ctrlspace#context#PluginFolder()
return s:pluginFolder
endfunction
function! ctrlspace#context#Separator()
return "|CS_###_CS|"
endfunction
function! ctrlspace#context#PluginBuffer()
return s:pluginBuffer
endfunction
function! ctrlspace#context#SetPluginBuffer(value)
let s:pluginBuffer = a:value
return s:pluginBuffer
endfunction
function! ctrlspace#context#SymbolSizes()
return s:symbolSizes
endfunction
function! ctrlspace#context#Configuration()
return s:conf
endfunction