Skip to content

Commit

Permalink
first import.
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Apr 27, 2012
0 parents commit d1509c5
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
48 changes: 48 additions & 0 deletions autoload/ctrlp/launcher.vim
@@ -0,0 +1,48 @@
if exists('g:loaded_ctrlp_launcher') && g:loaded_ctrlp_launcher
finish
endif
let g:loaded_ctrlp_launcher = 1

let s:launcher_var = {
\ 'init': 'ctrlp#launcher#init()',
\ 'exit': 'ctrlp#launcher#exit()',
\ 'accept': 'ctrlp#launcher#accept',
\ 'lname': 'launcher',
\ 'sname': 'launcher',
\ 'type': 'launcher',
\ 'sort': 0,
\}

if exists('g:ctrlp_ext_vars') && !empty(g:ctrlp_ext_vars)
let g:ctrlp_ext_vars = add(g:ctrlp_ext_vars, s:launcher_var)
else
let g:ctrlp_ext_vars = [s:launcher_var]
endif

function! ctrlp#launcher#init()
let file = fnamemodify(expand('~/.ctrlp-launcher'), ':p')
let s:list = filereadable(file) ? filter(map(readfile(file), 'split(iconv(v:val, "utf-8", &encoding), "\\t\\+")'), 'len(v:val) > 0 && v:val[0]!~"^#"') : []
let g:hoge = s:list
let s:list += [["--edit-menu--", "split ~/.ctrlp-launcher"]]
return map(copy(s:list), 'v:val[0]')
endfunc

function! ctrlp#launcher#accept(mode, str)
let cmd = filter(copy(s:list), 'v:val[0] == a:str')[0][1]
call ctrlp#exit()
redraw!
exe cmd
endfunction

function! ctrlp#launcher#exit()
if exists('s:list')
unlet! s:list
endif
endfunction

let s:id = g:ctrlp_builtins + len(g:ctrlp_ext_vars)
function! ctrlp#launcher#id()
return s:id
endfunction

" vim:fen:fdl=0:ts=2:sw=2:sts=2
1 change: 1 addition & 0 deletions plugin/ctrlp-launcher.vim
@@ -0,0 +1 @@
command! CtrlPLauncher cal ctrlp#init(ctrlp#launcher#id())

0 comments on commit d1509c5

Please sign in to comment.