Hi Val,
Thanks a lot for you work, it's awesome! Currently, I have Vim's whole line completion mapped on a separate key combination (C-Space) as follows:
inoremap <C-@> <C-X><C-L>
However, the invoked completion does not use YCM's fuzzy matching, etc. Is it possible to somehow integrate YCM with Vim's whole line completion?
Thanks,
Anton
It is impossible. Because, line completion is builtin completion.
Pluguins cannot integrate with it.
Ah, that's a pity.. Thanks for letting me know!
Would it be possible to replicate such feature of vim? Lets say for one moment that we consider only the current buffer, could it be possible to feed the result of getline(1, "$"), plus some cleaning, to YCM and take advantage of the fuzzy matcher functionality?
Why do you want to use this feature? I don't use whole line completion...
This feature could be a replacement for copying and pasting lines when you need to add a new line that is similar to an existing one.
I think this feature is not useful. Yank and paste is better.
Agreed with @Shougo, I don't think this is a useful feature.
When you're in insert mode & writing something that you think you might have written in some other opened buffer, having line completion is very useful as compared to going back to normal mode, finding that buffer & copy & come back for pasting.
But In the end it's on personal taste I guess but I find this feature very useful in various situations.
change the mapping, e.g. to do dismiss the pum before using ctrl-x ctrl-l.
if pumvisible() | feedkeys( '<C-y>' ) | endif
feedkeys( '<C-x><C-l>' )
You won't get YCM's matching (which would simply be terrible for whole line completion due to it being designed for identifiers - single words), but you at least get whole line completion.
@puremourning Thank so much, this is exactly what I want to do.
I'm having a little difficulty in creating that mapping to call this function. Can you please help me out with this ?
This is what I've got so far:
imap <expr> <C-x><C-l> CloseYcmIfOpen()
function! CloseYcmIfOpen()
if pumvisible()
call feedkeys("\<C-y>")
endif
" feedkeys( '<C-x><C-l>' )
endfunc
A few things i noticed:
<C-y> with \ because it'll take it as literal strings otherwise<expr> puts the returned value in insert mode hence 0 is being printed, I tried returning empty string but there is a kind of delay there'<C-x><C-l>' keys is not right because it's going in a loop that way since the mapping is on the same expression.Appreciate any help..
So the \<C-y> feedkeys mapping is working i.e it's closing an opened ycm dialog but i'm not able to trigger the line completion after that.
You should return the keys instead:
inoremap <expr> <C-x><C-l> CloseYcmIfOpen()
function! CloseYcmIfOpen()
if pumvisible()
return "\<C-e>\<C-x>\<C-l>"
endif
return "\<C-x>\<C-l>"
endfunction
Thank you so much. Works like a charm !
Most helpful comment
You should return the keys instead: