Closed Hotschke closed 8 years ago
Sorry, current lexima.vim does not provide such a feature. However there is unofficial (not documented) function to do what you want.
function! Foo() abort
if pumvisible()
return "foo"
else
return ""
endif
endfunction
call lexima#insmode#map_hook('before', '<CR>', "\<C-r>=Foo()\<CR>")
lexima#insmode#map_hook
provides hook point to trigger user-defined mapping before (or after) certain key pressed.
Please note that this fucntion is now experimental and not assured future compatibility.
oh... I have a misunderstanding. You want to disable lexima rule when a specified condition is fullfiled, right?
I'm sorry there is no feature to do this.
I need to implement a new function to expand lexima's mapping Like this?
inoremap <expr> <CR>
\ pumvisible() ?
\ "\<C-r>=lexima#insmode#expand('<lt>CR>')\<CR>" : "ExternalMapping"
" ^ lexima's <CR> rule will be applied ^ lexima does not care
Yes, your second comment describes what I want. Trigger either lexima or something else, not both.
I think your proposal looks good. Is this very difficult to implement?
The developer of neocomplete
Shougo has given a solution for endwise
(:h neocomplete-faq
). As far as I can see this also works for lexima.vim.
inoremap <silent> <CR> <C-r>=<SID>ExpandSnippetOrReturnEmptyString()<CR>
function! s:ExpandSnippetOrReturnEmptyString()
if pumvisible()
let snippet = UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res > 0
return snippet
else
return "\<C-y>\<CR>"
endif
else
return "\<CR>"
endfunction
delimitmate provides following possibility:
Does lexima provide something similar?
My mapping looks as follows:
How can I adapt it if pumvisible is false that lexima is called?