Mercurial > dotfiles.old
comparison vim/autoload/plug.vim @ 216:d216f4d5508e
Setup latex compiler for dispatch
author | zegervdv <zegervdv@me.com> |
---|---|
date | Tue, 09 Dec 2014 19:51:07 +0100 |
parents | 4e723feac624 |
children | ed108055146c |
comparison
equal
deleted
inserted
replaced
215:ffe47a1b75f8 | 216:d216f4d5508e |
---|---|
81 \ 'list': type([]), | 81 \ 'list': type([]), |
82 \ 'dict': type({}), | 82 \ 'dict': type({}), |
83 \ 'funcref': type(function('call')) | 83 \ 'funcref': type(function('call')) |
84 \ } | 84 \ } |
85 let s:loaded = get(s:, 'loaded', {}) | 85 let s:loaded = get(s:, 'loaded', {}) |
86 let s:triggers = get(s:, 'triggers', {}) | |
86 | 87 |
87 function! plug#begin(...) | 88 function! plug#begin(...) |
88 if a:0 > 0 | 89 if a:0 > 0 |
89 let s:plug_home_org = a:1 | 90 let s:plug_home_org = a:1 |
90 let home = s:path(fnamemodify(expand(a:1), ':p')) | 91 let home = s:path(fnamemodify(expand(a:1), ':p')) |
97 endif | 98 endif |
98 | 99 |
99 let g:plug_home = home | 100 let g:plug_home = home |
100 let g:plugs = {} | 101 let g:plugs = {} |
101 let g:plugs_order = [] | 102 let g:plugs_order = [] |
103 let s:triggers = {} | |
102 | 104 |
103 call s:define_commands() | 105 call s:define_commands() |
104 return 1 | 106 return 1 |
105 endfunction | 107 endfunction |
106 | 108 |
154 let s:loaded[name] = 1 | 156 let s:loaded[name] = 1 |
155 continue | 157 continue |
156 endif | 158 endif |
157 | 159 |
158 if has_key(plug, 'on') | 160 if has_key(plug, 'on') |
161 let s:triggers[name] = { 'map': [], 'cmd': [] } | |
159 for cmd in s:to_a(plug.on) | 162 for cmd in s:to_a(plug.on) |
160 if cmd =~ '^<Plug>.\+' | 163 if cmd =~ '^<Plug>.\+' |
161 if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) | 164 if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) |
162 for [mode, map_prefix, key_prefix] in | 165 for [mode, map_prefix, key_prefix] in |
163 \ [['i', '<C-O>', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] | 166 \ [['i', '<C-O>', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] |
164 execute printf( | 167 execute printf( |
165 \ '%snoremap <silent> %s %s:<C-U>call <SID>lod_map(%s, %s, "%s")<CR>', | 168 \ '%snoremap <silent> %s %s:<C-U>call <SID>lod_map(%s, %s, "%s")<CR>', |
166 \ mode, cmd, map_prefix, string(cmd), string(name), key_prefix) | 169 \ mode, cmd, map_prefix, string(cmd), string(name), key_prefix) |
167 endfor | 170 endfor |
168 endif | 171 endif |
169 elseif !exists(':'.cmd) | 172 call add(s:triggers[name].map, cmd) |
170 execute printf( | 173 elseif cmd =~ '^[A-Z]' |
171 \ 'command! -nargs=* -range -bang %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)', | 174 if exists(':'.cmd) != 2 |
172 \ cmd, string(cmd), string(name)) | 175 execute printf( |
176 \ 'command! -nargs=* -range -bang %s call s:lod_cmd(%s, "<bang>", <line1>, <line2>, <q-args>, %s)', | |
177 \ cmd, string(cmd), string(name)) | |
178 endif | |
179 call add(s:triggers[name].cmd, cmd) | |
173 endif | 180 endif |
174 endfor | 181 endfor |
175 endif | 182 endif |
176 | 183 |
177 if has_key(plug, 'for') | 184 if has_key(plug, 'for') |
322 endfor | 329 endfor |
323 doautocmd BufRead | 330 doautocmd BufRead |
324 return 1 | 331 return 1 |
325 endfunction | 332 endfunction |
326 | 333 |
334 function! s:remove_triggers(name) | |
335 if !has_key(s:triggers, a:name) | |
336 return | |
337 endif | |
338 for cmd in s:triggers[a:name].cmd | |
339 execute 'delc' cmd | |
340 endfor | |
341 for map in s:triggers[a:name].map | |
342 execute 'unmap' map | |
343 execute 'iunmap' map | |
344 endfor | |
345 call remove(s:triggers, a:name) | |
346 endfunction | |
347 | |
327 function! s:lod(names, types) | 348 function! s:lod(names, types) |
328 for name in a:names | 349 for name in a:names |
350 call s:remove_triggers(name) | |
329 let s:loaded[name] = 1 | 351 let s:loaded[name] = 1 |
330 endfor | 352 endfor |
331 call s:reorg_rtp() | 353 call s:reorg_rtp() |
332 | 354 |
333 for name in a:names | 355 for name in a:names |
344 doautocmd filetypeplugin FileType | 366 doautocmd filetypeplugin FileType |
345 doautocmd filetypeindent FileType | 367 doautocmd filetypeindent FileType |
346 endfunction | 368 endfunction |
347 | 369 |
348 function! s:lod_cmd(cmd, bang, l1, l2, args, name) | 370 function! s:lod_cmd(cmd, bang, l1, l2, args, name) |
349 execute 'delc' a:cmd | |
350 call s:lod([a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) | 371 call s:lod([a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) |
351 execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) | 372 execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) |
352 endfunction | 373 endfunction |
353 | 374 |
354 function! s:lod_map(map, name, prefix) | 375 function! s:lod_map(map, name, prefix) |
355 execute 'unmap' a:map | |
356 execute 'iunmap' a:map | |
357 call s:lod([a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) | 376 call s:lod([a:name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) |
358 let extra = '' | 377 let extra = '' |
359 while 1 | 378 while 1 |
360 let c = getchar(0) | 379 let c = getchar(0) |
361 if c == 0 | 380 if c == 0 |
674 | 693 |
675 if !isdirectory(g:plug_home) | 694 if !isdirectory(g:plug_home) |
676 try | 695 try |
677 call mkdir(g:plug_home, 'p') | 696 call mkdir(g:plug_home, 'p') |
678 catch | 697 catch |
679 return s:err(printf('Invalid plug directory: %s.' | 698 return s:err(printf('Invalid plug directory: %s. '. |
680 \ 'Try to call plug#begin with a valid directory', g:plug_home)) | 699 \ 'Try to call plug#begin with a valid directory', g:plug_home)) |
681 endtry | 700 endtry |
682 endif | 701 endif |
683 | 702 |
684 let s:update = { | 703 let s:update = { |
1245 redraw | 1264 redraw |
1246 if empty(todo) | 1265 if empty(todo) |
1247 call append(line('$'), 'Already clean.') | 1266 call append(line('$'), 'Already clean.') |
1248 else | 1267 else |
1249 call inputsave() | 1268 call inputsave() |
1250 let yes = a:force || (input('Proceed? (Y/N) ') =~? '^y') | 1269 let yes = a:force || (input('Proceed? (y/N) ') =~? '^y') |
1251 call inputrestore() | 1270 call inputrestore() |
1252 if yes | 1271 if yes |
1253 for dir in todo | 1272 for dir in todo |
1254 if isdirectory(dir) | 1273 if isdirectory(dir) |
1255 call system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(dir)) | 1274 call system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . s:shellesc(dir)) |
1462 endfunction | 1481 endfunction |
1463 | 1482 |
1464 function! s:revert() | 1483 function! s:revert() |
1465 let name = s:find_name(line('.')) | 1484 let name = s:find_name(line('.')) |
1466 if empty(name) || !has_key(g:plugs, name) || | 1485 if empty(name) || !has_key(g:plugs, name) || |
1467 \ input(printf('Revert the update of %s? (Y/N) ', name)) !~? '^y' | 1486 \ input(printf('Revert the update of %s? (y/N) ', name)) !~? '^y' |
1468 return | 1487 return |
1469 endif | 1488 endif |
1470 | 1489 |
1471 call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch), g:plugs[name].dir) | 1490 call s:system('git reset --hard HEAD@{1} && git checkout '.s:esc(g:plugs[name].branch), g:plugs[name].dir) |
1472 setlocal modifiable | 1491 setlocal modifiable |