From 8e7e62a988d6003f5b862209279cf1e5927998d2 Mon Sep 17 00:00:00 2001 From: Shidong Wang Date: Sun, 9 Dec 2018 10:04:55 +0800 Subject: [PATCH] Add find and dir support --- autoload/zvim/util.vim | 2 +- config/plugins/ctrlp.vim | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/autoload/zvim/util.vim b/autoload/zvim/util.vim index bdb356a5a..2cd544656 100644 --- a/autoload/zvim/util.vim +++ b/autoload/zvim/util.vim @@ -263,7 +263,7 @@ fu! zvim#util#Generate_ignore(ignore,tool, ...) abort elseif a:tool ==# 'rg' for ig in split(a:ignore,',') call add(ignore, '-g') - if a:0 > 0 + if get(a:000, 0, 0) == 1 call add(ignore, "'!" . ig . "'") else call add(ignore, '!' . ig) diff --git a/config/plugins/ctrlp.vim b/config/plugins/ctrlp.vim index 1ac28136b..36f8495fa 100644 --- a/config/plugins/ctrlp.vim +++ b/config/plugins/ctrlp.vim @@ -1,3 +1,5 @@ +let s:SYS = SpaceVim#api#import('system') + let g:ctrlp_map = get(g:,'ctrlp_map', '') let g:ctrlp_cmd = get(g:, 'ctrlp_cmd', 'CtrlP') let g:ctrlp_working_path_mode = get(g:, 'ctrlp_working_path_mode', 'ra') @@ -18,9 +20,15 @@ let g:ctrlp_custom_ignore = get(g:, 'ctrlp_custom_ignore', { \ }) if executable('rg') && !exists('g:ctrlp_user_command') let g:ctrlp_user_command = 'rg %s --no-ignore --hidden --files -g "" ' - \ . join(zvim#util#Generate_ignore(get(g:, 'spacevim_wildignore', ''),'rg')) + \ . join(zvim#util#Generate_ignore(get(g:, 'spacevim_wildignore', ''),'rg', SpaceVim#api#import('system').isWindows ? 0 : 1)) elseif executable('ag') && !exists('g:ctrlp_user_command') let g:ctrlp_user_command = 'ag --hidden -i -g "" ' . join(zvim#util#Generate_ignore(g:spacevim_wildignore,'ag')) . ' %s' +elseif s:SYS.isWindows + let g:ctrlp_user_command = + \ 'dir %s /-n /b /s /a-d | findstr /v /l ".jpg \\tmp\\"' " Windows +else + let g:ctrlp_user_command = + \ 'find %s -type f | grep -v -P "\.jpg$|/tmp/"' " MacOSX/Linux endif if !exists('g:ctrlp_match_func') && (has('python') || has('python3')) let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch' }