mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 17:40:06 +08:00
Add file search option (#4245)
This commit is contained in:
parent
64b9909276
commit
2dd0f66ec1
@ -173,6 +173,18 @@ let g:spacevim_enable_guicolors = 0
|
||||
" <
|
||||
let g:spacevim_escape_key_binding = 'jk'
|
||||
|
||||
""
|
||||
" @section file_searching_tools, options-file_searching_tools
|
||||
" @parentsection options
|
||||
" Set the default file searching tool used by `SPC f /`, by default it is `[]`.
|
||||
" The first item in this list is the name of the tool, the second one is the
|
||||
" default command. for example:
|
||||
" >
|
||||
" file_searching_tools = ['find', 'find -not -iwholename "*.git*" ']
|
||||
" <
|
||||
|
||||
let g:spacevim_file_searching_tools = []
|
||||
|
||||
""
|
||||
" @section enable_googlesuggest, options-enable_googlesuggest
|
||||
" @parentsection options
|
||||
|
@ -17,13 +17,17 @@ let s:FILE = SpaceVim#api#import('file')
|
||||
"}}}
|
||||
|
||||
|
||||
let s:support_tools = ['find', 'fd']
|
||||
let s:default_cmd = {
|
||||
let s:file_searching_commands = {
|
||||
\ 'find' : 'find -not -iwholename "*.git*" ',
|
||||
\ 'fd' : 'fd',
|
||||
\ }
|
||||
let s:current_tool = 'find'
|
||||
let s:MPT._prompt.mpt = ' ' . s:default_cmd[s:current_tool] . ' '
|
||||
if !empty(g:spacevim_file_searching_tools)
|
||||
call extend(s:file_searching_commands, {g:spacevim_file_searching_tools[0] : g:spacevim_file_searching_tools[1]})
|
||||
let s:current_tool = g:spacevim_file_searching_tools[0]
|
||||
else
|
||||
let s:current_tool = 'find'
|
||||
endif
|
||||
let s:MPT._prompt.mpt = ' ' . s:file_searching_commands[s:current_tool] . ' '
|
||||
let s:options = {}
|
||||
let s:second_option = {}
|
||||
let s:options.find = {
|
||||
@ -119,11 +123,7 @@ let s:second_option.fd = {
|
||||
\ }
|
||||
|
||||
function! s:start_find() abort
|
||||
if s:current_tool ==# 'find'
|
||||
let cmd = s:default_cmd[s:current_tool] . ' ' . s:MPT._prompt.begin . s:MPT._prompt.cursor . s:MPT._prompt.end
|
||||
elseif s:current_tool ==# 'fd'
|
||||
let cmd = s:default_cmd[s:current_tool] . ' ' . s:MPT._prompt.begin . s:MPT._prompt.cursor . s:MPT._prompt.end
|
||||
endif
|
||||
let cmd = s:file_searching_commands[s:current_tool] . ' ' . s:MPT._prompt.begin . s:MPT._prompt.cursor . s:MPT._prompt.end
|
||||
let s:MPT._quit = 1
|
||||
call s:MPT._clear_prompt()
|
||||
call s:close_buffer()
|
||||
@ -210,7 +210,7 @@ function! s:switch_tool() abort
|
||||
let s:MPT._prompt.begin = ''
|
||||
let s:MPT._prompt.cursor = ''
|
||||
let s:MPT._prompt.end = ''
|
||||
let s:MPT._prompt.mpt = ' ' . s:default_cmd[s:current_tool] . ' '
|
||||
let s:MPT._prompt.mpt = ' ' . s:file_searching_commands[s:current_tool] . ' '
|
||||
redraw
|
||||
call s:MPT._build_prompt()
|
||||
endfunction
|
||||
@ -227,13 +227,16 @@ function! s:handle_command_line(cmd) abort
|
||||
return
|
||||
endif
|
||||
let argv = split(s:MPT._prompt.begin)[-1]
|
||||
if s:MPT._prompt.begin[-1:] ==# ' ' && has_key(s:second_option[s:current_tool], argv)
|
||||
if s:MPT._prompt.begin[-1:] ==# ' '
|
||||
\ && has_key(s:second_option, s:current_tool)
|
||||
\ && has_key(s:second_option[s:current_tool], argv)
|
||||
let line = []
|
||||
for item in items(s:second_option[s:current_tool][argv])
|
||||
call add(line, ' ' . item[0] . repeat(' ', 8 - len(item[0])) . item[1])
|
||||
endfor
|
||||
call setline(1, line)
|
||||
elseif argv =~# '^-[a-zA-Z0-1]*'
|
||||
\ && has_key(s:options, s:current_tool)
|
||||
let argvs = filter(deepcopy(s:options[s:current_tool]), 'v:key =~ argv')
|
||||
let line = []
|
||||
for item in items(argvs)
|
||||
|
@ -43,41 +43,42 @@ CONTENTS *SpaceVim-contents*
|
||||
23. enable_ycm.............................|SpaceVim-options-enable_ycm|
|
||||
24. error_symbol.........................|SpaceVim-options-error_symbol|
|
||||
25. escape_key_binding.............|SpaceVim-options-escape_key_binding|
|
||||
26. filemanager...........................|SpaceVim-options-filemanager|
|
||||
27. filetree_direction.............|SpaceVim-options-filetree_direction|
|
||||
28. guifont...................................|SpaceVim-options-guifont|
|
||||
29. home_files_number...............|SpaceVim-options-home_files_number|
|
||||
30. info_symbol...........................|SpaceVim-options-info_symbol|
|
||||
31. keep_server_alive...............|SpaceVim-options-keep_server_alive|
|
||||
32. language.................................|SpaceVim-options-language|
|
||||
33. lint_engine...........................|SpaceVim-options-lint_engine|
|
||||
34. lint_on_the_fly...................|SpaceVim-options-lint_on_the_fly|
|
||||
35. max_column.............................|SpaceVim-options-max_column|
|
||||
36. plugin_bundle_dir...............|SpaceVim-options-plugin_bundle_dir|
|
||||
37. plugin_manager_processes.|SpaceVim-options-plugin_manager_processes|
|
||||
38. project_rooter_automatically
|
||||
26. file_searching_tools.........|SpaceVim-options-file_searching_tools|
|
||||
27. filemanager...........................|SpaceVim-options-filemanager|
|
||||
28. filetree_direction.............|SpaceVim-options-filetree_direction|
|
||||
29. guifont...................................|SpaceVim-options-guifont|
|
||||
30. home_files_number...............|SpaceVim-options-home_files_number|
|
||||
31. info_symbol...........................|SpaceVim-options-info_symbol|
|
||||
32. keep_server_alive...............|SpaceVim-options-keep_server_alive|
|
||||
33. language.................................|SpaceVim-options-language|
|
||||
34. lint_engine...........................|SpaceVim-options-lint_engine|
|
||||
35. lint_on_the_fly...................|SpaceVim-options-lint_on_the_fly|
|
||||
36. max_column.............................|SpaceVim-options-max_column|
|
||||
37. plugin_bundle_dir...............|SpaceVim-options-plugin_bundle_dir|
|
||||
38. plugin_manager_processes.|SpaceVim-options-plugin_manager_processes|
|
||||
39. project_rooter_automatically
|
||||
...............................|SpaceVim-options-project_rooter_automatically|
|
||||
39. project_rooter_outermost.|SpaceVim-options-project_rooter_outermost|
|
||||
40. project_rooter_patterns...|SpaceVim-options-project_rooter_patterns|
|
||||
41. projects_cache_num.............|SpaceVim-options-projects_cache_num|
|
||||
42. realtime_leader_guide.......|SpaceVim-options-realtime_leader_guide|
|
||||
43. relativenumber.....................|SpaceVim-options-relativenumber|
|
||||
44. retry_cnt...............................|SpaceVim-options-retry_cnt|
|
||||
45. search_tools.........................|SpaceVim-options-search_tools|
|
||||
46. sidebar_width.......................|SpaceVim-options-sidebar_width|
|
||||
47. snippet_engine.....................|SpaceVim-options-snippet_engine|
|
||||
48. statusline_iseparator.......|SpaceVim-options-statusline_iseparator|
|
||||
49. statusline_left_sections.|SpaceVim-options-statusline_left_sections|
|
||||
50. statusline_separator.........|SpaceVim-options-statusline_separator|
|
||||
51. statusline_unicode_symbols
|
||||
40. project_rooter_outermost.|SpaceVim-options-project_rooter_outermost|
|
||||
41. project_rooter_patterns...|SpaceVim-options-project_rooter_patterns|
|
||||
42. projects_cache_num.............|SpaceVim-options-projects_cache_num|
|
||||
43. realtime_leader_guide.......|SpaceVim-options-realtime_leader_guide|
|
||||
44. relativenumber.....................|SpaceVim-options-relativenumber|
|
||||
45. retry_cnt...............................|SpaceVim-options-retry_cnt|
|
||||
46. search_tools.........................|SpaceVim-options-search_tools|
|
||||
47. sidebar_width.......................|SpaceVim-options-sidebar_width|
|
||||
48. snippet_engine.....................|SpaceVim-options-snippet_engine|
|
||||
49. statusline_iseparator.......|SpaceVim-options-statusline_iseparator|
|
||||
50. statusline_left_sections.|SpaceVim-options-statusline_left_sections|
|
||||
51. statusline_separator.........|SpaceVim-options-statusline_separator|
|
||||
52. statusline_unicode_symbols
|
||||
.................................|SpaceVim-options-statusline_unicode_symbols|
|
||||
52. terminal_cursor_shape.......|SpaceVim-options-terminal_cursor_shape|
|
||||
53. vim_help_language...............|SpaceVim-options-vim_help_language|
|
||||
54. vimcompatible.......................|SpaceVim-options-vimcompatible|
|
||||
55. warning_symbol.....................|SpaceVim-options-warning_symbol|
|
||||
56. windows_index_type.............|SpaceVim-options-windows_index_type|
|
||||
57. windows_leader.....................|SpaceVim-options-windows_leader|
|
||||
58. windows_smartclose.............|SpaceVim-options-windows_smartclose|
|
||||
53. terminal_cursor_shape.......|SpaceVim-options-terminal_cursor_shape|
|
||||
54. vim_help_language...............|SpaceVim-options-vim_help_language|
|
||||
55. vimcompatible.......................|SpaceVim-options-vimcompatible|
|
||||
56. warning_symbol.....................|SpaceVim-options-warning_symbol|
|
||||
57. windows_index_type.............|SpaceVim-options-windows_index_type|
|
||||
58. windows_leader.....................|SpaceVim-options-windows_leader|
|
||||
59. windows_smartclose.............|SpaceVim-options-windows_smartclose|
|
||||
3. Configuration...........................................|SpaceVim-config|
|
||||
4. Commands..............................................|SpaceVim-commands|
|
||||
5. Functions............................................|SpaceVim-functions|
|
||||
@ -440,6 +441,16 @@ to disable this key binding, set this option to empty string.
|
||||
escape_key_binding = 'jk'
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
FILE_SEARCHING_TOOLS *SpaceVim-options-file_searching_tools*
|
||||
|
||||
Set the default file searching tool used by `SPC f /`, by default it is `[]`.
|
||||
The first item in this list is the name of the tool, the second one is the
|
||||
default command. for example:
|
||||
>
|
||||
file_searching_tools = ['find', 'find -not -iwholename "*.git*" ']
|
||||
<
|
||||
|
||||
==============================================================================
|
||||
FILEMANAGER *SpaceVim-options-filemanager*
|
||||
|
||||
|
@ -1409,6 +1409,17 @@ By default, `find` is the default tool, you can use `ctrl-e` to switch tools.
|
||||
|
||||
![find](https://user-images.githubusercontent.com/13142418/97999590-79717000-1e26-11eb-91b1-458ab30d6254.gif)
|
||||
|
||||
To change the default file searching tool, you can use `file_searching_tools` option.
|
||||
It is `[]` by default.
|
||||
|
||||
```toml
|
||||
[options]
|
||||
file_searching_tools = ['find', 'find -not -iwholename "*.git*" ']
|
||||
```
|
||||
|
||||
The first item is the name of the tool, the second one is the default searching command.
|
||||
|
||||
|
||||
#### Vim and SpaceVim files
|
||||
|
||||
Convenient key bindings are located under the prefix `SPC f v` to quickly navigate between Vim and SpaceVim specific files.
|
||||
|
Loading…
Reference in New Issue
Block a user