vim-go autocompletion not working - vim

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.

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

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.

If none of these suggestions solves your problem, try killing gocode from a terminal:
gocode exit (or killall gocode it that fails)
gocode -s -debug
In case of startup failure due to a lingering unix socket, simply remove it and try again. Once everything is working, you can terminate the debug enabled gocode process (the plugin will autostart as needed)

This is what worked for me. default gocode pkg seems to be no longer maitained. so update it with the one below.
my go and vim versions:
VIM - Vi IMproved 8.2
go version go1.16.4
follow the steps below:
gocode exit
go get -u github.com/mdempsky/gocode
run gocode in debug mode
gocode -s -debug
try the autocomplete.(vim-go C+X C+O)
viola! you should see the list like so:

Related

The nord color scheme for vim does not match the documentation

I installed the scheme according to the instructions, but the colors are still not as in the documentation.
https://github.com/arcticicestudio/nord-vim
OS - ubuntu 14, connecting via ssh.
Applied, restarted vim.
:PlugInstall
~$ vim ~/.vimrc
Error detected while processing /home/test/.vimrc:
line 17:
E518: Unknown option: termguicolors
Press ENTER or type command to continue
From the error it looks like you don't have that feature compiled on your
version of vim. Although it's not clear to me if you have set termguicolors
in your .vimrc because it was part of the installation instructions or not.
Either way, from :help: termguicolors:
'termguicolors' 'tgc' E954
'termguicolors' 'tgc' boolean (default off)
global
{not available when compiled without the
+termguicolors feature}
You can check if you have the 'termguicolors' feature by doing:
:version
and seeing if the 'termguicolors' has a '+' in front of it (you have it) or a
'-' in front of it (you don't).
Resolved problem.
Indeed, the problem was the lack of termguicolors.
Ubuntu was vim running version 7.4..
termguicolors has been added to vim since version 8. I had to update vim.
Thank you all.
vim --version
sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt install vim
vim --version
The error is fairly self-explanatory: you are setting an option that is not available in your Vim.
You have a few ways to get out of this situation…
Not setting the :help 'termguicolors' option at all.
Setting it conditionally:
if exists('+termguicolors')
set termguicolors
endif
See :help exists().
Installing a Vim build that includes the termguicolors feature (and making sure your terminal emulator supports it).
Note that this colorscheme's promised look can only be achieved in:
GUI Vim,
TUI Vim with the termguicolors feature built-in and the termguicolors option set, in a suitable terminal emulator,
in TUI Vim, if you change the colour palette of your terminal emulator.
You should have read the instructions before installing that plugin.

disable "Press ENTER or type command to continue" in terminal

I know how to disable this inside Vim, I am curious is it possible to disable this at all when running vim in terminal.
e.g.
tdi#piesek:~$ vim
ycm_client_support.[so|pyd|dll] and ycm_core.[so|pyd|dll] not detected; you need to compile YCM before using it. Read the docs!
Press ENTER or type command to continue
My scenario is that I install vim and Vundle plugins automatically via saltstack for all users (vim +PluginInstall +qall). Some plugins, however need more love, e.g. YouCompleteMe, which gives this message.
I would like to force vim to 'go on' even when there are some things that keep on wanting ENTER pressed.
If you know the commands (in your ~/.vimrc) who trigger the message, you can prepend :silent! in front of it. This will suppress any output and errors.
For general messages, you can try :set nomore.
cd ~/.vim/bundle/YouCompleteMe
./install.py
Fixed this problem for me, I have Ubuntu 14 as OS and CMake installed, previously..
I tried it by deleting one by one.And I find that set syntax cause the problem..not sure if is the culprit.
So you can delete it to solve the problem.

vimrc test for if_lua during vundle BundleInstall

I use the same .vimrc file on lots of systems. I'd like to bypass vundle installing some modules that I know won't work if 'if_lua' is not present.
Is there a vim script way of conditionally doing
Bundle 'Shougo/neocomplete.vim'
only if vim was compiled with lua to avoid the start up error:
$ vim myprogram.c
neocomplete does not work this version of Vim.
It requires Vim 7.3.885 or above and "if_lua" enabled Vim.
Press ENTER or type command to continue
thx
if has('lua')
Bundle 'Shougo/neocomplete.vim'
end

Vim Syntax Highlighting does not work

I've installed a fresh Arch Linux system on my laptop and downloaded the vim package.
I haven't altered the .vimrc file, but the syntax highlighting doesn't seem to work with any of the languages I tried (Python, Ruby, CSharp, C...).
Auto formatting (gg, =, G) also fails.
Until now when playing with vim (because I can't really say I've extensively used it) in other OSs (Ubuntu, Fedora), the syntax highlighting came on automatically.
Is there something I am missing here?
You need to have following settings in .vimrc file as per arch linux documentation
filetype plugin on
syntax on
This is the absolute minimum you need to put in your ~/.vimrc if you intend to use vim as your primary editor:
" activates filetype detection
filetype plugin indent on
" activates syntax highlighting among other things
syntax on
" allows you to deal with multiple unsaved
" buffers simultaneously without resorting
" to misusing tabs
set hidden
" just hit backspace without this one and
" see for yourself
set backspace=indent,eol,start
Anything else depends on your taste, workflow and needs.
vi /etc/profile
alias vi=vim
maybe you use vi instead of vim
I had this problem in Opensuse Leap 42.2 cloud. And solved it by installing vim-data
sudo zypper install vim-data
or just re-installing vim will include vim-data automatically.
sudo zypper remove vim
sudo zypper install vim
Type
:syntax on
to get it to work. It is not a default option for vim. Probably in the other systems, it was set to on in the system default vimrc
Or put
syntax on
in ~/.vimrc
Another reason syntax highlighting won't work is you might have a theme/colorscheme set that VIM cannot find.
colorscheme darkblue
Either delete the line or comment it out:
"colorscheme darkblue
I had a similar problem. I could not have syntax highlighting on. I also found that gvim launched without pulldown menus or toolbar icons. It turned out I did not have the vim-runtime package properly installed. In my case I was on debian jessie with a large set of files missing under /usr/share/vim/vim74/ directory.
$ ls /usr/share/vim/vim74/
debian.vim doc/ rgb.txt
The solution was to run:
$ sudo aptitude reinstall vim-runtime
That fixed the problem for me, for syntax highlighting and for missing menus/icons in gvim. I'm not sure why my system was in this state, but the reinstall of the above package solved both issues.
in my case , I changed the term(terminal type) from vt100 to xterm. And it works.
To change the terminal type:
in bash:
export TERM=xterm
in bourne shell or ksh:
TERM=xterm
export TERM
in csh or tcsh:
setenv TERM xterm
On my Ubuntu 18.04 system i.e. c-highlighting works but Icinga2 config file highlighting being provided by the vim-icinga2 package does not. Quote from https://packages.debian.org/sid/vim-icinga2:
As per the Debian vim policy, installed addons are not activated automatically, but the "vim-addon-manager" tool can be used for this purpose.
Executing vim-addon-manager -w install icinga2 following a regular vim-icinga2 package installation solved the issue. The -w option forces a system wide rather than a just per current user activation. Notice that executing vim-addon-manager without arguments yields a list of 39 modes being disabled by default:
> vim-addon-manager
# Name User Status System Status
align removed removed
alternate removed removed
...
icinga2 removed installed # Due to above command
...
If you do miss highlighting chances are your mode is among this list.
NB: Ubuntu 18.04 seemingly inherits Debian's policy. None of the above answers solved my issue. No ~/.vimrc configuration or manual activation was being required after the above described activation.

Vim: Recommendations for vimball plugins in pathogen

I plan to switch to vim 7.3 in the next days on my windows box - linux will soon follow. I also plan to switch my vim setup and let pathogen handle my plugins.
I've googled but not yet found a solution how to handle plugins using vimball technique for setup. Any hints?
You are looking for :UseVimball [path]
Open the vimball up with vim. Instead of sourcing it with :so % do
$ vim somthing.vba
:!mkdir ~/.vim/bundle/bundle-dir-name-here
:UseVimball ~/.vim/bundle/bundle-dir-name-here
Note you will have to make sure the path exists before you execute this command.
:h :UseVimball
You can try vim-addon-manager: it is able to put every plugin in a separate directory and correctly handles Vimball.

Resources