Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Autocommands for initial inputs #502

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions autoload/EasyMotion/command_line.vim
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@ function! EasyMotion#command_line#GetInput(num_strokes, prev, direction) "{{{
let s:prompt_base = s:getPromptMessage(a:num_strokes)
call s:search.set_prompt(s:prompt_base)

" Invoke autocmd so the user can temporarily hide floating popups, etc.
silent doautocmd User EasyMotionInputBegin

" Screen: cursor position, first and last line
let s:orig_pos = getpos('.')
let s:orig_line_start = getpos('w0')
Expand All @@ -184,6 +187,8 @@ function! EasyMotion#command_line#GetInput(num_strokes, prev, direction) "{{{
let s:save_direction = deepcopy(s:direction)

let input = s:search.get()
silent doautocmd User EasyMotionInputEnd

if input == '' && ! s:search.exit_code()
return a:prev
elseif s:search.exit_code() == 1 || s:search.exit_code() == -1
Expand Down
14 changes: 11 additions & 3 deletions doc/easymotion.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1143,10 +1143,17 @@ and their default values.
------------------------------------------------------------------------------
Autocommands *easymotion-autocommands*
*EasyMotionPromptBegin* *EasyMotionPromptEnd*
*EasyMotionInputBegin* *EasyMotionInputEnd*

EasyMotion invokes two |User| autocommands, |EasyMotionPromptBegin| and
EasyMotion invokes four |User| autocommands, |EasyMotionPromptBegin| and
|EasyMotionPromptEnd|, so you can temporarily disable your linter to avoid
annoying syntax errors.
annoying syntax errors, and |EasyMotionInputBegin| and |EasyMotionInputEnd|,
so you can temporarily hide floating popups and windows that hide buffer text.

EasyMotionInputBegin Before EasyMotion asks for input of characters
(with S/F/T commands).
EasyMotionInputEnd After EasyMotion got the input, or the operation
was cancelled.

EasyMotionPromptBegin Before the content of buffer is changed with
markers. If EasyMotion directly jumps to the
Expand All @@ -1158,7 +1165,8 @@ EasyMotionPromptEnd After the content of buffer and the undo tree are

Example with coc.nvim: >

autocmd User EasyMotionPromptBegin silent! CocDisable
autocmd User EasyMotionInputBegin silent! call coc#float#close_all()
autocmd User EasyMotionPromptBegin silent! CocDisable
autocmd User EasyMotionPromptEnd silent! CocEnable
<

Expand Down