After installing deoplete and mapping the tab key to code completion via adding the below code to my init.vim, the deoplete completion would only work after reloading init.vim. Someone posted this same dilemma : https://github.com/Shougo/deoplete.nvim/issues/164
According to Shougo though it is a problem with Ultisnips.
in the init.vim...
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort "{{{
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction"}}}
I think <TAB> mapping is overwritten by UltiSnips to expand snippets.
You should check it by verbose imap <TAB>.
verbose imap <TAB> displays the tab mapping in my init.vim file I posted above. It doesn't seem like it's being overwritten.
Right now my tab key scrolls through options in the snippet/completion popup window. I think that I would have to map Ultisnips completion to a key other than <TAB>. Otherwise I'm not sure how it differentiate between scrolling through options and choosing one of the snippets to complete. I resolved the problem by setting snippet completion to the <leader>j key.
let mapleader = "\<space>"
let g:UltiSnipsExpandTrigger = "<leader>j"
Hm. You can use the mappings.
https://github.com/SirVer/ultisnips/blob/master/autoload/UltiSnips/map_keys.vim#L56
Thanks! These mappings ended up working out. <TAB> seems to be working now for both scrolling through a set of potential autocompletions with deoplete and for expanding a snippet.
Sorry for my confusion, but can you specify how you got it working? The map_keys link is throwing me off. @Luis-Henriquez-Perez
Sure I use this function for Ultisnips:
'
function!
let snippet = UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res > 0
return snippet
else
return "\
endif
endfunction
inoremap
'
And this function for Deoplete:
`
inoremap
\ pumvisible() ? "\
\
\ deoplete#mappings#manual_complete()
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
`
And with this configuration deoplete's suggestions and ultisnips snippets show up and can be scrolled through with tab.
@Luis-Henriquez-Perez that seems to expand a snippet, but does not scroll through deoplete, and inside of a snippet will not go to the next mark. Maybe some configuration is missing? (I uncommented all other config I had and used only yours)
I think perhaps I did miss some more configurations. This is all my ultisnips config:
'
let g:UltiSnipsExpandTrigger = "
let g:ulti_expand_or_jump_res = 0
let g:UltiSnipsEnableSnipMate = 1
let g:UltiSnipsSnippetsDir = "~/.config/nvim/UltiSnips"
function!
let snippet = UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res > 0
return snippet
else
return "\
endif
endfunction
inoremap
'
I think that the expandtrigger set to nothing is something important I left out before.
I got
No mapping found
No mapping found
I think I should just stick with Tab and Shift Tab, then