Created
October 5, 2020 14:32
-
-
Save tsuyoshicho/5c82fee4eae38ba5572421e71e243290 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! s:popup_select(rawchar, ...) abort " {{{ | |
| let result = '' | |
| call s:plugin_status_update() | |
| if g:user.plugin.asyncomplete | |
| let result = result . asyncomplete#close_popup() | |
| if a:0 | |
| let result = result . a:1 | |
| endif | |
| else | |
| let result = result . a:rawchar | |
| endif | |
| return result | |
| endfunction " }}} | |
| function! s:popup_cancel(rawchar, ...) abort " {{{ | |
| let result = '' | |
| call s:plugin_status_update() | |
| if g:user.plugin.asyncomplete | |
| let result = result . asyncomplete#cancel_popup() | |
| if a:0 | |
| let result = result . a:1 | |
| endif | |
| else | |
| let result = result . a:rawchar | |
| endif | |
| return result | |
| endfunction " }}} | |
| function! s:insert_char(rawchar, charname) abort " {{{ | |
| let result = '' | |
| call s:plugin_status_update() | |
| if g:user.plugin.lexima | |
| let result = result . lexima#expand(a:charname, 'i') | |
| else | |
| let result = result . a:rawchar | |
| endif | |
| return result | |
| endfunction " }}} | |
| function! s:imap_setup() abort " {{{ | |
| inoremap <expr><silent> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>" | |
| inoremap <expr><silent> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>" | |
| inoremap <expr><silent> <CR> | |
| \ pumvisible() ? <SID>popup_select("\<C-y>" ) : <SID>insert_char("\<CR>", '<' . 'CR' . '>') | |
| inoremap <expr><silent> <Space> | |
| \ pumvisible() ? <SID>popup_cancel("\<C-e>", "\<Space>") : <SID>insert_char("\<Space>", '<' . 'Space' . '>') | |
| inoremap <expr><silent> <C-y> | |
| \ pumvisible() ? <SID>popup_select("\<C-y>" ) : "\<C-y>" | |
| inoremap <expr><silent> <C-e> | |
| \ pumvisible() ? <SID>popup_cancel("\<C-e>" ) : "\<C-e>" | |
| endfunction " }}} | |
| autocmd MyAutoGroup VimEnter * nested call s:imap_setup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment