1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 05:20:04 +08:00

Add dir support

This commit is contained in:
wsdjeg 2018-01-22 19:40:32 +08:00
parent 8896c319b8
commit 7f4da473b4
2 changed files with 8 additions and 1 deletions

View File

@ -170,7 +170,7 @@ function! SpaceVim#mapping#space#init() abort
" Searching in current buffer
call SpaceVim#mapping#space#def('nnoremap', ['s', 's'], "call SpaceVim#plugins#flygrep#open({'input' : input(\"grep pattern:\"), 'files': bufname(\"%\")})",
\ 'grep in current buffer', 1)
call SpaceVim#mapping#space#def('nnoremap', ['s', 'S'], "execute 'Unite grep:%::' . expand(\"<cword>\") . ' -start-insert'",
call SpaceVim#mapping#space#def('nnoremap', ['s', 'S'], "call SpaceVim#plugins#flygrep#open({'input' : expand(\"<cword>\"), 'files': bufname(\"%\")})",
\ 'grep cursor word in current buffer', 1)
" Searching in all loaded buffers
call SpaceVim#mapping#space#def('nnoremap', ['s', 'b'], "call SpaceVim#plugins#flygrep#open({'input' : input(\"grep pattern:\"), 'files':'@buffers'})",

View File

@ -7,6 +7,7 @@ let s:MPT._prompt.mpt = '➭ '
" keys:
" files: files for grep, @buffers means listed buffer.
" dir: specific a directory for grep
function! SpaceVim#plugins#flygrep#open(agrv) abort
rightbelow split __flygrep__
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell nonu norelativenumber
@ -24,6 +25,12 @@ function! SpaceVim#plugins#flygrep#open(agrv) abort
else
let s:grep_files = ''
endif
let dir = get(a:agrv, 'dir', '')
if !empty(dir) && isdirectory(dir)
let s:grep_dir = dir
else
let s:grep_dir = ''
endif
call s:MPT.open()
let &t_ve = save_tve
endfunction