mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 05:30:05 +08:00
Add findstr support for flygrep (#2344)
* Add findstr support for flygrep * Add key binding for findstr * Simple support * Update doc * Update wiki
This commit is contained in:
parent
8893d9bebf
commit
83d13ea59c
@ -618,7 +618,10 @@ let g:spacevim_enable_powerline_fonts = 1
|
|||||||
" let g:spacevim_lint_on_save = 0
|
" let g:spacevim_lint_on_save = 0
|
||||||
" <
|
" <
|
||||||
let g:spacevim_lint_on_save = 1
|
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
|
" Set the project rooter patterns, by default it is
|
||||||
" `['.git/', '_darcs/', '.hg/', '.bzr/', '.svn/']`
|
" `['.git/', '_darcs/', '.hg/', '.bzr/', '.svn/']`
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
" License: GPLv3
|
" 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 = {}
|
||||||
let s:search_tools.namespace = {
|
let s:search_tools.namespace = {
|
||||||
\ 'rg' : 'r',
|
\ 'rg' : 'r',
|
||||||
@ -13,6 +18,7 @@ let s:search_tools.namespace = {
|
|||||||
\ 'pt' : 't',
|
\ 'pt' : 't',
|
||||||
\ 'ack' : 'k',
|
\ 'ack' : 'k',
|
||||||
\ 'grep' : 'g',
|
\ 'grep' : 'g',
|
||||||
|
\ 'findstr' : 'i',
|
||||||
\ }
|
\ }
|
||||||
let s:search_tools.a = {}
|
let s:search_tools.a = {}
|
||||||
let s:search_tools.a.command = 'ag'
|
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.smart_case = []
|
||||||
let s:search_tools.g.ignore_case = ['-i']
|
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
|
function! SpaceVim#mapping#search#grep(key, scope) abort
|
||||||
let cmd = s:search_tools[a:key]['command']
|
let cmd = s:search_tools[a:key]['command']
|
||||||
let opt = s:search_tools[a:key]['default_opts']
|
let opt = s:search_tools[a:key]['default_opts']
|
||||||
|
@ -273,6 +273,26 @@ function! SpaceVim#mapping#space#init() abort
|
|||||||
\ 'Background search cursor words in project with rg', 1)
|
\ 'Background search cursor words in project with rg', 1)
|
||||||
call SpaceVim#mapping#space#def('nnoremap', ['s', 'r', 'J'], 'call SpaceVim#plugins#searcher#find(expand("<cword>"), "rg")',
|
call SpaceVim#mapping#space#def('nnoremap', ['s', 'r', 'J'], 'call SpaceVim#plugins#searcher#find(expand("<cword>"), "rg")',
|
||||||
\ 'Background search cursor words in project with rg', 1)
|
\ '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("<cword>"), "findstr")',
|
||||||
|
\ 'Background search cursor words in project with findstr', 1)
|
||||||
" pt
|
" pt
|
||||||
let g:_spacevim_mappings_space.s.t = {'name' : '+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)
|
call SpaceVim#mapping#space#def('nnoremap', ['s', 't', 'b'], 'call SpaceVim#mapping#search#grep("t", "b")', 'search in all buffers with pt', 1)
|
||||||
|
@ -68,7 +68,11 @@ function! s:get_search_cmd(expr) abort
|
|||||||
elseif !empty(s:grep_files) && type(s:grep_files) == 1
|
elseif !empty(s:grep_files) && type(s:grep_files) == 1
|
||||||
let cmd += [a:expr] + [s:grep_files]
|
let cmd += [a:expr] + [s:grep_files]
|
||||||
elseif !empty(s:grep_dir)
|
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
|
else
|
||||||
let cmd += [a:expr] + s:grep_ropt
|
let cmd += [a:expr] + s:grep_ropt
|
||||||
endif
|
endif
|
||||||
@ -535,6 +539,11 @@ function! SpaceVim#plugins#flygrep#open(agrv) abort
|
|||||||
let s:grep_dir = ''
|
let s:grep_dir = ''
|
||||||
endif
|
endif
|
||||||
let s:grep_exe = get(a:agrv, 'cmd', s:grep_default_exe)
|
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_opt = get(a:agrv, 'opt', s:grep_default_opt)
|
||||||
let s:grep_ropt = get(a:agrv, 'ropt', s:grep_default_ropt)
|
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)
|
let s:grep_ignore_case = get(a:agrv, 'ignore_case', s:grep_default_ignore_case)
|
||||||
|
@ -10,7 +10,8 @@
|
|||||||
- Add layer option for autocomplete layer ([#2236](https://github.com/SpaceVim/SpaceVim/pull/2236))
|
- 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 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 `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))
|
||||||
|
|
||||||
### 功能改进
|
### 功能改进
|
||||||
|
|
||||||
|
@ -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 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 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 `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
|
### Improvement
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user