diff --git a/CHANGELOG.md b/CHANGELOG.md index b63c484fe..b6afb3706 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ CHANGELOG ### Added - Add new option `g:clap_insert_mode_only` to disable the feature of other mode, use the insert mode only. ([#335](https://github.com/liuchengxu/vim-clap/pull/335)) +- Add new option `g:clap_providers_relaunch_code`(`@@` default). You can input `@@` or use C-L to invoke `:Clap` to reselect another provider at any time.([#328](https://github.com/liuchengxu/vim-clap/pull/328)) +- Add new keymapping C-L.([#328](https://github.com/liuchengxu/vim-clap/pull/328)) - Now you can use `:Clap grep ++query=@visual` to search the visual selection. ([#336](https://github.com/liuchengxu/vim-clap/pull/336)) ## [0.8] 2020-02-21 diff --git a/README.md b/README.md index 157c8f3d9..5e021b585 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,8 @@ Vim-clap is a modern generic interactive finder and dispatcher, based on the new * [Commands](#commands) * [Global variables](#global-variables) * [Keybindings](#keybindings) + * [Insert mode](#insert-mode) + * [Normal mode](#normal-mode) * [Execute some code during the process](#execute-some-code-during-the-process) * [Change highlights](#change-highlights) * [How to define your own provider](#how-to-define-your-own-provider) @@ -192,6 +194,7 @@ See `:help clap-options` for more information. - Use Tab to expand the directory for `:Clap filer`. - [x] Use Ctrl-t or Ctrl-x, Ctrl-v to open the selected entry in a new tab or a new split. - [x] Use Ctrl-u to clear inputs. +- [x] Use Ctrl-l to launch the whole provider list panel for invoking another provider at any time. #### Normal mode @@ -199,6 +202,7 @@ Normal mode mappings are neovim only now. - [x] Use j/Down or k/Up to navigate the result list up and down linewise. - [x] Use Ctrl-d/Ctrl-u/PageDown/PageUp to scroll the result list down and up. +- [x] Use Ctrl-l to launch the whole provider list panel for invoking another provider at any time. - [x] Use gg and G to scroll to the first and last item. - [x] Use Enter to select the entry and exit. - [x] Actions defined by `g:clap_open_action`. diff --git a/autoload/clap.vim b/autoload/clap.vim index 164499776..f2a321857 100644 --- a/autoload/clap.vim +++ b/autoload/clap.vim @@ -86,6 +86,7 @@ let g:clap_open_action = get(g:, 'clap_open_action', s:default_action) let g:clap_enable_icon = get(g:, 'clap_enable_icon', exists('g:loaded_webdevicons') || get(g:, 'spacevim_nerd_fonts', 0)) let g:clap_insert_mode_only = get(g:, 'clap_insert_mode_only', v:false) +let g:clap_providers_relaunch_code = get(g:, 'clap_providers_relaunch_code', '@@') function! s:inject_default_impl_is_ok(provider_info) abort let provider_info = a:provider_info diff --git a/autoload/clap/floating_win.vim b/autoload/clap/floating_win.vim index 3fc22f96e..463f34e07 100644 --- a/autoload/clap/floating_win.vim +++ b/autoload/clap/floating_win.vim @@ -45,6 +45,9 @@ let s:preview_winhl = 'Normal:ClapPreview,EndOfBuffer:ClapPreviewInvisibleEndOfB " | preview | " ----------------------------- function! g:clap#floating_win#display.open() abort + if exists('s:display_winid') && nvim_win_is_valid(s:display_winid) + return + endif " Check if the buffer is still valid as when switching between the sessions, it could become invalid. if !nvim_buf_is_valid(s:display_bufnr) let s:display_bufnr = nvim_create_buf(v:false, v:true) @@ -122,6 +125,9 @@ function! s:open_win_border_left() abort endfunction function! g:clap#floating_win#spinner.open() abort + if exists('s:spinner_winid') && nvim_win_is_valid(s:spinner_winid) + return + endif let opts = nvim_win_get_config(s:display_winid) let opts.col += s:symbol_width let opts.row -= 1 @@ -163,6 +169,9 @@ function! g:clap#floating_win#spinner.shrink() abort endfunction function! g:clap#floating_win#input.open() abort + if exists('s:input_winid') && nvim_win_is_valid(s:input_winid) + return + endif let opts = nvim_win_get_config(s:spinner_winid) let opts.col += opts.width let opts.width = s:display_opts.width - opts.width - s:symbol_width * 2 - g:__clap_indicator_winwidth diff --git a/autoload/clap/handler.vim b/autoload/clap/handler.vim index 0ae883306..c9bafd5cd 100644 --- a/autoload/clap/handler.vim +++ b/autoload/clap/handler.vim @@ -8,11 +8,30 @@ let s:old_input = '' let s:multi_select_enabled = v:false let s:support_multi_select = v:false +function! clap#handler#relaunch_providers() abort + call clap#handler#exit() + call timer_start(10, { -> clap#for('providers') }) + call g:clap.input.set('') +endfunction + +function! clap#handler#relaunch_is_ok() abort + if g:clap.input.get() ==# g:clap_providers_relaunch_code + call clap#handler#relaunch_providers() + return v:true + endif + return v:false +endfunction + function! clap#handler#on_typed() abort + if clap#handler#relaunch_is_ok() + return + endif + if g:clap.provider.is_rpc_type() call g:clap.provider.on_typed() return endif + let l:cur_input = g:clap.input.get() if s:old_input == l:cur_input return diff --git a/autoload/clap/popup/move_manager.vim b/autoload/clap/popup/move_manager.vim index 866b2c03e..f093775e9 100644 --- a/autoload/clap/popup/move_manager.vim +++ b/autoload/clap/popup/move_manager.vim @@ -39,6 +39,10 @@ function! s:move_manager.ctrl_e(_winid) abort call s:mock_input() endfunction +function! s:move_manager.ctrl_l(_winid) abort + call clap#handler#relaunch_providers() +endfunction + function! s:apply_on_typed() abort if g:clap.provider.is_sync() let g:__clap_should_refilter = v:true @@ -121,6 +125,7 @@ let s:move_manager["\"] = s:move_manager.bs let s:move_manager["\"] = s:move_manager.ctrl_d let s:move_manager["\"] = s:move_manager["\"] let s:move_manager["\"] = s:move_manager.ctrl_u +let s:move_manager["\"] = s:move_manager.ctrl_l function! s:define_open_action_filter() abort for k in keys(g:clap_open_action) @@ -167,6 +172,9 @@ function! s:apply_input(_timer) abort endfunction function! s:apply_input_with_delay() abort + if clap#handler#relaunch_is_ok() + return + endif if s:input_timer != -1 call timer_stop(s:input_timer) endif diff --git a/doc/clap.txt b/doc/clap.txt index e0e271e6a..082d34d68 100644 --- a/doc/clap.txt +++ b/doc/clap.txt @@ -248,6 +248,18 @@ g:clap_insert_mode_only *g:clap_insert_mode_only* to `v:true` . +g:clap_providers_relaunch_code *g:clap_providers_relaunch_code* + + Type: |String| + Default: `'@@'` + + This feature is inspired by VS code command palette prefix-based searching. + You can input `@@` or use `` to invoke `:Clap` to reselect the provider + at any time. Although it does not use the prefix searching, it's more + convient due to the inherent fuzzy matching feature of vim-clap since you + don't have to remember each provider's prefix. + + g:clap_disable_run_rooter *g:clap_disable_run_rooter* Type: |Bool| diff --git a/ftplugin/clap_input.vim b/ftplugin/clap_input.vim index b2da23e18..f4ba912f9 100644 --- a/ftplugin/clap_input.vim +++ b/ftplugin/clap_input.vim @@ -44,6 +44,8 @@ endif inoremap col('.')>strlen(getline('.'))pumvisible()?"\C-E>":"\End>" +inoremap :call clap#handler#relaunch_providers() + inoremap :call clap#handler#sink() inoremap :call clap#handler#exit() inoremap :call clap#handler#exit() @@ -71,6 +73,8 @@ nnoremap :call clap#handler#sink() nnoremap :call clap#handler#exit() nnoremap :call clap#handler#exit() +nnoremap :call clap#handler#relaunch_providers() + nnoremap :call clap#navigation#linewise('down') nnoremap :call clap#navigation#linewise('up')