diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 9dc615d61..b78cdea66 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -618,7 +618,10 @@ let g:spacevim_enable_powerline_fonts = 1 " let g:spacevim_lint_on_save = 0 " < let g:spacevim_lint_on_save = 1 -let g:spacevim_search_tools = ['rg', 'ag', 'pt', 'ack', 'grep'] +"" +" Default search tools supported by flygrep. The default order is ['rg', 'ag', +" 'pt', 'ack', 'grep', 'findstr'] +let g:spacevim_search_tools = ['rg', 'ag', 'pt', 'ack', 'grep', 'findstr'] "" " Set the project rooter patterns, by default it is " `['.git/', '_darcs/', '.hg/', '.bzr/', '.svn/']` diff --git a/autoload/SpaceVim/mapping/search.vim b/autoload/SpaceVim/mapping/search.vim index 01e79e310..ee5b93f3a 100644 --- a/autoload/SpaceVim/mapping/search.vim +++ b/autoload/SpaceVim/mapping/search.vim @@ -6,6 +6,11 @@ " License: GPLv3 "============================================================================= +" How to add new search tools? +" +" first, namespace should avoid b d f j p B D F J P +" then, the exist namespace should be avoid too + let s:search_tools = {} let s:search_tools.namespace = { \ 'rg' : 'r', @@ -13,6 +18,7 @@ let s:search_tools.namespace = { \ 'pt' : 't', \ 'ack' : 'k', \ 'grep' : 'g', + \ 'findstr' : 'i', \ } let s:search_tools.a = {} let s:search_tools.a.command = 'ag' @@ -71,6 +77,16 @@ let s:search_tools.g.default_fopts = [] let s:search_tools.g.smart_case = [] let s:search_tools.g.ignore_case = ['-i'] +let s:search_tools.i = {} +let s:search_tools.i.command = 'findstr' +let s:search_tools.i.default_opts = ['/RSN'] +let s:search_tools.i.recursive_opt = [] +let s:search_tools.i.expr_opt = [] +let s:search_tools.i.fixed_string_opt = [] +let s:search_tools.i.default_fopts = [] +let s:search_tools.i.smart_case = [] +let s:search_tools.i.ignore_case = ['/I'] + function! SpaceVim#mapping#search#grep(key, scope) abort let cmd = s:search_tools[a:key]['command'] let opt = s:search_tools[a:key]['default_opts'] diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 9c6dbd981..4d002a450 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -273,6 +273,26 @@ function! SpaceVim#mapping#space#init() abort \ 'Background search cursor words in project with rg', 1) call SpaceVim#mapping#space#def('nnoremap', ['s', 'r', 'J'], 'call SpaceVim#plugins#searcher#find(expand(""), "rg")', \ 'Background search cursor words in project with rg', 1) + + " findstr + let g:_spacevim_mappings_space.s.i = {'name' : '+findstr'} + call SpaceVim#mapping#space#def('nnoremap', ['s', 'i', 'b'], 'call SpaceVim#mapping#search#grep("i", "b")', 'search in all buffers with findstr', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'i', 'B'], 'call SpaceVim#mapping#search#grep("i", "B")', + \ 'search cursor word in all buffers with findstr', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'i', 'd'], 'call SpaceVim#mapping#search#grep("i", "d")', 'search in buffer directory with findstr', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'i', 'D'], 'call SpaceVim#mapping#search#grep("i", "D")', + \ 'search cursor word in buffer directory with findstr', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'i', 'p'], 'call SpaceVim#mapping#search#grep("i", "p")', 'search in project with findstr', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'i', 'P'], 'call SpaceVim#mapping#search#grep("i", "P")', + \ 'search cursor word in project with findstr', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'i', 'f'], 'call SpaceVim#mapping#search#grep("i", "f")', + \ 'search in arbitrary directory with findstr', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'i', 'F'], 'call SpaceVim#mapping#search#grep("i", "F")', + \ 'search cursor word in arbitrary directory with findstr', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'i', 'j'], 'call SpaceVim#plugins#searcher#find("", "findstr")', + \ 'Background search cursor words in project with findstr', 1) + call SpaceVim#mapping#space#def('nnoremap', ['s', 'i', 'J'], 'call SpaceVim#plugins#searcher#find(expand(""), "findstr")', + \ 'Background search cursor words in project with findstr', 1) " pt let g:_spacevim_mappings_space.s.t = {'name' : '+pt'} call SpaceVim#mapping#space#def('nnoremap', ['s', 't', 'b'], 'call SpaceVim#mapping#search#grep("t", "b")', 'search in all buffers with pt', 1) diff --git a/autoload/SpaceVim/plugins/flygrep.vim b/autoload/SpaceVim/plugins/flygrep.vim index 0412a2156..3e46abf0d 100644 --- a/autoload/SpaceVim/plugins/flygrep.vim +++ b/autoload/SpaceVim/plugins/flygrep.vim @@ -68,7 +68,11 @@ function! s:get_search_cmd(expr) abort elseif !empty(s:grep_files) && type(s:grep_files) == 1 let cmd += [a:expr] + [s:grep_files] elseif !empty(s:grep_dir) - let cmd += [a:expr] + [s:grep_dir] + if s:grep_exe == 'findstr' + let cmd += [s:grep_dir] + [a:expr] + ['%CD%\*'] + else + let cmd += [a:expr] + [s:grep_dir] + endif else let cmd += [a:expr] + s:grep_ropt endif @@ -535,6 +539,11 @@ function! SpaceVim#plugins#flygrep#open(agrv) abort let s:grep_dir = '' endif let s:grep_exe = get(a:agrv, 'cmd', s:grep_default_exe) + if empty(s:grep_dir) && empty(s:grep_files) && s:grep_exe == 'findstr' + let s:grep_files = '*.*' + elseif s:grep_exe == 'findstr' && !empty(s:grep_dir) + let s:grep_dir = '/D:' . s:grep_dir + endif let s:grep_opt = get(a:agrv, 'opt', s:grep_default_opt) let s:grep_ropt = get(a:agrv, 'ropt', s:grep_default_ropt) let s:grep_ignore_case = get(a:agrv, 'ignore_case', s:grep_default_ignore_case) diff --git a/wiki/cn/Following-HEAD.md b/wiki/cn/Following-HEAD.md index d2a281e13..3a3b370bc 100644 --- a/wiki/cn/Following-HEAD.md +++ b/wiki/cn/Following-HEAD.md @@ -10,7 +10,8 @@ - Add layer option for autocomplete layer ([#2236](https://github.com/SpaceVim/SpaceVim/pull/2236)) - Add function for customizing searching tools ([#2235](https://github.com/SpaceVim/SpaceVim/pull/2235)) - Add `lang#scheme` layer ([#2248](https://github.com/SpaceVim/SpaceVim/pull/2248)) -- Add log for bootstrap function ([#2248](https://github.com/SpaceVim/SpaceVim/pull/2323)) +- Add log for bootstrap function ([#2232](https://github.com/SpaceVim/SpaceVim/pull/2323)) +- Add findstr support in flygrep ([#2344](https://github.com/SpaceVim/SpaceVim/pull/2344)) ### 功能改进 diff --git a/wiki/en/Following-HEAD.md b/wiki/en/Following-HEAD.md index d56f6729d..8c9276dcc 100644 --- a/wiki/en/Following-HEAD.md +++ b/wiki/en/Following-HEAD.md @@ -10,7 +10,8 @@ The next release is v1.0.0. - Add layer option for autocomplete layer ([#2236](https://github.com/SpaceVim/SpaceVim/pull/2236)) - Add function for customizing searching tools ([#2235](https://github.com/SpaceVim/SpaceVim/pull/2235)) - Add `lang#scheme` layer ([#2248](https://github.com/SpaceVim/SpaceVim/pull/2248)) -- Add log for bootstrap function ([#2248](https://github.com/SpaceVim/SpaceVim/pull/2323)) +- Add log for bootstrap function ([#2232](https://github.com/SpaceVim/SpaceVim/pull/2323)) +- Add findstr support in flygrep ([#2344](https://github.com/SpaceVim/SpaceVim/pull/2344)) ### Improvement