Skip to content

Commit

Permalink
Add project search mode (#39)
Browse files Browse the repository at this point in the history
This is the initial implementation, so should be refactored
  • Loading branch information
tacahiroy committed Oct 13, 2015
1 parent df6dc6c commit b7a7250
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions autoload/ctrlp/funky.vim
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,21 @@ endfunction
function! s:uniq(list)
return exists('*uniq') ? uniq(a:list) : a:list
endfunction

" Open files
function! s:project_files()
let bufs = []
for f in ctrlp#files()
if bufexists(f)
call add(bufs, bufnr(f))
elseif filereadable(f)
silent! execute 'edit ' . f
call add(bufs, bufnr(f))
endif
endfor

return bufs
endfunction
" }}}

" Provides a list of strings to search in
Expand All @@ -209,6 +224,11 @@ function! ctrlp#funky#init(bufnr)
execute bufwinnr(a:bufnr) . 'wincmd w'
let pos = getpos('.')

" TODO: Need to fix priority for options
if s:is_project
let bufs = s:project_files()
endif

if s:is_multi_buffers
let bufs = map(ctrlp#buffers(), 'bufnr(v:val)')
else
Expand Down Expand Up @@ -413,6 +433,7 @@ let s:errmsg = ''
let s:custom_hl_list = {}

let s:is_multi_buffers = get(g:, 'ctrlp_funky_multi_buffers', 0)
let s:is_project = get(g:, 'ctrlp_funky_project_search', 1)

let s:report_filter_error = get(g:, 'ctrlp_funky_report_filter_error', 0)
let s:sort_by_mru = get(g:, 'ctrlp_funky_sort_by_mru', 0)
Expand All @@ -436,6 +457,7 @@ let s:use_cache = s:cache.is_enabled()

call s:fu.debug('INFO: use_cache? ' . (s:use_cache ? 'TRUE' : 'FALSE'))
call s:fu.debug('INFO: mutli_buffers? ' . (s:is_multi_buffers ? 'TRUE' : 'FALSE'))
call s:fu.debug('INFO: project_search? ' . (s:is_project ? 'TRUE' : 'FALSE'))

" The main variable for this extension.
"
Expand Down

0 comments on commit b7a7250

Please sign in to comment.