Skip to content

kwk/dotvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation on Fedora and Ubuntu

Clone the repo

git clone git://github.com/kwk/dotvim.git ~/.vim

Initialize the submodules

You need to bring in the code of the plugins and their third-party dependencies by updating the plugin submodules:

cd ~/.vim
git submodule init
git submodule update --init --recursive

Install LLVM, CMake, and Python-dev to compile YouCompleteMe

These steps are tedious, I know, but it has to be done only once and only for the YouCompleteMe plugin.

Fedora

sudo dnf install cmake gcc-c++ make python3-devel

As non-root run the following commands to build YouCompleteMe.

cd ~

mkdir ycm_build

cd ycm_build

cmake -G "Unix Makefiles" \
  -DUSE_SYSTEM_LIBCLANG=ON \
  -DCMAKE_CXX_FLAGS="$(llvm-config --cppflags)" \
  -DCMAKE_C_FLAGS="$(llvm-config --cflags)" \
  -DUSE_CLANG_COMPLETER=ON \
  . \
  ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

make -j4 ycm_support_libs

Now you should see that there are .so files in your YouCompleteMe directory:

find ~/.vim/bundle/YouCompleteMe/ -name "*.so"

The output should somewhat look like this:

.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so
.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_support.so
.vim/bundle/YouCompleteMe/third_party/ycmd/libclang.so

Ubuntu

Follow the steps to install the development version of LLVM via Apt. This is needed to get the YouCompleteMe to work. Maybe you can also use the other versions but I like to have the development version.

sudo -s

apt-get install cmake python-dev

wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key| apt-key add -

apt-get update

apt-get install clang-3.6 clang-3.6-doc libclang-common-3.6-dev \
libclang-3.6-dev libclang1-3.6 libclang1-3.6-dbg libllvm-3.6-ocaml-dev \
libllvm3.6 libllvm3.6-dbg lldb-3.6 llvm-3.6 llvm-3.6-dev llvm-3.6-doc \
llvm-3.6-examples llvm-3.6-runtime clang-modernize-3.6 clang-format-3.6 \
python-clang-3.6 lldb-3.6-dev

As non-root run the following commands to build YouCompleteMe.

cd ~

mkdir ycm_build

cd ycm_build

cmake -G "Unix Makefiles" \
  -DUSE_SYSTEM_LIBCLANG=ON \
  -DCMAKE_CXX_FLAGS="$(llvm-config-3.6 --cppflags)" \
  -DCMAKE_C_FLAGS="$(llvm-config-3.6 --cflags)" \
  -DUSE_CLANG_COMPLETER=ON \
  . \
  ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

make -j4 ycm_support_libs

Now you should see that there are .so files in your YouCompleteMe directory:

find ~/.vim/bundle/YouCompleteMe/ -name "*.so"

The output should somewhat look like this:

.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_core.so
.vim/bundle/YouCompleteMe/third_party/ycmd/ycm_client_support.so
.vim/bundle/YouCompleteMe/third_party/ycmd/libclang.so

Create symlinks:

This will finally activate your vim config

ln -s ~/.vim/vimrc ~/.vimrc
ln -s ~/.vim/gvimrc ~/.gvimrc

Upgrading a plugin bundle

At some point in the future, the fugitive plugin might be updated. To fetch the latest changes, go into the fugitive repository, and pull the latest version:

cd ~/.vim/bundle/fugitive
git pull origin master

Upgrading all bundled plugins

You can use the foreach command to execute any shell script in from the root of all submodule directories. To update to the latest version of each plugin bundle, run the following:

git submodule foreach git pull origin master

Configure your CMake-based C/C++ project to work with YouCompleteMe

Most of the time your C/C++ project uses custom compiler flags. To make YouCompleteMe automatically find them, you have to enable the CMAKE_EXPORT_COMPILE_COMMANDS when configuring your CMake build. Then a file named compile_commands.json will be created in the build directory.

We can make use of this file by copying a script to your project's source directory:

cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py \
  /YOUR/SOURCE/ROOT/DIR/

Then open the file /YOUR/SOURCE/ROOT/DIR/.ycm_extra_conf.py and change the compilation_database variable to point to the directory in which you build with CMake. Remember, that is where the compile_commands.json file is.

The next time you open a file from your C/C++ project, YouCompleteMe is smart enough to figure out the include paths etc. on its own.

Enable C++11 in YouCompleteMe

If you are don't like YouCompleteMe to warn you about obviously correct C++11 code snippets, follow these steps.

No matter if you use the default .ycm_extra_conf.py or your own you should comment out the -Wc++98-compat in the flags array to allow C++11 in your code.

How to install a new plugin

cd ~/.vim/bundle
git submodule add http://url-to/project.git project
git add ../.gitmodules 
git add project
git commit -m "added project plugin"

About

This is inspired by the post Synchronizing plugins with git submodules and pathogen and the part of upgrading a plugin bundle is a 1:1 copy from the page.

About

My vim configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published