title: How to trigger omnicomplete/auto-completion on keystrokes in INSERT mode?
body: <p>VIM's omnicomplete autocompletion is not really working as expected.</p>
  
  <p>Is there a way to make it smarter?  Like, to monitor the context of surround text?  (e.g. don't trigger if within comments or quotes)</p>
  
  <p>I ask because I cannot get to a happy place since switching to Vim when compared to the autocomplete/IntelliSense in IDEs such as Visual Studio, IntelliJ, Sublime and Atom (I've used all of these for development in the past).</p>
  
  <p>The basic goals to this question:</p>
  
  <ul>
  <li>Can Omnicomplete be triggered on A-Za-z keystrokes in INSERT mode?  I already have it being triggered via "." dot symbols.</li>
  <li>How to get Omnicomplete to insert the func's parameters?</li>
  </ul>
  
  <p>I am new to Vim for a few months and desperately trying to get a smooth workflow.  But without a good autocomplete option, while forcing me to be more vigilant in learning the code I am trying to use, it is greatly slowly me down over other IDEs I've used in the past.  </p>
  
  <h1>Atom + Go-Plus</h1>
  
  <p>Let's examine my expectations with Atom + Go-Plus.</p>
  
  <p>I have a func named <code>func generate(entropy chan&lt;- uint64)</code> located elsewhere in another Go file in the same package.</p>
  
  <p>When I type the letter <code>g</code> on line 22, I immediately get a prompt with everything that begins with g: </p>
  
  <p><a href="https://i.stack.imgur.com/ng7Zz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ng7Zz.png" alt="Atom&#39;s autocomplete with Go-Plus"></a></p>
  
  <p>As you can see, there are 3 options that immediately pop up (the first two I think are just code snippets).  I can use an arrow key to scroll down to either option. </p>
  
  <p>If I select the 3rd option (or if I continue to type <code>gen</code> the field narrows down to only 1 option), and <code>press enter</code> Atom/Visual Studio/Sublime all fill out the details of the method for me:</p>
  
  <p><a href="https://i.stack.imgur.com/0DuUo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0DuUo.png" alt="atom with go-plus autocompletion"></a></p>
  
  <p>I did not type any of the above.  It was inserted and I can override the details, modify them, or just TAB off and continue typing.</p>
  
  <h1>Vim + Vim-Go (really Omnicomplete)</h1>
  
  <p>Let's compare that with my current (maybe broken?) config of <code>omnicomplete</code>.  I have this in my .vimrc:</p>
  
  <p><code>
  set completeopt=longest,menuone
  </code></p>
  
  <p>Within vim, if I type <code>gen</code>, all I get is what seems to be my previously entered text that I typed elsewhere in this buffer (and only in this buffer, not in other buffers).  If I happen to misspell something, all I get the misspelled version I previously entered for the life that I have vim open.  This tells me there is no IntelliSense/autocomplete at work - just something monitoring the keystrokes I make:</p>
  
  <p><a href="https://i.stack.imgur.com/4lLQ3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/4lLQ3.png" alt="vim with omnicomplete and autocomplete not working"></a></p>
  
  <p>As you can see, autocomplete isn't working as I type.  Though, this does come in handy with comments and strings in other places and I kind of like how vim remembers my free-text I type.  </p>
  
  <p>Not really sure what Vim option is enabling this; but, it is not autocompletion.</p>
  
  <p>Now, I can press <code>CTRL-X + CTRL-O</code> to force autocompletion and get <code>generate()</code> to show up:</p>
  
  <p><a href="https://i.stack.imgur.com/GR4bv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GR4bv.png" alt="vim with omnicomplete and autocomplete"></a></p>
  
  <p>This is better; but, I would expect it to show me autocomplete options as I type: not requiring 3 additional keystrokes to make it happen.  That is a whole lot of C-x C-o happenings throughout a few hours of coding.</p>
  
  <p><strong>Is there a way to have Vim monitor my keystrokes in INSERT mode and display autocomplete if there is a matching ctag or function?</strong>  That may be the answer to this functionality.</p>
  
  <h1>Autocomplete with Parameters</h1>
  
  <p>There is a 2nd problem with autocompletion with <code>omnicomplete</code> that I could overlook the C-x C-o requirement of the above if this worked: once I do select the method I want to autocomplete, it does not insert the parameters/fields for me.</p>
  
  <p>Going back to the screenshot above, if I select that method, this is what I get:</p>
  
  <p><a href="https://i.stack.imgur.com/mEbHN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mEbHN.png" alt="vim with vim-go autocomplete not fully completing"></a></p>
  
  <p>Notice that <strong>it does not insert</strong> the func's paramters.  It does not match the 2nd picture posted above, where the autocomplete in Atom, Sublime, and Visual Studio all complete the method with parameters showing.</p>
  
  <p>I have read the vim wikia and have tried various options with <code>set completeopt</code> without any viable alternative.  </p>
  
  <p>For example, <code>set completeopt+=preview</code> gives me the preview window after selecting:</p>
  
  <p><a href="https://i.stack.imgur.com/VIMOk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VIMOk.png" alt="enter image description here"></a></p>
  
  <p>Why giving me the parameters in a preview, it still does not autocomplete my <code>line 22</code> of code and is often a distraction (I often times disable it because I type far faster than having to stop and "look up" all the time).</p>
  
  <p>It took a lot of tweaking of the config file to get the below working; but, I was able to get "dot" autocompletion to work.  So, there is some form of autocompletion working:</p>
  
  <p><a href="https://i.stack.imgur.com/zr3wM.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zr3wM.png" alt="vim and vim-go autocompletion with dot"></a></p>
  
  <p>But again, it does not fill in the parameters once I select a function which is pretty annoying to have to type <code>ESC + back arrow + back arrow + : + GoDoc</code> just to see what it was: that's 10 character strokes to see what it was.</p>
  
  <p>Sure, Atom, Sublime, and VS is much prettier when "dot autocompleting":</p>
  
  <p><a href="https://i.stack.imgur.com/x7Hk3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/x7Hk3.png" alt="atom and go-plus dot autocompletion"></a></p>
  
  <p>(it is also better ordered by types, though I do have vim setup to remember the last used at the top so that helps).  But I don't care about pretty - I just want my parameters to show up when selecting with 'dot'.  </p>
  
  <p>Any advice in how to tweak my vim-go and related plugins would be very welcome as I'd prefer to stay with Vim over any IDEs.  Thank you.</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <p>I see that <a href="https://github.com/fatih/vim-go/pull/685" rel="noreferrer">the author of <code>vim-go</code></a> has worked on the parameters-completion part and got it working:</p>
  
  <p><a href="https://i.stack.imgur.com/Qs4AR.gif" rel="noreferrer"><img src="https://i.stack.imgur.com/Qs4AR.gif" alt="autocompletion with parameters in vim-go"></a></p>
  
  <p>Though, I can't seem to get it working on my install (still debugging it), I wanted to show others that it is indeed possible to have autocomplete with parameters being filled.</p>