2013-01-22 00:36:17 -05:00
YouCompleteMe: a code-completion engine for Vim
===============================================
2018-01-18 08:23:17 -05:00
[![Gitter room ](https://img.shields.io/gitter/room/Valloric/YouCompleteMe.svg )](https://gitter.im/Valloric/YouCompleteMe)
2019-07-15 17:00:49 -04:00
[![Build status ](https://dev.azure.com/YouCompleteMe/YCM/_apis/build/status/ycm-core.YouCompleteMe?branchName=master )](https://dev.azure.com/YouCompleteMe/YCM/_build?definitionId=3& branchName=master)
2019-06-29 04:15:25 -04:00
[![Coverage status ](https://img.shields.io/codecov/c/github/ycm-core/YouCompleteMe/master.svg )](https://codecov.io/gh/ycm-core/YouCompleteMe)
2013-04-19 02:42:03 -04:00
2017-12-31 17:29:13 -05:00
Help, Advice, Support
---------------------
Looking for help, advice or support? Having problems getting YCM to work?
First carefully read the [installation instructions ](#installation ) for your OS.
We recommend you use the supplied `install.py` .
Next check the [User Guide ](#user-guide ) section on the semantic completer that
2018-08-16 22:59:15 -04:00
you are using. For C/C++/Objective-C/Objective-C++/CUDA, you _must_ read [this
section](#c-family-semantic-completion).
2017-12-31 17:29:13 -05:00
Finally, check the [FAQ ](#faq ).
If, after reading the installation and user guides, and checking the FAQ, you're
still having trouble, check the [contacts ](#contact ) section below for how to
get in touch.
Please do **NOT** go to #vim on freenode for support. Please contact the
YouCompleteMe maintainers directly using the [contact details ](#contact ) below.
Contents
--------
2015-01-20 15:55:06 -05:00
- [Intro ](#intro )
2015-01-19 16:27:34 -05:00
- [Installation ](#installation )
2019-05-04 16:29:50 -04:00
- [macOS ](#macos )
2018-08-19 20:12:09 -04:00
- [Linux 64-bit ](#linux-64-bit )
2016-02-29 14:34:47 -05:00
- [Windows ](#windows )
- [FreeBSD/OpenBSD ](#freebsdopenbsd )
2015-01-19 16:27:34 -05:00
- [Full Installation Guide ](#full-installation-guide )
2015-09-13 08:28:22 -04:00
- [Quick Feature Summary ](#quick-feature-summary )
2015-01-19 16:27:34 -05:00
- [User Guide ](#user-guide )
- [General Usage ](#general-usage )
2016-02-26 20:09:00 -05:00
- [Client-Server Architecture ](#client-server-architecture )
- [Completion String Ranking ](#completion-string-ranking )
2016-05-16 11:51:41 -04:00
- [General Semantic Completion ](#general-semantic-completion )
- [C-family Semantic Completion ](#c-family-semantic-completion )
2018-04-06 21:55:24 -04:00
- [Java Semantic Completion ](#java-semantic-completion )
2016-02-26 20:09:00 -05:00
- [Python Semantic Completion ](#python-semantic-completion )
2018-04-06 21:55:24 -04:00
- [Rust Semantic Completion ](#rust-semantic-completion )
2019-06-28 08:52:28 -04:00
- [Go Semantic Completion ](#go-semantic-completion )
2017-09-26 14:17:46 -04:00
- [JavaScript and TypeScript Semantic Completion ](#javascript-and-typescript-semantic-completion )
2016-02-26 20:09:00 -05:00
- [Semantic Completion for Other Languages ](#semantic-completion-for-other-languages )
2019-06-28 08:52:28 -04:00
- [LSP Configuration ](#lsp-configuration )
2016-02-26 20:09:00 -05:00
- [Writing New Semantic Completers ](#writing-new-semantic-completers )
- [Diagnostic Display ](#diagnostic-display )
- [Diagnostic Highlighting Groups ](#diagnostic-highlighting-groups )
2015-01-19 16:27:34 -05:00
- [Commands ](#commands )
- [YcmCompleter subcommands ](#ycmcompleter-subcommands )
2016-02-26 20:09:00 -05:00
- [GoTo Commands ](#goto-commands )
- [Semantic Information Commands ](#semantic-information-commands )
2018-03-25 21:08:19 -04:00
- [Refactoring Commands ](#refactoring-commands )
2016-02-26 20:09:00 -05:00
- [Miscellaneous Commands ](#miscellaneous-commands )
- [Functions ](#functions )
2016-05-31 04:40:25 -04:00
- [Autocommands ](#autocommands )
2015-01-19 16:27:34 -05:00
- [Options ](#options )
- [FAQ ](#faq )
2016-01-26 18:54:44 -05:00
- [Contributor Code of Conduct ](#contributor-code-of-conduct )
2015-01-19 16:27:34 -05:00
- [Contact ](#contact )
- [License ](#license )
2017-12-31 17:29:13 -05:00
2015-01-20 15:55:06 -05:00
Intro
-----
2013-01-22 00:36:17 -05:00
YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for
2015-08-18 23:11:39 -04:00
[Vim][]. It has several completion engines:
- an identifier-based engine that works with every programming language,
- a [Clang][]-based engine that provides native semantic code
2018-08-16 22:59:15 -04:00
completion for C/C++/Objective-C/Objective-C++/CUDA (from now on referred to
as "the C-family languages"),
2019-01-16 09:08:21 -05:00
- a [clangd][]-based **experimental** completion engine for the C-family
languages.
2018-07-25 16:25:31 -04:00
- a [Jedi][]-based completion engine for Python 2 and 3,
2019-06-28 08:52:28 -04:00
- an [OmniSharp-Roslyn][]-based completion engine for C#,
- a [Gopls][]-based completion engine for Go,
2017-09-26 14:17:46 -04:00
- a [TSServer][]-based completion engine for JavaScript and TypeScript,
2019-06-28 08:52:28 -04:00
- a [rls][]-based completion engine for Rust,
2017-10-03 02:41:10 -04:00
- a [jdt.ls][]-based experimental completion engine for Java.
2019-07-15 17:06:02 -04:00
- a [generic Language Server Protocol implementation for any language ](#plugging-an-arbitrary-lsp-server )
2015-08-18 23:11:39 -04:00
- and an omnifunc-based completer that uses data from Vim's omnicomplete system
to provide semantic completions for many other languages (Ruby, PHP etc.).
2013-01-22 00:36:17 -05:00
2013-01-30 02:46:10 -05:00
![YouCompleteMe GIF demo ](http://i.imgur.com/0OP4ood.gif )
2013-01-22 00:36:17 -05:00
2013-01-31 14:05:49 -05:00
Here's an explanation of what happens in the short GIF demo above.
First, realize that **no keyboard shortcuts had to be pressed** to get the list
of completion candidates at any point in the demo. The user just types and the
suggestions pop up by themselves. If the user doesn't find the completion
2013-05-28 14:21:43 -04:00
suggestions relevant and/or just wants to type, they can do so; the completion
2013-01-31 14:05:49 -05:00
engine will not interfere.
2013-05-28 14:21:43 -04:00
When the user sees a useful completion string being offered, they press the TAB
2013-01-31 14:05:49 -05:00
key to accept it. This inserts the completion string. Repeated presses of the
TAB key cycle through the offered completions.
If the offered completions are not relevant enough, the user can continue typing
to further filter out unwanted completions.
A critical thing to notice is that the completion **filtering is NOT based on
the input being a string prefix of the completion** (but that works too). The
input needs to be a _[subsequence][] match_ of a completion. This is a fancy way
of saying that any input characters need to be present in a completion string in
the order in which they appear in the input. So `abc` is a subsequence of
`xaybgc` , but not of `xbyxaxxc` . After the filter, a complicated sorting system
ranks the completion strings so that the most relevant ones rise to the top of
the menu (so you usually need to press TAB just once).
**All of the above works with any programming language** because of the
identifier-based completion engine. It collects all of the identifiers in the
2013-05-26 16:28:00 -04:00
current file and other files you visit (and your tags files) and searches them
when you type (identifiers are put into per-filetype groups).
2013-01-31 14:05:49 -05:00
2013-02-16 17:26:24 -05:00
The demo also shows the semantic engine in use. When the user presses `.` , `->`
2013-04-15 01:11:41 -04:00
or `::` while typing in insert mode (for C++; different triggers are used for
other languages), the semantic engine is triggered (it can also be triggered
with a keyboard shortcut; see the rest of the docs).
2013-01-31 14:05:49 -05:00
2014-01-07 02:05:01 -05:00
The last thing that you can see in the demo is YCM's diagnostic display features
(the little red X that shows up in the left gutter; inspired by [Syntastic][])
2019-01-16 09:08:21 -05:00
if you are editing a C-family file. As the completer engine compiles your file
and detects warnings or errors, they will be presented in various ways. You
don't need to save your file or press any keyboard shortcut to trigger this, it
"just happens" in the background.
2013-01-31 14:05:49 -05:00
In essence, YCM obsoletes the following Vim plugins because it has all of their
features plus extra:
- clang_complete
- AutoComplPop
- Supertab
- neocomplcache
2016-02-26 20:09:00 -05:00
**And that's not all...**
2016-01-24 11:37:57 -05:00
YCM also provides [semantic IDE-like features ](#quick-feature-summary ) in a
number of languages, including:
- finding declarations, definitions, usages, etc. of identifiers,
- displaying type information for classes, variables, functions etc.,
- displaying documentation for methods, members, etc. in the preview window,
- fixing common coding errors, like missing semi-colons, typos, etc.,
2018-04-06 21:55:24 -04:00
- semantic renaming of variables across files,
- formatting code,
- removing unused imports, sorting imports, etc.
2016-01-24 11:37:57 -05:00
Features vary by file type, so make sure to check out the [file type feature
summary](#quick-feature-summary) and the
[full list of completer subcommands ](#ycmcompleter-subcommands ) to
find out what's available for your favourite languages.
2013-03-31 23:42:29 -04:00
2013-04-23 00:44:18 -04:00
You'll also find that YCM has filepath completers (try typing `./` in a file)
and a completer that integrates with [UltiSnips][].
2015-01-19 16:27:34 -05:00
Installation
------------
2019-05-04 16:29:50 -04:00
### macOS
2013-01-22 00:36:17 -05:00
2017-01-01 19:01:39 -05:00
These instructions (using `install.py` ) are the quickest way to install
YouCompleteMe, however they may not work for everyone. If the following
instructions don't work for you, check out the [full installation
guide](#full-installation-guide).
2013-01-22 00:36:17 -05:00
2019-05-04 16:29:50 -04:00
[MacVim][] is required. YCM won't work with the pre-installed Vim from Apple as
its Python support is broken. If you don't already use [MacVim][], install it
with [Homebrew][brew]. Install CMake as well:
2013-02-05 03:18:42 -05:00
2019-05-04 16:29:50 -04:00
brew install cmake macvim
2013-01-22 00:36:17 -05:00
2019-05-11 08:39:45 -04:00
Install YouCompleteMe with [Vundle][].
2013-02-12 23:58:00 -05:00
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
2016-02-24 16:43:03 -05:00
using Vundle and the ycm_core library APIs have changed (happens
2013-10-24 15:31:38 -04:00
rarely), YCM will notify you to recompile it. You should then rerun the install
process.
2013-02-07 21:34:45 -05:00
2015-03-27 15:59:19 -04:00
**NOTE:** If you want C-family completion, you MUST have the latest Xcode
2015-12-19 12:41:09 -05:00
installed along with the latest Command Line Tools (they are installed
automatically when you run `clang` for the first time, or manually by running
`xcode-select --install` )
2013-02-14 12:50:44 -05:00
2019-01-16 09:08:21 -05:00
Compiling YCM **with** semantic support for C-family languages through
**libclang**:
2013-01-22 00:36:17 -05:00
2013-02-07 21:34:45 -05:00
cd ~/.vim/bundle/YouCompleteMe
2015-08-22 02:23:58 -04:00
./install.py --clang-completer
2013-01-22 00:36:17 -05:00
2019-01-16 09:08:21 -05:00
Compiling YCM **with** semantic support for C-family languages through
**experimental clangd**:
cd ~/.vim/bundle/YouCompleteMe
./install.py --clangd-completer
Note that you can install YCM with both **libclang** and **clangd** enabled. In
that case **clangd** will be preferred unless you have the following in your
`vimrc` :
```viml
2019-02-18 10:37:33 -05:00
let g:ycm_use_clangd = 0
2019-01-16 09:08:21 -05:00
```
2013-01-22 00:36:17 -05:00
Compiling YCM **without** semantic support for C-family languages:
2013-02-07 21:34:45 -05:00
cd ~/.vim/bundle/YouCompleteMe
2015-08-22 02:23:58 -04:00
./install.py
2013-01-22 00:36:17 -05:00
2015-12-19 12:41:09 -05:00
The following additional language support options are available:
2019-05-04 16:29:50 -04:00
- C# support: install Mono with [Homebrew][brew] or by downloading the [Mono
macOS package][mono-install-macos] and add `--cs-completer` when calling
2018-08-19 20:12:09 -04:00
`install.py` .
2017-10-02 17:06:25 -04:00
- Go support: install [Go][go-install] and add `--go-completer` when calling
2018-08-19 20:12:09 -04:00
`install.py` .
2018-10-14 09:19:15 -04:00
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] and
add `--ts-completer` when calling `install.py` .
2019-06-28 08:52:28 -04:00
- Rust support: add `--rust-completer` when calling `install.py` .
- If your Python interpreter is older than 2.7.9, you will also need
[rustup][] in your `PATH` .
2017-10-03 02:41:10 -04:00
- Java support: install [JDK8 (version 8 required)][jdk-install] and add
2018-08-19 20:12:09 -04:00
`--java-completer` when calling `install.py` .
2015-12-19 12:41:09 -05:00
2019-01-16 09:08:21 -05:00
To simply compile with everything enabled, there's a `--all` flag. Note that
this flag does **not** install **clangd** . You need to specify it manually by
adding `--clangd-completer` . So, to install with all language features, ensure
2019-06-28 08:52:28 -04:00
`xbuild` , `go` , `tsserver` , `node` and `npm` tools are
2019-01-16 09:08:21 -05:00
installed and in your `PATH` , then simply run:
2015-12-19 12:41:09 -05:00
cd ~/.vim/bundle/YouCompleteMe
2016-03-05 11:20:19 -05:00
./install.py --all
2013-07-17 22:36:25 -04:00
2013-03-31 23:38:29 -04:00
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
you will need to provide the compilation flags for your project to YCM. It's all
in the User Guide.
2013-01-22 00:36:17 -05:00
YCM comes with sane defaults for its options, but you still may want to take a
look at what's available for configuration. There are a few interesting options
that are conservatively turned off by default that you may want to turn on.
2018-08-19 20:12:09 -04:00
### Linux 64-bit
2013-01-22 00:36:17 -05:00
2017-01-01 19:01:39 -05:00
These instructions (using `install.py` ) are the quickest way to install
YouCompleteMe, however they may not work for everyone. If the following
instructions don't work for you, check out the [full installation
guide](#full-installation-guide).
2013-01-22 00:36:17 -05:00
2018-08-19 20:12:09 -04:00
Make sure you have Vim 7.4.1578 with Python 2 or Python 3 support. The Vim
package on Fedora 27 and later and the pre-installed Vim on Ubuntu 16.04 and
later are recent enough. You can see the version of Vim installed by running
`vim --version` . If the version is too old, you may need to [compile Vim from
source][vim-build] (don't worry, it's easy).
2013-01-22 00:36:17 -05:00
Install YouCompleteMe with [Vundle][].
2013-02-12 23:58:00 -05:00
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
2018-08-19 20:12:09 -04:00
using Vundle and the ycm_core library APIs have changed (happens rarely), YCM
will notify you to recompile it. You should then rerun the install process.
2015-10-21 18:19:27 -04:00
2018-08-19 20:12:09 -04:00
Install development tools, CMake, and Python headers:
2015-10-21 18:19:27 -04:00
2018-08-19 20:12:09 -04:00
- Fedora 27 and later:
2015-10-21 18:19:27 -04:00
2018-10-06 21:07:35 -04:00
sudo dnf install cmake gcc-c++ make python3-devel
2015-10-21 18:19:27 -04:00
2018-08-19 20:12:09 -04:00
- Ubuntu 14.04:
2017-03-08 13:48:48 -05:00
2018-08-19 20:12:09 -04:00
sudo apt install build-essential cmake3 python3-dev
2015-10-21 18:19:27 -04:00
2018-08-19 20:12:09 -04:00
- Ubuntu 16.04 and later:
2017-03-07 19:43:56 -05:00
2018-08-19 20:12:09 -04:00
sudo apt install build-essential cmake python3-dev
2015-10-21 18:19:27 -04:00
2019-01-16 09:08:21 -05:00
Compiling YCM **with** semantic support for C-family languages through
**libclang**:
2015-10-21 18:19:27 -04:00
cd ~/.vim/bundle/YouCompleteMe
2019-05-02 12:27:42 -04:00
python3 install.py --clang-completer
2019-01-16 09:08:21 -05:00
Compiling YCM **with** semantic support for C-family languages through
**experimental clangd**:
cd ~/.vim/bundle/YouCompleteMe
2019-05-02 12:27:42 -04:00
python3 install.py --clangd-completer
2019-01-16 09:08:21 -05:00
Note that you can install YCM with both **libclang** and **clangd** enabled. In
that case **clangd** will be preferred unless you have the following in your
`vimrc` :
```viml
2019-02-18 10:37:33 -05:00
let g:ycm_use_clangd = 0
2019-01-16 09:08:21 -05:00
```
2015-10-21 18:19:27 -04:00
Compiling YCM **without** semantic support for C-family languages:
cd ~/.vim/bundle/YouCompleteMe
2018-08-19 20:12:09 -04:00
python3 install.py
2015-10-21 18:19:27 -04:00
2015-12-19 12:41:09 -05:00
The following additional language support options are available:
2018-08-19 20:12:09 -04:00
- C# support: install [Mono][mono-install-linux] and add `--cs-completer`
when calling `install.py` .
2017-10-02 17:06:25 -04:00
- Go support: install [Go][go-install] and add `--go-completer` when calling
2018-08-19 20:12:09 -04:00
`install.py` .
2018-10-14 09:19:15 -04:00
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] and
add `--ts-completer` when calling `install.py` .
2019-06-28 08:52:28 -04:00
- Rust support: add `--rust-completer` when calling `install.py` .
- If your Python interpreter is older than 2.7.9, you will also need
[rustup][] in your `PATH` .
2017-10-03 02:41:10 -04:00
- Java support: install [JDK8 (version 8 required)][jdk-install] and add
2018-08-19 20:12:09 -04:00
`--java-completer` when calling `install.py` .
2015-12-19 12:41:09 -05:00
2019-01-16 09:08:21 -05:00
To simply compile with everything enabled, there's a `--all` flag. Note that
this flag does **not** install **clangd** . You need to specify it manually by
adding `--clangd-completer` . So, to install with all language features, ensure
2019-06-28 08:52:28 -04:00
`xbuild` , `go` , `tsserver` , `node` , `npm` and tools are
2019-01-16 09:08:21 -05:00
installed and in your `PATH` , then simply run:
2015-12-19 12:41:09 -05:00
cd ~/.vim/bundle/YouCompleteMe
2018-08-19 20:12:09 -04:00
python3 install.py --all
2013-07-17 22:36:25 -04:00
2013-03-31 23:38:29 -04:00
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
you will need to provide the compilation flags for your project to YCM. It's all
in the User Guide.
2013-01-22 00:36:17 -05:00
YCM comes with sane defaults for its options, but you still may want to take a
look at what's available for configuration. There are a few interesting options
that are conservatively turned off by default that you may want to turn on.
2016-02-26 20:09:00 -05:00
### Windows
2013-02-23 19:50:21 -05:00
2017-01-01 19:01:39 -05:00
These instructions (using `install.py` ) are the quickest way to install
YouCompleteMe, however they may not work for everyone. If the following
instructions don't work for you, check out the [full installation
guide](#full-installation-guide).
2015-09-20 20:36:34 -04:00
**Important:** we assume that you are using the `cmd.exe` command prompt and
that you know how to add an executable to the PATH environment variable.
2017-04-11 07:46:20 -04:00
Make sure you have at least Vim 7.4.1578 with Python 2 or Python 3 support. You
2016-03-20 08:55:25 -04:00
can check the version and which Python is supported by typing `:version` inside
Vim. Look at the features included: `+python/dyn` for Python 2 and
`+python3/dyn` for Python 3. Take note of the Vim architecture, i.e. 32 or
64-bit. It will be important when choosing the Python installer. We recommend
2018-12-21 10:34:27 -05:00
using a 64-bit client. [Daily updated installers of 32-bit and 64-bit Vim with
2016-03-20 08:55:25 -04:00
Python 2 and Python 3 support][vim-win-download] are available.
2015-09-20 20:36:34 -04:00
2017-05-16 13:09:19 -04:00
Add the line:
set encoding=utf-8
to your [vimrc][] if not already present. This option is required by YCM. Note
that it does not prevent you from editing a file in another encoding than UTF-8.
You can do that by specifying [the `++enc` argument][++enc] to the `:e` command.
2015-09-20 20:36:34 -04:00
Install YouCompleteMe with [Vundle][].
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
2016-02-24 16:43:03 -05:00
using Vundle and the ycm_core library APIs have changed (happens
2015-09-20 20:36:34 -04:00
rarely), YCM will notify you to recompile it. You should then rerun the install
process.
Download and install the following software:
2016-03-20 08:55:25 -04:00
- [Python 2 or Python 3][python-win-download]. Be sure to pick the version
2017-10-03 02:41:10 -04:00
corresponding to your Vim architecture. It is _Windows x86_ for a 32-bit Vim
and _Windows x86-64_ for a 64-bit Vim. We recommend installing Python 3.
Additionally, the version of Python you install must match up exactly with
2017-11-13 19:23:23 -05:00
the version of Python that Vim is looking for. Type `:version` and look at the
2017-10-03 02:41:10 -04:00
bottom of the page at the list of compiler flags. Look for flags that look
similar to `-DDYNAMIC_PYTHON_DLL=\"python27.dll\"` and
`-DDYNAMIC_PYTHON3_DLL=\"python35.dll\"` . The former indicates that Vim is
looking for Python 2.7 and the latter indicates that Vim is looking for
Python 3.5. You'll need one or the other installed, matching the version
2017-11-13 19:23:23 -05:00
number exactly.
2015-09-20 20:36:34 -04:00
- [CMake][cmake-download]. Add CMake executable to the PATH environment
2018-08-19 20:12:09 -04:00
variable.
2019-04-23 18:13:10 -04:00
- [Visual Studio Build Tools 2017][visual-studio-download]. During setup,
select _Visual C++ build tools_ in _Workloads_ .
2015-09-20 20:36:34 -04:00
2019-01-16 09:08:21 -05:00
Compiling YCM **with** semantic support for C-family languages through
**libclang**:
2015-09-20 20:36:34 -04:00
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
2018-02-26 10:45:48 -05:00
python install.py --clang-completer
2015-09-20 20:36:34 -04:00
2019-01-16 09:08:21 -05:00
Compiling YCM **with** semantic support for C-family languages through
**experimental clangd**:
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
python install.py --clangd-completer
Note that you can install YCM with both **libclang** and **clangd** enabled. In
that case **clangd** will be preferred unless you have the following in your
`vimrc` :
```viml
2019-02-18 10:37:33 -05:00
let g:ycm_use_clangd = 0
2019-01-16 09:08:21 -05:00
```
2015-09-20 20:36:34 -04:00
Compiling YCM **without** semantic support for C-family languages:
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
2018-02-26 10:45:48 -05:00
python install.py
2015-09-20 20:36:34 -04:00
2015-12-19 12:41:09 -05:00
The following additional language support options are available:
2017-10-02 17:06:25 -04:00
- C# support: add `--cs-completer` when calling `install.py` .
2016-01-25 04:47:59 -05:00
Be sure that [the build utility `msbuild` is in your PATH][add-msbuild-to-path].
2017-10-02 17:06:25 -04:00
- Go support: install [Go][go-install] and add `--go-completer` when calling
2016-03-20 17:43:33 -04:00
`install.py` .
2018-10-14 09:19:15 -04:00
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] and
add `--ts-completer` when calling `install.py` .
2019-06-28 08:52:28 -04:00
- Rust support: add `--rust-completer` when calling `install.py` .
- If your Python interpreter is older than 2.7.9, you will also need
[rustup][] in your `PATH` .
2017-10-03 02:41:10 -04:00
- Java support: install [JDK8 (version 8 required)][jdk-install] and add
2018-08-19 20:12:09 -04:00
`--java-completer` when calling `install.py` .
2015-12-19 12:41:09 -05:00
2019-01-16 09:08:21 -05:00
To simply compile with everything enabled, there's a `--all` flag. Note that
this flag does **not** install **clangd** . You need to specify it manually by
adding `--clangd-completer` . So, to install with all language features, ensure
2019-06-28 08:52:28 -04:00
`msbuild` , `go` , `tsserver` , `node` and `npm` tools are installed and
2019-01-16 09:08:21 -05:00
in your `PATH` , then simply run:
2015-12-19 12:41:09 -05:00
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
2016-03-05 11:20:19 -05:00
python install.py --all
2015-09-20 20:36:34 -04:00
You can specify the Microsoft Visual C++ (MSVC) version using the `--msvc`
2018-04-16 14:18:55 -04:00
option. YCM officially supports MSVC 14 (Visual Studio 2015) and 15 (2017).
2015-09-20 20:36:34 -04:00
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
you will need to provide the compilation flags for your project to YCM. It's all
in the User Guide.
YCM comes with sane defaults for its options, but you still may want to take a
look at what's available for configuration. There are a few interesting options
that are conservatively turned off by default that you may want to turn on.
2013-01-22 00:36:17 -05:00
2016-02-26 20:09:00 -05:00
### FreeBSD/OpenBSD
2014-12-03 13:37:52 -05:00
2017-01-01 19:01:39 -05:00
These instructions (using `install.py` ) are the quickest way to install
YouCompleteMe, however they may not work for everyone. If the following
instructions don't work for you, check out the [full installation
guide](#full-installation-guide).
**NOTE:** OpenBSD / FreeBSD are not officially supported platforms by YCM.
2014-11-17 06:54:16 -05:00
2017-04-11 07:46:20 -04:00
Make sure you have Vim 7.4.1578 with Python 2 or Python 3 support.
2014-12-03 18:46:30 -05:00
OpenBSD 5.5 and later have a Vim that's recent enough. You can see the version of
Vim installed by running `vim --version` .
2018-05-09 11:56:09 -04:00
For FreeBSD 11.x, the requirement is cmake:
2014-12-03 18:46:30 -05:00
2018-05-09 11:56:09 -04:00
pkg install cmake
2014-11-17 06:54:16 -05:00
Install YouCompleteMe with [Vundle][].
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
2016-02-24 16:43:03 -05:00
using Vundle and the ycm_core library APIs have changed (happens
2014-11-17 06:54:16 -05:00
rarely), YCM will notify you to recompile it. You should then rerun the install
process.
2019-01-16 09:08:21 -05:00
Compiling YCM **with** semantic support for C-family languages through
**libclang**:
2014-11-17 06:54:16 -05:00
cd ~/.vim/bundle/YouCompleteMe
2018-05-09 11:56:09 -04:00
./install.py --clang-completer
2014-11-17 06:54:16 -05:00
2019-01-16 09:08:21 -05:00
Compiling YCM **with** semantic support for C-family languages through
**experimental clangd**:
cd ~/.vim/bundle/YouCompleteMe
./install.py --clangd-completer
Note that you can install YCM with both **libclang** and **clangd** enabled. In
that case **clangd** will be preferred unless you have the following in your
`vimrc` :
```viml
2019-02-18 10:37:33 -05:00
let g:ycm_use_clangd = 0
2019-01-16 09:08:21 -05:00
```
2014-11-17 06:54:16 -05:00
Compiling YCM **without** semantic support for C-family languages:
cd ~/.vim/bundle/YouCompleteMe
2018-05-09 11:56:09 -04:00
./install.py
If the `python` executable is not present, or the default `python` is not the
one that should be compiled against, specify the python interpreter explicitly:
python3 install.py --clang-completer
2014-11-17 06:54:16 -05:00
2015-12-19 12:41:09 -05:00
The following additional language support options are available:
2017-10-02 17:06:25 -04:00
- C# support: install Mono and add `--cs-completer` when calling
2016-06-09 07:07:51 -04:00
`./install.py` .
2017-10-02 17:06:25 -04:00
- Go support: install [Go][go-install] and add `--go-completer` when calling
2016-03-20 17:43:33 -04:00
`./install.py` .
2018-10-14 09:19:15 -04:00
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] and
add `--ts-completer` when calling `install.py` .
2019-06-28 08:52:28 -04:00
- Rust support: add `--rust-completer` when calling `./install.py` .
- If your Python interpreter is older than 2.7.9, you will also need
[rustup][] in your `PATH` .
2017-10-03 02:41:10 -04:00
- Java support: install [JDK8 (version 8 required)][jdk-install] and add
`--java-completer` when calling `./install.py` .
2015-12-19 12:41:09 -05:00
2019-01-16 09:08:21 -05:00
To simply compile with everything enabled, there's a `--all` flag. Note that
this flag does **not** install **clangd** . You need to specify it manually by
adding `--clangd-completer` . So, to install with all language features, ensure
2019-06-28 08:52:28 -04:00
`xbuild` , `go` , `tsserver` , `node` , `npm` and tools are
2019-01-16 09:08:21 -05:00
installed and in your `PATH` , then simply run:
2015-12-19 12:41:09 -05:00
cd ~/.vim/bundle/YouCompleteMe
2016-03-05 11:20:19 -05:00
./install.py --all
2014-11-17 06:54:16 -05:00
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
you will need to provide the compilation flags for your project to YCM. It's all
in the User Guide.
YCM comes with sane defaults for its options, but you still may want to take a
look at what's available for configuration. There are a few interesting options
that are conservatively turned off by default that you may want to turn on.
2015-01-19 16:27:34 -05:00
### Full Installation Guide
2013-01-22 00:36:17 -05:00
2015-09-20 20:36:34 -04:00
These are the steps necessary to get YCM working on a Unix OS and on Windows.
**Note to Windows users:** we assume that you are running the `cmd.exe` command
prompt and that the needed executables are in the PATH environment variable. Do
not just copy the shell commands. Replace `~` by `%USERPROFILE%` in them and use
the right Vim home directory. It should be `vimfiles` by default instead of
`.vim` .
2013-01-22 00:36:17 -05:00
2013-03-31 23:38:29 -04:00
See the _FAQ_ if you have any issues.
2013-02-03 01:28:11 -05:00
2013-02-12 23:58:00 -05:00
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
2016-02-24 16:43:03 -05:00
using Vundle and the ycm_core library APIs have changed (happens
2013-10-24 15:31:38 -04:00
rarely), YCM will notify you to recompile it. You should then rerun the install
process.
2013-02-12 23:58:00 -05:00
2013-01-26 19:47:59 -05:00
**Please follow the instructions carefully. Read EVERY WORD.**
2013-01-22 00:36:17 -05:00
2017-04-11 07:46:20 -04:00
1. **Ensure that your version of Vim is _at least_ 7.4.1578 _and_ that it has
2016-03-20 08:55:25 -04:00
support for Python 2 or Python 3 scripting**.
2013-01-22 00:36:17 -05:00
Inside Vim, type `:version` . Look at the first two to three lines of output;
2015-03-17 15:56:01 -04:00
it should say `Vi IMproved X.Y` , where X.Y is the major version of vim. If
2016-04-27 18:31:05 -04:00
your version is greater than 7.4, then you're all set. If your version is
7.4 then look below that where it says, `Included patches: 1-Z` , where Z
2017-06-28 02:06:20 -04:00
will be some number. That number needs to be 1578 or higher.
2013-01-22 00:36:17 -05:00
2013-02-02 16:29:27 -05:00
If your version of Vim is not recent enough, you may need to [compile Vim
from source][vim-build] (don't worry, it's easy).
2017-04-11 07:46:20 -04:00
After you have made sure that you have Vim 7.4.1578+, type the following in
2016-02-28 20:45:41 -05:00
Vim: `:echo has('python') || has('python3')` . The output should be 1. If
it's 0, then get a version of Vim with Python support.
2013-01-22 00:36:17 -05:00
2015-09-20 20:36:34 -04:00
On Windows, check also if your Vim architecture is 32 or 64-bit. This is
2016-03-20 08:55:25 -04:00
critical because it must match the Python and the YCM libraries
2015-09-20 20:36:34 -04:00
architectures. We recommend using a 64-bit Vim.
2013-01-22 00:36:17 -05:00
2. **Install YCM** with [Vundle][] (or [Pathogen][], but Vundle is a better
2014-06-04 23:13:34 -04:00
idea). With Vundle, this would mean adding a `Plugin
2013-01-22 00:36:17 -05:00
'Valloric/YouCompleteMe'` line to your [vimrc][].
2013-10-24 18:58:20 -04:00
If you don't install YCM with Vundle, make sure you have run
`git submodule update --init --recursive` after checking out the YCM
2013-10-24 19:00:00 -04:00
repository (Vundle will do this for you) to fetch YCM's dependencies.
2013-10-24 18:58:20 -04:00
2018-05-02 14:55:30 -04:00
3. *Complete this step ONLY if you care about semantic completion support for
C-family languages. Otherwise it's not necessary.*
2013-01-22 00:36:17 -05:00
**Download the latest version of `libclang`** . Clang is an open-source
2018-08-16 22:59:15 -04:00
compiler that can compile C-family languages. The `libclang` library it
provides is used to power the YCM semantic completion engine for those
2019-04-27 16:01:33 -04:00
languages. YCM is designed to work with libclang version 8.0.0 or higher.
2013-01-22 00:36:17 -05:00
2019-01-16 09:08:21 -05:00
In addition to `libclang` , YCM also supports an **experimental**
2019-03-17 16:00:32 -04:00
[clangd][]-based completer. You can download the latest version of
[clangd][] from [llvm.org releases][clang-download]. Follow Step 4 to learn
how to tell YCM where to find clangd binary. Please note that YCM is
2019-04-27 16:01:33 -04:00
designed to work with [clangd][] version 8.0.0 or higher.
2019-01-16 09:08:21 -05:00
You can use the system libclang or clangd _only if you are sure it is
2019-04-27 16:01:33 -04:00
version 8.0.0 or higher_, otherwise don't. Even if it is, we recommend using
2019-01-16 09:08:21 -05:00
the [official binaries from llvm.org][clang-download] if at all possible.
Make sure you download the correct archive file for your OS.
2013-01-22 00:36:17 -05:00
2019-01-16 09:08:21 -05:00
We **STRONGLY recommend AGAINST use** of the system libclang or clangd
instead of the upstream compiled binaries. Random things may break. Save
yourself the hassle and use the upstream pre-built libclang or clangd.
2014-04-02 17:30:39 -04:00
2016-03-04 22:39:18 -05:00
4. **Compile the `ycm_core` library** that YCM needs. This library
is the C++ engine that YCM uses to get fast completions.
2013-01-22 00:36:17 -05:00
You will need to have `cmake` installed in order to generate the required
makefiles. Linux users can install cmake with their package manager (`sudo
apt-get install cmake` for Ubuntu) whereas other users can [download and
2019-05-04 16:29:50 -04:00
install][cmake-download] cmake from its project site. macOS users can also
get it through [Homebrew][brew] with `brew install cmake` .
2013-01-22 00:36:17 -05:00
2015-09-20 20:36:34 -04:00
On a Unix OS, you need to make sure you have Python headers installed. On a
2016-03-04 22:39:18 -05:00
Debian-like Linux distro, this would be `sudo apt-get install python-dev
2019-05-04 16:29:50 -04:00
python3-dev`. On macOS they should already be present.
2013-02-07 19:56:58 -05:00
2016-03-20 08:55:25 -04:00
On Windows, you need to download and install [Python 2 or
Python 3][python-win-download]. Pick the version corresponding to your Vim
architecture. You will also need Microsoft Visual C++ (MSVC) to build YCM.
2019-04-23 18:13:10 -04:00
You can obtain it by installing [Visual Studio Build
Tools][visual-studio-download]. MSVC 14 (Visual Studio 2015) and 15 (2017)
are officially supported.
2015-09-20 20:36:34 -04:00
2013-01-22 00:36:17 -05:00
Here we'll assume you installed YCM with Vundle. That means that the
top-level YCM directory is in `~/.vim/bundle/YouCompleteMe` .
We'll create a new folder where build files will be placed. Run the
following:
cd ~
mkdir ycm_build
cd ycm_build
Now we need to generate the makefiles. If you DON'T care about semantic
2019-03-17 16:00:32 -04:00
support for C-family languages or plan to use **experimental** [clangd][]
2019-01-16 09:08:21 -05:00
based completer, run the following command in the `ycm_build` directory:
2013-07-17 22:36:25 -04:00
2015-09-20 20:36:34 -04:00
cmake -G "< generator > " . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
where `<generator>` is `Unix Makefiles` on Unix systems and one of the
following Visual Studio generators on Windows:
2016-01-11 07:05:55 -05:00
- `Visual Studio 14 Win64`
2017-04-08 06:43:10 -04:00
- `Visual Studio 15 Win64`
2015-09-20 20:36:34 -04:00
Remove the `Win64` part in these generators if your Vim architecture is
32-bit.
2013-01-22 00:36:17 -05:00
2014-11-17 06:54:16 -05:00
For those who want to use the system version of boost, you would pass
2014-12-31 18:52:15 -05:00
`-DUSE_SYSTEM_BOOST=ON` to cmake. This may be necessary on some systems
2014-11-17 06:54:16 -05:00
where the bundled version of boost doesn't compile out of the box.
2017-01-01 19:01:39 -05:00
**NOTE:** We **STRONGLY recommend AGAINST use** of the system boost instead
2014-11-17 06:54:16 -05:00
of the bundled version of boost. Random things may break. Save yourself
the hassle and use the bundled version of boost.
2019-01-16 09:08:21 -05:00
If you DO care about semantic support for C-family languages, and want to
use libclang as the provider instead of **experimental** [clangd][]-based
completer then your `cmake` call will be a bit more complicated. We'll
assume you downloaded a binary distribution of LLVM+Clang from llvm.org in
step 3 and that you extracted the archive file to folder
`~/ycm_temp/llvm_root_dir` (with `bin` , `lib` , `include` etc. folders right
inside that folder). On Windows, you can extract the files from the
LLVM+Clang installer using [7-zip][7z-download].
2015-03-17 15:56:01 -04:00
2017-01-01 19:01:39 -05:00
**NOTE:** This _only_ works with a _downloaded_ LLVM binary package, not a
2015-03-17 15:56:01 -04:00
custom-built LLVM! See docs below for `EXTERNAL_LIBCLANG_PATH` when using a
custom LLVM build.
With that in mind, run the following command in the `ycm_build` directory:
2013-07-17 22:36:25 -04:00
2015-09-20 20:36:34 -04:00
cmake -G "< generator > " -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
where `<generator>` is replaced like above.
Now that configuration files have been generated, compile the libraries
using this command:
2013-01-22 00:36:17 -05:00
2016-02-24 16:43:03 -05:00
cmake --build . --target ycm_core --config Release
2013-07-17 22:36:25 -04:00
2015-09-20 20:36:34 -04:00
The `--config Release` part is specific to Windows and will be ignored on a
Unix OS.
2013-01-22 00:36:17 -05:00
For those who want to use the system version of libclang, you would pass
`-DUSE_SYSTEM_LIBCLANG=ON` to cmake _instead of_ the
`-DPATH_TO_LLVM_ROOT=...` flag.
2017-01-01 19:01:39 -05:00
**NOTE:** We **STRONGLY recommend AGAINST use** of the system libclang instead
2014-04-02 17:30:39 -04:00
of the upstream compiled binaries. Random things may break. Save yourself
the hassle and use the upstream pre-built libclang.
2013-01-22 00:36:17 -05:00
You could also force the use of a custom libclang library with
`-DEXTERNAL_LIBCLANG_PATH=/path/to/libclang.so` flag (the library would end
2019-05-04 16:29:50 -04:00
with `.dylib` on macOS). Again, this flag would be used _instead of_ the
2015-03-17 15:56:01 -04:00
other flags. **If you compiled LLVM from source, this is the flag you should
be using.**
2013-01-22 00:36:17 -05:00
2016-02-03 11:51:35 -05:00
Running the `cmake` command will also place the `libclang.[so|dylib|dll]` in
2015-09-20 20:36:34 -04:00
the `YouCompleteMe/third_party/ycmd` folder for you if you compiled with
clang support (it needs to be there for YCM to work).
2013-01-26 19:44:58 -05:00
2019-01-16 09:08:21 -05:00
If you DO care about semantic support for C-family languages, and want to
use **experimental** [clangd][]-based completer then you need to add
2019-02-18 10:37:33 -05:00
following line to your `vimrc` :
2019-01-16 09:08:21 -05:00
```viml
let g:ycm_clangd_binary_path = "/path/to/clangd"
```
2019-03-17 16:00:32 -04:00
You need to change `/path/to/clangd` with the path of binary you downloaded
in step 3.
2019-01-16 09:08:21 -05:00
2018-05-02 14:55:30 -04:00
5. *This step is optional.*
Build the [regex][] module for improved Unicode support and better
performance with regular expressions. The procedure is similar to compiling
the `ycm_core` library:
cd ~
mkdir regex_build
cd regex_build
cmake -G "< generator > " . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex
cmake --build . --target _regex --config Release
where `<generator>` is the same generator used in the previous step.
6. Set up support for additional languages, as desired:
2015-12-19 12:41:09 -05:00
2017-04-08 06:54:33 -04:00
- C# support: install [Mono on non-Windows platforms][mono-install].
2019-06-28 08:52:28 -04:00
Navigate to `YouCompleteMe/third_party/ycmd/third_party/omnisharp-roslyn` .
Download an [Omnisharp-Roslyn release archive][roslyn-releases] and
extract the archive to
`YouCompleteMe/third_party/ycmd/third_party/omnisharp-roslyn` .
2017-06-05 05:31:28 -04:00
2017-12-07 07:25:33 -05:00
On Windows, be sure that [the build utility `msbuild` is in your
2017-06-05 05:31:28 -04:00
PATH][add-msbuild-to-path].
2015-12-19 12:41:09 -05:00
2017-04-08 06:54:33 -04:00
- Go support: install [Go][go-install] and add it to your path. Navigate to
2019-06-28 08:52:28 -04:00
`YouCompleteMe/third_party/ycmd/third_party/go/src/golang.org/x/tools/cmd/gopls`
and run
2019-02-19 12:03:16 -05:00
2019-06-28 08:52:28 -04:00
go build
2015-12-19 12:41:09 -05:00
2018-10-14 09:19:15 -04:00
- JavaScript and TypeScript support: install [Node.js and npm][npm-install],
navigate to `YouCompleteMe/third_party/ycmd` and run
`npm install -g --prefix third_party/tsserver typescript` .
2015-12-19 12:41:09 -05:00
2019-06-28 08:52:28 -04:00
- Rust support: install [rustup][]. Export `RUSTUP_HOME` environment
variable and point it to an empty temporary directory.
Run the following commands:
rustup toolchain install nightly
rustup default nightly
rustup component add rls rust-analysis rust-src
Ensure that `YouCompleteMe/third_party/ycmd/third_party/rls` directory
exists and is empty. Go into the temporary directory and then into
`toolchains/<toolchain>` . Finally, move everything from that directory to
`YouCompleteMe/third_party/ycmd/third_party/rls` .
2016-01-07 11:52:15 -05:00
2017-10-03 02:41:10 -04:00
- Java support: install [JDK8 (version 8 required)][jdk-install]. Download a
[binary release of eclipse.jdt.ls][jdtls-release] and extract it to
`YouCompleteMe/third_party/ycmd/third_party/eclipse.jdt.ls/target/repository` .
Note: this approach is not recommended for most users and is supported
only for advanced users and developers of YCM on a best-efforts basis.
Please use `install.py` to enable java support.
2013-03-31 23:38:29 -04:00
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
you will need to provide the compilation flags for your project to YCM. It's all
in the User Guide.
2013-01-22 00:36:17 -05:00
YCM comes with sane defaults for its options, but you still may want to take a
look at what's available for configuration. There are a few interesting options
that are conservatively turned off by default that you may want to turn on.
2015-09-13 08:28:22 -04:00
Quick Feature Summary
-----
### General (all languages)
* Super-fast identifier completer including tags files and syntax elements
* Intelligent suggestion ranking and filtering
* File and path suggestions
* Suggestions from Vim's OmniFunc
* UltiSnips snippet suggestions
2018-08-16 22:59:15 -04:00
### C-family languages (C, C++, Objective C, Objective C++, CUDA)
2015-09-13 08:28:22 -04:00
2018-08-16 22:36:27 -04:00
* Semantic auto-completion with automatic fixes
2015-09-13 08:28:22 -04:00
* Real-time diagnostic display
2015-10-20 09:06:49 -04:00
* Go to include/declaration/definition (`GoTo`, etc.)
2015-09-24 17:25:27 -04:00
* View documentation comments for identifiers (`GetDoc`)
2019-01-27 10:16:41 -05:00
* Type information for identifiers (`GetType`)
* Automatically fix certain errors (`FixIt`)
2015-09-13 08:28:22 -04:00
### C♯
* Semantic auto-completion
* Real-time diagnostic display
* Go to declaration/definition (`GoTo`, etc.)
2019-06-28 08:52:28 -04:00
* Go to implementation (`GoToImplementation`)
2019-01-27 10:16:41 -05:00
* View documentation comments for identifiers (`GetDoc`)
* Type information for identifiers (`GetType`)
2015-09-13 08:28:22 -04:00
* Automatically fix certain errors (`FixIt`)
2019-06-28 08:52:28 -04:00
* Management of OmniSharp-Roslyn server instance
2015-09-13 08:28:22 -04:00
2016-01-20 15:52:02 -05:00
### Python
2015-09-13 08:28:22 -04:00
2019-01-27 10:16:41 -05:00
* Semantic auto-completion
2018-07-25 16:25:31 -04:00
* Go to definition (`GoTo`)
* Reference finding (`GoToReferences`)
2015-09-24 17:25:27 -04:00
* View documentation comments for identifiers (`GetDoc`)
2019-01-27 10:16:41 -05:00
* Type information for identifiers (`GetType`)
2015-09-13 08:28:22 -04:00
### Go
* Semantic auto-completion
2019-06-28 08:52:28 -04:00
* Real-time diagnostic display
* Go to declaration/definition (`GoTo`, etc.)
* Go to type definition (`GoToType`)
* Automatically fix certain errors (`FixIt`)
* Type information for identifiers (`GetType`)
* Code formatting (`Format`)
* Management of `gopls` server instance
2015-09-13 08:28:22 -04:00
2017-09-26 14:17:46 -04:00
### JavaScript and TypeScript
2015-09-13 08:28:22 -04:00
2018-04-06 21:55:24 -04:00
* Semantic auto-completion with automatic import insertion
2019-01-27 10:16:41 -05:00
* Real-time diagnostic display
2018-04-06 21:55:24 -04:00
* Go to definition (`GoTo`, `GoToDefinition` , and `GoToDeclaration` are
identical)
* Go to type definition (`GoToType`)
* Reference finding (`GoToReferences`)
2015-09-24 17:25:27 -04:00
* View documentation comments for identifiers (`GetDoc`)
2018-04-06 21:55:24 -04:00
* Type information for identifiers (`GetType`)
* Automatically fix certain errors (`FixIt`)
2019-01-27 10:16:41 -05:00
* Renaming symbols (`RefactorRename < new name > `)
2018-04-06 21:55:24 -04:00
* Code formatting (`Format`)
* Organize imports (`OrganizeImports`)
* Management of `TSServer` server instance
2015-09-13 08:28:22 -04:00
2016-01-07 11:52:15 -05:00
### Rust
* Semantic auto-completion
2019-06-28 08:52:28 -04:00
* Real-time diagnostic display
* Go to declaration/definition (`GoTo`, etc.)
* Go to implementation (`GoToImplementation`)
* Reference finding (`GoToReferences`)
2016-10-20 10:03:09 -04:00
* View documentation comments for identifiers (`GetDoc`)
2019-06-28 08:52:28 -04:00
* Type information for identifiers (`GetType`)
* Renaming symbols (`RefactorRename < new name > `)
* Code formatting (`Format`)
* Execute custom server command (`ExecuteCommand < args > `)
* Management of `rls` server instance
2015-12-19 12:41:09 -05:00
2017-10-03 02:41:10 -04:00
### Java
**NOTE**: Java support is currently experimental. Please let us know your
[feedback ](#contact ).
2018-02-10 18:48:22 -05:00
* Semantic auto-completion with automatic import insertion
2019-01-27 10:16:41 -05:00
* Real-time diagnostic display
2017-10-03 02:41:10 -04:00
* Go to definition (`GoTo`, `GoToDefinition` , and `GoToDeclaration` are
identical)
2019-04-27 15:59:53 -04:00
* Go to type definition (`GoToType`)
* Go to implementation (`GoToImplementation`)
2017-10-03 02:41:10 -04:00
* Reference finding (`GoToReferences`)
* View documentation comments for identifiers (`GetDoc`)
* Type information for identifiers (`GetType`)
2019-01-27 10:16:41 -05:00
* Automatically fix certain errors including code generation (`FixIt`)
* Renaming symbols (`RefactorRename < new name > `)
2018-02-07 13:57:45 -05:00
* Code formatting (`Format`)
2018-04-06 21:55:24 -04:00
* Organize imports (`OrganizeImports`)
2017-10-03 02:41:10 -04:00
* Detection of java projects
2019-06-28 08:52:28 -04:00
* Execute custom server command (`ExecuteCommand < args > `)
2017-10-03 02:41:10 -04:00
* Management of `jdt.ls` server instance
2013-01-22 00:36:17 -05:00
User Guide
----------
2013-01-23 00:05:32 -05:00
### General Usage
2013-01-22 00:36:17 -05:00
2018-04-07 00:01:54 -04:00
If the offered completions are too broad, keep typing characters; YCM will
continue refining the offered completions based on your input.
2018-04-06 23:41:49 -04:00
Filtering is "smart-case" and "smart-[diacritic][]" sensitive; if you are
typing only lowercase letters, then it's case-insensitive. If your input
contains uppercase letters, then the uppercase letters in your query must
match uppercase letters in the completion strings (the lowercase letters still
match both). On top of that, a letter with no diacritic marks will match that
letter with or without marks:
2018-04-25 06:30:03 -04:00
< table >
< tbody >
< tr >
< th > matches< / th >
< th > foo< / th >
2018-04-29 06:45:22 -04:00
< th > fôo< / th >
2018-04-25 06:30:03 -04:00
< th > fOo< / th >
2018-04-29 06:45:22 -04:00
< th > fÔo< / th >
2018-04-25 06:30:03 -04:00
< / tr >
< tr >
< th > foo< / th >
< td > ✔️< / td >
< td > ✔️< / td >
< td > ✔️< / td >
< td > ✔️< / td >
< / tr >
< tr >
2018-04-29 06:45:22 -04:00
< th > fôo< / th >
2018-04-25 06:30:03 -04:00
< td > ❌< / td >
< td > ✔️< / td >
< td > ❌< / td >
< td > ✔️< / td >
< / tr >
< tr >
< th > fOo< / th >
< td > ❌< / td >
< td > ❌< / td >
< td > ✔️< / td >
< td > ✔️< / td >
< / tr >
< tr >
2018-04-29 06:45:22 -04:00
< th > fÔo< / th >
2018-04-25 06:30:03 -04:00
< td > ❌< / td >
< td > ❌< / td >
< td > ❌< / td >
< td > ✔️< / td >
< / tr >
< / tbody >
< / table >
2018-04-07 00:01:54 -04:00
Use the TAB key to accept a completion and continue pressing TAB to cycle
through the completions. Use Shift-TAB to cycle backwards. Note that if you're
using console Vim (that is, not Gvim or MacVim) then it's likely that the
Shift-TAB binding will not work because the console will not pass it to Vim.
You can remap the keys; see the [Options ](#options ) section below.
2013-01-23 00:05:32 -05:00
2013-05-26 16:28:00 -04:00
Knowing a little bit about how YCM works internally will prevent confusion. YCM
has several completion engines: an identifier-based completer that collects all
of the identifiers in the current file and other files you visit (and your tags
files) and searches them when you type (identifiers are put into per-filetype
groups).
2019-01-16 09:08:21 -05:00
There are also several semantic engines in YCM. There are libclang-based and
clangd-based completers that provide semantic completion for C-family languages.
There's a Jedi-based completer for semantic completion for Python. There's also
an omnifunc-based completer that uses data from Vim's omnicomplete system to
2013-05-26 16:28:00 -04:00
provide semantic completions when no native completer exists for that language
in YCM.
There are also other completion engines, like the UltiSnips completer and the
filepath completer.
YCM automatically detects which completion engine would be the best in any
situation. On occasion, it queries several of them at once, merges the
outputs and presents the results to you.
2016-02-26 20:09:00 -05:00
### Client-Server Architecture
2013-10-24 15:31:38 -04:00
YCM has a client-server architecture; the Vim part of YCM is only a thin client
2016-02-17 07:52:25 -05:00
that talks to the [ycmd HTTP+JSON server][ycmd] that has the vast majority of
YCM logic and functionality. The server is started and stopped automatically as
you start and stop Vim.
2013-10-24 15:31:38 -04:00
2016-02-26 20:09:00 -05:00
### Completion String Ranking
2013-01-31 14:05:49 -05:00
The subsequence filter removes any completions that do not match the input, but
then the sorting system kicks in. It's actually very complicated and uses lots
of factors, but suffice it to say that "word boundary" (WB) subsequence
character matches are "worth" more than non-WB matches. In effect, this means
given an input of "gua", the completion "getUserAccount" would be ranked higher
2013-01-31 22:21:11 -05:00
in the list than the "Fooguxa" completion (both of which are subsequence
matches). A word-boundary character are all capital characters, characters
preceded by an underscore and the first letter character in the completion
string.
2013-01-31 14:05:49 -05:00
2016-02-26 20:09:00 -05:00
### General Semantic Completion
2013-01-23 00:05:32 -05:00
2018-04-07 00:01:54 -04:00
You can use Ctrl+Space to trigger the completion suggestions anywhere, even
without a string prefix. This is useful to see which top-level functions are
available for use.
2013-02-12 23:31:46 -05:00
2016-02-26 20:09:00 -05:00
### C-family Semantic Completion
2013-02-12 23:31:46 -05:00
2017-01-01 19:01:39 -05:00
In order to perform semantic analysis such as code completion, `GoTo` and
2019-01-16 09:08:21 -05:00
diagnostics, YouCompleteMe uses `libclang` or `clangd` . Both of them make use of
2017-01-01 19:01:39 -05:00
clang compiler, sometimes also referred to as llvm. Like any compiler,
2019-01-16 09:08:21 -05:00
clang also requires a set of compile flags in order to parse your code. Simply
put: If clang can't parse your code, YouCompleteMe can't provide semantic
2017-01-01 19:01:39 -05:00
analysis.
2019-01-16 09:08:21 -05:00
There are 2 methods which can be used to provide compile flags to clang:
2017-01-01 19:01:39 -05:00
#### Option 1: Use a [compilation database][compdb]
The easiest way to get YCM to compile your code is to use a compilation
database. A compilation database is usually generated by your build system
(e.g. `CMake` ) and contains the compiler invocation for each compilation unit in
your project.
For information on how to generate a compilation database, see the [clang
documentation][compdb]. In short:
- If using CMake, add `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` when configuring (or
add `set( CMAKE_EXPORT_COMPILE_COMMANDS ON )` to `CMakeLists.txt` ) and copy or
symlink the generated database to the root of your project.
- If using Ninja, check out the `compdb` tool (`-t compdb`) in its
[docs][ninja-compdb].
2019-07-27 12:08:24 -04:00
- If using GNU make, check out [compiledb][] or [Bear][].
2017-01-01 19:01:39 -05:00
- For other build systems, check out
2019-01-16 09:08:21 -05:00
[`.ycm_extra_conf.py` ](#option-2-provide-the-flags-manually ) below. Note that
**experimental** [clangd][]-based completer doesn't support this option. So it
(and anything after this point) only applies to `libclang` -based completer.
2017-01-01 19:01:39 -05:00
If no [`.ycm_extra_conf.py` ](#option-2-provide-the-flags-manually ) is found,
2018-07-23 19:58:28 -04:00
YouCompleteMe automatically tries to load a compilation database if there is
one.
2017-01-01 19:01:39 -05:00
YCM looks for a file named `compile_commands.json` in the directory of the
opened file or in any directory above it in the hierarchy (recursively); when
the file is found, it is loaded. YouCompleteMe performs the following lookups
when extracting flags for a particular file:
- If the database contains an entry for the file, the flags for that file are
used.
- If the file is a header file and a source file with the same root exists in
the database, the flags for the source file are used. For example, if the file
is `/home/Test/project/src/lib/something.h` and the database contains an entry
for `/home/Test/project/src/lib/something.cc` , then the flags for
`/home/Test/project/src/lib/something.cc` are used.
- Otherwise, if any flags have been returned from the directory containing the
requested file, those flags are used. This heuristic is intended to provide
potentially working flags for newly created files.
Finally, YCM converts any relative paths in the extracted flags to absolute
paths. This ensures that compilation can be performed from any Vim working
directory.
#### Option 2: Provide the flags manually
If you don't have a compilation database, or aren't able to generate one,
you have to tell YouCompleteMe how to compile your code some other way.
2018-07-23 19:58:28 -04:00
Every C-family project is different. It is not possible for YCM to guess what
2017-01-01 19:01:39 -05:00
compiler flags to supply for your project. Fortunately, YCM provides a mechanism
for you to generate the flags for a particular file with _arbitrary complexity_ .
This is achieved by requiring you to provide a Python module which implements a
2018-06-10 11:57:43 -04:00
trivial function which, given the file name as argument, returns a list of
2017-01-01 19:01:39 -05:00
compiler flags to use to compile that file.
2013-02-28 12:57:56 -05:00
YCM looks for a `.ycm_extra_conf.py` file in the directory of the opened file or
in any directory above it in the hierarchy (recursively); when the file is
2018-07-23 19:58:28 -04:00
found, it is loaded (only once!) as a Python module. YCM calls a `Settings`
2013-01-23 00:05:32 -05:00
method in that module which should provide it with the information necessary to
2018-07-23 19:58:28 -04:00
compile the current file. You can also provide a path to a global configuration
file with the
[`g:ycm_global_ycm_extra_conf` ](#the-gycm_global_ycm_extra_conf-option ) option,
which will be used as a fallback. To prevent the execution of malicious code
from a file you didn't write YCM will ask you once per `.ycm_extra_conf.py` if
it is safe to load. This can be disabled and you can white-/blacklist files. See
the [`g:ycm_confirm_extra_conf` ](#the-gycm_confirm_extra_conf-option ) and
[`g:ycm_extra_conf_globlist` ](#the-gycm_extra_conf_globlist-option ) options
respectively.
2013-01-23 00:05:32 -05:00
This system was designed this way so that the user can perform any arbitrary
sequence of operations to produce a list of compilation flags YCM should hand
to Clang.
2017-01-01 19:01:39 -05:00
**NOTE**: It is highly recommended to include `-x <language>` flag to libclang.
This is so that the correct language is detected, particularly for header files.
2018-05-24 01:34:15 -04:00
Common values are `-x c` for C, `-x c++` for C++, `-x objc` for Objective-C, and
`-x cuda` for CUDA.
2017-01-01 19:01:39 -05:00
2018-07-23 19:58:28 -04:00
To give you an impression, if your C++ project is trivial, and your usual
2017-01-01 19:01:39 -05:00
compilation command is: `g++ -Wall -Wextra -Werror -o FILE.o FILE.cc` , then the
following `.ycm_extra_conf.py` is enough to get semantic analysis from
YouCompleteMe:
```python
2018-07-23 19:58:28 -04:00
def Settings( **kwargs ):
2017-01-01 19:01:39 -05:00
return {
'flags': [ '-x', 'c++', '-Wall', '-Wextra', '-Werror' ],
}
```
2018-07-23 19:58:28 -04:00
As you can see from the trivial example, YCM calls the `Settings` method which
returns a dictionary with a single element `'flags'` . This element is a `list`
of compiler flags to pass to libclang for the current file. The absolute path of
that file is accessible under the `filename` key of the `kwargs` dictionary.
That's it! This is actually enough for most projects, but for complex projects
it is not uncommon to integrate directly with an existing build system using the
full power of the Python language.
2017-01-01 19:01:39 -05:00
For a more elaborate example,
2018-07-25 16:25:31 -04:00
[see ycmd's own `.ycm_extra_conf.py` ][ycmd_flags_example]. You should be able to
use it _as a starting point_ . **Don't** just copy/paste that file somewhere and
2017-01-01 19:01:39 -05:00
expect things to magically work; **your project needs different flags** . Hint:
just replace the strings in the `flags` variable with compilation flags
necessary for your project. That should be enough for 99% of projects.
2013-01-23 00:05:32 -05:00
2017-01-01 19:01:39 -05:00
You could also consider using [YCM-Generator][ygen] to generate the
`ycm_extra_conf.py` file.
2013-01-22 00:36:17 -05:00
2017-09-10 06:07:07 -04:00
#### Errors during compilation
2015-03-18 20:19:45 -04:00
2013-01-31 22:21:11 -05:00
If Clang encounters errors when compiling the header files that your file
includes, then it's probably going to take a long time to get completions. When
the completion menu finally appears, it's going to have a large number of
unrelated completion strings (type/function names that are not actually
members). This is because Clang fails to build a precompiled preamble for your
file if there are any errors in the included headers and that preamble is key to
getting fast completions.
Call the `:YcmDiags` command to see if any errors or warnings were detected in
2014-01-07 02:05:01 -05:00
your file.
2013-01-31 22:21:11 -05:00
2019-01-16 09:08:21 -05:00
#### Selecting a C-family completion engine
Currently YCM supports two completion engines for C-family semantic completion.
One libclang-based and an **experimental** [clangd]-based completer. When in
doubt we recommend using the libclang-based engine. Here is a quick comparison
of the two completer engines:
- **Project wide indexing** : Clangd has both dynamic and static index support.
The dynamic index stores up-to-date symbols coming from any files you are
currently editing, whereas static index contains project-wide symbol
information. This symbol information is used for code completion and code
navigation. Whereas libclang is limited to the current translation unit(TU).
2019-04-05 19:01:28 -04:00
- **Code navigation** : Clangd provides all the GoTo requests libclang provides and it
2019-01-16 09:08:21 -05:00
improves those using the above mentioned index information to contain
project-wide information rather than just the current TU.
- **Rename** : Clangd can perform semantic rename operations on the current
file, whereas libclang doesn’ t support such functionality.
- **Code Completion** : Clangd can perform code completions at a lower latency
than libclang; also, it has information about all the symbols in your
project so it can suggest items outside your current TU and also provides
proper `#include` insertions for those items.
- **Format Code** : Clangd provides code formatting either for the selected
lines or the whole file, whereas libclang doesn’ t have such functionality.
- **Performance** : Clangd has faster reparse and code completion times
compared to libclang.
Note that for clangd to have some of the above mentioned functionality, you need
2019-06-28 08:52:28 -04:00
to enable clangd indexing by adding `-background-index` to
[g:ycm_clangd_args ](#the-gycm_clangd_args-option ). Clangd will automatically
enable indexing in version 9.
2019-01-16 09:08:21 -05:00
To enable:
- libclang-based completer pass `--clang-completer`
- [clangd][]-based completer pass `--clangd-completer`
to `install.py` while following the [installation guide ](#installation ). As
mentioned before, pass `--clang-completer` when in doubt, since the
[clangd][]-based completer is still experimental.
2017-10-03 02:41:10 -04:00
### Java Semantic Completion
**NOTE**: Java support is currently experimental. Please let us know your
[feedback ](#contact ).
#### Java quick Start
1. Ensure that you have enabled the Java completer. See the
[installation guide ](#installation ) for details.
2. Create a project file (gradle or maven) file in the root directory of your
Java project, by following the instructions below.
2019-06-28 08:52:28 -04:00
3. (Optional) [Configure the LSP server ](#lsp-configuration ). The [jdt.ls
configuration options][jdtls-preferences] can be found in their codebase.
2017-10-03 02:41:10 -04:00
2019-06-28 08:52:28 -04:00
4. If you previously used Eclim or Syntastic for Java, disable them for Java.
5. Edit a Java file from your project.
2017-10-03 02:41:10 -04:00
2018-02-10 18:48:22 -05:00
For the best experience, we highly recommend at least Vim 8.0.1493 when using
Java support with YouCompleteMe.
2017-10-03 02:41:10 -04:00
#### Java Project Files
In order to provide semantic analysis, the Java completion engine requires
knowledge of your project structure. In particular it needs to know the class
path to use, when compiling your code. Fortunately [jdt.ls][]
supports [eclipse project files][eclipse-project],
[maven projects][mvn-project] and [gradle projects][gradle-project].
**NOTE:** Our recommendation is to use either maven or gradle projects.
#### Diagnostic display - Syntastic
The native support for Java includes YCM's native realtime diagnostics display.
2018-06-10 11:57:43 -04:00
This can conflict with other diagnostics plugins like Syntastic, so when
enabling Java support, please **manually disable Syntastic Java diagnostics** .
2017-10-03 02:41:10 -04:00
Add the following to your `vimrc` :
```viml
let g:syntastic_java_checkers = []
```
#### Diagnostic display - Eclim
The native support for Java includes YCM's native realtime diagnostics display.
2018-06-10 11:57:43 -04:00
This can conflict with other diagnostics plugins like Eclim, so when enabling
2017-10-03 02:41:10 -04:00
Java support, please **manually disable Eclim Java diagnostics** .
Add the following to your `vimrc` :
```viml
let g:EclimFileTypeValidate = 0
```
**NOTE**: We recommend disabling Eclim entirely when editing Java with YCM's
native Java support. This can be done temporarily with `:EclimDisable` .
#### Eclipse Projects
Eclipse style projects require two files: [.project][eclipse-dot-project] and
[.classpath][eclipse-dot-classpath].
If your project already has these files due to previously being set up within
eclipse, then no setup is required. [jdt.ls][] should load the project just
fine (it's basically eclipse after all).
However, if not, it is possible (easy in fact) to craft them manually, though it
is not recommended. You're better off using gradle or maven (see below).
[A simple eclipse style project example][ycmd-eclipse-project] can be found in
2018-06-10 11:57:43 -04:00
the ycmd test directory. Normally all that is required is to copy these files to
the root of your project and to edit the `.classpath` to add additional
libraries, such as:
2017-10-03 02:41:10 -04:00
```xml
< classpathentry kind = "lib" path = "/path/to/external/jar" / >
< classpathentry kind = "lib" path = "/path/to/external/java/source" / >
```
It may also be necessary to change the directory in which your source files are
located (paths are relative to the .project file itself):
```xml
< classpathentry kind = "src" output = "target/classes" path = "path/to/src/" / >
```
**NOTE**: The eclipse project and classpath files are not a public interface
and it is highly recommended to use Maven or Gradle project definitions if you
don't already use eclipse to manage your projects.
#### Maven Projects
Maven needs a file named [pom.xml][mvn-project] in the root of the project.
Once again a simple [pom.xml][ycmd-mvn-pom-xml] can be found in ycmd source.
The format of [pom.xml][mvn-project] files is way beyond the scope of this
document, but we do recommend using the various tools that can generate them for
you, if you're not familiar with them already.
2018-06-10 11:57:43 -04:00
#### Gradle Projects
2017-10-03 02:41:10 -04:00
Gradle projects require a [build.gradle][gradle-project]. Again, there is a
[trivial example in ycmd's tests][ycmd-gradle-project].
The format of [build.gradle][gradle-project] files is way beyond the scope of
this document, but we do recommend using the various tools that can generate
them for you, if you're not familiar with them already.
#### Troubleshooting
If you're not getting completions or diagnostics, check the server health:
* The Java completion engine takes a while to start up and parse your project.
You should be able to see its progress in the command line, and
`:YcmDebugInfo` . Ensure that the following lines are present:
```
-- jdt.ls Java Language Server running
-- jdt.ls Java Language Server Startup Status: Ready
```
* If the above lines don't appear after a few minutes, check the jdt.ls and ycmd
log files using [`:YcmToggleLogs` ](#the-ycmtogglelogs-command ). The jdt.ls
log file is called `.log` (for some reason).
If you get a message about "classpath is incomplete", then make sure you have
correctly configured the [project files ](#java-project-files ).
If you get messages about unresolved imports, then make sure you have
correctly configured the [project files ](#java-project-files ), in particular
check that the classpath is set correctly.
For anything else, [contact us ](#contact ). Java support is experimental at
present so we'd love to hear your feedback! Please do remember to check
[CONTRIBUTING.md][contributing-md] for the list of diagnostics we'll need.
2018-04-06 21:55:24 -04:00
### Python Semantic Completion
2018-07-25 16:25:31 -04:00
YCM relies on the [Jedi][] engine to provide completion and code navigation. By
2018-10-07 18:03:46 -04:00
default, it will pick the version of Python running the [ycmd server][ycmd] and
use its `sys.path` . While this is fine for simple projects, this needs to be
configurable when working with virtual environments or in a project with
2018-07-25 16:25:31 -04:00
third-party packages. The next sections explain how to do that.
2018-04-06 21:55:24 -04:00
2018-07-25 16:25:31 -04:00
#### Working with virtual environments
A common practice when working on a Python project is to install its
dependencies in a virtual environment and develop the project inside that
environment. To support this, YCM needs to know the interpreter path of the
virtual environment. You can specify it by creating a `.ycm_extra_conf.py` file
at the root of your project with the following contents:
```python
def Settings( **kwargs ):
return {
'interpreter_path': '/path/to/virtual/environment/python'
}
```
where `/path/to/virtual/environment/python` is the path to the Python used
by the virtual environment you are working in. Typically, the executable can be
found in the `Scripts` folder of the virtual environment directory on Windows
and in the `bin` folder on other platforms.
If you don't like having to create a `.ycm_extra_conf.py` file at the root of
your project and would prefer to specify the interpreter path with a Vim option,
read the [Configuring through Vim options ](#configuring-through-vim-options )
section.
#### Working with third-party packages
Another common practice is to put the dependencies directly into the project and
add their paths to `sys.path` at runtime in order to import them. YCM needs to
be told about this path manipulation to support those dependencies. This can be
done by creating a `.ycm_extra_conf.py` file at the root of the project. This
file must define a `Settings( **kwargs )` function returning a dictionary with
the list of paths to prepend to `sys.path` under the `sys_path` key. For
instance, the following `.ycm_extra_conf.py`
```python
def Settings( **kwargs ):
return {
'sys_path': [
'/path/to/some/third_party/package',
'/path/to/another/third_party/package'
]
}
2018-04-06 21:55:24 -04:00
```
2018-07-25 16:25:31 -04:00
adds the paths `/path/to/some/third_party/package` and
`/path/to/another/third_party/package` at the start of `sys.path` .
If you would rather prepend paths to `sys.path` with a Vim option, read the
[Configuring through Vim options ](#configuring-through-vim-options ) section.
If you need further control on how to add paths to `sys.path` , you should define
the `PythonSysPath( **kwargs )` function in the `.ycm_extra_conf.py` file. Its
keyword arguments are `sys_path` which contains the default `sys.path` , and
`interpreter_path` which is the path to the Python interpreter. Here's a trivial
example that insert the `/path/to/third_party/package` path at the second
position of `sys.path` :
```python
def PythonSysPath( **kwargs ):
sys_path = kwargs[ 'sys_path' ]
sys_path.insert( 1, '/path/to/third_party/package' )
return sys_path
```
A more advanced example can be found in [YCM's own
`.ycm_extra_conf.py` ][ycm_flags_example].
#### Configuring through Vim options
You may find inconvenient to have to create a `.ycm_extra_conf.py` file at the
root of each one of your projects in order to set the path to the Python
interpreter and/or add paths to `sys.path` and would prefer to be able to
configure those through Vim options. Don't worry, this is possible by using the
[`g:ycm_extra_conf_vim_data` ](#the-gycm_extra_conf_vim_data-option ) option and
creating a global extra configuration file. Let's take an example. Suppose that
you want to set the interpreter path with the `g:ycm_python_interpreter_path`
option and prepend paths to `sys.path` with the `g:ycm_python_sys_path` option.
Suppose also that you want to name the global extra configuration file
`global_extra_conf.py` and that you want to put it in your HOME folder. You
should then add the following lines to your vimrc:
2018-04-06 21:55:24 -04:00
```viml
2018-07-25 16:25:31 -04:00
let g:ycm_python_interpreter_path = ''
let g:ycm_python_sys_path = []
let g:ycm_extra_conf_vim_data = [
\ 'g:ycm_python_interpreter_path',
\ 'g:ycm_python_sys_path'
\]
let g:ycm_global_ycm_extra_conf = '~/global_extra_conf.py'
2018-04-06 21:55:24 -04:00
```
2018-07-25 16:25:31 -04:00
and create the `~/global_extra_conf.py` file with the following contents:
```python
def Settings( **kwargs ):
client_data = kwargs[ 'client_data' ]
return {
'interpreter_path': client_data[ 'g:ycm_python_interpreter_path' ],
'sys_path': client_data[ 'g:ycm_python_sys_path' ]
}
```
That's it. You are done. Note that you don't need to restart the server when
setting one of the options. YCM will automatically pick the new values.
2018-04-06 21:55:24 -04:00
### Rust Semantic Completion
Completions and GoTo commands within the current crate and its dependencies
should work out of the box with no additional configuration (provided that you
built YCM with the `--rust-completer` flag; see the [*Installation*
2019-06-28 08:52:28 -04:00
section](#installation) for details). The install script takes care of
installing [the Rust source code][rust-src], so no configuration is necessary.
In case you are running Python 2.7.8 and older, you will need to manually
install [rustup][].
To [configure RLS ](#lsp-configuration ) look up [rls configuration options][
rls-preferences]
### Go Semantic Completion
Completions and GoTo commands should work out of the box (provided that you
built YCM with the `--go-completer` flag; see the [*Installation*
section](#installation) for details). The server only works for projects with
the "canonical" layout.
While YCM can configure [a LSP server ](#lsp-configuration ), currently `gopls`
doesn't implement [the required notification][gopls-preferences].
2018-04-06 21:55:24 -04:00
2017-09-26 14:17:46 -04:00
### JavaScript and TypeScript Semantic Completion
**NOTE:** YCM originally used the [Tern][] engine for JavaScript but due to
[Tern][] not being maintained anymore by its main author and the [TSServer][]
engine offering more features, YCM is moving to [TSServer][]. This won't affect
you if you were already using [Tern][] but you are encouraged to do the switch
by deleting the `third_party/ycmd/third_party/tern_runtime/node_modules`
directory in YCM folder. If you are a new user but still want to use [Tern][],
you should pass the `--js-completer` option to the `install.py` script during
installation. Further instructions on how to setup YCM with [Tern][] are
available on [the wiki][tern-instructions].
2018-04-06 21:55:24 -04:00
2017-09-26 14:17:46 -04:00
All JavaScript and TypeScript features are provided by the [TSServer][] engine,
2018-10-14 09:19:15 -04:00
which is included in the TypeScript SDK. To enable these features, install
[Node.js and npm][npm-install] and call the `install.py` script with the
`--ts-completer` flag.
2017-09-26 14:17:46 -04:00
[TSServer][] relies on [the `jsconfig.json` file][jsconfig.json] for JavaScript
and [the `tsconfig.json` file][tsconfig.json] for TypeScript to analyze your
2018-04-06 21:55:24 -04:00
project. Ensure the file exists at the root of your project.
2017-09-26 14:17:46 -04:00
To get diagnostics in JavaScript, set the `checkJs` option to `true` in your
`jsconfig.json` file:
```json
{
"compilerOptions": {
"checkJs": true
}
}
```
2016-02-26 20:09:00 -05:00
### Semantic Completion for Other Languages
2013-03-23 14:55:59 -04:00
2017-09-26 14:17:46 -04:00
C-family, C#, Go, Java, Python, Rust, and JavaScript/TypeScript languages are
2019-06-28 08:52:28 -04:00
supported natively by YouCompleteMe using the [Clang][], [OmniSharp-Roslyn][],
[Gopls][], [jdt.ls][], [Jedi][], [rls][], and [TSServer][] engines,
2017-09-26 14:17:46 -04:00
respectively. Check the [installation ](#installation ) section for instructions
to enable these features if desired.
2015-04-15 13:13:15 -04:00
2019-06-28 08:52:28 -04:00
#### Plugging an arbitrary LSP server
Similar to other LSP clients, YCM can use an arbitrary LSP server with the help
of [`g:ycm_language_server` ](#the-gycm_language_server-option ) option. An
example of a value of this option would be:
```viml
2019-07-05 15:47:02 -04:00
let g:ycm_language_server =
\ [
\ {
\ 'name': 'yaml',
\ 'cmdline': [ '/path/to/yaml/server/yaml-language-server', '--stdio' ],
\ 'filetypes': [ 'yaml' ]
\ },
\ {
\ 'name': 'php',
\ 'cmdline': [ '/path/to/php', '/path/to/php/server/php-language-server.php' ],
\ 'filetypes': [ 'php' ]
\ }
\ ]
2019-06-28 08:52:28 -04:00
```
When [configuring a LSP server ](#lsp-configuration ) the value of the `name` key
will be used as the `kwargs[ 'language' ]` .
2019-07-15 17:06:02 -04:00
See [the LSP Examples ](https://github.com/ycm-core/lsp-examples ) project for more
examples of configuring the likes of PHP, Ruby, Kotlin, and D.
2019-06-28 08:52:28 -04:00
#### Using `omnifunc` for semantic completion
2013-03-23 14:55:59 -04:00
YCM will use your `omnifunc` (see `:h omnifunc` in Vim) as a source for semantic
completions if it does not have a native semantic completion engine for your
file's filetype. Vim comes with okayish omnifuncs for various languages like
2016-09-11 05:23:53 -04:00
Ruby, PHP, etc. It depends on the language.
2013-03-23 14:55:59 -04:00
2017-10-03 02:41:10 -04:00
You can get a stellar omnifunc for Ruby with [Eclim][]. Just make sure you have
the _latest_ Eclim installed and configured (this means Eclim `>= 2.2.*` and
Eclipse `>= 4.2.*` ).
2013-05-15 06:15:42 -04:00
After installing Eclim remember to create a new Eclipse project within your
2017-10-03 02:41:10 -04:00
application by typing `:ProjectCreate <path-to-your-project> -n ruby` inside vim
and don't forget to have `let g:EclimCompletionMethod = 'omnifunc'` in your
vimrc. This will make YCM and Eclim play nice; YCM will use Eclim's omnifuncs as
the data source for semantic completions and provide the auto-triggering and
subsequence-based matching (and other YCM features) on top of it.
2013-03-23 14:55:59 -04:00
2019-06-28 08:52:28 -04:00
### LSP Configuration
Many LSP servers allow some level of user configuration. YCM enables this with
the help of `.ycm_extra_conf.py` files. Here's an example of jdt.ls user
configuration.
```python
def Settings( **kwargs ):
if kwargs[ 'language' ] == 'java':
return { 'ls': { 'java.format.onType.enabled': True } }
```
The `ls` key tells YCM that the dictionary should be passed to thet LSP server.
For each of the LSP server's configuration you should look up the respective
server's documentation.
2013-03-23 14:55:59 -04:00
### Writing New Semantic Completers
You have two options here: writing an `omnifunc` for Vim's omnicomplete system
that YCM will then use through its omni-completer, or a custom completer for YCM
using the [Completer API][completer-api].
Here are the differences between the two approaches:
- You have to use VimScript to write the omnifunc, but get to use Python to
write for the Completer API; this by itself should make you want to use the
API.
- The Completer API is a _much_ more powerful way to integrate with YCM and it
provides a wider set of features. For instance, you can make your Completer
query your semantic back-end in an asynchronous fashion, thus not blocking
Vim's GUI thread while your completion system is processing stuff. This is
impossible with VimScript. All of YCM's completers use the Completer API.
- Performance with the Completer API is better since Python executes faster than
VimScript.
If you want to use the `omnifunc` system, see the relevant Vim docs with `:h
complete-functions`. For the Completer API, see [the API docs][completer-api].
If you want to upstream your completer into YCM's source, you should use the
Completer API.
2016-02-26 20:09:00 -05:00
### Diagnostic Display
2013-01-30 17:46:58 -05:00
2019-06-28 08:52:28 -04:00
YCM will display diagnostic notifications for the C-family, C#, Go, Java,
JavaScript, Rust and TypeScript languages. Since YCM continuously recompiles
your file as you type, you'll get notified of errors and warnings in your file
as fast as possible.
2013-01-30 17:46:58 -05:00
2014-01-08 23:03:33 -05:00
Here are the various pieces of the diagnostic UI:
2014-01-08 23:04:43 -05:00
- Icons show up in the Vim gutter on lines that have a diagnostic.
2014-01-08 23:03:33 -05:00
- Regions of text related to diagnostics are highlighted (by default, a red
2014-01-09 16:21:11 -05:00
wavy underline in `gvim` and a red background in `vim` ).
2014-01-08 23:03:33 -05:00
- Moving the cursor to a line with a diagnostic echoes the diagnostic text.
- Vim's location list is automatically populated with diagnostic data (off by
default, see options).
2014-01-07 02:05:01 -05:00
The new diagnostics (if any) will be displayed the next time you press any key
on the keyboard. So if you stop typing and just wait for the new diagnostics to
come in, that _will not work_ . You need to press some key for the GUI to update.
2013-01-30 17:46:58 -05:00
Having to press a key to get the updates is unfortunate, but cannot be changed
due to the way Vim internals operate; there is no way that a background task can
update Vim's GUI after it has finished running. You _have to_ press a key. This
will make YCM check for any pending diagnostics updates.
You _can_ force a full, blocking compilation cycle with the
`:YcmForceCompileAndDiagnostics` command (you may want to map that command to a
key; try putting `nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>` in your
vimrc). Calling this command will force YCM to immediately recompile your file
and display any new diagnostics it encounters. Do note that recompilation with
this command may take a while and during this time the Vim GUI _will_ be
blocked.
2014-01-07 02:05:01 -05:00
YCM will display a short diagnostic message when you move your cursor to the
line with the error. You can get a detailed diagnostic message with the
`<leader>d` key mapping (can be changed in the options) YCM provides when your
cursor is on the line with the diagnostic.
2013-01-31 15:32:07 -05:00
You can also see the full diagnostic message for all the diagnostics in the
current file in Vim's `locationlist` , which can be opened with the `:lopen` and
2013-04-12 14:08:04 -04:00
`:lclose` commands (make sure you have set `let
2014-01-08 23:03:33 -05:00
g:ycm_always_populate_location_list = 1` in your vimrc). A good way to toggle
2013-04-12 14:08:04 -04:00
the display of the `locationlist` with a single key mapping is provided by
another (very small) Vim plugin called [ListToggle][] (which also makes it
possible to change the height of the `locationlist` window), also written by
yours truly.
2013-01-31 15:32:07 -05:00
2016-02-26 20:09:00 -05:00
#### Diagnostic Highlighting Groups
2014-01-08 23:03:33 -05:00
You can change the styling for the highlighting groups YCM uses. For the signs
in the Vim gutter, the relevant groups are:
- `YcmErrorSign` , which falls back to group `SyntasticErrorSign` and then
`error` if they exist
2014-01-09 13:59:44 -05:00
- `YcmWarningSign` , which falls back to group `SyntasticWarningSign` and then
2014-01-08 23:03:33 -05:00
`todo` if they exist
You can also style the line that has the warning/error with these groups:
- `YcmErrorLine` , which falls back to group `SyntasticErrorLine` if it exists
- `YcmWarningLine` , which falls back to group `SyntasticWarningLine` if it
exists
2017-09-28 06:15:30 -04:00
Note that the line highlighting groups only work when the
[`g:ycm_enable_diagnostic_signs` ](#the-gycm_enable_diagnostic_signs-option )
option is set. If you want highlighted lines but no signs in the Vim gutter,
ensure that your Vim version is 7.4.2201 or later and set the `signcolumn`
option to `off` in your vimrc:
```viml
set signcolumn=off
```
2014-01-09 17:11:15 -05:00
2014-05-09 16:15:15 -04:00
The syntax groups used to highlight regions of text with errors/warnings:
- `YcmErrorSection` , which falls back to group `SyntasticError` if it exists and
then `SpellBad`
- `YcmWarningSection` , which falls back to group `SyntasticWarning` if it exists
and then `SpellCap`
2014-01-08 23:03:33 -05:00
Here's how you'd change the style for a group:
2015-09-15 14:57:34 -04:00
```viml
2014-01-08 23:03:33 -05:00
highlight YcmErrorLine guibg=#3f0000
```
2013-02-02 16:38:04 -05:00
Commands
--------
2013-10-24 15:31:38 -04:00
### The `:YcmRestartServer` command
2016-02-17 07:52:25 -05:00
If the [ycmd completion server][ycmd] suddenly stops for some reason, you can
restart it with this command.
2013-10-24 15:31:38 -04:00
2013-05-20 21:10:55 -04:00
### The `:YcmForceCompileAndDiagnostics` command
2013-02-02 16:38:04 -05:00
Calling this command will force YCM to immediately recompile your file
and display any new diagnostics it encounters. Do note that recompilation with
this command may take a while and during this time the Vim GUI _will_ be
blocked.
You may want to map this command to a key; try putting `nnoremap < F5 >
:YcmForceCompileAndDiagnostics< CR > ` in your vimrc.
2013-05-20 21:10:55 -04:00
### The `:YcmDiags` command
2013-02-02 16:38:04 -05:00
Calling this command will fill Vim's `locationlist` with errors or warnings if
2015-08-05 17:09:07 -04:00
any were detected in your file and then open it. If a given error or warning can
be fixed by a call to `:YcmCompleter FixIt` , then ` (FixIt available)` is
appended to the error or warning text. See the `FixIt` completer subcommand for
2015-08-18 23:11:39 -04:00
more information.
2015-08-05 17:09:07 -04:00
2018-06-10 11:57:43 -04:00
**NOTE:** The absence of ` (FixIt available)` does not strictly imply a fix-it
2017-01-01 19:01:39 -05:00
is not available as not all completers are able to provide this indication. For
2015-08-05 17:09:07 -04:00
example, the c-sharp completer provides many fix-its but does not add this
additional indication.
2013-02-02 16:38:04 -05:00
2014-01-29 13:59:15 -05:00
The `g:ycm_open_loclist_on_ycm_diags` option can be used to prevent the location
list from opening, but still have it filled with new diagnostic data. See the
_Options_ section for details.
2013-05-20 21:10:55 -04:00
### The `:YcmShowDetailedDiagnostic` command
2013-02-06 21:32:47 -05:00
This command shows the full diagnostic text when the user's cursor is on the
line with the diagnostic.
2013-05-20 21:10:55 -04:00
### The `:YcmDebugInfo` command
2013-02-02 16:38:04 -05:00
This will print out various debug information for the current file. Useful to
see what compile commands will be used for the file if you're using the semantic
completion engine.
2015-11-03 13:41:05 -05:00
### The `:YcmToggleLogs` command
2017-12-22 09:00:27 -05:00
This command presents the list of logfiles created by YCM, the [ycmd
server][ycmd], and the semantic engine server for the current filetype, if any.
One of these logfiles can be opened in the editor (or closed if already open) by
entering the corresponding number or by clicking on it with the mouse.
Additionally, this command can take the logfile names as arguments. Use the
`<TAB>` key (or any other key defined by the `wildchar` option) to complete the
arguments or to cycle through them (depending on the value of the `wildmode`
option). Each logfile given as an argument is directly opened (or closed if
already open) in the editor. Only for debugging purposes.
2015-11-03 13:41:05 -05:00
2013-05-20 21:10:55 -04:00
### The `:YcmCompleter` command
2013-02-25 09:14:01 -05:00
2016-01-24 11:37:57 -05:00
This command gives access to a number of additional [IDE-like
features](#quick-feature-summary) in YCM, for things like semantic GoTo, type
information, FixIt and refactoring.
2018-09-26 20:33:11 -04:00
This command accepts a range that can either be specified through a selection in
one of Vim's visual modes (see `:h visual-use` ) or on the command line. For
instance, `:2,5YcmCompleter` will apply the command from line 2 to line 5. This
is useful for [the `Format` subcommand ](#the-format-subcommand ).
Call `YcmCompleter` without further arguments for a list of the commands you can
call for the current completer.
2013-02-25 09:14:01 -05:00
2016-01-24 11:37:57 -05:00
See the [file type feature summary ](#quick-feature-summary ) for an overview of
the features available for each file type. See the _YcmCompleter subcommands_
section for more information on the available subcommands and their usage.
2013-03-31 23:38:29 -04:00
2016-02-26 20:09:00 -05:00
YcmCompleter Subcommands
2013-03-31 23:38:29 -04:00
------------------------
2017-01-01 19:01:39 -05:00
**NOTE:** See the docs for the `YcmCompleter` command before tackling this
section.
2013-03-31 23:38:29 -04:00
The invoked subcommand is automatically routed to the currently active semantic
2013-04-01 08:55:37 -04:00
completer, so `:YcmCompleter GoToDefinition` will invoke the `GoToDefinition`
2013-03-31 23:38:29 -04:00
subcommand on the Python semantic completer if the currently active file is a
2018-08-16 22:59:15 -04:00
Python one and on the Clang completer if the currently active file is a C-family
language one.
2013-03-31 23:38:29 -04:00
You may also want to map the subcommands to something less verbose; for
2014-03-21 14:34:00 -04:00
instance, `nnoremap <leader>jd :YcmCompleter GoTo<CR>`
2013-03-31 23:38:29 -04:00
maps the `<leader>jd` sequence to the longer subcommand invocation.
2016-02-26 20:09:00 -05:00
### GoTo Commands
2016-01-24 11:37:57 -05:00
These commands are useful for jumping around and exploring code. When moving
the cursor, the subcommands add entries to Vim's `jumplist` so you can use
2017-10-22 05:06:56 -04:00
`CTRL-O` to jump back to where you were before invoking the command (and
2016-05-31 04:40:25 -04:00
`CTRL-I` to jump forward; see `:h jumplist` for details). If there is more
than one destination, the quickfix list (see `:h quickfix` ) is populated with
the available locations and opened to full width at the bottom of the screen.
You can change this behavior by using [the `YcmQuickFixOpened`
autocommand](#the-ycmquickfixopened-autocommand).
2013-04-01 12:58:20 -04:00
2016-01-24 11:37:57 -05:00
#### The `GoToInclude` subcommand
2015-10-20 09:06:49 -04:00
Looks up the current line for a header and jumps to it.
2018-05-24 01:34:15 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda`
2015-10-20 09:06:49 -04:00
2016-01-24 11:37:57 -05:00
#### The `GoToDeclaration` subcommand
2013-03-31 23:38:29 -04:00
2016-01-08 10:49:56 -05:00
Looks up the symbol under the cursor and jumps to its declaration.
2013-03-31 23:38:29 -04:00
2017-09-26 14:17:46 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda, cs, go, java, javascript,
python, rust, typescript`
2013-03-31 23:38:29 -04:00
2016-01-24 11:37:57 -05:00
#### The `GoToDefinition` subcommand
2013-03-31 23:38:29 -04:00
Looks up the symbol under the cursor and jumps to its definition.
2017-01-01 19:01:39 -05:00
**NOTE:** For C-family languages **this only works in certain situations** ,
namely when the definition of the symbol is in the current translation unit. A
translation unit consists of the file you are editing and all the files you are
including with `#include` directives (directly or indirectly) in that file.
2013-03-31 23:38:29 -04:00
2018-05-24 01:34:15 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda, cs, go, java, javascript,
python, rust, typescript`
2013-03-31 23:38:29 -04:00
2016-01-24 11:37:57 -05:00
#### The `GoTo` subcommand
2013-03-31 23:38:29 -04:00
2014-03-21 14:34:00 -04:00
This command tries to perform the "most sensible" GoTo operation it can.
Currently, this means that it tries to look up the symbol under the cursor and
jumps to its definition if possible; if the definition is not accessible from
2015-10-20 09:06:49 -04:00
the current translation unit, jumps to the symbol's declaration. For
2018-08-16 22:59:15 -04:00
C-family languages, it first tries to look up the current line for a header and
2016-01-08 10:49:56 -05:00
jump to it. For C#, implementations are also considered and preferred.
2013-03-31 23:38:29 -04:00
2018-05-24 01:34:15 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda, cs, go, java, javascript,
python, rust, typescript`
2013-03-31 23:38:29 -04:00
2016-01-24 11:37:57 -05:00
#### The `GoToImprecise` subcommand
2014-03-21 15:37:01 -04:00
WARNING: This command trades correctness for speed!
Same as the `GoTo` command except that it doesn't recompile the file with
libclang before looking up nodes in the AST. This can be very useful when you're
editing files that take long to compile but you know that you haven't made any
changes since the last parse that would lead to incorrect jumps. When you're
just browsing around your codebase, this command can spare you quite a bit of
latency.
2018-05-24 01:34:15 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda`
2014-03-21 15:37:01 -04:00
2016-01-24 11:37:57 -05:00
#### The `GoToReferences` subcommand
2015-12-19 13:39:15 -05:00
This command attempts to find all of the references within the project to the
identifier under the cursor and populates the quickfix list with those
locations.
2019-06-28 08:52:28 -04:00
Supported in filetypes: `java, javascript, python, typescript, rust`
2015-12-19 13:39:15 -05:00
2016-01-24 11:37:57 -05:00
#### The `GoToImplementation` subcommand
2013-05-24 17:48:46 -04:00
2016-01-24 11:37:57 -05:00
Looks up the symbol under the cursor and jumps to its implementation (i.e.
non-interface). If there are multiple implementations, instead provides a list
of implementations to choose from.
2013-05-24 17:48:46 -04:00
2019-06-28 08:52:28 -04:00
Supported in filetypes: `cs, java, rust`
2013-05-24 17:48:46 -04:00
2016-01-24 11:37:57 -05:00
#### The `GoToImplementationElseDeclaration` subcommand
2013-03-31 23:38:29 -04:00
2016-01-24 11:37:57 -05:00
Looks up the symbol under the cursor and jumps to its implementation if one,
else jump to its declaration. If there are multiple implementations, instead
provides a list of implementations to choose from.
Supported in filetypes: `cs`
2018-04-08 15:10:05 -04:00
#### The `GoToType` subcommand
Looks up the symbol under the cursor and jumps to the definition of its type
e.g. if the symbol is an object, go to the definition of its class.
2019-06-28 08:52:28 -04:00
Supported in filetypes: `go, java, javascript, typescript`
2018-04-08 15:10:05 -04:00
2016-02-26 20:09:00 -05:00
### Semantic Information Commands
2016-01-24 11:37:57 -05:00
These commands are useful for finding static information about the code, such
as the types of variables, viewing declarations and documentation strings.
#### The `GetType` subcommand
2015-02-12 07:22:20 -05:00
Echos the type of the variable or method under the cursor, and where it differs,
2015-03-27 15:59:19 -04:00
the derived type.
2015-02-12 07:22:20 -05:00
For example:
```c++
std::string s;
```
Invoking this command on `s` returns `std::string => std::basic_string<char>`
2017-01-01 19:01:39 -05:00
**NOTE:** Causes re-parsing of the current translation unit.
2015-02-12 07:22:20 -05:00
2018-05-24 01:34:15 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda, java, javascript,
2019-06-28 08:52:28 -04:00
go, python, typescript, rust`
2015-02-12 07:22:20 -05:00
2016-10-02 13:36:11 -04:00
#### The `GetTypeImprecise` subcommand
WARNING: This command trades correctness for speed!
Same as the `GetType` command except that it doesn't recompile the file with
libclang before looking up nodes in the AST. This can be very useful when you're
editing files that take long to compile but you know that you haven't made any
changes since the last parse that would lead to incorrect type. When you're
just browsing around your codebase, this command can spare you quite a bit of
latency.
2018-05-24 01:34:15 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda`
2016-10-02 13:36:11 -04:00
2016-01-24 11:37:57 -05:00
#### The `GetParent` subcommand
2015-02-12 07:22:20 -05:00
Echos the semantic parent of the point under the cursor.
The semantic parent is the item that semantically contains the given position.
For example:
```c++
class C {
void f();
};
2015-03-27 15:59:19 -04:00
void C::f() {
2015-02-12 07:22:20 -05:00
}
```
2015-03-27 15:59:19 -04:00
In the out-of-line definition of `C::f` , the semantic parent is the class `C` ,
2015-02-12 07:22:20 -05:00
of which this function is a member.
2015-03-27 15:59:19 -04:00
In the example above, both declarations of `C::f` have `C` as their semantic
context, while the lexical context of the first `C::f` is `C` and the lexical
2015-02-12 07:22:20 -05:00
context of the second `C::f` is the translation unit.
For global declarations, the semantic parent is the translation unit.
2017-01-01 19:01:39 -05:00
**NOTE:** Causes re-parsing of the current translation unit.
2015-02-12 07:22:20 -05:00
2018-05-24 01:34:15 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda`
2015-02-12 07:22:20 -05:00
2016-01-24 11:37:57 -05:00
#### The `GetDoc` subcommand
Displays the preview window populated with quick info about the identifier
under the cursor. Depending on the file type, this includes things like:
* The type or declaration of identifier,
* Doxygen/javadoc comments,
* Python docstrings,
* etc.
2018-05-24 01:34:15 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda, cs, java, javascript,
python, typescript, rust`
2016-01-24 11:37:57 -05:00
2016-10-02 13:36:11 -04:00
#### The `GetDocImprecise` subcommand
WARNING: This command trades correctness for speed!
Same as the `GetDoc` command except that it doesn't recompile the file with
libclang before looking up nodes in the AST. This can be very useful when you're
editing files that take long to compile but you know that you haven't made any
changes since the last parse that would lead to incorrect docs. When you're
just browsing around your codebase, this command can spare you quite a bit of
latency.
2018-05-24 01:34:15 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda`
2016-10-02 13:36:11 -04:00
2018-02-07 13:57:45 -05:00
### Refactoring Commands
2016-01-24 11:37:57 -05:00
These commands make changes to your source code in order to perform refactoring
or code correction. YouCompleteMe does not perform any action which cannot be
undone, and never saves or writes files to the disk.
#### The `FixIt` subcommand
2015-08-05 17:09:07 -04:00
2016-06-19 15:38:07 -04:00
Where available, attempts to make changes to the buffer to correct diagnostics
on the current line. Where multiple suggestions are available (such as when
there are multiple ways to resolve a given warning, or where multiple
diagnostics are reported for the current line), the options are presented
and one can be selected.
2015-08-05 17:09:07 -04:00
Completers which provide diagnostics may also provide trivial modifications to
the source in order to correct the diagnostic. Examples include syntax errors
such as missing trailing semi-colons, spurious characters, or other errors which
the semantic engine can deterministically suggest corrections.
If no fix-it is available for the current line, or there is no diagnostic on the
current line, this command has no effect on the current buffer. If any
modifications are made, the number of changes made to the buffer is echo'd and
the user may use the editor's undo command to revert.
When a diagnostic is available, and `g:ycm_echo_current_diagnostic` is set to 1,
then the text ` (FixIt)` is appended to the echo'd diagnostic when the
2015-08-18 23:11:39 -04:00
completer is able to add this indication. The text ` (FixIt available)` is
also appended to the diagnostic text in the output of the `:YcmDiags` command
2015-08-05 17:09:07 -04:00
for any diagnostics with available fix-its (where the completer can provide this
indication).
2017-01-01 19:01:39 -05:00
**NOTE:** Causes re-parsing of the current translation unit.
2015-08-05 17:09:07 -04:00
2019-06-28 08:52:28 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda, cs, go, java, javascript,
2017-09-26 14:17:46 -04:00
typescript`
2015-08-05 17:09:07 -04:00
2016-01-24 11:37:57 -05:00
#### The `RefactorRename <new name>` subcommand
2015-09-24 17:25:27 -04:00
2016-01-24 11:37:57 -05:00
In supported file types, this command attempts to perform a semantic rename of
the identifier under the cursor. This includes renaming declarations,
definitions and usages of the identifier, or any other language-appropriate
action. The specific behavior is defined by the semantic engine in use.
2015-09-24 17:25:27 -04:00
2016-01-24 11:37:57 -05:00
Similar to `FixIt` , this command applies automatic modifications to your source
files. Rename operations may involve changes to multiple files, which may or may
not be open in Vim buffers at the time. YouCompleteMe handles all of this for
you. The behavior is described in [the following section ](#multi-file-refactor ).
2015-09-24 17:25:27 -04:00
2019-06-28 08:52:28 -04:00
Supported in filetypes: `java, javascript, typescript, rust`
2016-01-24 11:37:57 -05:00
#### Multi-file Refactor
When a Refactor or FixIt command touches multiple files, YouCompleteMe attempts
to apply those modifications to any existing open, visible buffer in the current
tab. If no such buffer can be found, YouCompleteMe opens the file in a new
small horizontal split at the top of the current window, applies the change,
2017-01-01 19:01:39 -05:00
and then *hides* the window. **NOTE:** The buffer remains open, and must be
2016-01-24 11:37:57 -05:00
manually saved. A confirmation dialog is opened prior to doing this to remind
you that this is about to happen.
Once the modifications have been made, the quickfix list (see `:help quickfix` )
2018-02-22 17:05:38 -05:00
is populated with the locations of all modifications. This can be used to review
all automatic changes made by using `:copen` . Typically, use the `CTRL-W
< enter > ` combination to open the selected file in a new split. It is possible to
customize how the quickfix window is opened by using [the `YcmQuickFixOpened`
2016-05-31 04:40:25 -04:00
autocommand](#the-ycmquickfixopened-autocommand).
2016-01-24 11:37:57 -05:00
The buffers are *not* saved automatically. That is, you must save the modified
buffers manually after reviewing the changes from the quickfix list. Changes
can be undone using Vim's powerful undo features (see `:help undo` ). Note
that Vim's undo is per-buffer, so to undo all changes, the undo commands must
be applied in each modified buffer separately.
2017-01-01 19:01:39 -05:00
**NOTE:** While applying modifications, Vim may find files which are already
open and have a swap file. The command is aborted if you select Abort or Quit in
any such prompts. This leaves the Refactor operation partially complete and must
be manually corrected using Vim's undo features. The quickfix list is *not*
2016-01-24 11:37:57 -05:00
populated in this case. Inspect `:buffers` or equivalent (see `:help buffers` )
to see the buffers that were opened by the command.
2018-02-07 13:57:45 -05:00
#### The `Format` subcommand
2018-04-06 21:55:24 -04:00
This command formats the whole buffer or some part of it according to the value
2018-02-07 13:57:45 -05:00
of the Vim options `shiftwidth` and `expandtab` (see `:h 'sw'` and `:h et`
respectively). To format a specific part of your document, you can either select
it in one of Vim's visual modes (see `:h visual-use` ) and run the command or
directly enter the range on the command line, e.g. `:2,5YcmCompleter Format` to
format it from line 2 to line 5.
2019-06-28 08:52:28 -04:00
Supported in filetypes: `java, javascript, go, typescript, rust`
2018-04-06 21:55:24 -04:00
#### The `OrganizeImports` subcommand
This command removes unused imports and sorts imports in the current file. It
can also group imports from the same module in TypeScript and resolves imports
in Java.
2017-09-26 14:17:46 -04:00
Supported in filetypes: `java, javascript, typescript`
2018-02-07 13:57:45 -05:00
2016-02-26 20:09:00 -05:00
### Miscellaneous Commands
2015-09-24 17:25:27 -04:00
2016-01-24 11:37:57 -05:00
These commands are for general administration, rather than IDE-like features.
They cover things like the semantic engine server instance and compilation
flags.
2019-06-28 08:52:28 -04:00
#### The `ExecuteCommand <args>` subcommand
Some LSP completers (currently Rust and Java completers) support executing
server specific commands. Consult the [rls][] and [jdt.ls][] respective
documentations to find out what commands are supported and which arguments are
expected.
The support for `ExecuteCommand` was implemented to support plugins like
[vimspector][] to debug java, but isn't limited to that specific use case.
2016-01-24 11:37:57 -05:00
#### The `RestartServer` subcommand
2013-08-12 20:00:05 -04:00
Restarts the semantic-engine-as-localhost-server for those semantic engines that
work as separate servers that YCM talks to.
2018-07-25 16:25:31 -04:00
Supported in filetypes: `cs, go, java, javascript, rust, typescript`
2016-09-19 09:30:57 -04:00
#### The `ClearCompilationFlagCache` subcommand
2018-07-23 19:58:28 -04:00
YCM caches the flags it gets from the `Settings` function in your
`.ycm_extra_conf.py` file unless you return them with the `do_cache` parameter
2017-09-05 08:17:39 -04:00
set to `False` . It also caches the flags extracted from the compilation
database. The cache is in memory and is never invalidated (unless you restart
the server with the `:YcmRestartServer` command).
2016-09-19 09:30:57 -04:00
This command clears that cache entirely. YCM will then re-query your
2018-07-23 19:58:28 -04:00
`Settings` function or your compilation database as needed in the future.
2016-09-19 09:30:57 -04:00
2019-06-28 08:52:28 -04:00
Supported in filetypes: `c, cpp, objc, objcpp, cuda, rust`
2013-08-12 20:00:05 -04:00
2016-01-24 11:37:57 -05:00
#### The `ReloadSolution` subcommand
2014-05-22 10:45:52 -04:00
2019-06-28 08:52:28 -04:00
Instruct the Omnisharp-Roslyn server to clear its cache and reload all files
from disk. This is useful when files are added, removed, or renamed in the
solution, files are changed outside of Vim, or whenever Omnisharp-Roslyn cache
is out-of-sync.
2014-05-22 10:45:52 -04:00
Supported in filetypes: `cs`
2015-12-04 18:59:18 -05:00
Functions
--------
2015-12-05 12:24:15 -05:00
### The `youcompleteme#GetErrorCount` function
2015-12-04 18:59:18 -05:00
Get the number of YCM Diagnostic errors. If no errors are present, this function
returns 0.
For example:
```viml
2015-12-05 12:24:15 -05:00
call youcompleteme#GetErrorCount()
2015-12-04 18:59:18 -05:00
```
2015-12-05 14:06:29 -05:00
Both this function and `youcompleteme#GetWarningCount` can be useful when
integrating YCM with other Vim plugins. For example, a [lightline][] user could
add a diagnostics section to their statusline which would display the number of
errors and warnings.
2015-12-05 12:24:15 -05:00
### The `youcompleteme#GetWarningCount` function
2015-12-04 18:59:18 -05:00
Get the number of YCM Diagnostic warnings. If no warnings are present, this
function returns 0.
For example:
```viml
2015-12-05 12:24:15 -05:00
call youcompleteme#GetWarningCount()
2015-12-04 18:59:18 -05:00
```
2016-05-31 04:40:25 -04:00
Autocommands
------------
2017-02-19 08:03:50 -05:00
### The `YcmLocationOpened` autocommand
This `User` autocommand is fired when YCM opens the location list window in
response to the `YcmDiags` command. By default, the location list window is
2017-09-17 14:16:21 -04:00
opened to the bottom of the current window and its height is set to fit all
entries. This behavior can be overridden by using the `YcmLocationOpened`
2017-02-19 08:03:50 -05:00
autocommand which is triggered while the cursor is in the location list window.
For instance:
```viml
function! s:CustomizeYcmLocationWindow()
" Move the window to the top of the screen.
2017-05-05 15:12:41 -04:00
wincmd K
2017-02-19 08:03:50 -05:00
" Set the window height to 5.
2017-05-05 15:12:41 -04:00
5wincmd _
" Switch back to working window.
wincmd p
2017-02-19 08:03:50 -05:00
endfunction
autocmd User YcmLocationOpened call s:CustomizeYcmLocationWindow()
```
2016-05-31 04:40:25 -04:00
### The `YcmQuickFixOpened` autocommand
This `User` autocommand is fired when YCM opens the quickfix window in response
to the `GoTo*` and `RefactorRename` subcommands. By default, the quickfix window
is opened to full width at the bottom of the screen and its height is set to fit
all entries. This behavior can be overridden by using the `YcmQuickFixOpened`
2017-02-19 08:03:50 -05:00
autocommand which is triggered while the cursor is in the quickfix window. For
instance:
2016-05-31 04:40:25 -04:00
```viml
2017-02-19 08:03:50 -05:00
function! s:CustomizeYcmQuickFixWindow()
" Move the window to the top of the screen.
2017-05-05 15:12:41 -04:00
wincmd K
2016-05-31 04:40:25 -04:00
" Set the window height to 5.
2017-05-05 15:12:41 -04:00
5wincmd _
2016-05-31 04:40:25 -04:00
endfunction
autocmd User YcmQuickFixOpened call s:CustomizeYcmQuickFixWindow()
```
2015-12-04 18:59:18 -05:00
2013-01-22 00:36:17 -05:00
Options
-------
All options have reasonable defaults so if the plug-in works after installation
you don't need to change any options. These options can be configured in your
[vimrc script][vimrc] by including a line like this:
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_min_num_of_chars_for_completion = 1
```
2013-01-22 00:36:17 -05:00
2017-04-01 14:03:19 -04:00
Note that after changing an option in your [vimrc script][vimrc] you have to
2018-05-14 08:18:18 -04:00
restart [ycmd][] with the `:YcmRestartServer` command for the changes to take
effect.
2013-01-22 00:36:17 -05:00
### The `g:ycm_min_num_of_chars_for_completion` option
This option controls the number of characters the user needs to type before
2013-04-30 13:18:15 -04:00
identifier-based completion suggestions are triggered. For example, if the
option is set to `2` , then when the user types a second alphanumeric character
after a whitespace character, completion suggestions will be triggered. This
option is NOT used for semantic completion.
2013-04-15 01:27:27 -04:00
2013-11-17 17:44:43 -05:00
Setting this option to a high number like `99` effectively turns off the
identifier completion engine and just leaves the semantic engine.
2013-01-22 00:36:17 -05:00
Default: `2`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_min_num_of_chars_for_completion = 2
```
2013-01-22 00:36:17 -05:00
2013-06-29 18:43:10 -04:00
### The `g:ycm_min_num_identifier_candidate_chars` option
This option controls the minimum number of characters that a completion
candidate coming from the identifier completer must have to be shown in the
popup menu.
A special value of `0` means there is no limit.
2017-01-01 19:01:39 -05:00
**NOTE:** This option only applies to the identifier completer; it has no effect
on the various semantic completers.
2013-06-29 18:43:10 -04:00
Default: `0`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_min_num_identifier_candidate_chars = 0
```
2013-06-29 18:43:10 -04:00
2017-09-05 10:44:15 -04:00
### The `g:ycm_max_num_candidates` option
This option controls the maximum number of semantic completion suggestions shown
in the completion menu. This only applies to suggestions from semantic
completion engines; see [the `g:ycm_max_identifier_candidates`
option](#the-gycm_max_num_identifier_candidates-option) to limit the number of
suggestions from the identifier-based engine.
A special value of `0` means there is no limit.
**NOTE:** Setting this option to `0` or to a value greater than `100` is not
recommended as it will slow down completion when there are a very large number
of suggestions.
Default: `50`
```viml
let g:ycm_max_num_candidates = 50
```
### The `g:ycm_max_num_identifier_candidates` option
This option controls the maximum number of completion suggestions from the
identifier-based engine shown in the completion menu.
A special value of `0` means there is no limit.
**NOTE:** Setting this option to `0` or to a value greater than `100` is not
recommended as it will slow down completion when there are a very large number
of suggestions.
Default: `10`
```viml
let g:ycm_max_num_identifier_candidates = 10
```
2013-12-02 19:36:53 -05:00
### The `g:ycm_auto_trigger` option
When set to `0` , this option turns off YCM's identifier completer (the
as-you-type popup) _and_ the semantic triggers (the popup you'd get after typing
2014-01-08 23:03:33 -05:00
`.` or `->` in say C++). You can still force semantic completion with the
`<C-Space>` shortcut.
2013-12-02 19:36:53 -05:00
If you want to just turn off the identifier completer but keep the semantic
triggers, you should set `g:ycm_min_num_of_chars_for_completion` to a high
number like `99` .
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_auto_trigger = 1
```
2013-12-02 19:36:53 -05:00
2013-03-09 23:30:10 -05:00
### The `g:ycm_filetype_whitelist` option
2013-01-22 00:36:17 -05:00
This option controls for which Vim filetypes (see `:h filetype` ) should YCM be
2013-03-09 23:30:10 -05:00
turned on. The option value should be a Vim dictionary with keys being filetype
2018-07-23 20:14:38 -04:00
strings (like `python` , `cpp` , etc.) and values being unimportant (the
dictionary is used like a hash set, meaning that only the keys matter).
2013-03-09 23:30:10 -05:00
The `*` key is special and matches all filetypes. By default, the whitelist
contains only this `*` key.
YCM also has a `g:ycm_filetype_blacklist` option that lists filetypes for which
YCM shouldn't be turned on. YCM will work only in filetypes that both the
whitelist and the blacklist allow (the blacklist "allows" a filetype by _not_
having it as a key).
For example, let's assume you want YCM to work in files with the `cpp` filetype.
The filetype should then be present in the whitelist either directly (`cpp` key
in the whitelist) or indirectly through the special `*` key. It should _not_ be
present in the blacklist.
Filetypes that are blocked by the either of the lists will be completely ignored
by YCM, meaning that neither the identifier-based completion engine nor the
semantic engine will operate in them.
2013-01-22 00:36:17 -05:00
You can get the filetype of the current file in Vim with `:set ft?` .
2018-10-06 21:06:15 -04:00
Default: `{'*': 1}`
2013-03-09 23:30:10 -05:00
2015-09-15 14:57:34 -04:00
```viml
2018-10-06 21:06:15 -04:00
let g:ycm_filetype_whitelist = {'*': 1}
2015-09-15 14:57:34 -04:00
```
2013-03-09 23:30:10 -05:00
### The `g:ycm_filetype_blacklist` option
This option controls for which Vim filetypes (see `:h filetype` ) should YCM be
turned off. The option value should be a Vim dictionary with keys being filetype
2018-07-23 20:14:38 -04:00
strings (like `python` , `cpp` , etc.) and values being unimportant (the
dictionary is used like a hash set, meaning that only the keys matter).
2013-03-09 23:30:10 -05:00
See the `g:ycm_filetype_whitelist` option for more details on how this works.
2013-10-29 22:20:16 -04:00
Default: `[see next line]`
2013-01-22 00:36:17 -05:00
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_filetype_blacklist = {
2018-10-06 21:06:15 -04:00
\ 'tagbar': 1,
\ 'notes': 1,
\ 'markdown': 1,
2019-02-05 12:21:37 -05:00
\ 'netrw': 1,
2018-10-06 21:06:15 -04:00
\ 'unite': 1,
\ 'text': 1,
\ 'vimwiki': 1,
\ 'pandoc': 1,
\ 'infolog': 1,
\ 'mail': 1
2015-09-15 14:57:34 -04:00
\}
```
2013-01-22 00:36:17 -05:00
### The `g:ycm_filetype_specific_completion_to_disable` option
This option controls for which Vim filetypes (see `:h filetype` ) should the YCM
semantic completion engine be turned off. The option value should be a Vim
2018-07-23 20:14:38 -04:00
dictionary with keys being filetype strings (like `python` , `cpp` , etc.) and
2013-01-22 00:36:17 -05:00
values being unimportant (the dictionary is used like a hash set, meaning that
only the keys matter). The listed filetypes will be ignored by the YCM semantic
completion engine, but the identifier-based completion engine will still trigger
in files of those filetypes.
Note that even if semantic completion is not turned off for a specific filetype,
you will not get semantic completion if the semantic engine does not support
2013-03-09 01:44:23 -05:00
that filetype.
2013-01-22 00:36:17 -05:00
You can get the filetype of the current file in Vim with `:set ft?` .
2014-09-07 23:34:09 -04:00
Default: `[see next line]`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_filetype_specific_completion_to_disable = {
\ 'gitcommit': 1
\}
```
2013-01-22 00:36:17 -05:00
2018-07-23 20:14:38 -04:00
### The `g:ycm_filepath_blacklist` option
This option controls for which Vim filetypes (see `:h filetype` ) should filepath
completion be disabled. The option value should be a Vim dictionary with keys
being filetype strings (like `python` , `cpp` , etc.) and values being unimportant
(the dictionary is used like a hash set, meaning that only the keys matter).
The `*` key is special and matches all filetypes. Use this key if you want to
completely disable filepath completion:
```viml
2018-10-06 21:06:15 -04:00
let g:ycm_filepath_blacklist = {'*': 1}
2018-07-23 20:14:38 -04:00
```
You can get the filetype of the current file in Vim with `:set ft?` .
Default: `[see next line]`
```viml
let g:ycm_filepath_blacklist = {
2018-10-06 21:06:15 -04:00
\ 'html': 1,
\ 'jsx': 1,
\ 'xml': 1,
2018-07-23 20:14:38 -04:00
\}
```
2014-01-08 22:43:21 -05:00
### The `g:ycm_show_diagnostics_ui` option
2013-03-25 22:47:26 -04:00
2014-01-08 22:43:21 -05:00
When set, this option turns on YCM's diagnostic display features. See the
_Diagnostic display_ section in the _User Manual_ for more details.
Specific parts of the diagnostics UI (like the gutter signs, text highlighting,
diagnostic echo and auto location list population) can be individually turned on
or off. See the other options below for details.
Note that YCM's diagnostics UI is only supported for C-family languages.
When set, this option also makes YCM remove all Syntastic checkers set for the
2018-05-24 01:34:15 -04:00
`c` , `cpp` , `objc` , `objcpp` , and `cuda` filetypes since this would conflict
with YCM's own diagnostics UI.
2013-03-25 22:47:26 -04:00
If you're using YCM's identifier completer in C-family languages but cannot use
the clang-based semantic completer for those languages _and_ want to use the GCC
Syntastic checkers, unset this option.
2014-01-08 22:43:21 -05:00
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_show_diagnostics_ui = 1
```
2014-01-08 22:43:21 -05:00
### The `g:ycm_error_symbol` option
YCM will use the value of this option as the symbol for errors in the Vim
gutter.
This option is part of the Syntastic compatibility layer; if the option is not
set, YCM will fall back to the value of the `g:syntastic_error_symbol` option
before using this option's default.
Default: `>>`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_error_symbol = '>>'
```
2014-01-08 22:43:21 -05:00
### The `g:ycm_warning_symbol` option
YCM will use the value of this option as the symbol for warnings in the Vim
gutter.
This option is part of the Syntastic compatibility layer; if the option is not
set, YCM will fall back to the value of the `g:syntastic_warning_symbol` option
before using this option's default.
Default: `>>`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_warning_symbol = '>>'
```
2014-01-08 22:43:21 -05:00
### The `g:ycm_enable_diagnostic_signs` option
When this option is set, YCM will put icons in Vim's gutter on lines that have a
2014-01-09 17:11:15 -05:00
diagnostic set. Turning this off will also turn off the `YcmErrorLine` and
`YcmWarningLine` highlighting.
2014-01-08 22:43:21 -05:00
This option is part of the Syntastic compatibility layer; if the option is not
set, YCM will fall back to the value of the `g:syntastic_enable_signs` option
before using this option's default.
2013-03-25 22:47:26 -04:00
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_enable_diagnostic_signs = 1
```
2014-01-08 22:43:21 -05:00
### The `g:ycm_enable_diagnostic_highlighting` option
When this option is set, YCM will highlight regions of text that are related to
the diagnostic that is present on a line, if any.
This option is part of the Syntastic compatibility layer; if the option is not
set, YCM will fall back to the value of the `g:syntastic_enable_highlighting`
option before using this option's default.
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_enable_diagnostic_highlighting = 1
```
2014-01-08 22:43:21 -05:00
### The `g:ycm_echo_current_diagnostic` option
When this option is set, YCM will echo the text of the diagnostic present on the
2015-08-05 17:09:07 -04:00
current line when you move your cursor to that line. If a `FixIt` is available
for the current diagnostic, then ` (FixIt)` is appended.
2014-01-08 22:43:21 -05:00
This option is part of the Syntastic compatibility layer; if the option is not
set, YCM will fall back to the value of the `g:syntastic_echo_current_error`
option before using this option's default.
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_echo_current_diagnostic = 1
```
2014-01-08 22:43:21 -05:00
2016-10-16 12:43:58 -04:00
### The `g:ycm_filter_diagnostics` option
2016-10-23 12:29:29 -04:00
This option controls which diagnostics will be rendered by YCM. This option
holds a dictionary of key-values, where the keys are Vim's filetype strings
delimited by commas and values are dictionaries describing the filter.
2016-10-16 12:43:58 -04:00
A filter is a dictionary of key-values, where the keys are the type of filter,
2016-10-23 12:29:29 -04:00
and the value is a list of arguments to that filter. In the case of just a
single item in the list, you may omit the brackets and just provide the argument
2017-10-03 02:41:10 -04:00
directly. If any filter matches a diagnostic, it will be dropped and YCM will
2016-10-23 12:29:29 -04:00
not render it.
2016-10-16 12:43:58 -04:00
The following filter types are supported:
- "regex": Accepts a string [regular expression][python-re]. This type matches
when the regex (treated as case-insensitive) is found in the diagnostic text.
2017-10-03 02:41:10 -04:00
- "level": Accepts a string level, either "warning" or "error." This type
2016-10-23 12:29:29 -04:00
matches when the diagnostic has the same level.
2016-10-16 12:43:58 -04:00
2017-01-01 19:01:39 -05:00
**NOTE:** The regex syntax is **NOT** Vim's, it's [Python's][python-re].
2016-10-16 12:43:58 -04:00
Default: `{}`
```viml
let g:ycm_filter_diagnostics = {
\ "java": {
\ "regex": [ ".*taco.*", ... ],
\ "level": "error",
\ ...
\ }
\ }
```
2014-01-08 22:43:21 -05:00
### The `g:ycm_always_populate_location_list` option
When this option is set, YCM will populate the location list automatically every
time it gets new diagnostic data. This option is off by default so as not to
interfere with other data you might have placed in the location list.
See `:help location-list` in Vim to learn more about the location list.
This option is part of the Syntastic compatibility layer; if the option is not
set, YCM will fall back to the value of the
`g:syntastic_always_populate_loc_list` option before using this option's
default.
Default: `0`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_always_populate_location_list = 0
```
2013-03-25 22:47:26 -04:00
2014-01-29 13:59:15 -05:00
### The `g:ycm_open_loclist_on_ycm_diags` option
When this option is set, `:YcmDiags` will automatically open the location list
after forcing a compilation and filling the list with diagnostic data.
See `:help location-list` in Vim to learn more about the location list.
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_open_loclist_on_ycm_diags = 1
```
2014-01-29 13:59:15 -05:00
2013-04-25 02:15:13 -04:00
### The `g:ycm_complete_in_comments` option
2013-02-16 15:56:21 -05:00
When this option is set to `1` , YCM will show the completion menu even when
2013-04-25 02:15:13 -04:00
typing inside comments.
2013-02-16 15:56:21 -05:00
Default: `0`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_complete_in_comments = 0
```
2013-04-25 02:15:13 -04:00
### The `g:ycm_complete_in_strings` option
When this option is set to `1` , YCM will show the completion menu even when
typing inside strings.
Note that this is turned on by default so that you can use the filename
completion inside strings. This is very useful for instance in C-family files
where typing `#include "` will trigger the start of filename completion. If you
turn off this option, you will turn off filename completion in such situations
as well.
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_complete_in_strings = 1
```
2013-02-16 17:00:46 -05:00
### The `g:ycm_collect_identifiers_from_comments_and_strings` option
When this option is set to `1` , YCM's identifier completer will also collect
identifiers from strings and comments. Otherwise, the text in comments and
strings will be ignored.
Default: `0`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_collect_identifiers_from_comments_and_strings = 0
```
2013-02-16 15:56:21 -05:00
2013-05-26 16:28:00 -04:00
### The `g:ycm_collect_identifiers_from_tags_files` option
When this option is set to `1` , YCM's identifier completer will also collect
identifiers from tags files. The list of tags files to examine is retrieved from
the `tagfiles()` Vim function which examines the `tags` Vim option. See `:h
'tags'` for details.
YCM will re-index your tags files if it detects that they have been modified.
The only supported tag format is the [Exuberant Ctags format][ctags-format]. The
2013-05-27 16:51:10 -04:00
format from "plain" ctags is NOT supported. Ctags needs to be called with the
`--fields=+l` option (that's a lowercase `L` , not a one) because YCM needs the
`language:<lang>` field in the tags output.
See the _FAQ_ for pointers if YCM does not appear to read your tag files.
2013-05-26 16:28:00 -04:00
2013-05-28 16:46:18 -04:00
This option is off by default because it makes Vim slower if your tags are on a
network directory.
Default: `0`
2013-05-26 16:28:00 -04:00
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_collect_identifiers_from_tags_files = 0
```
2013-05-26 16:28:00 -04:00
2013-05-27 03:08:21 -04:00
### The `g:ycm_seed_identifiers_with_syntax` option
When this option is set to `1` , YCM's identifier completer will seed its
identifier database with the keywords of the programming language you're
writing.
Since the keywords are extracted from the Vim syntax file for the filetype, all
keywords may not be collected, depending on how the syntax file was written.
Usually at least 95% of the keywords are successfully extracted.
Default: `0`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_seed_identifiers_with_syntax = 0
```
2013-05-27 03:08:21 -04:00
2013-10-26 19:22:43 -04:00
### The `g:ycm_extra_conf_vim_data` option
If you're using semantic completion for C-family files, this option might come
2018-07-23 19:58:28 -04:00
handy; it's a way of sending data from Vim to your `Settings` function in
2013-10-26 19:22:43 -04:00
your `.ycm_extra_conf.py` file.
This option is supposed to be a list of VimScript expression strings that are
2016-02-17 07:52:25 -05:00
evaluated for every request to the [ycmd server][ycmd] and then passed to your
2018-07-23 19:58:28 -04:00
`Settings` function as a `client_data` keyword argument.
2013-10-26 19:22:43 -04:00
2018-07-23 19:58:28 -04:00
For instance, if you set this option to `['v:version']` , your `Settings`
2013-10-26 19:22:43 -04:00
function will be called like this:
```python
2018-07-23 19:58:28 -04:00
# The '801' value is of course contingent on Vim 8.1; in 8.0 it would be '800'
Settings( ..., client_data = { 'v:version': 801 } )
2013-10-26 19:22:43 -04:00
```
So the `client_data` parameter is a dictionary mapping Vim expression strings to
their values at the time of the request.
2018-07-23 19:58:28 -04:00
The correct way to define parameters for your `Settings` function:
2013-10-27 13:19:22 -04:00
```python
2018-07-23 19:58:28 -04:00
def Settings( **kwargs ):
2013-10-27 13:19:22 -04:00
```
2013-10-27 13:22:08 -04:00
You can then get to `client_data` with `kwargs['client_data']` .
2013-10-27 13:19:22 -04:00
2013-10-26 19:22:43 -04:00
Default: `[]`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_extra_conf_vim_data = []
```
2013-10-26 19:22:43 -04:00
2016-03-12 16:04:57 -05:00
### The `g:ycm_server_python_interpreter` option
2013-11-14 13:50:05 -05:00
YCM will by default search for an appropriate Python interpreter on your system.
You can use this option to override that behavior and force the use of a
specific interpreter of your choosing.
2017-01-01 19:01:39 -05:00
**NOTE:** This interpreter is only used for the [ycmd server][ycmd]. The YCM
client running inside Vim always uses the Python interpreter that's embedded
inside Vim.
2013-11-14 13:50:05 -05:00
Default: `''`
2015-09-15 14:57:34 -04:00
```viml
2016-03-12 16:04:57 -05:00
let g:ycm_server_python_interpreter = ''
2015-09-15 14:57:34 -04:00
```
2013-11-14 13:50:05 -05:00
2016-05-06 01:52:04 -04:00
### The `g:ycm_keep_logfiles` option
2013-10-24 15:31:38 -04:00
2016-05-06 01:52:04 -04:00
When this option is set to `1` , YCM and the [ycmd completion server][ycmd] will
keep the logfiles around after shutting down (they are deleted on shutdown by
default).
2013-10-24 15:31:38 -04:00
To see where the logfiles are, call `:YcmDebugInfo` .
Default: `0`
2015-09-15 14:57:34 -04:00
```viml
2016-05-06 01:52:04 -04:00
let g:ycm_keep_logfiles = 0
2015-09-15 14:57:34 -04:00
```
2013-10-24 15:31:38 -04:00
2016-05-06 01:52:04 -04:00
### The `g:ycm_log_level` option
2013-10-24 15:31:38 -04:00
2016-05-06 01:52:04 -04:00
The logging level that YCM and the [ycmd completion server][ycmd] use. Valid
values are the following, from most verbose to least verbose:
2013-10-24 15:31:38 -04:00
- `debug`
- `info`
- `warning`
- `error`
- `critical`
Note that `debug` is _very_ verbose.
Default: `info`
2015-09-15 14:57:34 -04:00
```viml
2016-05-06 01:52:04 -04:00
let g:ycm_log_level = 'info'
2015-09-15 14:57:34 -04:00
```
2013-10-24 15:31:38 -04:00
2013-08-12 20:00:05 -04:00
### The `g:ycm_auto_start_csharp_server` option
2019-06-28 08:52:28 -04:00
When set to `1` , the OmniSharp-Roslyn server will be automatically started
(once per Vim session) when you open a C# file.
2013-08-12 20:00:05 -04:00
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_auto_start_csharp_server = 1
```
2013-08-12 20:00:05 -04:00
2013-08-12 20:57:43 -04:00
### The `g:ycm_auto_stop_csharp_server` option
2019-06-28 08:52:28 -04:00
When set to `1` , the OmniSharp-Roslyn server will be automatically stopped upon
2013-08-12 22:54:26 -04:00
closing Vim.
2013-08-12 20:57:43 -04:00
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_auto_stop_csharp_server = 1
```
2013-08-12 20:57:43 -04:00
2015-01-23 21:43:26 -05:00
### The `g:ycm_csharp_server_port` option
2015-03-17 15:56:01 -04:00
When g:ycm_auto_start_csharp_server is set to `1` , specifies the port for
2019-06-28 08:52:28 -04:00
the OmniSharp-Roslyn server to listen on. When set to `0` uses an unused port provided
2015-01-27 17:36:27 -05:00
by the OS.
2015-01-23 21:43:26 -05:00
Default: `0`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_csharp_server_port = 0
```
2015-01-23 21:43:26 -05:00
2015-08-31 12:51:23 -04:00
### The `g:ycm_csharp_insert_namespace_expr` option
2015-09-11 19:14:09 -04:00
By default, when YCM inserts a namespace, it will insert the `using` statement
under the nearest `using` statement. You may prefer that the `using` statement is
inserted somewhere, for example, to preserve sorting. If so, you can set this
2016-01-24 11:37:57 -05:00
option to override this behavior.
2015-09-11 19:14:09 -04:00
When this option is set, instead of inserting the `using` statement itself, YCM
will set the global variable `g:ycm_namespace_to_insert` to the namespace to
insert, and then evaluate this option's value as an expression. The option's
expression is responsible for inserting the namespace - the default insertion
will not occur.
Default: ''
2015-08-31 12:51:23 -04:00
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_csharp_insert_namespace_expr = ''
```
2015-08-31 12:51:23 -04:00
2013-01-22 00:36:17 -05:00
### The `g:ycm_add_preview_to_completeopt` option
When this option is set to `1` , YCM will add the `preview` string to Vim's
`completeopt` option (see `:h completeopt` ). If your `completeopt` option
already has `preview` set, there will be no effect. You can see the current
state of your `completeopt` setting with `:set completeopt?` (yes, the question
mark is important).
When `preview` is present in `completeopt` , YCM will use the `preview` window at
the top of the file to store detailed information about the current completion
candidate (but only if the candidate came from the semantic engine). For
instance, it would show the full function prototype and all the function
overloads in the window if the current completion is a function name.
Default: `0`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_add_preview_to_completeopt = 0
```
2013-01-22 00:36:17 -05:00
### The `g:ycm_autoclose_preview_window_after_completion` option
When this option is set to `1` , YCM will auto-close the `preview` window after
the user accepts the offered completion string. If there is no `preview` window
triggered because there is no `preview` string in `completeopt` , this option is
irrelevant. See the `g:ycm_add_preview_to_completeopt` option for more details.
Default: `0`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_autoclose_preview_window_after_completion = 0
```
2013-01-22 00:36:17 -05:00
2013-03-15 14:43:09 -04:00
### The `g:ycm_autoclose_preview_window_after_insertion` option
When this option is set to `1` , YCM will auto-close the `preview` window after
the user leaves insert mode. This option is irrelevant if
`g:ycm_autoclose_preview_window_after_completion` is set or if no `preview`
window is triggered. See the `g:ycm_add_preview_to_completeopt` option for more
details.
Default: `0`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_autoclose_preview_window_after_insertion = 0
```
2013-03-15 14:43:09 -04:00
2013-01-22 00:36:17 -05:00
### The `g:ycm_max_diagnostics_to_display` option
This option controls the maximum number of diagnostics shown to the user when
2019-01-20 07:16:54 -05:00
errors or warnings are detected in the file. This option is only relevant for
the C-family, C#, Java, JavaScript, and TypeScript languages.
A special value of `0` means there is no limit.
2013-01-22 00:36:17 -05:00
Default: `30`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_max_diagnostics_to_display = 30
```
2013-01-22 00:36:17 -05:00
2013-02-08 21:29:36 -05:00
### The `g:ycm_key_list_select_completion` option
2013-01-26 21:45:27 -05:00
2013-02-08 21:29:36 -05:00
This option controls the key mappings used to select the first completion
string. Invoking any of them repeatedly cycles forward through the completion
list.
2013-01-26 21:45:27 -05:00
2013-02-08 21:29:36 -05:00
Some users like adding `<Enter>` to this list.
2013-01-26 21:45:27 -05:00
2013-02-08 21:29:36 -05:00
Default: `['<TAB>', '<Down>']`
2013-01-26 21:45:27 -05:00
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_key_list_select_completion = ['< TAB > ', '< Down > ']
```
2013-01-26 21:45:27 -05:00
2013-02-08 21:29:36 -05:00
### The `g:ycm_key_list_previous_completion` option
2013-01-26 21:45:27 -05:00
2013-02-08 21:29:36 -05:00
This option controls the key mappings used to select the previous completion
string. Invoking any of them repeatedly cycles backwards through the completion
list.
2013-01-26 21:45:27 -05:00
2013-02-08 21:29:36 -05:00
Note that one of the defaults is `<S-TAB>` which means Shift-TAB. That mapping
will probably only work in GUI Vim (Gvim or MacVim) and not in plain console Vim
because the terminal usually does not forward modifier key combinations to Vim.
2013-01-26 21:45:27 -05:00
2013-02-08 21:29:36 -05:00
Default: `['<S-TAB>', '<Up>']`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_key_list_previous_completion = ['< S-TAB > ', '< Up > ']
```
2013-01-26 21:45:27 -05:00
2017-04-15 09:42:23 -04:00
### The `g:ycm_key_list_stop_completion` option
This option controls the key mappings used to close the completion menu. This is
useful when the menu is blocking the view, when you need to insert the `<TAB>`
character, or when you want to expand a snippet from [UltiSnips][] and navigate
through it.
Default: `['<C-y>']`
```viml
let g:ycm_key_list_stop_completion = ['< C-y > ']
```
2013-01-26 21:45:27 -05:00
### The `g:ycm_key_invoke_completion` option
This option controls the key mapping used to invoke the completion menu for
2017-07-31 17:04:56 -04:00
semantic completion. By default, semantic completion is triggered automatically
2013-01-26 21:45:27 -05:00
after typing `.` , `->` and `::` in insert mode (if semantic completion support
has been compiled in). This key mapping can be used to trigger semantic
completion anywhere. Useful for searching for top-level functions and classes.
2013-04-19 21:33:06 -04:00
Console Vim (not Gvim or MacVim) passes `<Nul>` to Vim when the user types
`<C-Space>` so YCM will make sure that `<Nul>` is used in the map command when
you're editing in console Vim, and `<C-Space>` in GUI Vim. This means that you
can just press `<C-Space>` in both console and GUI Vim and YCM will do the right
thing.
2013-01-26 21:45:27 -05:00
2013-02-06 21:32:47 -05:00
Setting this option to an empty string will make sure no mapping is created.
2013-01-26 21:45:27 -05:00
Default: `<C-Space>`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_key_invoke_completion = '< C-Space > '
```
2013-01-26 21:45:27 -05:00
2013-01-31 15:32:07 -05:00
### The `g:ycm_key_detailed_diagnostics` option
This option controls the key mapping used to show the full diagnostic text when
2013-02-06 21:32:47 -05:00
the user's cursor is on the line with the diagnostic. It basically calls
`:YcmShowDetailedDiagnostic` .
Setting this option to an empty string will make sure no mapping is created.
2013-01-31 15:32:07 -05:00
Default: `<leader>d`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_key_detailed_diagnostics = '< leader > d'
```
2013-01-31 15:32:07 -05:00
2013-01-30 16:23:57 -05:00
### The `g:ycm_global_ycm_extra_conf` option
2013-04-15 01:36:35 -04:00
Normally, YCM searches for a `.ycm_extra_conf.py` file for compilation flags
2013-02-15 09:01:18 -05:00
(see the User Guide for more details on how this works). This option specifies
2013-04-15 01:36:35 -04:00
a fallback path to a config file which is used if no `.ycm_extra_conf.py` is
2013-02-15 09:01:18 -05:00
found.
2013-01-30 16:23:57 -05:00
You can place such a global file anywhere in your filesystem.
2013-02-12 23:31:46 -05:00
Default: `''`
2013-01-30 16:23:57 -05:00
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_global_ycm_extra_conf = ''
```
2013-01-30 16:23:57 -05:00
2013-02-25 04:58:04 -05:00
### The `g:ycm_confirm_extra_conf` option
2013-02-26 21:28:58 -05:00
When this option is set to `1` YCM will ask once per `.ycm_extra_conf.py` file
2013-02-25 04:58:04 -05:00
if it is safe to be loaded. This is to prevent execution of malicious code
2013-02-26 21:28:58 -05:00
from a `.ycm_extra_conf.py` file you didn't write.
2013-02-25 04:58:04 -05:00
2013-08-02 19:12:48 -04:00
To selectively get YCM to ask/not ask about loading certain `.ycm_extra_conf.py`
files, see the `g:ycm_extra_conf_globlist` option.
2013-02-25 04:58:04 -05:00
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_confirm_extra_conf = 1
```
2013-02-25 04:58:04 -05:00
2013-02-24 18:21:34 -05:00
### The `g:ycm_extra_conf_globlist` option
This option is a list that may contain several globbing patterns. If a pattern
starts with a `!` all `.ycm_extra_conf.py` files matching that pattern will be
blacklisted, that is they won't be loaded and no confirmation dialog will be
shown. If a pattern does not start with a `!` all files matching that pattern
will be whitelisted. Note that this option is not used when confirmation is
disabled using `g:ycm_confirm_extra_conf` and that items earlier in the list
will take precedence over the later ones.
Rules:
* `*` matches everything
* `?` matches any single character
* `[seq]` matches any character in seq
* `[!seq]` matches any char not in seq
Example:
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_extra_conf_globlist = ['~/dev/*','!~/*']
```
2013-02-24 18:21:34 -05:00
* The first rule will match everything contained in the `~/dev` directory so
`.ycm_extra_conf.py` files from there will be loaded.
* The second rule will match everything in the home directory so a
`.ycm_extra_conf.py` file from there won't be loaded.
* As the first rule takes precedence everything in the home directory excluding
the `~/dev` directory will be blacklisted.
2017-01-01 19:01:39 -05:00
**NOTE:** The glob pattern is first expanded with Python's
`os.path.expanduser()` and then resolved with `os.path.abspath()` before being
matched against the filename.
2014-09-12 13:04:08 -04:00
2013-02-24 18:21:34 -05:00
Default: `[]`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_extra_conf_globlist = []
```
2013-02-24 18:21:34 -05:00
2013-04-23 00:44:18 -04:00
### The `g:ycm_filepath_completion_use_working_dir` option
By default, YCM's filepath completion will interpret relative paths like `../`
as being relative to the folder of the file of the currently active buffer.
Setting this option will force YCM to always interpret relative paths as being
relative to Vim's current working directory.
Default: `0`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_filepath_completion_use_working_dir = 0
```
2013-04-23 00:44:18 -04:00
2013-02-12 23:31:46 -05:00
### The `g:ycm_semantic_triggers` option
This option controls the character-based triggers for the various semantic
completion engines. The option holds a dictionary of key-values, where the keys
are Vim's filetype strings delimited by commas and values are lists of strings,
where the strings are the triggers.
2013-06-29 14:53:16 -04:00
Setting key-value pairs on the dictionary _adds_ semantic triggers to the
internal default set (listed below). You cannot remove the default triggers,
only add new ones.
2013-02-12 23:31:46 -05:00
A "trigger" is a sequence of one or more characters that trigger semantic
completion when typed. For instance, C++ (`cpp` filetype) has `.` listed as a
trigger. So when the user types `foo.` , the semantic engine will trigger and
serve `foo` 's list of member functions and variables. Since C++ also has `->`
listed as a trigger, the same thing would happen when the user typed `foo->` .
2014-08-29 16:29:01 -04:00
It's also possible to use a regular expression as a trigger. You have to prefix
your trigger with `re!` to signify it's a regex trigger. For instance,
`re!\w+\.` would only trigger after the `\w+\.` regex matches.
2017-01-01 19:01:39 -05:00
**NOTE:** The regex syntax is **NOT** Vim's, it's [Python's][python-re].
2014-08-29 16:29:01 -04:00
2013-02-12 23:31:46 -05:00
Default: `[see next line]`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_semantic_triggers = {
2018-10-06 21:06:15 -04:00
\ 'c': ['->', '.'],
\ 'objc': ['->', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s',
\ 're!\[.*\]\s'],
\ 'ocaml': ['.', '#'],
\ 'cpp,cuda,objcpp': ['->', '.', '::'],
\ 'perl': ['->'],
\ 'php': ['->', '::'],
\ 'cs,d,elixir,go,groovy,java,javascript,julia,perl6,python,scala,typescript,vb': ['.'],
\ 'ruby,rust': ['.', '::'],
\ 'lua': ['.', ':'],
\ 'erlang': [':'],
2015-09-15 14:57:34 -04:00
\ }
```
2013-01-22 00:36:17 -05:00
2013-04-08 16:26:34 -04:00
### The `g:ycm_cache_omnifunc` option
2013-04-15 01:42:32 -04:00
Some omnicompletion engines do not work well with the YCM cache—in particular,
they might not produce all possible results for a given prefix. By unsetting
2015-03-23 09:45:46 -04:00
this option you can ensure that the omnicompletion engine is re-queried on every
2013-04-15 01:42:32 -04:00
keypress. That will ensure all completions will be presented, but might cause
stuttering and lagginess if the omnifunc is slow.
2013-04-08 16:26:34 -04:00
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_cache_omnifunc = 1
```
2013-04-08 16:26:34 -04:00
2013-11-15 19:21:06 -05:00
### The `g:ycm_use_ultisnips_completer` option
By default, YCM will query the UltiSnips plugin for possible completions of
snippet triggers. This option can turn that behavior off.
Default: `1`
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_use_ultisnips_completer = 1
```
2013-11-15 19:21:06 -05:00
2014-02-23 08:50:51 -05:00
### The `g:ycm_goto_buffer_command` option
2018-07-24 11:12:50 -04:00
Defines where `GoTo*` commands result should be opened. Can take one of the
2018-08-14 04:21:12 -04:00
following values: `'same-buffer'` , `'split'` , or `'split-or-existing-window'` .
If this option is set to the `'same-buffer'` but current buffer can not be
switched (when buffer is modified and `nohidden` option is set), then result
will be opened in a split. When the option is set to
2018-07-24 11:12:50 -04:00
`'split-or-existing-window'` , if the result is already open in a window of the
2018-08-14 04:21:12 -04:00
current tab page (or any tab pages with the `:tab` modifier; see below), it will
jump to that window. Otherwise, the result will be opened in a split as if the
option was set to `'split'` .
2018-07-24 11:12:50 -04:00
To customize the way a new window is split, prefix the `GoTo*` command with one
of the following modifiers: `:aboveleft` , `:belowright` , `:botright` ,
`:leftabove` , `:rightbelow` , `:topleft` , and `:vertical` . For instance, to
split vertically to the right of the current window, run the command:
```viml
:rightbelow vertical YcmCompleter GoTo
```
To open in a new tab page, use the `:tab` modifier with the `'split'` or
`'split-or-existing-window'` options e.g.:
```viml
:tab YcmCompleter GoTo
```
2014-02-23 08:50:51 -05:00
2018-08-14 04:21:12 -04:00
**NOTE:** command modifiers were added in Vim 7.4.1898. If you are using an
older version, you can still configure this by setting the option to one of the
deprecated values: `'vertical-split'` , `'new-tab'` , or `'new-or-existing-tab'` .
2014-03-04 05:47:43 -05:00
Default: `'same-buffer'`
2014-09-03 15:53:24 -04:00
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_goto_buffer_command = 'same-buffer'
```
2014-02-23 08:50:51 -05:00
2014-12-03 04:38:02 -05:00
### The `g:ycm_disable_for_files_larger_than_kb` option
Defines the max size (in Kb) for a file to be considered for completion. If this
2015-03-17 16:20:20 -04:00
option is set to 0 then no check is made on the size of the file you're opening.
2014-12-03 04:38:02 -05:00
Default: 1000
2015-09-15 14:57:34 -04:00
```viml
let g:ycm_disable_for_files_larger_than_kb = 1000
```
2014-12-03 04:38:02 -05:00
2019-01-16 09:08:21 -05:00
### The `g:ycm_use_clangd` option
This option controls whether **clangd** should be used as completion engine for
2019-02-18 10:37:33 -05:00
C-family languages. Can take one of the following values: `1` , `0` , with
meanings:
2019-01-16 09:08:21 -05:00
2019-02-18 10:37:33 -05:00
- `1` : YCM will use clangd if clangd binary exists in third party or it was
provided with `ycm_clangd_binary_path` option.
- `0` : YCM will never use clangd completer.
2019-01-16 09:08:21 -05:00
2019-02-18 10:37:33 -05:00
Default: `1`
2019-01-16 09:08:21 -05:00
```viml
2019-02-18 10:37:33 -05:00
let g:ycm_use_clangd = 1
2019-01-16 09:08:21 -05:00
```
### The `g:ycm_clangd_binary_path` option
2019-02-18 10:37:33 -05:00
When `ycm_use_clangd` option is set to `1` , this option sets the path to
**clangd** binary.
2019-01-16 09:08:21 -05:00
Default: `''`
```viml
let g:ycm_clangd_binary_path = ''
```
### The `g:ycm_clangd_args` option
This option controls the command line arguments passed to the clangd binary. It
appends new options and overrides the existing ones.
Default: `[]`
```viml
let g:ycm_clangd_args = []
```
### The `g:ycm_clangd_uses_ycmd_caching` option
This option controls which ranking and filtering algorithm to use for completion
items. It can take values:
- `1` : Uses ycmd's caching and filtering logic.
- `0` : Uses clangd's caching and filtering logic.
Default: `1`
```viml
let g:ycm_clangd_uses_ycmd_caching = 1
```
2019-06-28 08:52:28 -04:00
### The `g:ycm_language_server` option
This option lets YCM use an arbitrary LSP server, not unlike coc.nvim and others.
However, the officially supported completers are favoured over custom LSP ones,
so overriding an existing completer means first making sure YCM won't choose
that existing completer in the first place.
A simple working example of this option can be found in the section called
["Semantic Completion for Other Languages" ](#semantic-completion-for-other-languages ).
Default: `[]`
```viml
let g:ycm_language_server = []
```
2013-01-22 00:36:17 -05:00
FAQ
---
2013-10-26 19:22:43 -04:00
### I used to be able to `import vim` in `.ycm_extra_conf.py`, but now can't
YCM was rewritten to use a client-server architecture where most of the logic is
2016-02-17 07:52:25 -05:00
in the [ycmd server][ycmd]. So the magic `vim` module you could have previously
2013-10-26 19:22:43 -04:00
imported in your `.ycm_extra_conf.py` files doesn't exist anymore.
To be fair, importing the magic `vim` module in extra conf files was never
supported in the first place; it only ever worked by accident and was never a
part of the extra conf API.
But fear not, you should be able to tweak your extra conf files to continue
working by using the `g:ycm_extra_conf_vim_data` option. See the docs on that
option for details.
2016-03-07 10:55:32 -05:00
### I get `ImportError` exceptions that mention `PyInit_ycm_core` or `initycm_core`
2016-03-04 22:39:18 -05:00
These errors are caused by building the YCM native libraries for Python 2 and
trying to load them into a Python 3 process (or the other way around).
For instance, if building for Python 2 but loading in Python 3:
```
ImportError: dynamic module does not define init function (PyInit_ycm_core)
```
If building for Python 3 but loading in Python 2:
```
ImportError: dynamic module does not define init function (initycm_core)
```
2016-03-12 16:04:57 -05:00
Setting the `g:ycm_server_python_interpreter` option to force the use of a
2016-03-04 22:39:18 -05:00
specific Python interpreter for `ycmd` is usually the easiest way to solve the
problem. Common values for that option are `/usr/bin/python` and
`/usr/bin/python3` .
2019-05-04 16:29:50 -04:00
### I get a linker warning regarding `libpython` on macOS when compiling YCM
2013-01-24 21:07:46 -05:00
If the warning is `ld: warning: path '/usr/lib/libpython2.7.dylib' following -L
not a directory`, then feel free to ignore it; it's caused by a limitation of
CMake and is not an issue. Everything should still work fine.
2013-01-25 17:49:23 -05:00
### I get a weird window at the top of my file when I use the semantic engine
This is Vim's `preview` window. Vim uses it to show you extra information about
something if such information is available. YCM provides Vim with such extra
information. For instance, when you select a function in the completion list,
the `preview` window will hold that function's prototype and the prototypes of
any overloads of the function. It will stay there after you select the
completion so that you can use the information about the parameters and their
types to write the function call.
If you would like this window to auto-close after you select a completion
string, set the `g:ycm_autoclose_preview_window_after_completion` option to `1`
2013-03-15 14:43:09 -04:00
in your `vimrc` file. Similarly, the `g:ycm_autoclose_preview_window_after_insertion`
option can be set to close the `preview` window after leaving insert mode.
2013-01-25 17:49:23 -05:00
2013-01-25 17:50:45 -05:00
If you don't want this window to ever show up, add `set completeopt-=preview` to
your `vimrc` . Also make sure that the `g:ycm_add_preview_to_completeopt` option
is set to `0` .
2013-01-22 00:36:17 -05:00
2013-01-26 20:47:05 -05:00
### It appears that YCM is not working
2013-01-26 19:52:37 -05:00
In Vim, run `:messages` and carefully read the output. YCM will echo messages to
the message log if it encounters problems. It's likely you misconfigured
something and YCM is complaining about it.
2013-01-28 13:03:32 -05:00
Also, you may want to run the `:YcmDebugInfo` command; it will make YCM spew out
2016-05-06 01:52:04 -04:00
various debugging information, including the YCM and [ycmd][] logfile paths and
the compile flags for the current file if the file is a C-family language file
and you have compiled in Clang support. Logfiles can be opened in the editor
using [the `:YcmToggleLogs` command ](#the-ycmtogglelogs-command ).
2013-01-28 13:03:32 -05:00
2013-01-31 22:21:11 -05:00
### Sometimes it takes much longer to get semantic completions than normal
This means that libclang (which YCM uses for C-family semantic completion)
2013-02-04 12:48:55 -05:00
failed to pre-compile your file's preamble. In other words, there was an error
2013-01-31 22:21:11 -05:00
compiling some of the source code you pulled in through your header files. I
2014-01-08 23:03:33 -05:00
suggest calling the `:YcmDiags` command to see what they were.
2013-01-31 22:21:11 -05:00
2013-02-04 12:48:55 -05:00
Bottom line, if libclang can't pre-compile your file's preamble because there
were errors in it, you're going to get slow completions because there's no AST
cache.
2013-02-01 19:05:27 -05:00
### YCM auto-inserts completion strings I don't want!
2017-10-08 05:40:32 -04:00
If this happens when Vim automatically wraps text then it's a Vim bug that has
been fixed in version 8.0.0127. Update your Vim to this version or later.
This could also be some mappings that interfere with YCM's internal ones. Make
sure you don't have something mapped to `<C-p>` , `<C-x>` or `<C-u>` (in insert
mode).
2013-02-01 19:05:27 -05:00
YCM _never_ selects something for you; it just shows you a menu and the user has
to explicitly select something. If something is being selected automatically,
this means there's a bug or a misconfiguration somewhere.
2013-02-03 01:28:11 -05:00
### I get a `E227: mapping already exists for <blah>` error when I start Vim
This means that YCM tried to set up a key mapping but failed because you already
had something mapped to that key combination. The `<blah>` part of the message
will tell you what was the key combination that failed.
2013-05-11 17:15:34 -04:00
Look in the _Options_ section and see if any of the default mappings conflict
2013-02-03 01:28:11 -05:00
with your own. Then change that option value to something else so that the
conflict goes away.
2013-04-22 16:44:43 -04:00
### I get `'GLIBC_2.XX' not found (required by libclang.so)` when starting Vim
2013-04-22 16:43:07 -04:00
Your system is too old for the precompiled binaries from llvm.org. Compile
Clang on your machine and then link against the `libclang.so` you just produced.
See the full installation guide for help.
2013-02-07 12:55:41 -05:00
### I get `LONG_BIT definition appears wrong for platform` when compiling
Look at the output of your CMake call. There should be a line in it like the
2019-05-04 16:29:50 -04:00
following (with `.dylib` in place of `.so` on macOS):
2013-02-07 12:55:41 -05:00
```
2013-02-07 12:57:22 -05:00
-- Found PythonLibs: /usr/lib/libpython2.7.so (Required is at least version "2.5")
2013-02-07 12:55:41 -05:00
```
That would be the **correct** output. An example of **incorrect** output would
be the following:
```
2013-02-07 12:57:22 -05:00
-- Found PythonLibs: /usr/lib/libpython2.7.so (found suitable version "2.5.1", minimum required is "2.5")
2013-02-07 12:55:41 -05:00
```
Notice how there's an extra bit of output there, the `found suitable version
"< version > "` part, where `<version>` is not the same as the version of the
dynamic library. In the example shown, the library is version 2.7 but the second
string is version `2.5.1` .
2013-02-07 12:58:16 -05:00
This means that CMake found one version of Python headers and a different
2013-02-07 12:55:41 -05:00
version for the library. This is wrong. It can happen when you have multiple
versions of Python installed on your machine.
You should probably add the following flags to your cmake call (again, `dylib`
2019-05-04 16:29:50 -04:00
instead of `so` on macOS):
2013-02-07 12:55:41 -05:00
```
-DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so
```
This will force the paths to the Python include directory and the Python library
to use. You may need to set these flags to something else, but you need to make
sure you use the same version of Python that your Vim binary is built against,
which is highly likely to be the system's default Python.
2013-06-09 14:12:51 -04:00
### I get `libpython2.7.a [...] relocation R_X86_64_32` when compiling
The error is usually encountered when compiling YCM on Centos or RHEL. The full
error looks something like the following:
```
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
```
It's possible to get a slightly different error that's similar to the one above.
Here's the problem and how you solve it:
Your `libpython2.7.a` was not compiled with `-fPIC` so it can't be linked into
`ycm_core.so` . Use the `-DPYTHON_LIBRARY=` CMake flag to point it to a `.so`
version of libpython on your machine (for instance,
`-DPYTHON_LIBRARY=/usr/lib/libpython2.7.so` ). Naturally, this means you'll have
to go through the full installation guide by hand.
2018-12-11 14:10:53 -05:00
### I see `undefined symbol: clang_getCompletionFixIt` in the server logs.
2013-02-17 22:07:50 -05:00
2018-12-11 14:10:53 -05:00
This means that the server is trying to load a version of libclang that is too
2019-04-27 16:01:33 -04:00
old. You need at least libclang 8.0.0. We recommend running the `install.py`
2018-12-11 14:10:53 -05:00
script without `--system-libclang` or downloading the [latest prebuilt binaries
from llvm.org][clang-download] when going through the [full installation
guide](#full-installation-guide).
2016-03-26 10:53:48 -04:00
### I get `Fatal Python error: PyThreadState_Get: no current thread` on startup
This is caused by linking a static version of `libpython` into ycmd's
`ycm_core.so` . This leads to multiple copies of the python interpreter loaded
when `python` loads `ycmd_core.so` and this messes up python's global state.
The details aren't important.
The solution is that the version of Python linked and run against must be built
with either `--enable-shared` or `--enable-framework` (on OS X).
2019-05-04 16:29:50 -04:00
This is achieved as follows (**NOTE:** for macOS, replace `--enable-shared`
2016-03-26 10:53:48 -04:00
with `--enable-framework` ):
- When building python from source: `./configure --enable-shared {options}`
- When building python from pyenv:
`PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install {version}`
2016-09-11 05:14:14 -04:00
### `install.py` says python must be compiled with `--enable-framework`. Wat?
2016-03-26 10:53:48 -04:00
See the previous answer for how to ensure your python is built to support
dynamic modules.
2013-05-26 16:28:00 -04:00
### YCM does not read identifiers from my tags files
2013-05-28 16:46:18 -04:00
First, put `let g:ycm_collect_identifiers_from_tags_files = 1` in your vimrc.
2013-05-26 16:28:00 -04:00
Make sure you are using [Exuberant Ctags][exuberant-ctags] to produce your tags
files since the only supported tag format is the [Exuberant Ctags
format][ctags-format]. The format from "plain" ctags is NOT supported. The
2018-04-03 16:20:01 -04:00
output of `ctags --version` should list "Exuberant Ctags". See [Universal
Ctags][universal-ctags] for a maintained version.
2013-05-26 16:28:00 -04:00
2013-05-27 16:51:10 -04:00
Ctags needs to be called with the `--fields=+l` (that's a lowercase `L` , not a
one) option because YCM needs the `language:<lang>` field in the tags output.
2017-01-01 19:01:39 -05:00
**NOTE:** [Exuberant Ctags][exuberant-ctags] by default sets language tag for
`*.h` files as `C++` . If you have C (not C++) project, consider giving parameter
`--langmap=c:.c.h` to ctags to see tags from `*.h` files.
2015-10-12 12:16:04 -04:00
2019-05-04 16:29:50 -04:00
**NOTE:** macOS comes with "plain" ctags installed by default. `brew install
2013-05-26 16:28:00 -04:00
ctags` will get you the Exuberant Ctags version.
Also make sure that your Vim `tags` option is set correctly. See `:h 'tags'` for
details. If you want to see which tag files YCM will read for a given buffer,
run `:echo tagfiles()` with the relevant buffer active. Note that that function
will only list tag files that already exist.
2017-10-06 19:44:13 -04:00
### `CTRL-U` in insert mode does not work while the completion menu is visible
2013-03-23 19:42:00 -04:00
2017-10-06 19:44:13 -04:00
YCM uses `completefunc` completion mode to show suggestions and Vim disables
`<C-U>` in that mode as a "feature." Sadly there's nothing I can do about this.
2013-03-23 19:42:00 -04:00
2018-03-11 15:09:46 -04:00
### My `CTRL-R` mapping does not work while the completion menu is visible
Vim prevents remapping of the `<C-R>` key in all `<C-X>` completion modes
(except the `<C-X><C-N>` /`< C-X >< C-P > ` mode which operates in the same mode as
`<C-N>` /`< C-P > `) and YCM uses the `<C-X><C-U>` (`completefunc`) mode for
completions. This means that adding `<C-R>` to any of the `g:ycm_key_list_*`
options has no effect. You need to use another key.
2013-06-29 16:02:11 -04:00
### YCM conflicts with UltiSnips TAB key usage
YCM comes with support for UltiSnips (snippet suggestions in the popup menu),
but you'll have to change the UltiSnips mappings. See `:h UltiSnips-triggers` in
Vim for details. You'll probably want to change some/all of the following
options:
2015-09-15 14:57:34 -04:00
```viml
g:UltiSnipsExpandTrigger
g:UltiSnipsJumpForwardTrigger
g:UltiSnipsJumpBackwardTrigger
```
2013-06-29 16:02:11 -04:00
2016-09-08 12:09:27 -04:00
### Snippets added with `:UltiSnipsAddFiletypes` do not appear in the popup menu
For efficiency, YCM only fetches UltiSnips snippets in specific scenarios like
visiting a buffer or setting its filetype. You can force YCM to retrieve them by
manually triggering the `FileType` autocommand:
```viml
:doautocmd FileType
```
2013-02-02 16:29:38 -05:00
### Why isn't YCM just written in plain VimScript, FFS?
Because of the identifier completion engine and subsequence-based filtering.
Let's say you have _many_ dozens of files open in a single Vim instance (I often
do); the identifier-based engine then needs to store thousands (if not tens of
thousands) of identifiers in its internal data-structures. When the user types,
YCM needs to perform subsequence-based filtering on _all_ of those identifiers
(every single one!) in less than 10 milliseconds.
I'm sorry, but that level of performance is just plain impossible to achieve
with VimScript. I've tried, and the language is just too slow. No, you can't get
acceptable performance even if you limit yourself to just the identifiers in the
2014-12-31 18:52:15 -05:00
current file and simple prefix-based filtering.
2013-02-02 16:29:38 -05:00
### Why does YCM demand such a recent version of Vim?
2017-04-11 07:46:20 -04:00
YCM needs a version of Vim with the timers feature to achieve full
asynchronicity. This feature is available since Vim 7.4.1578.
2014-01-18 18:14:24 -05:00
2013-02-08 00:06:16 -05:00
### Nasty bugs happen if I have the `vim-autoclose` plugin installed
Use the [delimitMate][] plugin instead. It does the same thing without
conflicting with YCM.
2013-07-13 14:38:34 -04:00
### Is there some sort of YCM mailing list? I have questions
If you have questions about the plugin or need help, please use the
[ycm-users][] mailing list, _don't_ create issues on the tracker. The tracker is
for bug reports and feature requests.
2013-02-07 21:06:12 -05:00
2013-11-09 13:06:11 -05:00
### I get an internal compiler error when installing
This can be a problem on virtual servers with limited memory. A possible
2014-08-27 17:37:18 -04:00
solution is to add more swap memory. A more practical solution would be to force
the build script to run only one compile job at a time. You can do this by
setting the `YCM_CORES` environment variable to `1` . Example:
```
2015-08-22 02:23:58 -04:00
YCM_CORES=1 ./install.py --clang-completer
2014-08-27 17:37:18 -04:00
```
2013-11-09 13:06:11 -05:00
2014-01-29 13:25:31 -05:00
### I get weird errors when I press `Ctrl-C` in Vim
_Never_ use `Ctrl-C` in Vim.
Using `Ctrl-C` to exit insert mode in Vim is a bad idea. The main issue here is
that `Ctrl-C` in Vim doesn't just leave insert mode, it leaves it without
triggering `InsertLeave` autocommands (as per Vim docs). This is a bad idea and
is likely to break many other things and not just YCM.
Bottom line, if you use `Ctrl-C` to exit insert mode in Vim, you're gonna have a
bad time.
If pressing `<esc>` is too annoying (agreed, it is), we suggest mapping it to
something more convenient. On a QWERTY keyboard, a good pick for the `<esc>` map
is `inoremap jk <Esc>` . This is right on the home row, it's an incredibly rare
digraph in English and if you ever need to type those two chars in sequence in
insert mode, you just type `j` , then wait 500ms, then type `k` .
2014-01-05 19:36:00 -05:00
### Why did YCM stop using Syntastic for diagnostics display?
2014-01-04 20:26:15 -05:00
Previously, YCM would send any diagnostics it would receive from the libclang
semantic engine to Syntastic for display as signs in the gutter, red squiggles
etc. Today, YCM uses its own code to do that.
Using Syntastic for this was always a kludge. Syntastic assumes its "checker"
plugins behave in a certain way; those assumptions have never fit YCM. For
instance, YCM continuously recompiles your code in the background for C-family
languages and tries to push new diagnostics to the user as fast as possible,
even while the user types.
Syntastic assumes that a checker only runs on file save ("active" mode) or even
less frequently, when the user explicitly invokes it ("passive" mode). This
mismatch in assumptions causes performance problems since Syntastic code isn't
optimized for this use case of constant diagnostic refreshing.
Poor support for this use case also led to crash bugs in Vim caused by
2014-01-08 23:03:33 -05:00
Syntastic-Vim interactions ([issue #593 ][issue-593]) and other problems, like
random Vim flickering. Attempts were made to resolve these issues in
Syntastic, but ultimately some of them failed (for various reasons).
2014-01-04 20:26:15 -05:00
Implementing diagnostic display code directly in YCM resolves all of these
2014-01-08 23:03:33 -05:00
problems. Performance also improved substantially since the relevant code is now
written in Python instead of VimScript (which is very slow) and is tailored only
for YCM's use-cases. We were also able to introduce new features in this area
since we're now not limited to the Syntastic checker API.
2014-01-04 20:26:15 -05:00
We've tried to implement this in the most backwards-compatible way possible; YCM
options that control diagnostic display fall back to Syntastic options that
control the same concepts if the user has those set.
Still, some Syntastic-specific configuration you might have had might not
2014-01-05 19:35:20 -05:00
be supported by the new code. Please file issues on the tracker in such
2014-01-04 20:26:15 -05:00
cases; if we find the request to be reasonable, we'll find a way to address it.
2013-11-18 23:23:39 -05:00
### Completion doesn't work with the C++ standard library headers
2015-03-27 15:59:19 -04:00
This is caused by an issue with libclang that only affects some operating
systems. Compiling with `clang` the binary will use the correct default header
search paths but compiling with `libclang.so` (which YCM uses) does not.
2013-11-18 23:23:39 -05:00
2019-05-04 16:29:50 -04:00
macOS is normally affected, but there's a workaround in YCM for that specific
2015-03-27 15:59:19 -04:00
OS. If you're not running that OS but still have the same problem, continue
reading.
The workaround is to call `echo | clang -v -E -x c++ -` and look at the
2013-11-18 23:23:39 -05:00
paths under the `#include <...> search starts here:` heading. You should take
those paths, prepend `-isystem` to each individual path and append them all to
2018-07-23 19:58:28 -04:00
the list of flags you return from your `Settings` function in your
2013-11-18 23:23:39 -05:00
`.ycm_extra_conf.py` file.
2013-11-18 23:26:20 -05:00
See [issue #303 ][issue-303] for details.
2013-11-18 23:23:39 -05:00
2016-01-14 12:31:02 -05:00
### When I start vim I get a runtime error saying `R6034 An application has made an attempt to load the C runtime library incorrectly.`
2015-12-22 20:14:12 -05:00
2016-06-18 18:35:05 -04:00
[CMake and other things seem to screw up the PATH with their own msvcrXX.dll
versions.][identify-R6034-cause] Add the following to the very top of your vimrc
to remove these entries from the path.
2016-01-14 12:31:02 -05:00
```python
python < < EOF
2016-01-29 03:48:24 -05:00
import os
import re
2016-01-25 04:37:08 -05:00
path = os.environ['PATH'].split(';')
2016-01-29 03:48:24 -05:00
def contains_msvcr_lib(folder):
2016-01-25 04:37:08 -05:00
try:
for item in os.listdir(folder):
2016-01-29 03:48:24 -05:00
if re.match(r'msvcr\d+\.dll', item):
2016-01-25 04:37:08 -05:00
return True
except:
pass
return False
2016-01-29 03:48:24 -05:00
path = [folder for folder in path if not contains_msvcr_lib(folder)]
2016-01-25 04:37:08 -05:00
os.environ['PATH'] = ';'.join(path)
2016-01-14 12:31:02 -05:00
EOF
```
2015-12-22 20:14:12 -05:00
2016-01-20 15:52:02 -05:00
### I hear that YCM only supports Python 2, is that true?
2016-02-28 20:45:41 -05:00
**No.** Both the Vim client and the [ycmd server][ycmd] run on Python 2 or 3. If
2018-07-25 16:25:31 -04:00
you are talking about code completion in a project, you can configure the Python
used for your project through a `.ycm_extra_conf.py` file. See [the Python
Semantic Completion section](#python-semantic-completion) for more details.
2016-01-20 15:52:02 -05:00
2016-04-19 19:48:46 -04:00
### On Windows I get `E887: Sorry, this command is disabled, the Python's site module could not be loaded`
2017-04-01 14:03:19 -04:00
If you are running vim on Windows with Python 2.7.11, this is likely caused by a
[bug][vim_win-python2.7.11-bug]. Follow this
[workaround][vim_win-python2.7.11-bug_workaround] or use a different version
(Python 2.7.12 does not suffer from the bug).
2016-04-19 19:48:46 -04:00
2018-07-25 16:25:31 -04:00
### I can't complete Python packages in a virtual environment.
This means that the Python used to run [Jedi][] is not the Python of the virtual
environment you're in. To resolve this you should create a `.ycm_extra_conf.py`
file at the root of your project that sets the `interpreter_path` option to the
Python of your virtual environment, e.g.
```python
def Settings(**kwargs):
return {
'interpreter_path': '/path/to/virtual/env/bin/python'
}
```
2016-06-12 12:47:53 -04:00
2018-07-25 16:25:31 -04:00
See [the Python Semantic Completion section ](#python-semantic-completion ) for
more details.
2016-06-12 12:47:53 -04:00
2016-12-16 22:21:09 -05:00
### I want to defer loading of YouCompleteMe until after Vim finishes booting
In recent versions of Vim, you can install YCM in a folder under
`~/.vim/pack/*/opt` and then load it once the user is idle via an autocommand:
```viml
augroup load_ycm
autocmd!
autocmd CursorHold, CursorHoldI * :packadd YouCompleteMe
\ | autocmd! load_ycm
augroup END
```
2017-05-08 12:25:52 -04:00
### YCM does not shut down when I quit Vim
YCM relies on the `VimLeave` event to shut down the [ycmd server][ycmd]. Some
plugins prevent this event from triggering by exiting Vim through an autocommand
2018-12-23 05:34:50 -05:00
without using the `nested` keyword (see `:h autocmd-nested` ). You should
identify which plugin is responsible for the issue and report it to the plugin
author. Note that when this happens, [ycmd][] will automatically shut itself
down after 30 minutes.
2017-05-08 12:25:52 -04:00
2018-05-05 16:31:37 -04:00
### YCM does not work with my Anaconda Python setup
Anaconda is often incompatible with the pre-built libclang used by YCM
and therefore is not supported. The recommended way to solve this is to run
`/path/to/real/python install.py` (for example `/usr/bin/python install.py` ).
2018-07-25 16:25:31 -04:00
If you want completion in Anaconda projects, point the `interpreter_path` option
in your `.ycm_extra_conf.py` file to the path of your Anaconda Python e.g.
```python
def Settings(**kwargs):
return {
'interpreter_path': '/path/to/anaconda/python'
}
```
See [the Python Semantic Completion section ](#python-semantic-completion ) for
more details.
2018-05-05 16:31:37 -04:00
2018-08-08 18:42:56 -04:00
### Automatic import insertion after selecting a completion breaks undo
This is a Vim bug fixed in version 8.1.0256. Update your Vim to this version or
later.
2019-02-05 12:21:37 -05:00
### `TAB` is already mapped to trigger completion in the command-line window
Vim automatically maps the key set by the `wildchar` option, which is `TAB` by
default, to complete commands in the command-line window. If you would prefer
using this key to cycle through YCM's suggestions without changing the value of
`wildchar` , add the following to your vimrc:
```viml
autocmd CmdwinEnter * inoremap < expr > < buffer > < TAB >
\ pumvisible() ? "\<C-n>" : "\<TAB>"
```
2016-01-26 18:49:58 -05:00
Contributor Code of Conduct
---------------------------
Please note that this project is released with a [Contributor Code of
Conduct][ccoc]. By participating in this project you agree to abide by its
terms.
2015-12-22 20:14:12 -05:00
2013-01-22 00:36:17 -05:00
Contact
-------
2016-10-31 12:48:35 -04:00
If you have questions about the plugin or need help, please join the [Gitter
room][gitter] or use the [ycm-users][] mailing list.
2013-07-13 14:38:34 -04:00
If you have bug reports or feature suggestions, please use the [issue
2017-12-31 17:29:13 -05:00
tracker][tracker]. Before you do, please carefully read
[CONTRIBUTING.md][contributing-md] as this asks for important diagnostics which
the team will use to help get you going.
2013-07-13 14:38:34 -04:00
The latest version of the plugin is available at
2013-04-05 21:02:00 -04:00
< http: / / valloric . github . io / YouCompleteMe / > .
2013-01-22 00:36:17 -05:00
The author's homepage is < http: / / val . markovic . io > .
2017-12-31 17:29:13 -05:00
Please do **NOT** go to #vim on freenode for support. Please contact the
2018-11-01 00:59:07 -04:00
YouCompleteMe maintainers directly using the [contact details ](#contact ).
2016-01-26 18:49:58 -05:00
2013-01-22 00:36:17 -05:00
License
-------
This software is licensed under the [GPL v3 license][gpl].
2018-04-16 14:20:02 -04:00
© 2015-2018 YouCompleteMe contributors
2013-01-22 00:36:17 -05:00
2016-02-17 07:52:25 -05:00
[ycmd]: https://github.com/Valloric/ycmd
2013-01-22 00:36:17 -05:00
[Clang]: http://clang.llvm.org/
2015-09-20 20:36:34 -04:00
[vundle]: https://github.com/VundleVim/Vundle.vim#about
2013-01-22 00:36:17 -05:00
[pathogen]: https://github.com/tpope/vim-pathogen#pathogenvim
2015-06-05 04:31:20 -04:00
[clang-download]: http://llvm.org/releases/download.html
2015-11-18 15:35:19 -05:00
[brew]: http://brew.sh
2015-11-18 11:58:55 -05:00
[cmake-download]: https://cmake.org/download/
2019-05-04 16:29:50 -04:00
[macvim]: https://macvim-dev.github.io/macvim/
2013-01-22 00:36:17 -05:00
[vimrc]: http://vimhelp.appspot.com/starting.txt.html#vimrc
[gpl]: http://www.gnu.org/copyleft/gpl.html
[vim]: http://www.vim.org/
[syntastic]: https://github.com/scrooloose/syntastic
2015-12-05 14:06:29 -05:00
[lightline]: https://github.com/itchyny/lightline.vim
2018-07-25 16:25:31 -04:00
[ycm_flags_example]: https://github.com/Valloric/YouCompleteMe/blob/master/.ycm_extra_conf.py
[ycmd_flags_example]: https://raw.githubusercontent.com/Valloric/ycmd/66030cd94299114ae316796f3cad181cac8a007c/.ycm_extra_conf.py
2013-01-23 00:05:32 -05:00
[compdb]: http://clang.llvm.org/docs/JSONCompilationDatabase.html
2015-11-18 11:58:55 -05:00
[subsequence]: https://en.wikipedia.org/wiki/Subsequence
2013-01-31 15:32:07 -05:00
[listtoggle]: https://github.com/Valloric/ListToggle
2013-02-02 16:29:27 -05:00
[vim-build]: https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source
2013-02-02 16:43:13 -05:00
[tracker]: https://github.com/Valloric/YouCompleteMe/issues?state=open
2013-02-06 13:21:01 -05:00
[issue18]: https://github.com/Valloric/YouCompleteMe/issues/18
2013-02-08 00:06:16 -05:00
[delimitMate]: https://github.com/Raimondi/delimitMate
2014-05-20 17:07:23 -04:00
[completer-api]: https://github.com/Valloric/ycmd/blob/master/ycmd/completers/completer.py
2013-03-23 14:55:59 -04:00
[eclim]: http://eclim.org/
2013-03-24 18:38:45 -04:00
[jedi]: https://github.com/davidhalter/jedi
2013-04-23 00:44:18 -04:00
[ultisnips]: https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt
2013-05-26 16:28:00 -04:00
[exuberant-ctags]: http://ctags.sourceforge.net/
2018-04-03 16:20:01 -04:00
[universal-ctags]: https://github.com/universal-ctags/ctags
2013-05-26 16:28:00 -04:00
[ctags-format]: http://ctags.sourceforge.net/FORMAT
2015-11-18 11:58:55 -05:00
[vundle-bug]: https://github.com/VundleVim/Vundle.vim/issues/48
2013-07-13 14:38:34 -04:00
[ycm-users]: https://groups.google.com/forum/?hl=en#!forum/ycm-users
2019-06-28 08:52:28 -04:00
[omnisharp-roslyn]: https://github.com/OmniSharp/omnisharp-roslyn
2013-11-18 23:26:20 -05:00
[issue-303]: https://github.com/Valloric/YouCompleteMe/issues/303
2014-01-05 19:35:20 -05:00
[issue-593]: https://github.com/Valloric/YouCompleteMe/issues/593
[issue-669]: https://github.com/Valloric/YouCompleteMe/issues/669
2014-01-18 18:14:24 -05:00
[status-mes]: https://groups.google.com/forum/#!topic/vim_dev/WeBBjkXE8H8
2014-08-29 16:29:01 -04:00
[python-re]: https://docs.python.org/2/library/re.html#regular-expression-syntax
2017-01-01 19:01:39 -05:00
[Bear]: https://github.com/rizsotto/Bear
2015-03-18 20:19:45 -04:00
[ygen]: https://github.com/rdnetto/YCM-Generator
2019-06-28 08:52:28 -04:00
[Gopls]: https://github.com/golang/go/wiki/gopls
[gopls-preferences]: https://github.com/golang/tools/blob/master/internal/lsp/server.go#L120
2015-07-31 13:55:05 -04:00
[TSServer]: https://github.com/Microsoft/TypeScript/tree/master/src/server
2017-09-26 14:17:46 -04:00
[jsconfig.json]: https://code.visualstudio.com/docs/languages/jsconfig
2018-04-06 21:55:24 -04:00
[tsconfig.json]: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
2018-12-21 10:34:27 -05:00
[vim-win-download]: https://github.com/vim/vim-win32-installer/releases
2015-09-20 20:36:34 -04:00
[python-win-download]: https://www.python.org/downloads/windows/
2019-04-23 18:13:10 -04:00
[visual-studio-download]: https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools& rel=15
2015-09-20 20:36:34 -04:00
[7z-download]: http://www.7-zip.org/download.html
2019-05-04 16:29:50 -04:00
[mono-install-macos]: http://www.mono-project.com/docs/getting-started/install/mac/
2018-08-19 20:12:09 -04:00
[mono-install-linux]: https://www.mono-project.com/download/stable/#download-lin
2016-06-09 07:07:51 -04:00
[mono-install]: http://www.mono-project.com/docs/getting-started/install/
2016-06-01 15:25:43 -04:00
[go-install]: https://golang.org/doc/install
2018-08-19 20:12:09 -04:00
[npm-install]: https://docs.npmjs.com/getting-started/installing-node#1-install-nodejs--npm
2017-09-26 14:17:46 -04:00
[tern-instructions]: https://github.com/Valloric/YouCompleteMe/wiki/JavaScript-Semantic-Completion-through-Tern
2015-12-19 12:41:09 -05:00
[Tern]: http://ternjs.net
2019-06-28 08:52:28 -04:00
[rls]: https://github.com/rust-lang/rls
[rls-preferences]: https://github.com/rust-lang/rls#configuration
2016-01-07 11:52:15 -05:00
[rust-src]: https://www.rust-lang.org/downloads.html
2016-01-14 12:31:02 -05:00
[add-msbuild-to-path]: http://stackoverflow.com/questions/6319274/how-do-i-run-msbuild-from-the-command-line-using-windows-sdk-7-1
2016-01-25 04:37:08 -05:00
[identify-R6034-cause]: http://stackoverflow.com/questions/14552348/runtime-error-r6034-in-embedded-python-application/34696022
2016-01-26 18:49:58 -05:00
[ccoc]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md
2016-04-19 19:48:46 -04:00
[vim_win-python2.7.11-bug]: https://github.com/vim/vim/issues/717
2017-04-01 14:03:19 -04:00
[vim_win-python2.7.11-bug_workaround]: https://github.com/vim/vim-win32-installer/blob/a27bbdba9bb87fa0e44c8a00d33d46be936822dd/appveyor.bat#L86-L88
2016-10-31 12:48:35 -04:00
[gitter]: https://gitter.im/Valloric/YouCompleteMe
2017-01-01 19:01:39 -05:00
[ninja-compdb]: https://ninja-build.org/manual.html
2017-05-16 13:09:19 -04:00
[++enc]: http://vimdoc.sourceforge.net/htmldoc/editing.html#++enc
2017-10-04 22:05:03 -04:00
[rustup]: https://www.rustup.rs/
2017-12-31 17:29:13 -05:00
[contributing-md]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
2017-10-03 02:41:10 -04:00
[jdt.ls]: https://github.com/eclipse/eclipse.jdt.ls
[jdk-install]: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
[mvn-project]: https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
[eclipse-project]: https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fproject_description_file.html
[gradle-project]: https://docs.gradle.org/current/userguide/tutorial_java_projects.html
[eclipse-dot-project]: https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fproject_description_file.html
[eclipse-dot-classpath]: https://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2FIClasspathEntry.html
2018-09-19 07:16:37 -04:00
[ycmd-eclipse-project]: https://github.com/Valloric/ycmd/tree/3602f38ef7a762fc765afd75e562aec9a134711e/ycmd/tests/java/testdata/simple_eclipse_project
[ycmd-mvn-pom-xml]: https://github.com/Valloric/ycmd/blob/3602f38ef7a762fc765afd75e562aec9a134711e/ycmd/tests/java/testdata/simple_maven_project/pom.xml
[ycmd-gradle-project]: https://github.com/Valloric/ycmd/tree/3602f38ef7a762fc765afd75e562aec9a134711e/ycmd/tests/java/testdata/simple_gradle_project
2017-10-03 02:41:10 -04:00
[jdtls-release]: http://download.eclipse.org/jdtls/milestones
2019-06-28 08:52:28 -04:00
[jdtls-preferences]: https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java
2018-04-06 23:41:49 -04:00
[diacritic]: https://www.unicode.org/glossary/#diacritic
2018-05-02 14:55:30 -04:00
[regex]: https://pypi.org/project/regex/
2019-01-16 09:08:21 -05:00
[clangd]: https://clang.llvm.org/extra/clangd.html
[fixedcdb]: https://clang.llvm.org/docs/JSONCompilationDatabase.html#alternatives
[clangd-indexing]: https://clang.llvm.org/extra/clangd.html#project-wide-indexing
2019-06-28 08:52:28 -04:00
[vimspector]: https://github.com/puremourning/vimspector
[roslyn-releases]: https://github.com/OmniSharp/omnisharp-roslyn/releases
2019-07-27 12:08:24 -04:00
[compiledb]: https://pypi.org/project/compiledb/