lifepillar / vim-mucomplete

Chained completion that works the way you want!
MIT License
912 stars 18 forks source link

Incomplete omni completion with vim-go with minimal chain #201

Open scfarley opened 1 year ago

scfarley commented 1 year ago

When using vim-mucomplete with vim-go with a minimal chain, mu-complete does provide a full list of completions from omni. For example, if the chain only includes omni and path then typing signal. will show a partial list:

This list apparently is limited to the first three possibilities. Typing <C-x><C-o> will pull up the full list.

However, if the chain includes keyn or one of a few other choices, then the a full list is displayed following the period, which has in addition to the previous list:

NOTE: This presumes no mistake is made during typing. If someone types a little then hits backspace/delete, then typing the period will show a complete list. NOTE: If the Go package is not already loaded via an import, then the completion will show the full list.

Minimal vimrc appended to troubleshooting_vimrc.vim:

" Prepend vim-go to avoid b:did_ftplugin being set by Vim runtime.
" See:  https://github.com/fatih/vim-go/issues/1997
set runtimepath^=~/.vim/plugged/vim-go
set runtimepath+=~/.vim/plugged/vim-mucomplete

" Optionally add additional configuration below this line
set completeopt+=noselect
set backspace=indent,eol,start

" Restore backspace.
inoremap <silent> <plug>(MUcompleteFwdKey) <right>
imap <right> <plug>(MUcompleteCycFwd)
inoremap <silent> <plug>(MUcompleteBwdKey) <left>
imap <left> <plug>(MUcompleteCycBwd)

let g:mucomplete#enable_auto_at_startup = 1
let g:mucomplete#minimum_prefix_length = 1
let g:mucomplete#can_complete = {}
let g:mucomplete#can_complete.go = {
    \ 'omni': { t -> t =~# '\m\k\%(\k\|\.\)$' } }
let g:mucomplete#chains = {
    \ 'go' : ['omni', 'path']
    \ }

Minimal Go: tiny.go

package main

import "os/signal"

func main() {
    signal.Ignore()
}

go.mod

module tiny

go 1.19
lifepillar commented 1 year ago

Do these settings help?

let g:mucomplete#completion_delay = 50
let g:mucomplete#reopen_immediately = 0
lifepillar commented 1 year ago

What is the value of omnifunc? I am trying your vimrc, but when I set the filetype to Go, omnifunc remains empty.

scfarley commented 1 year ago

Do these settings help?

let g:mucomplete#completion_delay = 50
let g:mucomplete#reopen_immediately = 0

They did not help exactly, even if omni was the only option in Go's chain. However, I tried g:mucomplete#completion_delay = 5000. If I type signal. quick enough, then it does provide the full list.

What is the value of omnifunc? I am trying your vimrc, but when I set the filetype to Go, omnifunc remains empty.

omnifunc=go#complete#Complete

I needed the following or my omnifunc was also empty. I spent more time on figuring how to get omnifunc to be set than anything else in the sample vimrc. If vim-go is not before $VIMRUNTIME, it will not be set as noted in that issue.

" Prepend vim-go to avoid b:did_ftplugin being set by Vim runtime.
" See:  https://github.com/fatih/vim-go/issues/1997
set runtimepath^=~/.vim/plugged/vim-go