- Notifications
You must be signed in to change notification settings - Fork2.8k
A code-completion engine for Vim
License
ycm-core/YouCompleteMe
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Looking for help, advice, or support? Having problems getting YCM to work?
First carefully read theinstallation instructions for your OS.We recommend you use the suppliedinstall.py
- the "full" installation guideis for rare, advanced use cases and most users should useinstall.py
.
If the server isn't starting and you're getting a "YouCompleteMe unavailable"error, check theTroubleshooting guide.
Next, check theUser Guide section on the semantic completer thatyou are using. For C/C++/Objective-C/Objective-C++/CUDA, youmust readthissection.
Finally, check theFAQ.
If, after reading the installation and user guides, and checking the FAQ, you'restill having trouble, check thecontacts section below for how toget in touch.
Please doNOT go to #vim on Freenode for support. Please contact theYouCompleteMe maintainers directly using thecontact details below.
Please note that the below instructions suggest using Vundle. Currently thereare problems with Vundle, so here are somealternative instructions using Vim packages.
- Intro
- Installation
- Quick Feature Summary
- User Guide
- General Usage
- Client-Server Architecture
- Completion String Ranking
- General Semantic Completion
- Signature Help
- Semantic Highlighting
- Inlay Hints
- C-family Semantic Completion
- Java Semantic Completion
- C# Semantic Completion
- Python Semantic Completion
- Rust Semantic Completion
- Go Semantic Completion
- JavaScript and TypeScript Semantic Completion
- Semantic Completion for Other Languages
- LSP Configuration
- Writing New Semantic Completers
- Diagnostic Display
- Symbol Search
- Type/Call Hierarchy
- Commands
- Functions
- Autocommands
- Options
- FAQ
- Contributor Code of Conduct
- Contact
- License
- Sponsorship
YouCompleteMe is a fast, as-you-type, fuzzy-search code completion,comprehension and refactoring engine forVim.
It has several completion engines built-in and supports any protocol-compliantLanguage Server, so can work with practically any language. YouCompleteMecontains:
- an identifier-based engine that works with every programming language,
- a powerfulclangd-based engine that provides native semantic codecompletion for C/C++/Objective-C/Objective-C++/CUDA (from now on referred toas "the C-family languages"),
- aJedi-based completion engine for Python 2 and 3,
- anOmniSharp-Roslyn-based completion engine for C#,
- aGopls-based completion engine for Go,
- aTSServer-based completion engine for JavaScript and TypeScript,
- arust-analyzer-based completion engine for Rust,
- ajdt.ls-based completion engine for Java.
- ageneric Language Server Protocol implementation for any language
- and an omnifunc-based completer that uses data from Vim's omnicomplete systemto provide semantic completions for many other languages (Ruby, PHP, etc.).
Here's an explanation of what happened in the last GIF demo above.
First, realize thatno keyboard shortcuts had to be pressed to get the listof completion candidates at any point in the demo. The user just types and thesuggestions pop up by themselves. If the user doesn't find the completionsuggestions relevant and/or just wants to type, they can do so; the completionengine will not interfere.
When the user sees a useful completion string being offered, they press the TABkey to accept it. This inserts the completion string. Repeated presses of theTAB key cycle through the offered completions.
If the offered completions are not relevant enough, the user can continue typingto further filter out unwanted completions.
A critical thing to notice is that the completionfiltering is NOT based onthe input being a string prefix of the completion (but that works too). Theinput needs to be asubsequence match of a completion. This is a fancy wayof saying that any input characters need to be present in a completion string inthe order in which they appear in the input. Soabc
is a subsequence ofxaybgc
, but not ofxbyxaxxc
. After the filter, a complicated sorting systemranks the completion strings so that the most relevant ones rise to the top ofthe menu (so you usually need to press TAB just once).
All of the above works with any programming language because of theidentifier-based completion engine. It collects all of the identifiers in thecurrent file and other files you visit (and your tags files) and searches themwhen you type (identifiers are put into per-filetype groups).
The demo also shows the semantic engine in use. When the user presses.
,->
or::
while typing in insert mode (for C++; different triggers are used forother languages), the semantic engine is triggered (it can also be triggeredwith a keyboard shortcut; see the rest of the docs).
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 bySyntastic)if you are editing a C-family file. As the completer engine compiles your fileand detects warnings or errors, they will be presented in various ways. Youdon't need to save your file or press any keyboard shortcut to trigger this, it"just happens" in the background.
And that's not all...
YCM might be the only Vim completion engine with the correct Unicode support.Though we do assume UTF-8 everywhere.
YCM also providessemantic IDE-like features in anumber of languages, including:
- displaying signature help (argument hints) when entering the arguments to afunction call (Vim only)
- finding declarations, definitions, usages, etc.of identifiers, and aninteractive symbol finder
- displaying type information for classes,variables, functions etc.,
- displaying documentation for methods, members, etc. in thepreviewwindow, or in apopup next to the cursor (Vim only)
- fixing common coding errors, like missingsemi-colons, typos, etc.,
- semantic renaming of variables across files,
- formatting code,
- removing unused imports, sorting imports, etc.
For example, here's a demo of signature help:
Below we can see YCM being able to do a few things:
- Retrieve references across files
- Go to declaration/definition
- Expand
auto
in C++ - Fix some common errors, and provide refactorings, with
FixIt
- Not shown in the GIF are
GoToImplementation
andGoToType
for servers that support it.
And here's some documentation being shown in a hover popup, automatically andmanually:
Features vary by file type, so make sure to check out thefile type featuresummary and thefull list of completer subcommands tofind out what's available for your favourite languages.
You'll also find that YCM has filepath completers (try typing./
in a file)and a completer that integrates withUltiSnips.
Runtime | Min Version | Recommended Version (full support) | Python |
---|---|---|---|
Vim | 9.1.0016 | 9.1.0016 | 3.8 |
Neovim | 0.5 | Vim 9.1.0016 | 3.8 |
Our policy is to support the Vim version that's in the latest LTS of Ubuntu.
Vim must have aworking Python 3 runtime.
For Neovim users, our policy is to require the latest released version.Currently, Neovim 0.5.0 is required. Please note that some features are notavailable in Neovim, and Neovim is not officially supported.
YCM has two components: A server and a client. Both the server and clientrequire Python 3.8 or later 3.x release.
For the Vim client, Vim must be, compiled with--enable-shared
(or--enable-framework
on macOS). You can check if this is working with:py3 import sys; print( sys.version)
. It should say something like3.8.2 (...)
.
For Neovim, you must have a python 3.8 runtime and the Neovim pythonextensions. See Neovim's:help provider-python
for how to set that up.
For the server, you must run theinstall.py
script with a python 3.8 (orlater) runtime. Anaconda etc. are not supported. YCM will remember the runtimeyou used to runinstall.py
and will use that when launching the server, so ifyou usually use anaconda, then make sure to use the full path to a real cpython3,e.g./usr/bin/python3 install.py --all
etc.
Our policy is to support the python3 version that's available in the latestUbuntu LTS (similar to our Vim version policy). We don't increase the Pythonruntime version without a reason, though. Typically, we do this when the currentpython version we're using goes out of support. At that time we will typicallypick a version that will be supported for a number of years.
In order to provide the best possible performance and stability, ycmd hasupdated its code to C++17. This requires a version bump of the minimumsupported compilers. The new requirements are:
Compiler | Current Min |
---|---|
GCC | 8 |
Clang | 7 |
MSVC | 15.7 (VS 2017) |
YCM requires CMake 3.13 or greater. If your CMake is too old, you may be able tosimplypip install --user cmake
to get a really new version.
When enabling language support for a particular language, there may be runtimerequirements, such as needing a very recent Java Development Kit for Javasupport. In general, YCM is not in control of the required versions for thedownstream compilers, though we do our best to signal where we know them.
- Install YCM plugin viaVundle
- Install CMake, MacVim and Python 3; Note that the pre-installedmacOS systemVim is not supported (due to it having broken Python integration).
$ brew install cmake python go nodejs
Install mono fromMono Project (NOTE: on Intel Macs youcan also
brew install mono
. On arm Macs, you may require Rosetta)For Java support you must install a JDK, one way to do this is with Homebrew:
$ brew install java$ sudo ln -sfn $(brew --prefix java)/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
Pre-installed macOSsystem Vim does not support Python 3. So you need toinstall either a Vim that supports Python 3 ORMacVim withHomebrew:
- Option 1: Installing a Vim that supports Python 3
brew install vim
- Option 2: InstallingMacVim
brew install macvim
Compile YCM.
For Intel and arm64 Macs, the bundled libclang/clangd work:
cd ~/.vim/bundle/YouCompleteMepython3 install.py --all
If you have troubles with finding system frameworks or C++ standard library,try using the homebrew llvm:
brew install llvmcd ~/.vim/bundle/YouCompleteMepython3 install.py --system-libclang --all
And edit your vimrc to add the following line to use the Homebrew llvm'sclangd:
" Use homebrew's clangdletg:ycm_clangd_binary_path=trim(system('brew --prefix llvm')).'/bin/clangd'
For using an arbitrary LSP server, checkthe relevantsection
These instructions (usinginstall.py
) are the quickest way to installYouCompleteMe, however they may not work for everyone. If the followinginstructions don't work for you, check out thefull installationguide.
A supported Vim version with Python 3 is required.MacVim is a good option,even if you only use the terminal. YCM won't work with the pre-installed Vimfrom Apple as its Python support is broken. If you don't already use a Vimthat supports Python 3 orMacVim, install it withHomebrew. InstallCMake as well:
brew install vim cmake
OR
brew install macvim cmake
Install YouCompleteMe withVundle.
Remember: YCM is a plugin with a compiled component. If youupdate YCMusing Vundle and theycm_core
library APIs have changed (happensrarely), YCM will notify you to recompile it. You should then rerun the installprocess.
NOTE: If you want C-family completion, you MUST have the latest Xcodeinstalled along with the latest Command Line Tools (they are installedautomatically when you runclang
for the first time, or manually by runningxcode-select --install
)
Compiling YCMwith semantic support for C-family languages throughclangd:
cd ~/.vim/bundle/YouCompleteMe./install.py --clangd-completer
Compiling YCMwithout semantic support for C-family languages:
cd ~/.vim/bundle/YouCompleteMe./install.py
The following additional language support options are available:
- C# support: install by downloading theMono macOS packageand add
--cs-completer
when callinginstall.py
. - Go support: installGo and add
--go-completer
when callinginstall.py
. - JavaScript and TypeScript support: installNode.js 18+ and npm andadd
--ts-completer
when callinginstall.py
. - Rust support: add
--rust-completer
when callinginstall.py
. - Java support: installJDK 17 and add
--java-completer
when callinginstall.py
.
To simply compile with everything enabled, there's a--all
flag. So, toinstall with all language features, ensurexbuild
,go
,node
andnpm
tools are installed and in yourPATH
, then simply run:
cd ~/.vim/bundle/YouCompleteMe./install.py --all
That's it. You're done. Refer to theUser 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 allin the User Guide.
YCM comes with sane defaults for its options, but you still may want to take alook at what's available for configuration. There are a few interesting optionsthat are conservatively turned off by default that you may want to turn on.
The following assume you're using Ubuntu 24.04.
- Install YCM plugin viaVundle
- Install CMake, Vim and Python
apt install build-essential cmake vim-nox python3-dev
- Install mono-complete, go, node, java, and npm
apt install mono-complete golang nodejs openjdk-17-jdk openjdk-17-jre npm
- Compile YCM
cd ~/.vim/bundle/YouCompleteMepython3 install.py --all
- For plugging an arbitrary LSP server, checkthe relevant section
These instructions (usinginstall.py
) are the quickest way to installYouCompleteMe, however they may not work for everyone. If the followinginstructions don't work for you, check out thefull installationguide.
Make sure you have a supported version of Vim with Python 3 support and asupported compiler. The latest LTS of Ubuntu is the minimum platform for simpleinstallation. For earlier releases or other distributions, you may have to dosome work to acquire the dependencies.
If your Vim version is too old, you may need tocompile Vim fromsource (don't worry, it's easy).
Install YouCompleteMe withVundle.
Remember: YCM is a plugin with a compiled component. If youupdate YCMusing Vundle and theycm_core
library APIs have changed (which happens rarely), YCMwill notify you to recompile it. You should then rerun the installation process.
Install development tools, CMake, and Python headers:
- Fedora-like distributions:
sudo dnf install cmake gcc-c++ make python3-devel
- Ubuntu LTS:
sudo apt install build-essential cmake3 python3-dev
Compiling YCMwith semantic support for C-family languages throughclangd:
cd ~/.vim/bundle/YouCompleteMepython3 install.py --clangd-completer
Compiling YCMwithout semantic support for C-family languages:
cd ~/.vim/bundle/YouCompleteMepython3 install.py
The following additional language support options are available:
- C# support: installMono and add
--cs-completer
when callinginstall.py
. - Go support: installGo and add
--go-completer
when callinginstall.py
. - JavaScript and TypeScript support: installNode.js 18+ and npm andadd
--ts-completer
when callinginstall.py
. - Rust support: add
--rust-completer
when callinginstall.py
. - Java support: installJDK 17 and add
--java-completer
when callinginstall.py
.
To simply compile with everything enabled, there's a--all
flag. So, toinstall with all language features, ensurexbuild
,go
,node
, andnpm
tools are installed and in yourPATH
, then simply run:
cd ~/.vim/bundle/YouCompleteMepython3 install.py --all
That's it. You're done. Refer to theUser 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 allin the User Guide.
YCM comes with sane defaults for its options, but you still may want to take alook at what's available for configuration. There are a few interesting optionsthat are conservatively turned off by default that you may want to turn on.
- Install YCM plugin viaVundle
- InstallVisual Studio Build Tools 2019
- Install CMake, Vim and Python
- Install go, node and npm
- Compile YCM
cd YouCompleteMepython3 install.py --all
- Add
set encoding=utf-8
to yourvimrc - For plugging an arbitrary LSP server, checkthe relevant section
These instructions (usinginstall.py
) are the quickest way to installYouCompleteMe, however they may not work for everyone. If the followinginstructions don't work for you, check out thefull installationguide.
Important: we assume that you are using thecmd.exe
command prompt andthat you know how to add an executable to the PATH environment variable.
Make sure you have a supported Vim version with Python 3 support. Youcan check the version and which Python is supported by typing:version
insideVim. Look at the features included:+python3/dyn
for Python 3.Take note of the Vim architecture, i.e. 32 or64-bit. It will be important when choosing the Python installer. We recommendusing a 64-bit client.Daily updated installers of 32-bit and 64-bit Vim withPython 3 support are available.
Add the following line to yourvimrc if not already present.:
setencoding=utf-8
This option is required by YCM. Note that it does not prevent you from editing afile in another encoding than UTF-8. You can do that by specifyingthe++enc
argument to the:e
command.
Install YouCompleteMe withVundle.
Remember: YCM is a plugin with a compiled component. If youupdate YCMusing Vundle and theycm_core
library APIs have changed (happensrarely), YCM will notify you to recompile it. You should then rerun the installprocess.
Download and install the following software:
- Python 3. Be sure to pick the versioncorresponding to your Vim architecture. It isWindows x86 for a 32-bit VimandWindows x86-64 for a 64-bit Vim. We recommend installing Python 3.Additionally, the version of Python you install must match up exactly withthe version of Python that Vim is looking for. Type
:version
and look at thebottom of the page at the list of compiler flags. Look for flags that looksimilar to-DDYNAMIC_PYTHON3_DLL=\"python36.dll\"
. This indicatesthat Vim is looking for Python 3.6. You'll need one or the other installed,matching the version number exactly. - CMake. Add CMake executable to the PATH environmentvariable.
- Build Tools for Visual Studio 2019. During setup,selectC++ build tools inWorkloads.
Compiling YCMwith semantic support for C-family languages throughclangd:
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMepython install.py --clangd-completer
Compiling YCMwithout semantic support for C-family languages:
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMepython install.py
The following additional language support options are available:
- C# support: add
--cs-completer
when callinginstall.py
.Be sure thatthe build utilitymsbuild
is in your PATH. - Go support: installGo and add
--go-completer
when callinginstall.py
. - JavaScript and TypeScript support: installNode.js 18+ and npm andadd
--ts-completer
when callinginstall.py
. - Rust support: add
--rust-completer
when callinginstall.py
. - Java support: installJDK 17 and add
--java-completer
when callinginstall.py
.
To simply compile with everything enabled, there's a--all
flag. So, toinstall with all language features, ensuremsbuild
,go
,node
andnpm
tools are installed and in yourPATH
, then simply run:
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMepython install.py --all
You can specify the Microsoft Visual C++ (MSVC) version using the--msvc
option. YCM officially supports MSVC 15 (2017), MSVC 16 (Visual Studio 2019)and MSVC 17 (Visual Studio 17 2022).
That's it. You're done. Refer to theUser 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 allin the User Guide.
YCM comes with sane defaults for its options, but you still may want to take alook at what's available for configuration. There are a few interesting optionsthat are conservatively turned off by default that you may want to turn on.
Thefull installation guide has been moved to the wiki.
- 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
- Semantic auto-completion with automatic fixes
- Signature help
- Real-time diagnostic display
- Go to include/declaration/definition (
GoTo
, etc.) - Go to alternate file (e.g. associated header
GoToAlternateFile
) - Find Symbol (
GoToSymbol
), with interactive search - Document outline (
GoToDocumentOutline
), with interactive search - View documentation comments for identifiers (
GetDoc
) - Type information for identifiers (
GetType
) - Automatically fix certain errors (
FixIt
) - Perform refactoring (
FixIt
) - Reference finding (
GoToReferences
) - Renaming symbols (
RefactorRename <new name>
) - Code formatting (
Format
) - Semantic highlighting
- Inlay hints
- Type hierarchy
- Call hierarchy
- Semantic auto-completion
- Signature help
- Real-time diagnostic display
- Go to declaration/definition (
GoTo
, etc.) - Go to implementation (
GoToImplementation
) - Find Symbol (
GoToSymbol
), with interactive search - View documentation comments for identifiers (
GetDoc
) - Type information for identifiers (
GetType
) - Automatically fix certain errors (
FixIt
) - Perform refactoring (
FixIt
) - Management of OmniSharp-Roslyn server instance
- Renaming symbols (
RefactorRename <new name>
) - Code formatting (
Format
)
- Semantic auto-completion
- Signature help
- Go to definition (
GoTo
) - Find Symbol (
GoToSymbol
), with interactive search - Reference finding (
GoToReferences
) - View documentation comments for identifiers (
GetDoc
) - Type information for identifiers (
GetType
) - Renaming symbols (
RefactorRename <new name>
)
- Semantic auto-completion
- Signature help
- Real-time diagnostic display
- Go to declaration/definition (
GoTo
, etc.) - Go to type definition (
GoToType
) - Go to implementation (
GoToImplementation
) - Document outline (
GoToDocumentOutline
), with interactive search - Automatically fix certain errors (
FixIt
) - Perform refactoring (
FixIt
) - View documentation comments for identifiers (
GetDoc
) - Type information for identifiers (
GetType
) - Code formatting (
Format
) - Management of
gopls
server instance - Inlay hints
- Call hierarchy
- Semantic auto-completion with automatic import insertion
- Signature help
- Real-time diagnostic display
- Go to definition (
GoTo
,GoToDefinition
, andGoToDeclaration
areidentical) - Go to type definition (
GoToType
) - Go to implementation (
GoToImplementation
) - Find Symbol (
GoToSymbol
), with interactive search - Reference finding (
GoToReferences
) - View documentation comments for identifiers (
GetDoc
) - Type information for identifiers (
GetType
) - Automatically fix certain errors and perform refactoring (
FixIt
) - Perform refactoring (
FixIt
) - Renaming symbols (
RefactorRename <new name>
) - Code formatting (
Format
) - Organize imports (
OrganizeImports
) - Management of
TSServer
server instance - Inlay hints
- Call hierarchy
- Semantic auto-completion
- Real-time diagnostic display
- Go to declaration/definition (
GoTo
, etc.) - Go to implementation (
GoToImplementation
) - Reference finding (
GoToReferences
) - Document outline (
GoToDocumentOutline
), with interactive search - View documentation comments for identifiers (
GetDoc
) - Automatically fix certain errors (
FixIt
) - Perform refactoring (
FixIt
) - Type information for identifiers (
GetType
) - Renaming symbols (
RefactorRename <new name>
) - Code formatting (
Format
) - Management of
rust-analyzer
server instance - Semantic highlighting
- Inlay hints
- Call hierarchy
- Semantic auto-completion with automatic import insertion
- Signature help
- Real-time diagnostic display
- Go to definition (
GoTo
,GoToDefinition
, andGoToDeclaration
areidentical) - Go to type definition (
GoToType
) - Go to implementation (
GoToImplementation
) - Find Symbol (
GoToSymbol
), with interactive search - Reference finding (
GoToReferences
) - Document outline (
GoToDocumentOutline
), with interactive search - View documentation comments for identifiers (
GetDoc
) - Type information for identifiers (
GetType
) - Automatically fix certain errors including code generation (
FixIt
) - Renaming symbols (
RefactorRename <new name>
) - Code formatting (
Format
) - Organize imports (
OrganizeImports
) - Detection of Java projects
- Execute custom server command (
ExecuteCommand <args>
) - Management of
jdt.ls
server instance - Semantic highlighting
- Inlay hints
- Type hierarchy
- Call hierarchy
If the offered completions are too broad, keep typing characters; YCM willcontinue refining the offered completions based on your input.
Filtering is "smart-case" and "smart-diacritic" sensitive; if you aretyping only lowercase letters, then it's case-insensitive. If your inputcontains uppercase letters, then the uppercase letters in your query mustmatch uppercase letters in the completion strings (the lowercase letters stillmatch both). On top of that, a letter with no diacritic marks will match thatletter with or without marks:
matches | foo | fôo | fOo | fÔo |
---|---|---|---|---|
foo | ✔️ | ✔️ | ✔️ | ✔️ |
fôo | ❌ | ✔️ | ❌ | ✔️ |
fOo | ❌ | ❌ | ✔️ | ✔️ |
fÔo | ❌ | ❌ | ❌ | ✔️ |
Use the TAB key to accept a completion and continue pressing TAB to cyclethrough the completions. Use Shift-TAB to cycle backward. Note that if you'reusing console Vim (that is, not gvim or MacVim) then it's likely that theShift-TAB binding will not work because the console will not pass it to Vim.You can remap the keys; see theOptions section below.
Knowing a little bit about how YCM works internally will prevent confusion. YCMhas several completion engines: an identifier-based completer that collects allof the identifiers in the current file and other files you visit (and your tagsfiles) and searches them when you type (identifiers are put into per-filetypegroups).
There are also several semantic engines in YCM. There are libclang-based andclangd-based completers that provide semantic completion for C-family languages.There's a Jedi-based completer for semantic completion for Python. There's alsoan omnifunc-based completer that uses data from Vim's omnicomplete system toprovide semantic completions when no native completer exists for that languagein YCM.
There are also other completion engines, like the UltiSnips completer and thefilepath completer.
YCM automatically detects which completion engine would be the best in anysituation. On occasion, it queries several of them at once, merges theoutputs and presents the results to you.
YCM has a client-server architecture; the Vim part of YCM is only a thin clientthat talks to theycmd HTTP+JSON server that has the vast majority ofYCM logic and functionality. The server is started and stopped automatically asyou start and stop Vim.
The subsequence filter removes any completions that do not match the input, butthen the sorting system kicks in. It's actually very complicated and uses lotsof factors, but suffice it to say that "word boundary" (WB) subsequencecharacter matches are "worth" more than non-WB matches. In effect, this meansthat given an input of "gua", the completion "getUserAccount" would be ranked higherin the list than the "Fooguxa" completion (both of which are subsequencematches). Word-boundary characters are all capital characters, characterspreceded by an underscore, and the first letter character in the completionstring.
Valid signatures are displayed in a second popup menu and the current signatureis highlighted along with the current argument.
Signature help is triggered in insert mode automatically wheng:ycm_auto_trigger
is enabled and is not supported when it is not enabled.
The signatures popup is hidden when there are no matching signatures or when youleave insert mode. If you want to manually control when it is visible, you canmap something to<plug>YCMToggleSignatureHelp
(see below).
For more details on this feature and a few demos, check out thePR that proposed it.
The signature help popup sometimes gets in the way. You can toggle itsvisibility with a mapping. YCM provides the "Plug" mapping<Plug>(YCMToggleSignatureHelp)
for this.
For example, to hide/show the signature help popup by pressing Ctrl+l in insertmode:imap <silent> <C-l> <Plug>(YCMToggleSignatureHelp)
.
NOTE: No default mapping is provided because insert mappings are verydifficult to create without breaking or overriding some existing functionality.Ctrl-l is not a suggestion, just an example.
Semantic highlighting is the process where the buffer text is coloured accordingto the underlying semantic type of the word, rather than classic syntaxhighlighting based on regular expressions. This can be powerful additional datathat we can process very quickly.
This feature is only supported in Vim.
For example, here is a function with classic highlighting:
And here is the same function with semantic highlighting:
As you can see, the function calls, macros, etc. are correctly identified.
This can be enabled globally withlet g:ycm_enable_semantic_highlighting=1
orper buffer, by settingb:ycm_enable_semantic_highlighting
.
YCM uses text properties (see:help text-prop-intro
) for semantichighlighting. In order to customise the coloring, you can define the textproperties that are used.
If you define a text property namedYCM_HL_<token type>
, then it will be usedin place of the defaults. The<token type>
is defined as the Language ServerProtocol semantic token type, defined in theLSP Spec.
Some servers also use custom values. In this case, YCM prints a warningincluding the token type name that you can customise.
For example, to renderparameter
tokens using theNormal
highlight group,you can do this:
callprop_type_add('YCM_HL_parameter', {'highlight':'Normal' } )
More generally, this pattern can be useful for customising the groups:
let MY_YCM_HIGHLIGHT_GROUP= {\'typeParameter':'PreProc',\'parameter':'Normal',\'variable':'Normal',\'property':'Normal',\'enumMember':'Normal',\'event':'Special',\'member':'Normal',\'method':'Normal',\'class':'Special',\'namespace':'Special',\}for tokenTypeinkeys( MY_YCM_HIGHLIGHT_GROUP )callprop_type_add('YCM_HL_' . tokenType,\{'highlight': MY_YCM_HIGHLIGHT_GROUP[ tokenType ] } )endfor
NOTE: Highly experimental feature, requiring Vim 9.0.214 or later (notsupported in NeoVim).
Wheng:ycm_enable_inlay_hints
(globally) orb:ycm_enable_inlay_hints
(for aspecific buffer) is set to1
, then YCM will insert inlay hints as supported bythe language semantic engine.
An inlay hint is text that is rendered on the screen that is not part of the buffer andis often used to mark up the type or name of arguments, parameters, etc. whichhelp the developer understand the semantics of the code.
Here are some examples:
- C
- TypeScript
- Go
By default, YCM renders the inlay hints with theNonText
highlight group. Tooverride this, define theYcmInlayHint
highlight yourself, e.g. in your.vimrc
:
hilinkYcmInlayHintComment
Similar to semantic highlighting above, you can override specific highlightingfor different inlay hint types by defining text properties named after the kindof inlay hint, for example:
callprop_type_add('YCM_INLAY_Type', #{highlight:'Comment' } )
The list of inlay hint kinds can be found inpython/ycm/inlay_hints.py
g:ycm_enable_inlay_hints
orb:ycm_enable_inlay_hints
- enable/disableglobally or for local bufferg:ycm_clear_inlay_hints_in_insert_mode
- set to1
to remove all inlayhints when entering insert mode and reinstate them when leaving insert mode
Inlay hints can add a lot of text to the screen and may be distracting. You cantoggle them on/off instantly, by mapping something to<Plug>(YCMToggleInlayHints)
, for example:
nnoremap<silent><localleader>h<Plug>(YCMToggleInlayHints)
No default mapping is provided for this due to the personal nature of mappings.
You can use Ctrl+Space to trigger the completion suggestions anywhere, evenwithout a string prefix. This is useful to see which top-level functions areavailable for use.
NOTE: YCM originally used thelibclang
based engine for C-family, butusers should migrate to clangd, as it provides more features and betterperformance. Users who rely onoverride_filename
in their.ycm_extra_conf.py
will need to stay on the oldlibclang
engine. Instructions on how to stay onthe old engine are available onthe wiki.
Some of the features of clangd:
- Project wide indexing: Clangd has both dynamic and static index support.The dynamic index stores up-to-date symbols coming from any files you arecurrently editing, whereas static index contains project-wide symbolinformation. This symbol information is used for code completion and codenavigation. Whereas libclang is limited to the current translation unit(TU).
- Code navigation: Clangd provides all the GoTo requests libclang provides and itimproves those using the above-mentioned index information to containproject-wide information rather than just the current TU.
- Rename: Clangd can perform semantic rename operations on the currentfile, whereas libclang doesn't support such functionality.
- Code Completion: Clangd can perform code completions at a lower latencythan libclang; also, it has information about all the symbols in yourproject so it can suggest items outside your current TU and also providesproper
#include
insertions for those items. - Signature help: Clangd provides signature help so that you can see thenames and types of arguments when calling functions.
- Format Code: Clangd provides code formatting either for the selectedlines or the whole file, whereas libclang doesn't have such functionality.
- Performance: Clangd has faster re-parse and code completion timescompared to libclang.
On supported architectures, theinstall.py
script will download a suitableclangd (--clangd-completer
) or libclang (--clang-completer
) for you.Supported architectures are:
- Linux glibc >= 2.39 (Intel, armv7-a, aarch64) - built on ubuntu 24.04
- MacOS >=10.15 (Intel, arm64)
- For Intel, compatibility per clang.llvm.org downloads
- For arm64, macOS 10.15+
- Windows (Intel) - compatibility per clang.llvm.org downloads
clangd:
Typically, clangd is installed by the YCM installer (either with--all
or with--clangd-completer
). This downloads a pre-builtclangd
binary for yourarchitecture. If your OS or architecture is not supported or is too old, you caninstall a compatibleclangd
and useg:ycm_clangd_binary_path
to point toit.
libclang:
libclang
can be enabled also with--all
or--clang-completer
. As withclangd
, YCM will try and download a version oflibclang
that is suitable foryour environment, but again if your environment can't be supported, you canbuild or acquirelibclang
for yourself and specify it when building, as:
$ EXTRA_CMAKE_ARGS='-DPATH_TO_LLVM_ROOT=/path/to/your/llvm' ./install.py --clang-completer --system-libclang
Please note that if using customclangd
orlibclang
itmust match theversion that YCM requires. Currently YCM requiresclang 17.0.1.
In order to perform semantic analysis such as code completion,GoTo
, anddiagnostics, YouCompleteMe usesclangd
, which makes use ofclang compiler, sometimes also referred to as LLVM. Like any compiler,clang also requires a set of compile flags in order to parse your code. Simplyput: If clang can't parse your code, YouCompleteMe can't provide semanticanalysis.
There are 2 methods that can be used to provide compile flags to clang:
Option 1: Use acompilation database
The easiest way to get YCM to compile your code is to use a compilationdatabase. A compilation database is usually generated by your build system(e.g.CMake
) and contains the compiler invocation for each compilation unit inyour project.
For information on how to generate a compilation database, see theclangdocumentation. In short:
- If using CMake, add
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
when configuring (oraddset( CMAKE_EXPORT_COMPILE_COMMANDS ON )
toCMakeLists.txt
) and copy orsymlink the generated database to the root of your project. - If using Ninja, check out the
compdb
tool (-t compdb
) in itsdocs. - If using GNU make, check outcompiledb orBear.
- For other build systems, check out
.ycm_extra_conf.py
below.
If no.ycm_extra_conf.py
is found,YouCompleteMe automatically tries to load a compilation database if there isone.
YCM looks for a file namedcompile_commands.json
in the directory of theopened file or in any directory above it in the hierarchy (recursively); whenthe file is found before a local.ycm_extra_conf.py
, YouCompleteMe stopssearching the directories and lets clangd take over and handle the flags.
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.
Every C-family project is different. It is not possible for YCM to guess whatcompiler flags to supply for your project. Fortunately, YCM provides a mechanismfor you to generate the flags for a particular file witharbitrary complexity.This is achieved by requiring you to provide a Python module that implements atrivial function that, given the file name as an argument, returns a list ofcompiler flags to use to compile that file.
YCM looks for a.ycm_extra_conf.py
file in the directory of the opened file orin any directory above it in the hierarchy (recursively); when the file isfound, it is loaded (only once!) as a Python module. YCM calls aSettings
method in that module which should provide it with the information necessary tocompile the current file. You can also provide a path to a global configurationfile with theg:ycm_global_ycm_extra_conf
option,which will be used as a fallback. To prevent the execution of malicious codefrom a file you didn't write YCM will ask you once per.ycm_extra_conf.py
ifit is safe to load. This can be disabled and you can white-/blacklist files. Seetheg:ycm_confirm_extra_conf
andg:ycm_extra_conf_globlist
optionsrespectively.
This system was designed this way so that the user can perform any arbitrarysequence of operations to produce a list of compilation flags YCM should handto Clang.
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.Common values are-x c
for C,-x c++
for C++,-x objc
for Objective-C, and-x cuda
for CUDA.
To give you an impression, if your C++ project is trivial, and your usualcompilation command is:g++ -Wall -Wextra -Werror -o FILE.o FILE.cc
, then thefollowing.ycm_extra_conf.py
is enough to get semantic analysis fromYouCompleteMe:
defSettings(**kwargs ):return {'flags': ['-x','c++','-Wall','-Wextra','-Werror' ], }
As you can see from the trivial example, YCM calls theSettings
method whichreturns a dictionary with a single element'flags'
. This element is alist
of compiler flags to pass to libclang for the current file. The absolute path ofthat file is accessible under thefilename
key of thekwargs
dictionary.That's it! This is actually enough for most projects, but for complex projectsit is not uncommon to integrate directly with an existing build system using thefull power of the Python language.
For a more elaborate example,see ycmd's own.ycm_extra_conf.py
. You should be able touse itas a starting point.Don't just copy/paste that file somewhere andexpect things to magically work;your project needs different flags. Hint:just replace the strings in theflags
variable with compilation flagsnecessary for your project. That should be enough for 99% of projects.
You could also consider usingYCM-Generator to generate theycm_extra_conf.py
file.
If Clang encounters errors when compiling the header files that your fileincludes, then it's probably going to take a long time to get completions. Whenthe completion menu finally appears, it's going to have a large number ofunrelated completion strings (type/function names that are not actuallymembers). This is because Clang fails to build a precompiled preamble for yourfile if there are any errors in the included headers and that preamble is key togetting fast completions.
Call the:YcmDiags
command to see if any errors or warnings were detected inyour file.
Ensure that you have enabled the Java completer. See theinstallation guide for details.
Create a project file (gradle or maven) file in the root directory of yourJava project, by following the instructions below.
(Optional)Configure the LSP server. Thejdt.lsconfiguration options can be found in their codebase.
If you previously used Eclim or Syntastic for Java, disable them for Java.
Edit a Java file from your project.
In order to provide semantic analysis, the Java completion engine requiresknowledge of your project structure. In particular, it needs to know the classpath to use, when compiling your code. Fortunatelyjdt.lssupportseclipse project files,maven projects andgradle projects.
NOTE: Our recommendation is to use either Maven or Gradle projects.
The native support for Java includes YCM's native real-time diagnostics display.This can conflict with other diagnostics plugins like Syntastic, so whenenabling Java support, pleasemanually disable Syntastic Java diagnostics.
Add the following to yourvimrc
:
letg:syntastic_java_checkers= []
The native support for Java includes YCM's native real-time diagnostics display.This can conflict with other diagnostics plugins like Eclim, so when enablingJava support, pleasemanually disable Eclim Java diagnostics.
Add the following to yourvimrc
:
letg:EclimFileTypeValidate=0
NOTE: We recommend disabling Eclim entirely when editing Java with YCM'snative Java support. This can be done temporarily with:EclimDisable
.
Eclipse-style projects require two files:.project and.classpath.
If your project already has these files due to previously being set up withinEclipse, then no setup is required.jdt.ls should load the project justfine (it's basically eclipse after all).
However, if not, it is possible (easy in fact) to craft them manually, though itis not recommended. You're better off using Gradle or Maven (see below).
A simple eclipse style project example can be found inthe ycmd test directory. Normally all that is required is to copy these files tothe root of your project and to edit the.classpath
to add additionallibraries, such as:
<classpathentrykind="lib"path="/path/to/external/jar" /> <classpathentrykind="lib"path="/path/to/external/java/source" />
It may also be necessary to change the directory in which your source files arelocated (paths are relative to the .project file itself):
<classpathentrykind="src"output="target/classes"path="path/to/src/" />
NOTE: The eclipse project and classpath files are not a public interfaceand it is highly recommended to use Maven or Gradle project definitions if youdon't already use Eclipse to manage your projects.
Maven needs a file namedpom.xml in the root of the project.Once again a simplepom.xml can be found in the ycmd source.
The format ofpom.xml files is way beyond the scope of thisdocument, but we do recommend using the various tools that can generate them foryou, if you're not familiar with them already.
Gradle projects require abuild.gradle. Again, there is atrivial example in ycmd's tests.
The format ofbuild.gradle files are way beyond the scope ofthis document, but we do recommend using the various tools that can generatethem for you if you're not familiar with them already.
Some users have experienced issues with their jdt.ls when using the Groovylanguage for their build.gradle. As such, try usingKotlin instead.
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 ycmdlog files using
:YcmToggleLogs
. The jdt.lslog file is called.log
(for some reason).
If you get a message about "classpath is incomplete", then make sure you havecorrectly configured theproject files.
If you get messages about unresolved imports, then make sure you havecorrectly configured theproject files, in particularcheck that the classpath is set correctly.
YCM relies onOmniSharp-Roslyn to provide completion and code navigation.OmniSharp-Roslyn needs a solution file for a C# project and there are two waysof letting YCM know about your solution files.
YCM will scan all parent directories of the file currently being edited and lookfor a file with.sln
extension.
If YCM loads.ycm_extra_conf.py
which containsCSharpSolutionFile
function,YCM will try to use that to determine the solution file. This is useful when onewants to override the default behaviour and specify a solution file that is notin any of the parent directories of the currently edited file. Example:
defCSharpSolutionFile(filepath ):# `filepath` is the path of the file user is editingreturn'/path/to/solution/file'# Can be relative to the `.ycm_extra_conf.py`
If the path returned byCSharpSolutionFile
is not an actual file, YCM willfall back to the other way of finding the file.
YCM ships with older version of OmniSharp-Roslyn based on Mono runtime.It is possible to use it with .NET 6.0 and newer, but it requires manual setup.
- Download NET 6.0 version of the OmniSharp server for your system fromreleases
- Set
g:ycm_roslyn_binary_path
to the unpacked executableOmniSharp
- Create a solution file if one doesn't already exist, it is currently requiredby YCM for internal bookkeeping
- Run
dotnet new sln
at the root of your project - Run
dotnet sln add <project1.csproj> <project2.csproj> ...
for all of your projects
- Run
- Run
:YcmRestartServer
YCM relies on theJedi engine to provide completion and code navigation. Bydefault, it will pick the version of Python running theycmd server anduse itssys.path
. While this is fine for simple projects, this needs to beconfigurable when working with virtual environments or in a project withthird-party packages. The next sections explain how to do that.
A common practice when working on a Python project is to install itsdependencies in a virtual environment and develop the project inside thatenvironment. To support this, YCM needs to know the interpreter path of thevirtual environment. You can specify it by creating a.ycm_extra_conf.py
fileat the root of your project with the following contents:
defSettings(**kwargs ):return {'interpreter_path':'/path/to/virtual/environment/python' }
Here,/path/to/virtual/environment/python
is the path to the Python usedby the virtual environment you are working in. Typically, the executable can befound in theScripts
folder of the virtual environment directory on Windowsand in thebin
folder on other platforms.
If you don't like having to create a.ycm_extra_conf.py
file at the root ofyour project and would prefer to specify the interpreter path with a Vim option,read theConfiguring through Vim optionssection.
Another common practice is to put the dependencies directly into the project andadd their paths tosys.path
at runtime in order to import them. YCM needs tobe told about this path manipulation to support those dependencies. This can bedone by creating a.ycm_extra_conf.py
file at the root of the project. Thisfile must define aSettings( **kwargs )
function returning a dictionary withthe list of paths to prepend tosys.path
under thesys_path
key. Forinstance, the following.ycm_extra_conf.py
adds the paths/path/to/some/third_party/package
and/path/to/another/third_party/package
at the start ofsys.path
:
defSettings(**kwargs ):return {'sys_path': ['/path/to/some/third_party/package','/path/to/another/third_party/package' ] }
If you would rather prepend paths tosys.path
with a Vim option, read theConfiguring through Vim options section.
If you need further control on how to add paths tosys.path
, you should definethePythonSysPath( **kwargs )
function in the.ycm_extra_conf.py
file. Itskeyword arguments aresys_path
which contains the defaultsys.path
, andinterpreter_path
which is the path to the Python interpreter. Here's a trivialexample that inserts the/path/to/third_party/package
path at the secondposition ofsys.path
:
defPythonSysPath(**kwargs ):sys_path=kwargs['sys_path' ]sys_path.insert(1,'/path/to/third_party/package' )returnsys_path
A more advanced example can be found inYCM's own.ycm_extra_conf.py
.
You may find it inconvenient to have to create a.ycm_extra_conf.py
file at theroot of each one of your projects in order to set the path to the Pythoninterpreter and/or add paths tosys.path
and would prefer to be able toconfigure those through Vim options. Don't worry, this is possible by using theg:ycm_extra_conf_vim_data
option andcreating a global extra configuration file. Let's take an example. Suppose thatyou want to set the interpreter path with theg:ycm_python_interpreter_path
option and prepend paths tosys.path
with theg:ycm_python_sys_path
option.Suppose also that you want to name the global extra configuration fileglobal_extra_conf.py
and that you want to put it in your HOME folder. Youshould then add the following lines to your vimrc:
letg:ycm_python_interpreter_path=''letg:ycm_python_sys_path= []letg:ycm_extra_conf_vim_data= [\'g:ycm_python_interpreter_path',\'g:ycm_python_sys_path'\]letg:ycm_global_ycm_extra_conf='~/global_extra_conf.py'
Then, create the~/global_extra_conf.py
file with the following contents:
defSettings(**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 whensetting one of the options. YCM will automatically pick the new values.
YCM usesrust-analyzer for Rust semantic completion.
NOTE: Previously, YCM usedrls for rust completion. This is no longersupported, as the Rust community has decided onrust-analyzer as the futureof Rust tooling.
Completions and GoTo commands within the current crate and its dependenciesshould work out of the box with no additional configuration (provided that youbuilt YCM with the--rust-completer
flag; see theInstallationsection for details). The install script takes care ofinstallingthe Rust source code, so no configuration is necessary.
rust-analyzer
supports a myriad of options. These are configured usingLSPconfiguration, and aredocumented here.
Completions and GoTo commands should work out of the box (provided that youbuilt YCM with the--go-completer
flag; see theInstallationsection for details). The server only works for projects withthe "canonical" layout.
gopls
also has a load ofdocumented options.
You can set these in your.ycm_extra_conf.py
. For example, to set the build tags:
defSettings(**kwargs ):ifkwargs['language' ]=='go':return {'ls': {'build.buildFlags': ['-tags=debug' ] } } }
NOTE: YCM originally used theTern engine for JavaScript but due toTern not being maintained anymore by its main author and theTSServerengine offering more features, YCM is moving toTSServer. This won't affectyou if you were already usingTern but you are encouraged to do the switchby deleting thethird_party/ycmd/third_party/tern_runtime/node_modules
directory in YCM folder. If you are a new user but still want to useTern,you should pass the--js-completer
option to theinstall.py
script duringinstallation. Further instructions on how to set up YCM withTern areavailable onthe wiki.
All JavaScript and TypeScript features are provided by theTSServer engine,which is included in the TypeScript SDK. To enable these features, installNode.js 18+ and npm and call theinstall.py
script with the--ts-completer
flag.
TSServer relies onthejsconfig.json
file for JavaScriptandthetsconfig.json
file for TypeScript to analyze yourproject. Ensure the file exists at the root of your project.
To get diagnostics in JavaScript, set thecheckJs
option totrue
in yourjsconfig.json
file:
{"compilerOptions": {"checkJs":true }}
C-family, C#, Go, Java, Python, Rust, and JavaScript/TypeScript languages aresupported natively by YouCompleteMe using theClang,OmniSharp-Roslyn,Gopls,jdt.ls,Jedi,rust-analyzer, andTSServer engines,respectively. Check theinstallation section for instructionsto enable these features if desired.
Similar to other LSP clients, YCM can use an arbitrary LSP server with the helpofg:ycm_language_server
option. Anexample of a value of this option would be:
letg:ycm_language_server=\[\ {\'name':'yaml',\'cmdline': ['/path/to/yaml/server/yaml-language-server','--stdio' ],\'filetypes': ['yaml' ]\ },\ {\'name':'csharp',\'cmdline': ['OmniSharp','-lsp' ],\'filetypes': ['csharp' ],\'project_root_files': ['*.csproj','*.sln' ]\ },\ {\'name':'godot',\'filetypes': ['gdscript' ],\'port':6008,\'project_root_files': ['project.godot' ]\ }\]
Each dictionary contains the following keys:
name
(string, mandatory): Whenconfiguring a LSPserver the value of thename
key will be used as thekwargs[ 'language' ]
. Can be anything you like.filetypes
(list of string, mandatory): List of Vim filetypes this servershould be used for.project_root_files
(list of string, optional): List of filenames to searchfor when trying to determine the project's root. Uses python's pathlib forglob matching.cmdline
(list of strings, optional): If supplied, the server is started withthis command line (each list element is a command line word). Typically, theserver should be started with STDIO communication. If not supplied,port
must be supplied.port
(number, optional): If supplied, ycmd will connect to the server atlocalhost:<port>
using TCP (remote servers are not supported).capabilities
(dict, optional): If supplied, this is a dictionary that ismerged with the LSP client capabilities reported to the language server. Thiscan be used to enable or disable certain features, such as the support forconfiguration sections (workspace/configuration
).
Seethe LSP Examples project for moreexamples of configuring the likes of PHP, Ruby, Kotlin, and D.
Many LSP servers allow some level of user configuration. YCM enables this withthe help of.ycm_extra_conf.py
files. Here's an example of jdt.ls userexamples of configuring the likes of PHP, Ruby, Kotlin, D, and many, many more.
defSettings(**kwargs ):ifkwargs['language' ]=='java':return {'ls': {'java.format.onType.enabled':True } }
Thels
key tells YCM that the dictionary should be passed to the LSP server.For each of the LSP server's configuration, you should look up the respectiveserver's documentation.
Some servers request settings from arbitrary 'sections' of configuration. Thereis no concept of configuration sections in Vim, so you can specify an additionalconfig_sections
dictionary which maps section to a dictionary of configrequired by the server. For example:
defSettings(**kwargs ):ifkwargs['language' ]=='java':return {'ls': {'java.format.onType.enabled':True },'config_sections': {'some section': {'some option':'some value' } }
The sections and options/values are completely server-specific and rarely welldocumented.
YCM will use youromnifunc
(see:h omnifunc
in Vim) as a source for semanticcompletions if it does not have a native semantic completion engine for yourfile's filetype. Vim comes with rudimentary omnifuncs for various languages likeRuby, PHP, etc. It depends on the language.
You can get a stellar omnifunc for Ruby withEclim. Just make sure you havethelatest Eclim installed and configured (this means Eclim>= 2.2.*
andEclipse>= 4.2.*
).
After installing Eclim remember to create a new Eclipse project within yourapplication by typing:ProjectCreate <path-to-your-project> -n ruby
inside Vimand don't forget to havelet g:EclimCompletionMethod = 'omnifunc'
in yourvimrc. This will make YCM and Eclim play nice; YCM will use Eclim's omnifuncs asthe data source for semantic completions and provide the auto-triggering andsubsequence-based matching (and other YCM features) on top of it.
You have two options here: writing anomnifunc
for Vim's omnicomplete systemthat YCM will then use through its omni-completer, or a custom completer for YCMusing theCompleter API.
Here are the differences between the two approaches:
- You have to use VimScript to write the omnifunc, but get to use Python towrite for the Completer API; this by itself should make you want to use theAPI.
- The Completer API is amuch more powerful way to integrate with YCM and itprovides a wider set of features. For instance, you can make your Completerquery your semantic back-end in an asynchronous fashion, thus not blockingVim's GUI thread while your completion system is processing stuff. This isimpossible with VimScript. All of YCM's completers use the Completer API.
- Performance with the Completer API is better since Python executes faster thanVimScript.
If you want to use theomnifunc
system, see the relevant Vim docs with:h complete-functions
. For the Completer API, seethe API docs.
If you want to upstream your completer into YCM's source, you should use theCompleter API.
YCM will display diagnostic notifications for the C-family, C#, Go, Java,JavaScript, Rust, and TypeScript languages. Since YCM continuously recompilesyour file as you type, you'll get notified of errors and warnings in your fileas fast as possible.
Here are the various pieces of the diagnostic UI:
- Icons show up in the Vim gutter on lines that have a diagnostic.
- Regions of text related to diagnostics are highlighted (by default, a redwavy underline in
gvim
and a red background invim
). - Moving the cursor to a line with a diagnostic echoes the diagnostic text.
- Vim's location list is automatically populated with diagnostic data (off bydefault, see options).
The new diagnostics (if any) will be displayed the next time you press any keyon the keyboard. So if you stop typing and just wait for the new diagnostics tocome in, thatwill not work. You need to press some key for the GUI to update.
Having to press a key to get the updates is unfortunate, but cannot be changeddue to the way Vim internals operate; there is no way that a background task canupdate Vim's GUI after it has finished running. Youhave to press a key. Thiswill make YCM check for any pending diagnostics updates.
Youcan force a full, blocking compilation cycle with the:YcmForceCompileAndDiagnostics
command (you may want to map that command to akey; try puttingnnoremap <F5> :YcmForceCompileAndDiagnostics<CR>
in yourvimrc). Calling this command will force YCM to immediately recompile your fileand display any new diagnostics it encounters. Do note that recompilation withthis command may take a while and during this time the Vim GUIwill beblocked.
YCM will display a short diagnostic message when you move your cursor to theline 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 yourcursor is on the line with the diagnostic.
You can also see the full diagnostic message for all the diagnostics in thecurrent file in Vim'slocationlist
, which can be opened with the:lopen
and:lclose
commands (make sure you have setlet g:ycm_always_populate_location_list = 1
in your vimrc). A good way to togglethe display of thelocationlist
with a single key mapping is provided byanother (very small) Vim plugin calledListToggle (which also makes itpossible to change the height of thelocationlist
window), also written byyours truly.
You can change the styling for the highlighting groups YCM uses. For the signsin the Vim gutter, the relevant groups are:
YcmErrorSign
, which falls back to groupSyntasticErrorSign
and thenerror
if they existYcmWarningSign
, which falls back to groupSyntasticWarningSign
and thentodo
if they exist
You can also style the line that has the warning/error with these groups:
YcmErrorLine
, which falls back to groupSyntasticErrorLine
if it existsYcmWarningLine
, which falls back to groupSyntasticWarningLine
if itexists
Finally, you can also style the popup for the detailed diagnostics (it is shownifg:ycm_show_detailed_diag_in_popup
is set) using the groupYcmErrorPopup
,which falls back toErrorMsg
.
Note that the line highlighting groups only work when theg:ycm_enable_diagnostic_signs
option is set. If you want highlighted lines but no signs in the Vim gutter,set thesigncolumn
option tono
in your vimrc:
setsigncolumn=no
The syntax groups used to highlight regions of text with errors/warnings:
YcmErrorSection
, which falls back to groupSyntasticError
if it exists andthenSpellBad
YcmWarningSection
, which falls back to groupSyntasticWarning
if it existsand thenSpellCap
Here's how you'd change the style for a group:
highlight YcmErrorLine guibg=#3f0000
This feature requires Vim and is not supported in Neovim
YCM provides a way to search for and jump to a symbol in the current project ordocument when using supported languages.
You can search for symbols in the current workspace when theGoToSymbol
request is supported and the current document whenGoToDocumentOutline
issupported.
Here's a quick demo:
As you can see, you can type and YCM filters down the list as you type. Thecurrent set of matches are displayed in a popup window in the centre of thescreen and you can select an entry with the keyboard, to jump to that position.Any matches are then added to the quickfix list.
To enable:
nmap <something> <Plug>(YCMFindSymbolInWorkspace)
nmap <something> <Plug>(YCMFindSymbolInDocument)
e.g.
nmap <leader>yfw <Plug>(YCMFindSymbolInWorkspace)
nmap <leader>yfd <Plug>(YCMFindSymbolInDocument)
When searching, YCM opens a prompt buffer at the top of the screen for theinput and puts you in insert mode. This means that you can hit<Esc>
to gointo normal mode and use any other input commands that are supported in promptbuffers. As you type characters, the search is updated.
Initially, results are queried from all open filetypes. You can hit<C-f>
toswitch to just the current filetype while the popup is open.
While the popup is open, the following keys are intercepted:
<C-j>
,<Down>
,<C-n>
,<Tab>
- select the next item<C-k>
,<Up>
,<C-p>
,<S-Tab>
- select the previous item<PageUp>
,<kPageUp>
- jump up one screenful of items<PageDown>
,<kPageDown>
- jump down one screenful of items<Home>
,<kHome>
- jump to first item<End>
,<kEnd>
- jump to last item<CR>
- jump to the selected item<C-c>
cancel/dismiss the popup<C-f>
- toggle results from all file types or just the current filetype
The search is also cancelled if you leave the prompt buffer window at any time,so you can use window commands<C-w>...
for example.
NOTE: Pressing<Esc>
does not close the popup - you must useCtrl-c
for that, or use a window command (e.g.<Ctrl-w>j
) or the mouse to leave theprompt buffer window.
This feature requires Vim and is not supported in Neovim
NOTE: This feature is highly experimental and offered in the hope that it isuseful. Please help us by reporting issues and offering feedback.
YCM provides a way to view and navigate hierarchies. The following hierarchiesare supported:
- Type hierachy
<Plug>(YCMTypeHierarchy)
: Display subtypes and supertypesof the symbol under cursor. Expand down to subtypes and up to supertypes. - Call hierarchy
<Plug>(YCMCallHierarchy)
: Display callees and callers ofthe symbol under cursor. Expand down to callers and up to callees.
Take a look at thisfor brief demo.
Hierarchy UI can be initiated by mapping something to the indicated plugmappings, for example:
nmap<leader>yth<Plug>(YCMTypeHierarchy)nmap<leader>ych<Plug>(YCMCallHierarchy)
This opens a "modal" popup showing the current element in the hierarchy tree.The current tree root is aligned to the left and child and parent nodes areexpanded to the right. Expand the tree "down" with<Tab> and "up" with
`.
The "root" of the tree can be re-focused to the selected item with<S-Tab>
and further<S-Tab>
will show the parents of the selected item. Thiscan take a little getting used to, but it's particularly important with multipleinheritance where a "child" of the current root may actually have other,invisible, parent links.<S-Tab>
on that row will show these by setting thedisplay root to the selected item.
When the hierarchy is displayed, the following keys are intercepted:
<Tab>
: Drill into the hierarchy at the selected item: expand and showchildren of the selected item.<S-Tab>
: Show parents of the selected item. When applied to sub-types, thiswill re-root the tree at that type, so that all parent types (are displayed).Similar for callers.<CR>
: Jump to the symbol currently selected.<Down>
,<C-n>
,<C-j>
,j
: Select the next item<Up>
,<C-p>
,<C-k>
,k
; Select the previous item- Any other key: closes the popup without jumping to any location
Note: you might think the call hierarchy tree is inverted, but we thinkthis way round is more intuitive because this is the typical way that callstacks are displayed (with the current function at the top, and its callersbelow).
If theycmd completion server suddenly stops for some reason, you canrestart it with this command.
Calling this command will force YCM to immediately recompile your fileand display any new diagnostics it encounters. Do note that recompilation withthis command may take a while and during this time the Vim GUIwill beblocked.
You may want to map this command to a key; try puttingnnoremap <F5> :YcmForceCompileAndDiagnostics<CR>
in your vimrc.
Calling this command will fill Vim'slocationlist
with errors or warnings ifany were detected in your file and then open it. If a given error or warning canbe fixed by a call to:YcmCompleter FixIt
, then (FixIt available)
isappended to the error or warning text. See theFixIt
completer subcommand formore information.
NOTE: The absence of (FixIt available)
does not strictly imply a fix-itis not available as not all completers are able to provide this indication. Forexample, the c-sharp completer provides many fix-its but does not add thisadditional indication.
Theg:ycm_open_loclist_on_ycm_diags
option can be used to prevent the locationlist from opening, but still have it filled with new diagnostic data. See theOptions section for details.
This command shows the full diagnostic text when the user's cursor is on theline with the diagnostic.
An options argument can be passed. If the argument ispopup
the diagnostictext will be displayed in a popup at the cursor position.
If you prefer the detailed diagnostic to always be shown in a popup, thenlet g:ycm_show_detailed_diag_in_popup=1
.
This will print out various debug information for the current file. Useful tosee what compile commands will be used for the file if you're using the semanticcompletion engine.
This command presents the list of logfiles created by YCM, theycmdserver, 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) byentering 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 thewildchar
option) to complete thearguments or to cycle through them (depending on the value of thewildmode
option). Each logfile given as an argument is directly opened (or closed ifalready open) in the editor. Only for debugging purposes.
This command gives access to a number of additionalIDE-likefeatures in YCM, for things like semantic GoTo, typeinformation, FixIt, and refactoring.
This command accepts a range that can either be specified through a selection inone of Vim's visual modes (see:h visual-use
) or on the command line. Forinstance,:2,5YcmCompleter
will apply the command from line 2 to line 5. Thisis useful fortheFormat
subcommand.
CallYcmCompleter
without further arguments for a list of the commands you cancall for the current completer.
See thefile type feature summary for an overview ofthe features available for each file type. See theYcmCompleter subcommandssection for more information on the available subcommands and their usage.
Some commands, likeFormat
accept a range, like:%YcmCompleter Format
.
Some commands likeGetDoc
and the variousGoTo
commands respect modifiers,like:rightbelow YcmCompleter GetDoc
,:vertical YcmCompleter GoTo
.
NOTE: See the docs for theYcmCompleter
command before tackling thissection.
The invoked subcommand is automatically routed to the currently active semanticcompleter, so:YcmCompleter GoToDefinition
will invoke theGoToDefinition
subcommand on the Python semantic completer if the currently active file is aPython one and on the Clang completer if the currently active file is a C-familylanguage one.
You may also want to map the subcommands to something less verbose; forinstance,nnoremap <leader>jd :YcmCompleter GoTo<CR>
maps the<leader>jd
sequence to the longer subcommand invocation.
These commands are useful for jumping around and exploring code. When movingthe cursor, the subcommands add entries to Vim'sjumplist
so you can useCTRL-O
to jump back to where you were before invoking the command (andCTRL-I
to jump forward; see:h jumplist
for details). If there is morethan one destination, the quickfix list (see:h quickfix
) is populated withthe available locations and opened to the full width at the bottom of the screen.You can change this behavior by usingtheYcmQuickFixOpened
autocommand.
Looks up the current line for a header and jumps to it.
Supported in filetypes:c, cpp, objc, objcpp, cuda
Jump to the associated file, as defined by the language server. Typically thiswill jump you to the associated header file for a C or C++ translation unit.
Supported in filetypes:c, cpp, objc, objcpp, cuda
(clangd only)
Looks up the symbol under the cursor and jumps to its declaration.
Supported in filetypes:c, cpp, objc, objcpp, cuda, cs, go, java, javascript, python, rust, typescript
Looks up the symbol under the cursor and jumps to its definition.
NOTE: For C-family languagesthis only works in certain situations,namely when the definition of the symbol is in the current translation unit. Atranslation unit consists of the file you are editing and all the files you areincluding with#include
directives (directly or indirectly) in that file.
Supported in filetypes:c, cpp, objc, objcpp, cuda, cs, go, java, javascript, python, rust, typescript
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 andjumps to its definition if possible; if the definition is not accessible fromthe current translation unit, jumps to the symbol's declaration. ForC-family languages, it first tries to look up the current line for a header andjump to it. For C#, implementations are also considered and preferred.
Supported in filetypes:c, cpp, objc, objcpp, cuda, cs, go, java, javascript, python, rust, typescript
WARNING: This command trades correctness for speed!
Same as theGoTo
command except that it doesn't recompile the file withlibclang before looking up nodes in the AST. This can be very useful when you'reediting files that take time to compile but you know that you haven't made anychanges since the last parse that would lead to incorrect jumps. When you'rejust browsing around your codebase, this command can spare you quite a bit oflatency.
Supported in filetypes:c, cpp, objc, objcpp, cuda
Finds the definition of all symbols matching a specified string. Note that thisdoes not use any sort of smart/fuzzy matching. However, aninteractive symbolsearch is also available.
Supported in filetypes:c, cpp, objc, objcpp, cuda, cs, java, javascript, python, typescript
This command attempts to find all of the references within the project to theidentifier under the cursor and populates the quickfix list with thoselocations.
Supported in filetypes:c, cpp, objc, objcpp, cuda, java, javascript, python, typescript, rust
Looks up the symbol under the cursor and jumps to its implementation (i.e.non-interface). If there are multiple implementations, instead provides a listof implementations to choose from.
Supported in filetypes:cs, go, java, rust, typescript, javascript
Looks up the symbol under the cursor and jumps to its implementation if one,else jump to its declaration. If there are multiple implementations, insteadprovides a list of implementations to choose from.
Supported in filetypes:cs
Looks up the symbol under the cursor and jumps to the definition of its typee.g. if the symbol is an object, go to the definition of its class.
Supported in filetypes:go, java, javascript, typescript
Provides a list of symbols in the current document, in the quickfix list. See alsointeractive symbol search.
Supported in filetypes:c, cpp, objc, objcpp, cuda, go, java, rust
Note: A much more powerful call and type hierarchy can be viewd interactively.Seeinteractive type and call hierarchy.
Populate the quickfix list with the callers, or callees respectively, of thefunction associated with the current cursor position. The semantics of thisdiffer depending on the filetype and language server.
Only supported for LSP servers that provide thecallHierarchyProvider
capability.
These commands are useful for finding static information about the code, suchas the types of variables, viewing declarations, and documentation strings.
Echos the type of the variable or method under the cursor, and where it differs,the derived type.
For example:
std::string s;
Invoking this command ons
returnsstd::string => std::basic_string<char>
NOTE: Causes re-parsing of the current translation unit.
Supported in filetypes:c, cpp, objc, objcpp, cuda, java, javascript, go, python, typescript, rust
WARNING: This command trades correctness for speed!
Same as theGetType
command except that it doesn't recompile the file withlibclang before looking up nodes in the AST. This can be very useful when you'reediting files that take time to compile but you know that you haven't made anychanges since the last parse that would lead to incorrect type. When you'rejust browsing around your codebase, this command can spare you quite a bit oflatency.
Supported in filetypes:c, cpp, objc, objcpp, cuda
Echos the semantic parent of the point under the cursor.
The semantic parent is the item that semantically contains the given position.
For example:
classC {voidf();};voidC::f() {}
In the out-of-line definition ofC::f
, the semantic parent is the classC
,of which this function is a member.
In the example above, both declarations ofC::f
haveC
as their semanticcontext, while the lexical context of the firstC::f
isC
and the lexicalcontext of the secondC::f
is the translation unit.
For global declarations, the semantic parent is the translation unit.
NOTE: Causes re-parsing of the current translation unit.
Supported in filetypes:c, cpp, objc, objcpp, cuda
Displays the preview window populated with quick info about the identifierunder the cursor. Depending on the file type, this includes things like:
- The type or declaration of identifier,
- Doxygen/javadoc comments,
- Python docstrings,
- etc.
The documentation is opened in the preview window, and options likepreviewheight
are respected. If you would like to customise the height andposition of this window, we suggest a custom command that:
- Sets
previewheight
temporarily - Runs the
GetDoc
command with supplied modifiers - Restores
previewheight
.
For example:
command-count ShowDocWithSize\letg:ph=&previewheight\<bar>setpreviewheight=<count>\<bar><mods> YcmCompleter GetDoc\<bar>let &previewheight=g:ph
You can then use something like:botright vertical 80ShowDocWithSize
. Here's anexample of that:https://asciinema.org/a/hE6Pi1gU6omBShwFna8iwGEe9
Supported in filetypes:c, cpp, objc, objcpp, cuda, cs, go, java, javascript, python, typescript, rust
WARNING: This command trades correctness for speed!
Same as theGetDoc
command except that it doesn't recompile the file withlibclang before looking up nodes in the AST. This can be very useful when you'reediting files that take long to compile but you know that you haven't made anychanges since the last parse that would lead to incorrect docs. When you'rejust browsing around your codebase, this command can spare you quite a bit oflatency.
Supported in filetypes:c, cpp, objc, objcpp, cuda
These commands make changes to your source code in order to perform refactoringor code correction. YouCompleteMe does not perform any action which cannot beundone, and never saves or writes files to the disk.
Where available, attempts to make changes to the buffer to correct diagnostics,or perform refactoring, on the current line or selection. Where multiplesuggestions are available (such as when there are multiple ways to resolve agiven warning, or where multiple diagnostics are reported for the current line,or multiple refactoring tweaks are available), the options are presented andone can be selected.
Completers that provide diagnostics may also provide trivial modifications tothe source in order to correct the diagnostic. Examples include syntax errorssuch as missing trailing semi-colons, spurious characters, or other errors whichthe semantic engine can deterministically suggest corrections. A small demopresenting how diagnostics can be fixed with clangd:
Completers (LSPs) may also provide refactoring tweaks, which may be availableeven when no diagnostic is presented for the current line. These includefunction extraction, variable extraction,switch
population, constructorgeneration, ... The tweaks work for a selection as well. Consult your LSP foravailable refactorings. A demonstration of refactoring capabilities with clangd:
If no fix-it is available for the current line, or there is no diagnostic on thecurrent line, this command has no effect on the current buffer. If anymodifications are made, the number of changes made to the buffer is echo'd andthe user may use the editor's undo command to revert.
When a diagnostic is available, andg:ycm_echo_current_diagnostic
is enabled,then the text (FixIt)
is appended to the echo'd diagnostic when thecompleter is able to add this indication. The text (FixIt available)
isalso appended to the diagnostic text in the output of the:YcmDiags
commandfor any diagnostics with available fix-its (where the completer can provide thisindication).
NOTE: Causes re-parsing of the current translation unit.
Supported in filetypes:c, cpp, objc, objcpp, cuda, cs, go, java, javascript, rust, typescript
In supported file types, this command attempts to perform a semantic rename ofthe identifier under the cursor. This includes renaming declarations,definitions, and usages of the identifier, or any other language-appropriateaction. The specific behavior is defined by the semantic engine in use.
Similar toFixIt
, this command applies automatic modifications to your sourcefiles. Rename operations may involve changes to multiple files, which may or maynot be open in Vim buffers at the time. YouCompleteMe handles all of this foryou. The behavior is described inthe following section.
Supported in filetypes:c, cpp, objc, objcpp, cuda, java, javascript, python, typescript, rust, cs
The following additional commands are supported for Python:
RefactorInline
RefactorExtractVariable
RefactorExtractFunction
See thejedi docs for what they do.
Supported in filetypes:python
When a Refactor or FixIt command touches multiple files, YouCompleteMe attemptsto apply those modifications to any existing open, visible buffer in the currenttab. If no such buffer can be found, YouCompleteMe opens the file in a newsmall horizontal split at the top of the current window, applies the change,and thenhides the window.NOTE: The buffer remains open, and must bemanually saved. A confirmation dialog is opened prior to doing this to remindyou that this is about to happen.
Once the modifications have been made, the quickfix list (see:help quickfix
)is populated with the locations of all modifications. This can be used to reviewall automatic changes made by using:copen
. Typically, use theCTRL-W <enter>
combination to open the selected file in a new split. It is possible tocustomize how the quickfix window is opened by usingtheYcmQuickFixOpened
autocommand.
The buffers arenot saved automatically. That is, you must save the modifiedbuffers manually after reviewing the changes from the quickfix list. Changescan be undone using Vim's powerful undo features (see:help undo
). Notethat Vim's undo is per-buffer, so to undo all changes, the undo commands mustbe applied in each modified buffer separately.
NOTE: While applying modifications, Vim may find files that are alreadyopen and have a swap file. The command is aborted if you select Abort or Quit inany such prompts. This leaves the Refactor operation partially complete and mustbe manually corrected using Vim's undo features. The quickfix list isnotpopulated in this case. Inspect:buffers
or equivalent (see:help buffers
)to see the buffers that were opened by the command.
This command formats the whole buffer or some part of it according to the valueof the Vim optionsshiftwidth
andexpandtab
(see:h 'sw'
and:h et
respectively). To format a specific part of your document, you can either selectit in one of Vim's visual modes (see:h visual-use
) and run the command ordirectly enter the range on the command line, e.g.:2,5YcmCompleter Format
toformat it from line 2 to line 5.
Supported in filetypes:c, cpp, objc, objcpp, cuda, java, javascript, go, typescript, rust, cs
This command removes unused imports and sorts imports in the current file. Itcan also group imports from the same module in TypeScript and resolve importsin Java.
Supported in filetypes:java, javascript, typescript
These commands are for general administration, rather than IDE-like features.They cover things like the semantic engine server instance and compilationflags.
Some LSP completers (currently only Java completers) support executingserver-specific commands. Consult thejdt.ls documentation to find outwhat commands are supported and which arguments are expected.
The support forExecuteCommand
was implemented to support plugins likeVimspector to debug java, but isn't limited to that specific use case.
Restarts the downstream semantic engine server for those semantic engines thatwork as separate servers that YCM talks to.
Supported in filetypes:c, cpp, objc, objcpp, cuda, cs, go, java, javascript, rust, typescript
Instruct the Omnisharp-Roslyn server to clear its cache and reload all filesfrom the disk. This is useful when files are added, removed, or renamed in thesolution, files are changed outside of Vim, or whenever Omnisharp-Roslyn cacheis out-of-sync.
Supported in filetypes:cs
Get the number of YCM Diagnostic errors. If no errors are present, this functionreturns 0.
For example:
callyoucompleteme#GetErrorCount()
Both this function andyoucompleteme#GetWarningCount
can be useful whenintegrating YCM with other Vim plugins. For example, alightline user couldadd a diagnostics section to their statusline which would display the number oferrors and warnings.
Get the number of YCM Diagnostic warnings. If no warnings are present, thisfunction returns 0.
For example:
callyoucompleteme#GetWarningCount()
Run acompleter subcommand and return the result asa string. This can be useful for example to display theGetDoc
output in apopup window, e.g.:
lets:ycm_hover_popup=-1functions:Hover()let response=youcompleteme#GetCommandResponse('GetDoc' )if response==''returnendifcallpopup_hide(s:ycm_hover_popup )lets:ycm_hover_popup=popup_atcursor(balloon_split( response ), {} )endfunction" CursorHold triggers in normal mode after a delayautocmdCursorHold*calls:Hover()" Or, if you prefer, a mapping:nnoremap<silent><leader>D:call<SID>Hover()<CR>
NOTE: This is only an example, for real hover support, seeg:ycm_auto_hover
.
If the completer subcommand result is not a string (for example, it's a FixIt ora Location), or if the completer subcommand raises an error, an empty string isreturned, so that calling code does not have to check for complex errorconditions.
The arguments to the function are the same as the arguments to the:YcmCompleter
ex command, e.g. the name of the subcommand, followed by anyadditional subcommand arguments. As with theYcmCompleter
command, if thefirst argument isft=<filetype>
the request is targeted at the specifiedfiletype completer. This is an advanced usage and not necessary in most cases.
NOTE: The request is run synchronously and blocks Vim until the response isreceived, so we do not recommend running this as part of an autocommand thattriggers frequently.
This works exactly likeyoucompleteme#GetCommandResponse
, except that insteadof returning the result, you supply acallback
argument. This argument must beaFuncRef
to a function taking a single argumentresponse
. This callbackwill be called with the command response at some point later, or immediately.
As withyoucompleteme#GetCommandResponse()
, this function will call thecallback with''
(an empty string) if the request is not sent, or if there wassome sort of error.
Here's an example that's similar to the one above:
lets:ycm_hover_popup=-1function!s:ShowDataPopup( response )abortif response==''returnendifcallpopup_hide(s:ycm_hover_popup )lets:ycm_hover_popup=popup_atcursor(balloon_split( response ), {} )endfunctionfunction!s:GetData()abortcallyoucompleteme#GetCommandResponseAsync(\function('s:ShowDataPopup' ),\'GetDoc' )endfunctionautocommandCursorHold*calls:GetData()
Again, seeg:ycm_auto_hover
for proper hoversupport.
NOTE: The callback may be called immediately, in the stack frame that calledthis function.
NOTE: Only one command request can be outstanding at once. Attempting torequest a second response while the first is outstanding will result in thesecond callback being immediately called with''
.
ThisUser
autocommand is fired when YCM opens the location list window inresponse to theYcmDiags
command. By default, the location list window isopened to the bottom of the current window and its height is set to fit allentries. This behavior can be overridden by using theYcmLocationOpened
autocommand which is triggered while the cursor is in the location list window.For instance:
function!s:CustomizeYcmLocationWindow()" Move the window to the top of the screen.wincmd K" Set the window height to 5.5wincmd _" Switch back to the working window.wincmdpendfunctionautocmdUserYcmLocationOpenedcalls:CustomizeYcmLocationWindow()
ThisUser
autocommand is fired when YCM opens the quickfix window in responseto theGoTo*
andRefactorRename
subcommands. By default, the quickfix windowis opened to full width at the bottom of the screen and its height is set to fitall entries. This behavior can be overridden by using theYcmQuickFixOpened
autocommand which is triggered while the cursor is in the quickfix window. Forinstance:
function!s:CustomizeYcmQuickFixWindow()" Move the window to the top of the screen.wincmd K" Set the window height to 5.5wincmd _endfunctionautocmdUserYcmQuickFixOpenedcalls:CustomizeYcmQuickFixWindow()
All options have reasonable defaults so if the plug-in works after installationyou don't need to change any options. These options can be configured in yourvimrc script by including a line like this:
letg:ycm_min_num_of_chars_for_completion=1
Note that after changing an option in yourvimrc script you have torestartycmd with the:YcmRestartServer
command for the changes to takeeffect.
This option controls the number of characters the user needs to type beforeidentifier-based completion suggestions are triggered. For example, if theoption is set to2
, then when the user types a second alphanumeric characterafter a whitespace character, completion suggestions will be triggered. Thisoption is NOT used for semantic completion.
Setting this option to a high number like99
effectively turns off theidentifier completion engine and just leaves the semantic engine.
Default:2
letg:ycm_min_num_of_chars_for_completion=2
This option controls the minimum number of characters that a completioncandidate coming from the identifier completer must have to be shown in thepopup menu.
A special value of0
means there is no limit.
NOTE: This option only applies to the identifier completer; it has no effecton the various semantic completers.
Default:0
letg:ycm_min_num_identifier_candidate_chars=0
This option controls the maximum number of semantic completion suggestions shownin the completion menu. This only applies to suggestions from semanticcompletion engines; seetheg:ycm_max_identifier_candidates
option to limit the number ofsuggestions from the identifier-based engine.
A special value of0
means there is no limit.
NOTE: Setting this option to0
or to a value greater than100
is notrecommended as it will slow down completion when there is a very large numberof suggestions.
Default:50
letg:ycm_max_num_candidates=50
Some completion engines require completion candidates to be 'resolved' in orderto get detailed info such as inline documentation, method signatures, etc. Thisinformation is displayed by YCM in the preview window, or ifcompleteopt
containspopup
, in the info popup next to the completion menu.
By default, if the info popup is in use, and there are more than 10 candidates,YCM will defer resolving candidates until they are selected in the completionmenu. Otherwise, YCM must resolve the details upfront, which can be costly.
If neitherpopup
norpreview
are incompleteopt
, YCM disables resolvingaltogether as the information would not be displayed.
This setting can be used to override these defaults and controls the number ofcompletion candidates that should be resolved upfront. Typically users do notneed to change this, as YCM will work out an appropriate value based on yourcompleteopt
andg:ycm_add_preview_to_completeopt
settings. However, you mayoverride this calculation by setting this value to a number:
-1
- Resolve all candidates upfront0
- Never resolve any candidates upfront.> 0
- Resolve up to this many candidates upfront. If the number ofcandidates is greater than this value, no candidates are resolved.
In the latter two cases, ifcompleteopt
containspopup
, then candidates areresolved on demand asynchronously.
Default:
0
if neitherpopup
norpreview
are incompleteopt
.10
ifpopup
is in completeopt.-1
ifpreview
is in completeopt.
Example:
letg:ycm_max_num_candidates_to_detail=0
This option controls the maximum number of completion suggestions from theidentifier-based engine shown in the completion menu.
A special value of0
means there is no limit.
NOTE: Setting this option to0
or to a value greater than100
is notrecommended as it will slow down completion when there is a very large numberof suggestions.
Default:10
letg:ycm_max_num_identifier_candidates=10
When set to0
, this option turns off YCM's identifier completer (theas-you-type popup)and the semantic triggers (the popup you'd get after typing.
or->
in say C++). You can still force semantic completion with the<C-Space>
shortcut.
If you want to just turn off the identifier completer but keep the semantictriggers, you should setg:ycm_min_num_of_chars_for_completion
to a highnumber like99
.
Wheng:ycm_auto_trigger
is0
, YCM sets thecompletefunc
, so that you canmanually trigger normal completion usingC-x C-u
.
If you want to map something else to trigger completion, such asC-d
,then you can map it to<plug>(YCMComplete)
. For example:
letg:ycm_auto_trigger=0imap<c-d><plug>(YCMComplete)
NOTE: It's not possible to map one of the keys ing:ycm_key_list_select_completion
(or similar) to<plug>(YCMComplete)
. Inpractice that means that you can't use<Tab>
for this.
Default:1
letg:ycm_auto_trigger=1
This option controls for which Vim filetypes (see:h filetype
) should YCM beturned on. The option value should be a Vim dictionary with keys being filetypestrings (likepython
,cpp
, etc.) and values being unimportant (thedictionary is used like a hash set, meaning that only the keys matter).
The*
key is special and matches all filetypes. By default, the whitelistcontains only this*
key.
YCM also has ag:ycm_filetype_blacklist
option that lists filetypes for whichYCM shouldn't be turned on. YCM will work only in filetypes that both thewhitelist and the blacklist allow (the blacklist "allows" a filetype bynothaving it as a key).
For example, let's assume you want YCM to work in files with thecpp
filetype.The filetype should then be present in the whitelist either directly (cpp
keyin the whitelist) or indirectly through the special*
key. It shouldnot bepresent in the blacklist.
Filetypes that are blocked by either of the lists will be completely ignoredby YCM, meaning that neither the identifier-based completion engine nor thesemantic engine will operate in them.
You can get the filetype of the current file in Vim with:set ft?
.
Default:{'*': 1}
letg:ycm_filetype_whitelist= {'*':1}
** Completion in buffers with no filetype **
There is one exception to the above rule. YCM supports completion in bufferswith no filetype set, but this must beexplicitly whitelisted. To identifybuffers with no filetype, we use theycm_nofiletype
pseudo-filetype. To enablecompletion in buffers with no filetype, set:
letg:ycm_filetype_whitelist= {\'*':1,\'ycm_nofiletype':1\}
This option controls for which Vim filetypes (see:h filetype
) should YCM beturned off. The option value should be a Vim dictionary with keys being filetypestrings (likepython
,cpp
, etc.) and values being unimportant (thedictionary is used like a hash set, meaning that only the keys matter).
See theg:ycm_filetype_whitelist
option for more details on how this works.
Default:[see next line]
letg:ycm_filetype_blacklist= {\'tagbar':1,\'notes':1,\'markdown':1,\'netrw':1,\'unite':1,\'text':1,\'vimwiki':1,\'pandoc':1,\'infolog':1,\'leaderf':1,\'mail':1\}
In addition,ycm_nofiletype
(representing buffers with no filetype set)is blacklisted ifycm_nofiletype
is notexplicitly whitelisted (usingg:ycm_filetype_whitelist
).
This option controls for which Vim filetypes (see:h filetype
) should the YCMsemantic completion engine be turned off. The option value should be a Vimdictionary with keys being filetype strings (likepython
,cpp
, etc.) andvalues being unimportant (the dictionary is used like a hash set, meaning thatonly the keys matter). The listed filetypes will be ignored by the YCM semanticcompletion engine, but the identifier-based completion engine will still triggerin 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 supportthat filetype.
You can get the filetype of the current file in Vim with:set ft?
.
Default:[see next line]
letg:ycm_filetype_specific_completion_to_disable= {\'gitcommit':1\}
This option controls for which Vim filetypes (see:h filetype
) should filepathcompletion be disabled. The option value should be a Vim dictionary with keysbeing filetype strings (likepython
,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 tocompletely disable filepath completion:
letg:ycm_filepath_blacklist= {'*':1}
You can get the filetype of the current file in Vim with:set ft?
.
Default:[see next line]
letg:ycm_filepath_blacklist= {\'html':1,\'jsx':1,\'xml':1,\}
When set, this option turns on YCM's diagnostic display features. See theDiagnostic display section in theUser 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 onor 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 thec
,cpp
,objc
,objcpp
, andcuda
filetypes since this would conflictwith YCM's own diagnostics UI.
If you're using YCM's identifier completer in C-family languages but cannot usethe clang-based semantic completer for those languagesand want to use the GCCSyntastic checkers, unset this option.
Default:1
letg:ycm_show_diagnostics_ui=1
YCM will use the value of this option as the symbol for errors in the Vimgutter.
This option is part of the Syntastic compatibility layer; if the option is notset, YCM will fall back to the value of theg:syntastic_error_symbol
optionbefore using this option's default.
Default:>>
letg:ycm_error_symbol='>>'
YCM will use the value of this option as the symbol for warnings in the Vimgutter.
This option is part of the Syntastic compatibility layer; if the option is notset, YCM will fall back to the value of theg:syntastic_warning_symbol
optionbefore using this option's default.
Default:>>
letg:ycm_warning_symbol='>>'
When this option is set, YCM will put icons in Vim's gutter on lines that have adiagnostic set. Turning this off will also turn off theYcmErrorLine
andYcmWarningLine
highlighting.
This option is part of the Syntastic compatibility layer; if the option is notset, YCM will fall back to the value of theg:syntastic_enable_signs
optionbefore using this option's default.
Default:1
letg:ycm_enable_diagnostic_signs=1
When this option is set, YCM will highlight regions of text that are related tothe diagnostic that is present on a line, if any.
This option is part of the Syntastic compatibility layer; if the option is notset, YCM will fall back to the value of theg:syntastic_enable_highlighting
option before using this option's default.
Default:1
letg:ycm_enable_diagnostic_highlighting=1
When this option is set to 1, YCM will echo the text of the diagnostic presenton the current line when you move your cursor to that line. If aFixIt
isavailable for the current diagnostic, then (FixIt)
is appended.
If you have a Vim that supports virtual text, you can set this optionto the stringvirtual-text
, and the diagnostic will be displayed inline withthe text, right aligned in the window and wrapping to the next line if there isnot enough space, for example:
NOTE: It'sstrongly recommended to also setg:ycm_update_diagnostics_in_insert_mode
to0
when usingvirtual-text
fordiagnostics. This is due to the increased amount of distraction provided bydrawing diagnostics next to your input position.
This option is part of the Syntastic compatibility layer; if the option is notset, YCM will fall back to the value of theg:syntastic_echo_current_error
option before using this option's default.
Default:1
Valid values:
0
- disabled1
- echo diagnostic to the command area'virtual-text'
- display the dignostic to the right of the line in thewindow using virtual text
letg:ycm_echo_current_diagnostic=1" Or, when you have Vim supporting virtual textletg:ycm_echo_current_diagnostic='virtual-text'
This option controls whether or not YCM shows documentation in a popup at thecursor location after a short delay. Only supported in Vim.
When this option is set to'CursorHold'
, the popup is displayed on theCursorHold
autocommand. See:help CursorHold
for the details, but this meansthat it is displayed afterupdatetime
milliseconds. When set to an emptystring, the popup is not automatically displayed.
In addition to this setting, there is the<plug>(YCMHover)
mapping, which canbe used to manually trigger or hide the popup (it works like a toggle).For example:
nmap<leader>D<plug>(YCMHover)
After dismissing the popup with this mapping, it will not be automaticallytriggered again until the cursor is moved (i.e.CursorMoved
autocommand).
The displayed documentation depends on what the completer for the currentlanguage supports. It's selected heuristically in this order of preference:
GetHover
withmarkdown
syntaxGetDoc
with no syntaxGetType
with the syntax of the current file.
You can customise this by manually setting upb:ycm_hover
to your liking. Thisbuffer-local variable can be set to a dictionary with the following keys:
command
: The YCM completer subcommand which should be run on hoversyntax
: The syntax to use (as inset syntax=
) in the popup window forhighlighting.popup_params
: The params passed to a popup window which gets opened.
For example, to use C/C++ syntax highlighting in the popup for C-familylanguages, add something like this to your vimrc:
augroupMyYCMCustomautocmd!autocmdFileTypec,cppletb:ycm_hover= {\'command':'GetDoc',\'syntax': &filetype\}augroupEND
You can also modify the opened popup withpopup_params
key.For example, you can limit the popup's maximum width and add a border to it:
augroupMyYCMCustomautocmd!autocmdFileTypec,cppletb:ycm_hover= {\'command':'GetDoc',\'syntax': &filetype\'popup_params': {\'maxwidth':80,\'border': [],\'borderchars': ['─','│','─','│','┌','┐','┘','└'],\ },\}augroupEND
See:help popup_create-arguments
for the list of available popup window options.
Default:'CursorHold'
This option controls which diagnostics will be rendered by YCM. This optionholds a dictionary of key-values, where the keys are Vim's filetype stringsdelimited by commas and values are dictionaries describing the filter.
A filter is a dictionary of key-values, where the keys are the type of filter,and the value is a list of arguments to that filter. In the case of just asingle item in the list, you may omit the brackets and just provide the argumentdirectly. If any filter matches a diagnostic, it will be dropped and YCM willnot render it.
The following filter types are supported:
- "regex": Accepts a stringregular expression. This type matcheswhen the regex (treated as case-insensitive) is found anywhere in the diagnostictext (
re.search
, notre.match
) - "level": Accepts a string level, either "warning" or "error." This typematches when the diagnostic has the same level, that is,specifying
level: "error"
will removeall errors from the diagnostics.
NOTE: The regex syntax isNOT Vim's, it'sPython's.
Default:{}
The following example will do, for Java filetype only:
- Removeall error level diagnostics, and,
- Also remove anything that contains
ta<something>co
letg:ycm_filter_diagnostics= {\"java": {\"regex": ["ta.+co",... ],\"level":"error",\...\ }\}
When this option is set, YCM will populate the location list automatically everytime it gets new diagnostic data. This option is off by default so as not tointerfere 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 notset, YCM will fall back to the value of theg:syntastic_always_populate_loc_list
option before using this option'sdefault.
Note: if YCM's errors aren't visible, it might be that YCM is updating an older location list. See:help :lhistory
and:lolder
.
Default:0
letg:ycm_always_populate_location_list=0
When this option is set,:YcmDiags
will automatically open the location listafter 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
letg:ycm_open_loclist_on_ycm_diags=1
When this option is set to1
, YCM will show the completion menu even whentyping inside comments.
Default:0
letg:ycm_complete_in_comments=0
When this option is set to1
, YCM will show the completion menu even whentyping inside strings.
Note that this is turned on by default so that you can use the filenamecompletion inside strings. This is very useful for instance in C-family fileswhere typing#include "
will trigger the start of filename completion. If youturn off this option, you will turn off filename completion in such situationsas well.
Default:1
letg:ycm_complete_in_strings=1
When this option is set to1
, YCM's identifier completer will also collectidentifiers from strings and comments. Otherwise, the text in comments andstrings will be ignored.
Default:0
letg:ycm_collect_identifiers_from_comments_and_strings=0
When this option is set to1
, YCM's identifier completer will also collectidentifiers from tags files. The list of tags files to examine is retrieved fromthetagfiles()
Vim function which examines thetags
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 theExuberant Ctags format. Theformat from "plain" ctags is NOT supported. Ctags needs to be called with the--fields=+l
option (that's a lowercaseL
, not a one) because YCM needs thelanguage:<lang>
field in the tags output.
See theFAQ for pointers if YCM does not appear to read your tag files.
This option is off by default because it makes Vim slower if your tags are on anetwork directory.
Default:0
letg:ycm_collect_identifiers_from_tags_files=0
When this option is set to1
, YCM's identifier completer will seed itsidentifier database with the keywords of the programming language you'rewriting.
Since the keywords are extracted from the Vim syntax file for the filetype, allkeywords may not be collected, depending on how the syntax file was written.Usually at least 95% of the keywords are successfully extracted.
Default:0
letg:ycm_seed_identifiers_with_syntax=0
If you're using semantic completion for C-family files, this option might comehandy; it's a way of sending data from Vim to yourSettings
function inyour.ycm_extra_conf.py
file.
This option is supposed to be a list of VimScript expression strings that areevaluated for every request to theycmd server and then passed to yourSettings
function as aclient_data
keyword argument.
For instance, if you set this option to['v:version']
, yourSettings
function will be called like this:
# The '801' value is of course contingent on Vim 8.1; in 8.0 it would be '800'Settings( ...,client_data= {'v:version':801 } )
So theclient_data
parameter is a dictionary mapping Vim expression strings totheir values at the time of the request.
The correct way to define parameters for yourSettings
function:
defSettings(**kwargs ):
You can then get toclient_data
withkwargs['client_data']
.
Default:[]
letg:ycm_extra_conf_vim_data= []
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 aspecific interpreter of your choosing.
NOTE: This interpreter is only used for theycmd server. The YCMclient running inside Vim always uses the Python interpreter that's embeddedinside Vim.
Default:''
letg:ycm_server_python_interpreter=''
When this option is set to1
, YCM and theycmd completion server willkeep the logfiles around after shutting down (they are deleted on shutdown bydefault).
To see where the log files are, call:YcmDebugInfo
.
Default:0
letg:ycm_keep_logfiles=0
The logging level that YCM and theycmd completion server use. Validvalues are the following, from most verbose to least verbose:
debug
info
warning
error
critical
Note thatdebug
isvery verbose.
Default:info
letg:ycm_log_level='info'
When set to1
, the OmniSharp-Roslyn server will be automatically started(once per Vim session) when you open a C# file.
Default:1
letg:ycm_auto_start_csharp_server=1
When set to1
, the OmniSharp-Roslyn server will be automatically stopped uponclosing Vim.
Default:1
letg:ycm_auto_stop_csharp_server=1
When g:ycm_auto_start_csharp_server is set to1
, specifies the port forthe OmniSharp-Roslyn server to listen on. When set to0
uses an unused port providedby the OS.
Default:0
letg:ycm_csharp_server_port=0
By default, when YCM inserts a namespace, it will insert theusing
statementunder the nearestusing
statement. You may prefer that theusing
statement isinserted somewhere, for example, to preserve sorting. If so, you can set thisoption to override this behavior.
When this option is set, instead of inserting theusing
statement itself, YCMwill set the global variableg:ycm_namespace_to_insert
to the namespace toinsert, and then evaluate this option's value as an expression. The option'sexpression is responsible for inserting the namespace - the default insertionwill not occur.
Default: ''
letg:ycm_csharp_insert_namespace_expr=''
When this option is set to1
, YCM will add thepreview
string to Vim'scompleteopt
option (see:h completeopt
). If yourcompleteopt
optionalready haspreview
set, there will be no effect. Alternatively, when set topopup
and your version of Vim supports popup windows (see:help popup
), thepopup
string will be used instead. You can see the current state of yourcompleteopt
setting with:set completeopt?
(yes, the question mark isimportant).
Whenpreview
is present incompleteopt
, YCM will use thepreview
window atthe top of the file to store detailed information about the current completioncandidate (but only if the candidate came from the semantic engine). Forinstance, it would show the full function prototype and all the functionoverloads in the window if the current completion is a function name.
Whenpopup
is present incompleteopt
, YCM will instead use apopup
window to the side of the completion popup for storing detailed informationabout the current completion candidate. In addition, YCM may truncate thedetailed completion information in order to give the popup sufficient roomto display that detailed information.
Default:0
letg:ycm_add_preview_to_completeopt=0
When this option is set to1
, YCM will auto-close thepreview
window afterthe user accepts the offered completion string. If there is nopreview
windowtriggered because there is nopreview
string incompleteopt
, this option isirrelevant. See theg:ycm_add_preview_to_completeopt
option for more details.
Default:0
letg:ycm_autoclose_preview_window_after_completion=0
When this option is set to1
, YCM will auto-close thepreview
window afterthe user leaves insert mode. This option is irrelevant ifg:ycm_autoclose_preview_window_after_completion
is set or if nopreview
window is triggered. See theg:ycm_add_preview_to_completeopt
option for moredetails.
Default:0
letg:ycm_autoclose_preview_window_after_insertion=0
This option controls the maximum number of diagnostics shown to the user whenerrors or warnings are detected in the file. This option is only relevant forthe C-family, C#, Java, JavaScript, and TypeScript languages.
A special value of0
means there is no limit.
Default:30
letg:ycm_max_diagnostics_to_display=30
This option controls the key mappings used to select the first completionstring. Invoking any of them repeatedly cycles forward through the completionlist.
Some users like adding<Enter>
to this list.
Default:['<TAB>', '<Down>']
letg:ycm_key_list_select_completion= ['<TAB>','<Down>']
This option controls the key mappings used to select the previous completionstring. Invoking any of them repeatedly cycles backward through the completionlist.
Note that one of the defaults is<S-TAB>
which means Shift-TAB. That mappingwill probably only work in GUI Vim (Gvim or MacVim) and not in plain console Vimbecause the terminal usually does not forward modifier key combinations to Vim.
Default:['<S-TAB>', '<Up>']
letg:ycm_key_list_previous_completion= ['<S-TAB>','<Up>']
This option controls the key mappings used to close the completion menu. This isuseful when the menu is blocking the view, when you need to insert the<TAB>
character, or when you want to expand a snippet fromUltiSnips and navigatethrough it.
Default:['<C-y>']
letg:ycm_key_list_stop_completion= ['<C-y>']
This option controls the key mapping used to invoke the completion menu forsemantic completion. By default, semantic completion is triggered automaticallyafter typing characters appropriate for the language, such as.
,->
,::
,etc. in insert mode (if semantic completion support has been compiled in). Thiskey mapping can be used to trigger semantic completion anywhere. Useful forsearching for top-level functions and classes.
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 whenyou're editing in console Vim, and<C-Space>
in GUI Vim. This means that youcan just press<C-Space>
in both the console and GUI Vim and YCM will do the rightthing.
Setting this option to an empty string will make sure no mapping is created.
Default:<C-Space>
letg:ycm_key_invoke_completion='<C-Space>'
This option controls the key mapping used to show the full diagnostic text whenthe 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.
If you prefer the detailed diagnostic to be shown in a popup, thenlet g:ycm_show_detailed_diag_in_popup=1
.
Default:<leader>d
letg:ycm_key_detailed_diagnostics='<leader>d'
Makes:YcmShowDetailedDiagnostic
always show in a popup rather than echoing tothe command line.
Default: 0
letg:ycm_show_detailed_diag_in_popup=0
Normally, YCM searches for a.ycm_extra_conf.py
file for compilation flags(see the User Guide for more details on how this works). This option specifiesa fallback path to a config file which is used if no.ycm_extra_conf.py
isfound.
You can place such a global file anywhere in your filesystem.
Default:''
letg:ycm_global_ycm_extra_conf=''
When this option is set to1
YCM will ask once per.ycm_extra_conf.py
fileif it is safe to be loaded. This is to prevent the execution of malicious codefrom a.ycm_extra_conf.py
file you didn't write.
To selectively get YCM to ask/not ask about loading certain.ycm_extra_conf.py
files, see theg:ycm_extra_conf_globlist
option.
Default:1
letg:ycm_confirm_extra_conf=1
This option is a list that may contain several globbing patterns. If a patternstarts with a!
all.ycm_extra_conf.py
files matching that pattern will beblacklisted, that is they won't be loaded and no confirmation dialog will beshown. If a pattern does not start with a!
all files matching that patternwill be whitelisted. Note that this option is not used when confirmation isdisabled usingg:ycm_confirm_extra_conf
and that items earlier in the listwill 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:
letg:ycm_extra_conf_globlist= ['~/dev/*','!~/*']
- 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 excludingthe
~/dev
directory will be blacklisted.
NOTE: The glob pattern is first expanded with Python'sos.path.expanduser()
and then resolved withos.path.abspath()
before beingmatched against the filename.
Default:[]
letg:ycm_extra_conf_globlist= []
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 beingrelative to Vim's current working directory.
Default:0
letg:ycm_filepath_completion_use_working_dir=0
This option controls the character-based triggers for the various semanticcompletion engines. The option holds a dictionary of key-values, where the keysare Vim's filetype strings delimited by commas and values are lists of strings,where the strings are the triggers.
Setting key-value pairs on the dictionaryadds semantic triggers to theinternal default set (listed below). You cannot remove the default triggers,only add new ones.
A "trigger" is a sequence of one or more characters that trigger semanticcompletion when typed. For instance, C++ (cpp
filetype) has.
listed as atrigger. So when the user typesfoo.
, the semantic engine will trigger andservefoo
's list of member functions and variables. Since C++ also has->
listed as a trigger, the same thing would happen when the user typedfoo->
.
It's also possible to use a regular expression as a trigger. You have to prefixyour trigger withre!
to signify it's a regex trigger. For instance,re!\w+\.
would only trigger after the\w+\.
regex matches.
NOTE: The regex syntax isNOT Vim's, it'sPython's.
Default:[see next line]
letg:ycm_semantic_triggers= {\'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': [':'],\}
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 unsettingthis option you can ensure that the omnicompletion engine is re-queried on everykeypress. That will ensure all completions will be presented but might causestuttering and lag if the omnifunc is slow.
Default:1
letg:ycm_cache_omnifunc=1
By default, YCM will query the UltiSnips plugin for possible completions ofsnippet triggers. This option can turn that behavior off.
Default:1
letg:ycm_use_ultisnips_completer=1
Defines whereGoTo*
commands result should be opened. Can take one of thefollowing values:'same-buffer'
,'split'
, or'split-or-existing-window'
.If this option is set to the'same-buffer'
but current buffer can not beswitched (when buffer is modified andnohidden
option is set), then resultwill be opened in a split. When the option is set to'split-or-existing-window'
, if the result is already open in a window of thecurrent tab page (or any tab pages with the:tab
modifier; see below), it willjump to that window. Otherwise, the result will be opened in a split as if theoption was set to'split'
.
To customize the way a new window is split, prefix theGoTo*
command with oneof the following modifiers::aboveleft
,:belowright
,:botright
,:leftabove
,:rightbelow
,:topleft
, and:vertical
. For instance, tosplit vertically to the right of the current window, run the command:
:rightbelowvertical YcmCompleter GoTo
To open in a new tab page, use the:tab
modifier with the'split'
or'split-or-existing-window'
options e.g.:
:tab YcmCompleter GoTo
Default:'same-buffer'
letg:ycm_goto_buffer_command='same-buffer'
Defines the max size (in Kb) for a file to be considered for completion. If thisoption is set to 0 then no check is made on the size of the file you're opening.
Default: 1000
letg:ycm_disable_for_files_larger_than_kb=1000
This option controls whetherclangd should be used as a completion engine forC-family languages. Can take one of the following values:1
,0
, withmeanings:
1
: YCM will use clangd if clangd binary exists in third party or it wasprovided withycm_clangd_binary_path
option.0
: YCM will never use clangd completer.
Default:1
letg:ycm_use_clangd=1
Whenycm_use_clangd
option is set to1
, this option sets the path toclangd binary.
Default:''
letg:ycm_clangd_binary_path=''
This option controls the command line arguments passed to the clangd binary. Itappends new options and overrides the existing ones.
Default:[]
letg:ycm_clangd_args= []
This option controls which ranking and filtering algorithm to use for completionitems. It can take values:
1
: Uses ycmd's caching and filtering logic.0
: Uses clangd's caching and filtering logic.
Default:1
letg:ycm_clangd_uses_ycmd_caching=1
This option lets YCM use an arbitrary Language Server Protocol (LSP) server, notunlike many other completion systems. The officially supported completers arefavoured over custom LSP ones, so overriding an existing completer means firstmaking 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".
Many working examples can be found in the YCMlsp-examples repo.
Default:[]
letg:ycm_language_server= []
This option allows you to disable all signature help for all completion engines.There is no way to disable it per-completer.
Default:0
" Disable signature helpletg:ycm_disable_signature_help=1
Set this to 1 to disable syntax highlighting in the signature help popup. Thiiscan help if your colourscheme doesn't work well with the default highliting andinverse video.
Default:0
" Disable signature help syntax highlitingletg:ycm_signature_help_disable_syntax=1
In case the system-widegopls
binary is newer than the bundled one, settingthis option to the path of the system-widegopls
would make YCM use that oneinstead.
If the path is justgopls
, YCM will search in$PATH
.
Similar totheg:ycm_clangd_args
, this option allowspassing additional flags to thegopls
command line.
Default:[]
letg:ycm_gopls_args= []
YCM no longer uses RLS for rust, and these options are therefore no longersupported.
To use a custom rust-analyzer, seeg:ycm_rust_toolchain_root
.
Optionally specify the path to a custom rust toolchain including at least asupported version ofrust-analyzer
.
Similar tothegopls
path, this optiontells YCM where is the TSServer executable located.
Similar tothegopls
path, this optiontells YCM where is the Omnisharp-Roslyn executable located.
With async diagnostics, LSP servers might send new diagnostics mid-typing.If seeing these new diagnostics while typing is not desired, this option canbe set to 0.
When this option is set to0
, diagnostic signs, virtual text, and highlightsare cleared when entering insert mode and replaced when leaving insert mode.This reduces visual noise while editing.
In addition, this option is recommended wheng:ycm_echo_current_diagnostic
isset tovirtual-text
as it prevents updating the virtual text while you aretyping.
Default:1
letg:ycm_update_diagnostics_in_insert_mode=1
The FAQ section has been moved to thewiki.
Please note that this project is released with aContributor Code ofConduct. By participating in this project you agree to abide by itsterms.
If you have questions about the plugin or need help, please join theGitterroom or use theycm-users mailing list.
If you have bug reports or feature suggestions, please use theissuetracker. Before you do, please carefully readCONTRIBUTING.md as this asks for important diagnostics whichthe team will use to help get you going.
The latest version of the plugin is available athttps://ycm-core.github.io/YouCompleteMe/.
The author's homepage ishttps://val.markovic.io.
Please doNOT go to #vim, Reddit, or Stack Overflow for support. Pleasecontact the YouCompleteMe maintainers directly using thecontactdetails.
This software is licensed under theGPL v3 license.© 2015-2018 YouCompleteMe contributors
If you like YCM so much that you're willing to part with your hard-earned cash, please consider donating to one of the following charities, which are meaningful to the current maintainers (in no particular order):
- Hector's Greyhound Rescue
- Be Humane
- Cancer Research UK
- ICCF Holland
- Any charity of your choosing.
Please note: The YCM maintainers do not specifically endorse nor necessarily have any relationship with the above charities. Disclosure: It is noted that one key maintainer is a family with Trustees of Greyhound Rescue Wales.