Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim-go autocompletion not working

I recently installed vim-go using pathogen, but the autocompletion feature is not working. If I am using it only shows commands I've already used. My .vimrc has

filetype plugin on

" Enable autocompletion
set omnifunc=syntaxcomplete#Complete
" Select keyword as you type
:set completeopt=longest,menuone

Do I need more than just this plugin? The other feature I have tested so far are working (:GoRun, syntax highlighting). This is on a Ubuntu machine.

like image 628
Gregsen Avatar asked Jun 07 '14 19:06

Gregsen


People also ask

How do I autocomplete in Vim?

document. and press *Ctrl + x* followed by *Ctrl + o* to see the auto-complete suggestions as below. This is how you can enable and use the auto-complete feature of Vim editor to write Javascript programs.

How do I turn off autocomplete in Vim?

And if you want to dismiss the list and not have it autocomplete anything, hit Ctrl+E .


2 Answers

Are you typing C-X C-O to open the autocompletation window? This works fine for me.

On the other hand, if you want to get real-time completion (completion by type) install the following plugins YCM or neocomplete

like image 154
Breno Leitão Avatar answered Oct 17 '22 00:10

Breno Leitão


The syntaxcomplete#Complete ships with Vim, not the Go filetype plugin, and it has very limited capabilities (basically, just offering the language's keywords). No wonder you're disappointed.

The ftplugin/go.vim file sets the correct, custom completion of the vim-go plugin:

setlocal omnifunc=go#complete#Complete

So, just ensure that the 'filetype' setting is correct (go), and that you don't have any additional configuration that overrides the plugin's.

:verbose setlocal omnifunc?

can tell you.

like image 38
Ingo Karkat Avatar answered Oct 17 '22 01:10

Ingo Karkat