2020-10-26
Vim: YouCompleteMe(그리고 Vundle)를 사용한 자동완성기능 사용
Vim 에서 자동완성은 Ctrl-n, Ctrl-p 로 되긴 한다는데, 좀 더 강력한(?) 기능을 자랑하는 YouCompleteMe를 사용해보기로 했다.
사용법은 홈페이지에 나와있긴 한데, 다소 전문가(?)용이라 조금 불친절한 면이 있다.
우분투에서, Vundle 을 사용한다는 가정하에 설치법을 정리해봤다.
Vundle 설치
Vim 용 Bundle(각종 플럭인 등등)을 간편하게 사용할 수 있게 해주는 Vundle. 이걸 먼저 설치해줘야만 한다.
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
설치 후엔 ~/.vimrc
를 편집해야 하는데, 기본값으로 다음이 필요하다.
set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugins "call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim' Plugin 'ycm-core/YouCompleteMe' " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help " :PluginList - lists configured plugins " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate " :PluginSearch foo - searches for foo; append `!` to refresh local cache " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line
여기서 Plugin 'ycm-core/YouCompleteMe'
는 Github 주소다. 제대로된 주소는 github.com/ycm-core/YouCompleteMe
이지만, 여기서 github.com 을 떼고 뒷 부분을 넣어주면 된다.
따라서, 다른 플럭인들도 Github 주소만 알아낸 뒤 저 형식으로 추가해주면 된다.
위 작업을 끝냈다면, 다음 명령을 내려서 YCM 을 설치할 수 있는 기반을 만들어줘야 한다.
$ vim +PluginInstall +qall
이러면, ~/.vim/bundle/YouCompleteMe
에 파일이 생성된다.
YCM 설치
~/.vim/bundle/YouCompleteMe 로 이동하여, git 명령을 내려준다.
cd ~/.vim/bundle/YouCompleteMe git submodule update --init --recursive # 마지막으로, '설치' 명령 실행. ./install.py --all
끝. 이제 Vim 에서 자동 완성을 사용할 수 있다.
C 언어를 사용하려면 뭔가 다른 꾸러미가 필요하다고 하는데, 나와는 관계없으므로 그 부분은 넘겼다.