Closed Murlocks closed 8 years ago
Thanks for your idea. I will try to implement but the current implementation is too complex to expose. It needs to refactor.
+1
Hi.
I have added lexima#expand()
function.
You can use it like below.
inoremap <expr> <CR> someCondition() ? yourMapping() : lexima#expand('<CR>', 'i')
Add this code after lexima#add_rule()
.
Please try it!
Does not work in my setup, here's my modified vimrc (Line 465) for reference.
Let me know, if I can be of help somehow.
Sorry I can not reproduce it.
Please send me the result of :imap
.
@cohama
Sorry, just recalled that I might have to disable automappings for <cr>
. Am I right?
Here's the :imap
output
i <Esc> *@<C-R>=lexima#insmode#escape()<CR><Esc>
i <Plug>(neocomplete_auto_refresh) * <C-R>=neocomplete#mappings#refresh()<CR>
i <Plug>(neocomplete_start_manual_complete) * <C-R>=neocomplete#mappings#manual_complete()<CR>
i <Plug>(neocomplete_start_auto_complete) * <C-R>=neocomplete#mappings#auto_complete()<CR>
i <Plug>(neocomplete_start_omni_complete) * <C-X><C-O>
i <Plug>(neocomplete_start_unite_quick_match) * unite#sources#neocomplete#start_quick_match()
i <Plug>(neocomplete_start_unite_complete) * unite#sources#neocomplete#start_complete()
i <Plug>(neosnippet_start_unite_snippet) * unite#sources#neosnippet#start_complete()
i <Plug>(neosnippet_jump) * neosnippet#mappings#jump_impl()
i <Plug>(neosnippet_expand) * neosnippet#mappings#expand_impl()
i <Plug>(neosnippet_jump_or_expand) * neosnippet#mappings#jump_or_expand_impl()
i <Plug>(neosnippet_expand_or_jump) * neosnippet#mappings#expand_or_jump_impl()
i <Plug>ISurround * <C-R>=<SNR>47_insert(1)<CR>
i <Plug>Isurround * <C-R>=<SNR>47_insert()<CR>
i <BS> * lexima#expand('<BS>', 'i')
i <Plug>(EasyAlign) * <C-O>:<C-U>call <SNR>2_lod_map('<Plug>(EasyAlign)', ['vim-easy-align'], "")<CR>
! <D-v> <C-R>*
i <C-G>S <Plug>ISurround
i <C-G>s <Plug>Isurround
i <C-G> * neocomplete#undo_completion()
i <Tab> pumvisible() ? "\<C-N>" : neosnippet#jumpable() ? "\<Plug>(neosnippet_jump)" : "\<Tab>"
i <C-L> * neocomplete#complete_common_string()
i <CR> * lexima#expand('<CR>', 'i')
i <C-S> <Plug>Isurround
i <Esc><Esc> * <Esc>
i <Esc> * pumvisible() ? neocomplete#cancel_popup() : "\<Esc>"
i <Space> * lexima#expand('<SPACE>', 'i')
i " * lexima#expand('"', 'i')
i ' * lexima#expand('''', 'i')
i ( * lexima#expand('(', 'i')
i ) * lexima#expand(')', 'i')
i [ * lexima#expand('[', 'i')
i ] * lexima#expand(']', 'i')
i ` * lexima#expand('`', 'i')
i { * lexima#expand('{', 'i')
i } * lexima#expand('}', 'i')
I made two mistakes.
1) I could not handle plugin load order.
If you add your vimrc imap <CR>...
but lexima will be loaded after the vimrc and overrides it. I will fix this but you can use a workaround as below.
" insert this line above imap
call lexima#init()
2) I missed the example.
It is necessary to escape '<'
to recognize '<CR>'
as 4 characters.
inoremap <expr> <CR> someCondition() ? yourMapping() : lexima#expand('<LT>CR>', 'i')
Works just fine. Thanks @cohama
A very late thank you!
I would love to have access to the function, and an option to disable the default auto mapping.
Here is the use case I am thinking of: A multipurpose functiono that routes to the proper call based on neocomplete popup, selected snippet, or default, lexima .