prabirshrestha / asyncomplete-ultisnips.vim

provides ultisnips autocomplete for asyncomplete.vim
MIT License
34 stars 1 forks source link

Completion/Snippet expansion does not happen when you hit <TAB> #5

Closed s-daveb closed 2 years ago

s-daveb commented 4 years ago

When i register this as a completion source and try to select a snippet and hit <enter>, nothing happens.

image

my .vimrc contains


let g:asyncomplete_auto_popup = 1
let g:asyncomplete_remove_duplicates = 1
let g:lsp_async_completion = 1

"  Enable disagnostics
let g:lsp_signs_enabled = 1
let g:lsp_diagnostics_echo_cursor = 1

" [...] other language servers

if has('python3')
    let g:UltiSnipsExpandTrigger="<c-l>"
    "let g:UltiSnipsExpandTrigger="<c-y>"
    call asyncomplete#register_source(asyncomplete#sources#ultisnips#get_source_options({
        \ 'name': 'ultisnips',
        \ 'whitelist': ['*'],
        \ 'completor': function('asyncomplete#sources#ultisnips#completor'),
        \ }))
endif

inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<cr>"

nnoremap <buffer> ,n :LspNextError<CR>
nnoremap <buffer> ,p :LspPreviousError<CR>imap <m-r> <Plug>(asyncomplete_force_refresh)

set completeopt=menu,menuone,preview,noinsert

Is this plug-in deprecated?

The documentation for asyc.vim says to use this repository for snippets, and the documentation for vim-lsp.vim says to use thomasfaingnaert/vim-lsp-ultisnips.

Pedrobc89 commented 2 years ago

Probably because of this line: let g:UltiSnipsExpandTrigger="<c-l>"

s-daveb commented 2 years ago

@Pedrobc89 I can see how you would say that, but that was my workaround to get UltiSnip functionality while <TAB>wasn't working. I should have removed that before filing this bug report.

In either case, I tested it again with the latest versions of all my plugins, and the UltiSnips provider is working with <TAB> again. 🥳

Marking this as closed/solved.

dezza commented 2 years ago

Hey man, just wanted to chime in if anyone is in a similar situation.

I think the takeaway from this issue is that this plugin only populates sources (completion results), (please correct me if I'm wrong)

You can achieve snippet expansion from menu by:

" vim8/legacy
function! ExpandSnippetOrReturn()
  let snippet = UltiSnips#ExpandSnippetOrJump()
  if g:ulti_expand_or_jump_res > 0
    return snippet
  else
    return "\<C-Y>" " select without newline in popup
  endif
endfunction

inoremap <expr> <CR> pumvisible() ? "<C-R>=ExpandSnippetOrReturn()<CR>" : "\<CR>"
vim9script
def g:ExpandSnippetOrReturn(): string
  var snippet = UltiSnips#ExpandSnippetOrJump()
  if g:ulti_expand_or_jump_res > 0
    return snippet
  else
    return "\<C-Y>" # select without newline in popup
  endif
enddef

inoremap <expr> <CR> pumvisible() ? "<C-R>=ExpandSnippetOrReturn()<CR>" : "\<CR>"