Hi all,
Does anyone use YouCompleteMe with Vim? It’s an autocompleter for Vim. I’m having some troubles installing it as I didn’t compile vim with python support. Is it worth the pain or are there alternatives?
Thanks,
Dan
Hi all,
Does anyone use YouCompleteMe with Vim? It’s an autocompleter for Vim. I’m having some troubles installing it as I didn’t compile vim with python support. Is it worth the pain or are there alternatives?
Thanks,
Dan
Serendipity… I just installed it last night thinking I would give it a try. I have NEVER seen a vim plugin take anywhere near the amount of time that YCM took – I was beginning to think that it had hung vim. When it finally completed and I looked at the install log, I saw that there were many submodules included: this is one huge puppy.
Now I have to compile the core engine and the instructions are quite emphatic about how things should be done exactly as described. And yes, it seems pretty arduous / restrictive so I’m not sure yet how far I’ll go with it. The questions I have so far are:
Must use MacVim instead of plain ol’ vim. Probably not an issue as I’ve used MacVim and mvim for a while, but it does make we wonder Why?
Must have the latest Xcode installed. Well; that’s nice but I have dependencies at a client site for earlier versions of Xcode and the command-line tools.
Anyway, I’ll probably give it a whirl and see how it goes. And like Dan, I’d love to hear about other’s epxerience with YCM.
Update Luckily, I’m using Homebrew so I already have a vim with python installed and the simple installation instructions for the YCM core engine worked just fine. (I just ignored those questions and am using the HomeBrew vim and the Xcode that I already have installed).
In a rails file I type “re” and get the following:
Now typing ‘s’ gets me to:
And gets me ‘respond_to’ in the code. Suh-weet.
I used YouCompleteMe for a bit and then I found this article: Vim, You Complete Me and started using Vim’s built-in completion and I haven’t missed YouCompleteMe at all. It’s fast, it’s customizable and hitting the tab key for completion feels just as natural in Vim as it does from the command line.
Thanks, @devinrm… that’s an excellent article. I’ll play around with that on my other machine and see what it does.
I was able to install VIM via Homebrew, update my ZSH to point to that particular installation, then install all the requirements for YouCompleteMe. But the tab complete sounds great, however, one question: does that remove the original functionality of tab?
No, tab still works as it should. The only difference would be if you pressed tab while typing a word instead of moving forward two spaces (or whatever you have your tab length set to) it would populate a list of words in a dropdown. See attachment:
I also tested these yesterday after seeing this thread:
Vim: GitHub - Shougo/neocomplete.vim: Next generation completion framework after neocomplcache
NeoVim: GitHub - Shougo/deoplete.nvim: Dark powered asynchronous completion framework for neovim/Vim8
And while I thought it was improvement over YouCompleteMe, I still like tab-completion better. It’s distraction free and I think it provides the most intuitive way of typing. Just my opinion though, do some experimenting. I’d be interested to hear your review of them all.
Cheers
I found it too complicated to setup.
I’m happy with my zsh shell and the snippets plugin from hondo and friends.
I really liked YouCompleteMe’s functionality, but I found that even on a fast machine, in a big repo with lots of tags that it got laggy. I think this problem is linked to what I like to have in an autocomplete list, which is a complete list of all tags from the repo and its dependencies.
I remain hopeful that async execution in Neovim will allow for the features of YouCompleteMe or something similar to be faster when working with a large tagfile.
In case anyone else runs into this thread I thought I’d add a little more detail for using built in completion, as best I know it (I’m still a n00b).
You can start with this function and mappings in your vimrc (if you’re using Thoughtbot’s dotfiles you don’t need this as they already put it in and it’s where I graciously stole it from):
" Tab completion
" will insert tab at beginning of line,
" will use completion if not at beginning
set wildmode=list:longest,list:full
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <Tab> <c-r>=InsertTabWrapper()<cr>
inoremap <S-Tab> <c-n>
Next you can add this to your vimrc:
" . scan the current buffer, b scan other loaded buffers that are in the buffer list, u scan the unloaded buffers that
" are in the buffer list, w scan buffers from other windows, t tag completion
set complete=.,b,u,w,t,]
" Keyword list
set complete+=k~/.vim/keywords.txt
Your keyword list should have one keyword per line like this:
validates_presence_of
validates_size_of
validates_uniqueness_of
Now with all that setup, you should be able to just hit the tab key (or Ctrl-n) and have a list of all your custom completions.
This is my completion setup. I love it, it’s really fast and fixes my auto-complete woes. I hope you find it useful and like I said I’m a n00b so if someone can improve upon it or if I’m doing it wrong, feel free to chime in and correct it/improve it.
Thanks, that’s incredibly useful! I disabled YouCompleteMe and went with the built in vim functionality with your config.
@devinrm don’t discount your contribution! This is great advice, and using a dictionary to autocomplete is a neat idea.
You might want to consider contributing the dictionary idea (and use setlocal complete+=k...
) to Keith Smiley’s rspec.vim
(not to be confused with thoughtbot’s vim-rspec
), which provides rspec-specific syntax highlighting. Being able to autocomplete shoulda-matchers
in RSpec seems like a good idea.