Setting up Clang Complete with VIM on Windows

Category: Tutorial

I've never used Clang Complete with VIM on Windows before, but I figured I'd document how to get it set up in the event anyone else has wanted to try it.

First step is to make sure your VIM was compiled with Python support, run If you're lucky and your system already has the correct Python installation you can check with the command

:echo has('python3')
:echo has('python')

If not we'll have to check if VIM was compiled with Python support and which version it was compiled to work with. You'll run the version command to check,

:version

and look for +python/dyn and +python3/dyn, if you don't have these you'll need to either install a version that does have this enabled or compile it yourself.

You'll need to scroll down to the compliation settings and verify which version of Python VIM was compiled to look for,

You'll find the options,

-DDYNAMIC_PYTHON3_DLL=\"python37.dll\"
-DDYNAMIC_PYTHON_DLL=\"python27.dll\"

Next you'll need to verify if you're using 64bit or 32bit VIM, you can check this with,

:echo has('win64')

Now you can install the proper Python version making sure it's the same architecture and make sure these DLLs are visible in your PATH.

After this step make sure you're seeing 1 when running either,

:echo has('python3')
:echo has('python')

If you're not seeing this make sure you've restarted your terminal from which you've launched VIM to make sure the PATH was updated.

Next, we need to find the correct version of libclang.dll, I installed Clang by installing the Visual Studio Build Tools and making sure to select Clang support.

This will install both 32bit and 64bit versions of libclang.dll.

You'll need to find the path where libclang.dll can be found, mine happens to be at,

C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\Llvm\bin

Now to install Clang Complete for VIM, it's just a matter of copying the files in this repository into,

%USERPROFILE%\vimfiles

and enabling the plugin by placing the following in your _vimrc file,

let g:clang_library_path="C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\Llvm\\bin"

You can verify that the plugin is working by following the troubleshooting steps in the Clang Complete repository, and use the plugin by pressing <C-x><C-u>.