Closed meck closed 6 years ago
@meck I'm also using neovim and was about to permanently disable this feature for me, but I made it work and and definitely loving it. This is my setup:
let g:UltiSnipsExpandTrigger="<NUL>"
let g:UltiSnipsListSnippets="<NUL>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
function! CompleteSnippet()
if empty(v:completed_item)
return
endif
call UltiSnips#ExpandSnippet()
if g:ulti_expand_res > 0
return
endif
let l:complete = type(v:completed_item) == v:t_dict ? v:completed_item.word : v:completed_item
let l:comp_len = len(l:complete)
let l:cur_col = mode() == 'i' ? col('.') - 2 : col('.') - 1
let l:cur_line = getline('.')
let l:start = l:comp_len <= l:cur_col ? l:cur_line[:l:cur_col - l:comp_len] : ''
let l:end = l:cur_col < len(l:cur_line) ? l:cur_line[l:cur_col + 1 :] : ''
call setline('.', l:start . l:end)
call cursor('.', l:cur_col - l:comp_len + 2)
call UltiSnips#Anon(l:complete)
endfunction
autocmd CompleteDone * call CompleteSnippet()
It will automatically insert the placeholder as text after a completion, and you can use <tab>
and `s-
Obviously, this does not mean you have to love the feature like I do. We should anyway investigate why it is not possible to disable it :)
I leave a screencast of how the feature works:
Thats a really good solution! Thanks! I still need to tinker with it a bit as i've overloaded tab and cr to both navigate the completion menu and snippet, and that breaks slightly.
The issue should be looked into thou.
When using HIE with neovim, which unfortunately docent support snippets in a good way, I tried deregistering: The LSP spec has a
snippetSupport
option inTextDocumentClientCapabilities
and it seems that isn't respected by HIE.I saw that there is global config to turn it of but it seems more logical to do it on a client basis according to the spec