index.html 151 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594
  1. <!DOCTYPE html>
  2. <html><head>
  3. <meta charset="utf-8"/>
  4. <meta content="chrome=1" http-equiv="X-UA-Compatible"/>
  5. <title>YouCompleteMe by Valloric</title>
  6. <link href="stylesheets/styles.css" rel="stylesheet"/>
  7. <link href="stylesheets/pygment_trac.css" rel="stylesheet"/>
  8. <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  9. <script src="javascripts/respond.js"></script>
  10. <!--[if lt IE 9]>
  11. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  12. <![endif]-->
  13. <!--[if lt IE 8]>
  14. <link rel="stylesheet" href="stylesheets/ie.css">
  15. <![endif]-->
  16. <meta content="width=device-width, initial-scale=1, user-scalable=no" name="viewport"/>
  17. </head>
  18. <body>
  19. <div class="wrapper">
  20. <section>
  21. <div id="title">
  22. <h1>YouCompleteMe</h1>
  23. <p>A code-completion engine for Vim</p>
  24. <hr/>
  25. <span class="credits left">Project maintained by <a href="https://github.com/Valloric">Valloric</a></span>
  26. <span class="credits right">Hosted on GitHub Pages — Theme by <a href="http://twitter.com/#!/michigangraham">mattgraham</a></span>
  27. </div>
  28. <div id="markdown-output"><p><a href="https://gitter.im/Valloric/YouCompleteMe"><img alt="Gitter room" src="https://img.shields.io/gitter/room/Valloric/YouCompleteMe.svg"/></a>
  29. <a href="https://dev.azure.com/YouCompleteMe/YCM/_build?definitionId=3&amp;branchName=master"><img alt="Build status" src="https://dev.azure.com/YouCompleteMe/YCM/_apis/build/status/ycm-core.YouCompleteMe?branchName=master"/></a>
  30. <a href="https://codecov.io/gh/ycm-core/YouCompleteMe"><img alt="Coverage status" src="https://img.shields.io/codecov/c/github/ycm-core/YouCompleteMe/master.svg"/></a></p><h2 id="warning-support-for-python-35-has-ended">Warning: Support for Python 3.5 has ended</h2><p>In mid 2020, YCM dropped support for Python 3.5 runtime.</p><p>Why?</p><p>On 13th September 2020, Python 3.5 will be officially end of life. And therefore, so
  31. will its relationship with YouCompleteMe and ycmd.</p><p>Looking for Python 2 support? Check the <a href="https://github.com/ycm-core/YouCompleteMe/wiki/Python-2">Wiki</a>.</p><h2 id="help-advice-support">Help, Advice, Support</h2><p>Looking for help, advice or support? Having problems getting YCM to work?</p><p>First carefully read the <a href="#installation">installation instructions</a> for your OS.
  32. We recommend you use the supplied <code>install.py</code>.</p><p>Next check the <a href="#user-guide">User Guide</a> section on the semantic completer that
  33. you are using. For C/C++/Objective-C/Objective-C++/CUDA, you <em>must</em> read <a href="#c-family-semantic-completion">this
  34. section</a>.</p><p>Finally, check the <a href="https://github.com/ycm-core/YouCompleteMe/wiki/FAQ">FAQ</a>.</p><p>If, after reading the installation and user guides, and checking the FAQ, you're
  35. still having trouble, check the <a href="#contact">contacts</a> section below for how to
  36. get in touch.</p><p>Please do <strong>NOT</strong> go to #vim on freenode for support. Please contact the
  37. YouCompleteMe maintainers directly using the <a href="#contact">contact details</a> below.</p><h2 id="contents">Contents</h2><ul>
  38. <li><a href="#intro">Intro</a></li>
  39. <li><a href="#installation">Installation</a><ul>
  40. <li><a href="#macos">macOS</a></li>
  41. <li><a href="#linux-64-bit">Linux 64-bit</a></li>
  42. <li><a href="#windows">Windows</a></li>
  43. <li><a href="#freebsdopenbsd">FreeBSD/OpenBSD</a></li>
  44. <li><a href="#full-installation-guide">Full Installation Guide</a></li>
  45. </ul>
  46. </li>
  47. <li><a href="#quick-feature-summary">Quick Feature Summary</a></li>
  48. <li><a href="#user-guide">User Guide</a><ul>
  49. <li><a href="#general-usage">General Usage</a></li>
  50. <li><a href="#client-server-architecture">Client-Server Architecture</a></li>
  51. <li><a href="#completion-string-ranking">Completion String Ranking</a></li>
  52. <li><a href="#general-semantic-completion">General Semantic Completion</a></li>
  53. <li><a href="#c-family-semantic-completion">C-family Semantic Completion</a></li>
  54. <li><a href="#java-semantic-completion">Java Semantic Completion</a></li>
  55. <li><a href="#c-semantic-completion">C# Semantic Completion</a></li>
  56. <li><a href="#python-semantic-completion">Python Semantic Completion</a></li>
  57. <li><a href="#rust-semantic-completion">Rust Semantic Completion</a></li>
  58. <li><a href="#go-semantic-completion">Go Semantic Completion</a></li>
  59. <li><a href="#javascript-and-typescript-semantic-completion">JavaScript and TypeScript Semantic Completion</a></li>
  60. <li><a href="#semantic-completion-for-other-languages">Semantic Completion for Other Languages</a></li>
  61. <li><a href="#lsp-configuration">LSP Configuration</a></li>
  62. <li><a href="#writing-new-semantic-completers">Writing New Semantic Completers</a></li>
  63. <li><a href="#diagnostic-display">Diagnostic Display</a><ul>
  64. <li><a href="#diagnostic-highlighting-groups">Diagnostic Highlighting Groups</a></li>
  65. </ul>
  66. </li>
  67. </ul>
  68. </li>
  69. <li><a href="#commands">Commands</a><ul>
  70. <li><a href="#ycmcompleter-subcommands">YcmCompleter subcommands</a><ul>
  71. <li><a href="#goto-commands">GoTo Commands</a></li>
  72. <li><a href="#semantic-information-commands">Semantic Information Commands</a></li>
  73. <li><a href="#refactoring-commands">Refactoring Commands</a></li>
  74. <li><a href="#miscellaneous-commands">Miscellaneous Commands</a></li>
  75. </ul>
  76. </li>
  77. </ul>
  78. </li>
  79. <li><a href="#functions">Functions</a></li>
  80. <li><a href="#autocommands">Autocommands</a></li>
  81. <li><a href="#options">Options</a></li>
  82. <li><a href="#faq">FAQ</a></li>
  83. <li><a href="#contributor-code-of-conduct">Contributor Code of Conduct</a></li>
  84. <li><a href="#contact">Contact</a></li>
  85. <li><a href="#license">License</a></li>
  86. </ul><h2 id="intro">Intro</h2><p>YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for
  87. <a href="https://www.vim.org/">Vim</a>. It has several completion engines:</p><ul>
  88. <li>an identifier-based engine that works with every programming language,</li>
  89. <li>a powerful <a href="https://clang.llvm.org/extra/clangd.html">clangd</a>-based engine that provides native semantic code
  90. completion for C/C++/Objective-C/Objective-C++/CUDA (from now on referred to
  91. as "the C-family languages"),</li>
  92. <li>a <a href="https://github.com/davidhalter/jedi">Jedi</a>-based completion engine for Python 2 and 3,</li>
  93. <li>an <a href="https://github.com/OmniSharp/omnisharp-roslyn">OmniSharp-Roslyn</a>-based completion engine for C#,</li>
  94. <li>a <a href="https://github.com/golang/go/wiki/gopls">Gopls</a>-based completion engine for Go,</li>
  95. <li>a <a href="https://github.com/Microsoft/TypeScript/tree/master/src/server">TSServer</a>-based completion engine for JavaScript and TypeScript,</li>
  96. <li>a <a href="https://github.com/rust-lang/rls">rls</a>-based completion engine for Rust,</li>
  97. <li>a <a href="https://github.com/eclipse/eclipse.jdt.ls">jdt.ls</a>-based completion engine for Java.</li>
  98. <li>a <a href="#plugging-an-arbitrary-lsp-server">generic Language Server Protocol implementation for any language</a></li>
  99. <li>and an omnifunc-based completer that uses data from Vim's omnicomplete system
  100. to provide semantic completions for many other languages (Ruby, PHP etc.).</li>
  101. </ul><p><img alt="YouCompleteMe GIF completion demo" src="https://i.imgur.com/0OP4ood.gif"/></p><p>Here's an explanation of what happens in the last GIF demo above.</p><p>First, realize that <strong>no keyboard shortcuts had to be pressed</strong> to get the list
  102. of completion candidates at any point in the demo. The user just types and the
  103. suggestions pop up by themselves. If the user doesn't find the completion
  104. suggestions relevant and/or just wants to type, they can do so; the completion
  105. engine will not interfere.</p><p>When the user sees a useful completion string being offered, they press the TAB
  106. key to accept it. This inserts the completion string. Repeated presses of the
  107. TAB key cycle through the offered completions.</p><p>If the offered completions are not relevant enough, the user can continue typing
  108. to further filter out unwanted completions.</p><p>A critical thing to notice is that the completion <strong>filtering is NOT based on
  109. the input being a string prefix of the completion</strong> (but that works too). The
  110. input needs to be a <em><a href="https://en.wikipedia.org/wiki/Subsequence">subsequence</a> match</em> of a completion. This is a fancy way
  111. of saying that any input characters need to be present in a completion string in
  112. the order in which they appear in the input. So <code>abc</code> is a subsequence of
  113. <code>xaybgc</code>, but not of <code>xbyxaxxc</code>. After the filter, a complicated sorting system
  114. ranks the completion strings so that the most relevant ones rise to the top of
  115. the menu (so you usually need to press TAB just once).</p><p><strong>All of the above works with any programming language</strong> because of the
  116. identifier-based completion engine. It collects all of the identifiers in the
  117. current file and other files you visit (and your tags files) and searches them
  118. when you type (identifiers are put into per-filetype groups).</p><p>The demo also shows the semantic engine in use. When the user presses <code>.</code>, <code>-&gt;</code>
  119. or <code>::</code> while typing in insert mode (for C++; different triggers are used for
  120. other languages), the semantic engine is triggered (it can also be triggered
  121. with a keyboard shortcut; see the rest of the docs).</p><p>The last thing that you can see in the demo is YCM's diagnostic display features
  122. (the little red X that shows up in the left gutter; inspired by <a href="https://github.com/scrooloose/syntastic">Syntastic</a>)
  123. if you are editing a C-family file. As the completer engine compiles your file
  124. and detects warnings or errors, they will be presented in various ways. You
  125. don't need to save your file or press any keyboard shortcut to trigger this, it
  126. "just happens" in the background.</p><p>In essence, YCM obsoletes the following Vim plugins because it has all of their
  127. features plus extra:</p><ul>
  128. <li>clang_complete</li>
  129. <li>AutoComplPop</li>
  130. <li>Supertab</li>
  131. <li>neocomplcache</li>
  132. </ul><p><strong>And that's not all...</strong></p><p>YCM might be the only vim completion engine with the correct Unicode support.
  133. Though we do assume UTF-8 everywhere.</p><p><img alt="YouCompleteMe GIF unicode demo" src="https://user-images.githubusercontent.com/10026824/34471853-af9cf32a-ef53-11e7-8229-de534058ddc4.gif"/></p><p>YCM also provides <a href="#quick-feature-summary">semantic IDE-like features</a> in a
  134. number of languages, including:</p><ul>
  135. <li>displaying signature help (argument hints) when entering the arguments to a
  136. function call (Vim only)</li>
  137. <li><a href="#goto-commands">finding declarations, definitions, usages</a>, etc.
  138. of identifiers,</li>
  139. <li><a href="#the-gettype-subcommand">displaying type information</a> for classes,
  140. variables, functions etc.,</li>
  141. <li>displaying documentation for methods, members, etc. in the <a href="#the-getdoc-subcommand">preview
  142. window</a>, or in a
  143. <a href="#the-gycm_auto_hover-option">popup next to the cursor</a> (Vim only)</li>
  144. <li><a href="#the-fixit-subcommand">fixing common coding errors</a>, like missing
  145. semi-colons, typos, etc.,</li>
  146. <li><a href="#the-refactorrename-subcommand">semantic renaming</a> of variables across files,</li>
  147. <li>formatting code,</li>
  148. <li>removing unused imports, sorting imports, etc.</li>
  149. </ul><p>For example, here's a demo of signature help:</p><p><img alt="Signature Help Early Demo" src="https://user-images.githubusercontent.com/10584846/58738348-5060da80-83fd-11e9-9537-d07fdbf4554c.gif"/></p><p>Below we can see YCM being able to do a few things:</p><ul>
  150. <li>Retrieve references across files</li>
  151. <li>Go to declaration/definition</li>
  152. <li>Expand <code>auto</code> in C++</li>
  153. <li>Fix some common errors with <code>FixIt</code></li>
  154. <li>Not shown in the gif is <code>GoToImplementation</code> and <code>GoToType</code>
  155. for servers that support it.</li>
  156. </ul><p><img alt="YouCompleteMe GIF subcommands demo" src="https://i.imgur.com/nmUUbdl.gif"/></p><p>And here's some documentation being shown in a hover popup, automatically and
  157. manually:</p><p><img alt="hover demo" src="https://user-images.githubusercontent.com/10584846/80312146-91af6500-87db-11ea-996b-7396f3134d1f.gif"/></p><p>Features vary by file type, so make sure to check out the <a href="#quick-feature-summary">file type feature
  158. summary</a> and the
  159. <a href="#ycmcompleter-subcommands">full list of completer subcommands</a> to
  160. find out what's available for your favourite languages.</p><p>You'll also find that YCM has filepath completers (try typing <code>./</code> in a file)
  161. and a completer that integrates with <a href="https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt">UltiSnips</a>.</p><h2 id="installation">Installation</h2><h3 id="macos">macOS</h3><h4 id="quick-start-installing-all-completers">Quick start, installing all completers</h4><ul>
  162. <li>Install YCM plugin via <a href="https://github.com/VundleVim/Vundle.vim#about">Vundle</a></li>
  163. <li>Install cmake, macvim and python; Note that the <em>system</em> vim is not supported.</li>
  164. </ul><p> </p><pre><code>brew install cmake macvim python
  165. </code></pre><ul>
  166. <li>Install mono, go, node and npm</li>
  167. </ul><p> </p><pre><code>brew install mono go nodejs
  168. </code></pre><ul>
  169. <li>Compile YCM</li>
  170. </ul><p> </p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  171. python3 install.py --all
  172. </code></pre><ul>
  173. <li>For plugging an arbitrary LSP server, check <a href="#plugging-an-arbitrary-lsp-server">the relevant section</a></li>
  174. </ul><h4 id="explanation-for-the-quick-start">Explanation for the quick start</h4><p>These instructions (using <code>install.py</code>) are the quickest way to install
  175. YouCompleteMe, however they may not work for everyone. If the following
  176. instructions don't work for you, check out the <a href="#full-installation-guide">full installation
  177. guide</a>.</p><p><a href="https://macvim-dev.github.io/macvim/">MacVim</a> is required. YCM won't work with the pre-installed Vim from Apple as
  178. its Python support is broken. If you don't already use <a href="https://macvim-dev.github.io/macvim/">MacVim</a>, install it
  179. with <a href="https://brew.sh">Homebrew</a>. Install CMake as well:</p><pre><code>brew install cmake macvim
  180. </code></pre><p>Install YouCompleteMe with <a href="https://github.com/VundleVim/Vundle.vim#about">Vundle</a>.</p><p><strong>Remember:</strong> YCM is a plugin with a compiled component. If you <strong>update</strong> YCM
  181. using Vundle and the <code>ycm_core</code> library APIs have changed (happens
  182. rarely), YCM will notify you to recompile it. You should then rerun the install
  183. process.</p><p><strong>NOTE:</strong> If you want C-family completion, you MUST have the latest Xcode
  184. installed along with the latest Command Line Tools (they are installed
  185. automatically when you run <code>clang</code> for the first time, or manually by running
  186. <code>xcode-select --install</code>)</p><p>Compiling YCM <strong>with</strong> semantic support for C-family languages through
  187. <strong>clangd</strong>:</p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  188. ./install.py --clangd-completer
  189. </code></pre><p>Compiling YCM <strong>without</strong> semantic support for C-family languages:</p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  190. ./install.py
  191. </code></pre><p>The following additional language support options are available:</p><ul>
  192. <li>C# support: install Mono with <a href="https://brew.sh">Homebrew</a> or by downloading the <a href="https://www.mono-project.com/docs/getting-started/install/mac/">Mono
  193. macOS package</a> and add <code>--cs-completer</code> when calling
  194. <code>install.py</code>.</li>
  195. <li>Go support: install <a href="https://golang.org/doc/install">Go</a> and add <code>--go-completer</code> when calling
  196. <code>install.py</code>.</li>
  197. <li>JavaScript and TypeScript support: install <a href="https://docs.npmjs.com/getting-started/installing-node#1-install-nodejs--npm">Node.js and npm</a> and
  198. add <code>--ts-completer</code> when calling <code>install.py</code>.</li>
  199. <li>Rust support: add <code>--rust-completer</code> when calling <code>install.py</code>.</li>
  200. <li>Java support: install <a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">JDK8 (version 8 required)</a> and add
  201. <code>--java-completer</code> when calling <code>install.py</code>.</li>
  202. </ul><p>To simply compile with everything enabled, there's a <code>--all</code> flag. You need to
  203. specify it manually by adding <code>--clangd-completer</code>. So, to install with all
  204. language features, ensure <code>xbuild</code>, <code>go</code>, <code>node</code> and <code>npm</code> tools
  205. are installed and in your <code>PATH</code>, then simply run:</p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  206. ./install.py --all
  207. </code></pre><p>That's it. You're done. Refer to the <em>User Guide</em> section on how to use YCM.
  208. Don't forget that if you want the C-family semantic completion engine to work,
  209. you will need to provide the compilation flags for your project to YCM. It's all
  210. in the User Guide.</p><p>YCM comes with sane defaults for its options, but you still may want to take a
  211. look at what's available for configuration. There are a few interesting options
  212. that are conservatively turned off by default that you may want to turn on.</p><h3 id="linux-64-bit">Linux 64-bit</h3><h4 id="quick-start-installing-all-completers">Quick start, installing all completers</h4><ul>
  213. <li>Install YCM plugin via <a href="https://github.com/VundleVim/Vundle.vim#about">Vundle</a></li>
  214. <li>Install cmake, vim and python</li>
  215. </ul><p> </p><pre><code>apt install build-essential cmake vim python3-dev
  216. </code></pre><ul>
  217. <li>Install mono-complete, go, node and npm</li>
  218. <li>Compile YCM</li>
  219. </ul><p> </p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  220. python3 install.py --all
  221. </code></pre><ul>
  222. <li>For plugging an arbitrary LSP server, check <a href="#plugging-an-arbitrary-lsp-server">the relevant section</a></li>
  223. </ul><h4 id="explanation-for-the-quick-start">Explanation for the quick start</h4><p>These instructions (using <code>install.py</code>) are the quickest way to install
  224. YouCompleteMe, however they may not work for everyone. If the following
  225. instructions don't work for you, check out the <a href="#full-installation-guide">full installation
  226. guide</a>.</p><p>Make sure you have Vim 7.4.1578 with Python 3 support. The Vim
  227. package on Fedora 27 and later and the pre-installed Vim on Ubuntu 16.04 and
  228. later are recent enough. You can see the version of Vim installed by running
  229. <code>vim --version</code>. If the version is too old, you may need to <a href="https://github.com/ycm-core/YouCompleteMe/wiki/Building-Vim-from-source">compile Vim from
  230. source</a> (don't worry, it's easy).</p><p><strong>NOTE</strong>: For all features, such as signature help, use Vim 8.1.1875 or later.</p><p>Install YouCompleteMe with <a href="https://github.com/VundleVim/Vundle.vim#about">Vundle</a>.</p><p><strong>Remember:</strong> YCM is a plugin with a compiled component. If you <strong>update</strong> YCM
  231. using Vundle and the <code>ycm_core</code> library APIs have changed (happens rarely), YCM
  232. will notify you to recompile it. You should then rerun the install process.</p><p>Install development tools, CMake, and Python headers:</p><ul>
  233. <li>Fedora 27 and later:</li>
  234. </ul><p> </p><pre><code> sudo dnf install cmake gcc-c++ make python3-devel
  235. </code></pre><ul>
  236. <li>Ubuntu 14.04:</li>
  237. </ul><p> </p><pre><code> sudo apt install build-essential cmake3 python3-dev
  238. </code></pre><ul>
  239. <li>Ubuntu 16.04 and later:</li>
  240. </ul><p> </p><pre><code> sudo apt install build-essential cmake python3-dev
  241. </code></pre><p>Compiling YCM <strong>with</strong> semantic support for C-family languages through
  242. <strong>clangd</strong>:</p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  243. python3 install.py --clangd-completer
  244. </code></pre><p>Compiling YCM <strong>without</strong> semantic support for C-family languages:</p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  245. python3 install.py
  246. </code></pre><p>The following additional language support options are available:</p><ul>
  247. <li>C# support: install <a href="https://www.mono-project.com/download/stable/#download-lin">Mono</a> and add <code>--cs-completer</code>
  248. when calling <code>install.py</code>.</li>
  249. <li>Go support: install <a href="https://golang.org/doc/install">Go</a> and add <code>--go-completer</code> when calling
  250. <code>install.py</code>.</li>
  251. <li>JavaScript and TypeScript support: install <a href="https://docs.npmjs.com/getting-started/installing-node#1-install-nodejs--npm">Node.js and npm</a> and
  252. add <code>--ts-completer</code> when calling <code>install.py</code>.</li>
  253. <li>Rust support: add <code>--rust-completer</code> when calling <code>install.py</code>.</li>
  254. <li>Java support: install <a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">JDK8 (version 8 required)</a> and add
  255. <code>--java-completer</code> when calling <code>install.py</code>.</li>
  256. </ul><p>To simply compile with everything enabled, there's a <code>--all</code> flag. You need to
  257. specify it manually by adding <code>--clangd-completer</code>. So, to install with all
  258. language features, ensure <code>xbuild</code>, <code>go</code>, <code>node</code>, <code>npm</code> and tools
  259. are installed and in your <code>PATH</code>, then simply run:</p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  260. python3 install.py --all
  261. </code></pre><p>That's it. You're done. Refer to the <em>User Guide</em> section on how to use YCM.
  262. Don't forget that if you want the C-family semantic completion engine to work,
  263. you will need to provide the compilation flags for your project to YCM. It's all
  264. in the User Guide.</p><p>YCM comes with sane defaults for its options, but you still may want to take a
  265. look at what's available for configuration. There are a few interesting options
  266. that are conservatively turned off by default that you may want to turn on.</p><h3 id="windows">Windows</h3><h4 id="quick-start-installing-all-completers">Quick start, installing all completers</h4><ul>
  267. <li>Install YCM plugin via <a href="https://github.com/VundleVim/Vundle.vim#about">Vundle</a></li>
  268. <li>Install <a href="https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&amp;rel=15">Visual Studio Build Tools 2017</a></li>
  269. <li>Install cmake, vim and python</li>
  270. <li>Install go, node and npm</li>
  271. <li>Compile YCM</li>
  272. </ul><p> </p><pre><code>cd YouCompleteMe
  273. python3 install.py --all
  274. </code></pre><ul>
  275. <li>Add <code>set encoding=utf-8</code> to your <a href="https://vimhelp.appspot.com/starting.txt.html#vimrc">vimrc</a></li>
  276. <li>For plugging an arbitrary LSP server, check <a href="#plugging-an-arbitrary-lsp-server">the relevant section</a></li>
  277. </ul><h4 id="explanation-for-the-quick-start">Explanation for the quick start</h4><p>These instructions (using <code>install.py</code>) are the quickest way to install
  278. YouCompleteMe, however they may not work for everyone. If the following
  279. instructions don't work for you, check out the <a href="#full-installation-guide">full installation
  280. guide</a>.</p><p><strong>Important:</strong> we assume that you are using the <code>cmd.exe</code> command prompt and
  281. that you know how to add an executable to the PATH environment variable.</p><p>Make sure you have at least Vim 7.4.1578 with Python 3 support. You
  282. can check the version and which Python is supported by typing <code>:version</code> inside
  283. Vim. Look at the features included: <code>+python3/dyn</code> for Python 3.
  284. Take note of the Vim architecture, i.e. 32 or
  285. 64-bit. It will be important when choosing the Python installer. We recommend
  286. using a 64-bit client. <a href="https://github.com/vim/vim-win32-installer/releases">Daily updated installers of 32-bit and 64-bit Vim with
  287. Python 3 support</a> are available.</p><p><strong>NOTE</strong>: For all features, such as signature help, use Vim 8.1.1875 or later.</p><p>Add the line:</p><pre><code>set encoding=utf-8
  288. </code></pre><p>to your <a href="https://vimhelp.appspot.com/starting.txt.html#vimrc">vimrc</a> if not already present. This option is required by YCM. Note
  289. that it does not prevent you from editing a file in another encoding than UTF-8.
  290. You can do that by specifying <a href="http://vimdoc.sourceforge.net/htmldoc/editing.html#++enc">the <code>++enc</code> argument</a> to the <code>:e</code> command.</p><p>Install YouCompleteMe with <a href="https://github.com/VundleVim/Vundle.vim#about">Vundle</a>.</p><p><strong>Remember:</strong> YCM is a plugin with a compiled component. If you <strong>update</strong> YCM
  291. using Vundle and the <code>ycm_core</code> library APIs have changed (happens
  292. rarely), YCM will notify you to recompile it. You should then rerun the install
  293. process.</p><p>Download and install the following software:</p><ul>
  294. <li><a href="https://www.python.org/downloads/windows/">Python 3</a>. Be sure to pick the version
  295. corresponding to your Vim architecture. It is <em>Windows x86</em> for a 32-bit Vim
  296. and <em>Windows x86-64</em> for a 64-bit Vim. We recommend installing Python 3.
  297. Additionally, the version of Python you install must match up exactly with
  298. the version of Python that Vim is looking for. Type <code>:version</code> and look at the
  299. bottom of the page at the list of compiler flags. Look for flags that look
  300. similar to <code>-DDYNAMIC_PYTHON3_DLL=\"python36.dll\"</code>. This indicates
  301. that Vim is looking for Python 3.6. You'll need one or the other installed,
  302. matching the version number exactly.</li>
  303. <li><a href="https://cmake.org/download/">CMake</a>. Add CMake executable to the PATH environment
  304. variable.</li>
  305. <li><a href="https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&amp;rel=15">Visual Studio Build Tools 2017</a>. During setup,
  306. select <em>Visual C++ build tools</em> in <em>Workloads</em>.</li>
  307. </ul><p>Compiling YCM <strong>with</strong> semantic support for C-family languages through
  308. <strong>clangd</strong>:</p><pre><code>cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
  309. python install.py --clangd-completer
  310. </code></pre><p>Compiling YCM <strong>without</strong> semantic support for C-family languages:</p><pre><code>cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
  311. python install.py
  312. </code></pre><p>The following additional language support options are available:</p><ul>
  313. <li>C# support: add <code>--cs-completer</code> when calling <code>install.py</code>.
  314. Be sure that <a href="https://stackoverflow.com/questions/6319274/how-do-i-run-msbuild-from-the-command-line-using-windows-sdk-7-1">the build utility <code>msbuild</code> is in your PATH</a>.</li>
  315. <li>Go support: install <a href="https://golang.org/doc/install">Go</a> and add <code>--go-completer</code> when calling
  316. <code>install.py</code>.</li>
  317. <li>JavaScript and TypeScript support: install <a href="https://docs.npmjs.com/getting-started/installing-node#1-install-nodejs--npm">Node.js and npm</a> and
  318. add <code>--ts-completer</code> when calling <code>install.py</code>.</li>
  319. <li>Rust support: add <code>--rust-completer</code> when calling <code>install.py</code>.</li>
  320. <li>Java support: install <a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">JDK8 (version 8 required)</a> and add
  321. <code>--java-completer</code> when calling <code>install.py</code>.</li>
  322. </ul><p>To simply compile with everything enabled, there's a <code>--all</code> flag. You need to
  323. specify it manually by adding <code>--clangd-completer</code>. So, to install with all
  324. language features, ensure <code>msbuild</code>, <code>go</code>, <code>node</code> and <code>npm</code> tools
  325. are installed and in your <code>PATH</code>, then simply run:</p><pre><code>cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
  326. python install.py --all
  327. </code></pre><p>You can specify the Microsoft Visual C++ (MSVC) version using the <code>--msvc</code>
  328. option. YCM officially supports MSVC 14 (Visual Studio 2015), 15 (2017) and
  329. MSVC 16 (Visual Studio 2019).</p><p>That's it. You're done. Refer to the <em>User Guide</em> section on how to use YCM.
  330. Don't forget that if you want the C-family semantic completion engine to work,
  331. you will need to provide the compilation flags for your project to YCM. It's all
  332. in the User Guide.</p><p>YCM comes with sane defaults for its options, but you still may want to take a
  333. look at what's available for configuration. There are a few interesting options
  334. that are conservatively turned off by default that you may want to turn on.</p><h3 id="freebsdopenbsd">FreeBSD/OpenBSD</h3><h4 id="quick-start-installing-all-completers">Quick start, installing all completers</h4><ul>
  335. <li>Install YCM plugin via <a href="https://github.com/VundleVim/Vundle.vim#about">Vundle</a></li>
  336. <li>Install cmake</li>
  337. </ul><p> </p><pre><code>pkg install cmake
  338. </code></pre><ul>
  339. <li>Install xbuild, go, node and npm</li>
  340. <li>Compile YCM</li>
  341. </ul><p> </p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  342. python3 install.py --all
  343. </code></pre><ul>
  344. <li>For plugging an arbitrary LSP server, check <a href="#plugging-an-arbitrary-lsp-server">the relevant section</a></li>
  345. </ul><h4 id="explanation-for-the-quick-start">Explanation for the quick start</h4><p>These instructions (using <code>install.py</code>) are the quickest way to install
  346. YouCompleteMe, however they may not work for everyone. If the following
  347. instructions don't work for you, check out the <a href="#full-installation-guide">full installation
  348. guide</a>.</p><p><strong>NOTE:</strong> OpenBSD / FreeBSD are not officially supported platforms by YCM.</p><p>Make sure you have Vim 7.4.1578 with Python 3 support.</p><p><strong>NOTE</strong>: For all features, such as signature help, use Vim 8.1.1875 or later.</p><p>OpenBSD 5.5 and later have a Vim that's recent enough. You can see the version of
  349. Vim installed by running <code>vim --version</code>.</p><p>For FreeBSD 11.x, the requirement is cmake:</p><pre><code>pkg install cmake
  350. </code></pre><p>Install YouCompleteMe with <a href="https://github.com/VundleVim/Vundle.vim#about">Vundle</a>.</p><p><strong>Remember:</strong> YCM is a plugin with a compiled component. If you <strong>update</strong> YCM
  351. using Vundle and the <code>ycm_core</code> library APIs have changed (happens
  352. rarely), YCM will notify you to recompile it. You should then rerun the install
  353. process.</p><p>Compiling YCM <strong>with</strong> semantic support for C-family languages through
  354. <strong>clangd</strong>:</p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  355. ./install.py --clangd-completer
  356. </code></pre><p>Compiling YCM <strong>without</strong> semantic support for C-family languages:</p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  357. ./install.py
  358. </code></pre><p>If the <code>python</code> executable is not present, or the default <code>python</code> is not the
  359. one that should be compiled against, specify the python interpreter explicitly:</p><pre><code>python3 install.py --clangd-completer
  360. </code></pre><p>The following additional language support options are available:</p><ul>
  361. <li>C# support: install Mono and add <code>--cs-completer</code> when calling
  362. <code>./install.py</code>.</li>
  363. <li>Go support: install <a href="https://golang.org/doc/install">Go</a> and add <code>--go-completer</code> when calling
  364. <code>./install.py</code>.</li>
  365. <li>JavaScript and TypeScript support: install <a href="https://docs.npmjs.com/getting-started/installing-node#1-install-nodejs--npm">Node.js and npm</a> and
  366. add <code>--ts-completer</code> when calling <code>install.py</code>.</li>
  367. <li>Rust support: add <code>--rust-completer</code> when calling <code>./install.py</code>.</li>
  368. <li>Java support: install <a href="https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html">JDK8 (version 8 required)</a> and add
  369. <code>--java-completer</code> when calling <code>./install.py</code>.</li>
  370. </ul><p>To simply compile with everything enabled, there's a <code>--all</code> flag. You need to
  371. specify it manually by adding <code>--clangd-completer</code>. So, to install with all
  372. language features, ensure <code>xbuild</code>, <code>go</code>, <code>node</code>, <code>npm</code> and tools
  373. are installed and in your <code>PATH</code>, then simply run:</p><pre><code>cd ~/.vim/bundle/YouCompleteMe
  374. ./install.py --all
  375. </code></pre><p>That's it. You're done. Refer to the <em>User Guide</em> section on how to use YCM.
  376. Don't forget that if you want the C-family semantic completion engine to work,
  377. you will need to provide the compilation flags for your project to YCM. It's all
  378. in the User Guide.</p><p>YCM comes with sane defaults for its options, but you still may want to take a
  379. look at what's available for configuration. There are a few interesting options
  380. that are conservatively turned off by default that you may want to turn on.</p><h3 id="full-installation-guide">Full Installation Guide</h3><p>The <a href="https://github.com/ycm-core/YouCompleteMe/wiki/Full-Installation-Guide">full installation guide</a> has been moved to the wiki.</p><h2 id="quick-feature-summary">Quick Feature Summary</h2><h3 id="general-all-languages">General (all languages)</h3><ul>
  381. <li>Super-fast identifier completer including tags files and syntax elements</li>
  382. <li>Intelligent suggestion ranking and filtering</li>
  383. <li>File and path suggestions</li>
  384. <li>Suggestions from Vim's OmniFunc</li>
  385. <li>UltiSnips snippet suggestions</li>
  386. </ul><h3 id="c-family-languages-c-c-objective-c-objective-c-cuda">C-family languages (C, C++, Objective C, Objective C++, CUDA)</h3><ul>
  387. <li>Semantic auto-completion with automatic fixes</li>
  388. <li>Signature help</li>
  389. <li>Real-time diagnostic display</li>
  390. <li>Go to include/declaration/definition (<code>GoTo</code>, etc.)</li>
  391. <li>Find Symbol (<code>GoToSymbol</code>)</li>
  392. <li>View documentation comments for identifiers (<code>GetDoc</code>)</li>
  393. <li>Type information for identifiers (<code>GetType</code>)</li>
  394. <li>Automatically fix certain errors (<code>FixIt</code>)</li>
  395. <li>Reference finding (<code>GoToReferences</code>)</li>
  396. <li>Renaming symbols (<code>RefactorRename &lt;new name&gt;</code>)</li>
  397. <li>Code formatting (<code>Format</code>)</li>
  398. </ul><h3 id="c">C♯</h3><ul>
  399. <li>Semantic auto-completion</li>
  400. <li>Signature help</li>
  401. <li>Real-time diagnostic display</li>
  402. <li>Go to declaration/definition (<code>GoTo</code>, etc.)</li>
  403. <li>Go to implementation (<code>GoToImplementation</code>)</li>
  404. <li>Find Symbol (<code>GoToSymbol</code>)</li>
  405. <li>View documentation comments for identifiers (<code>GetDoc</code>)</li>
  406. <li>Type information for identifiers (<code>GetType</code>)</li>
  407. <li>Automatically fix certain errors (<code>FixIt</code>)</li>
  408. <li>Management of OmniSharp-Roslyn server instance</li>
  409. <li>Renaming symbols (<code>RefactorRename &lt;new name&gt;</code>)</li>
  410. <li>Code formatting (<code>Format</code>)</li>
  411. </ul><h3 id="python">Python</h3><ul>
  412. <li>Semantic auto-completion</li>
  413. <li>Signature help</li>
  414. <li>Go to definition (<code>GoTo</code>)</li>
  415. <li>Find Symbol (<code>GoToSymbol</code>)</li>
  416. <li>Reference finding (<code>GoToReferences</code>)</li>
  417. <li>View documentation comments for identifiers (<code>GetDoc</code>)</li>
  418. <li>Type information for identifiers (<code>GetType</code>)</li>
  419. </ul><h3 id="go">Go</h3><ul>
  420. <li>Semantic auto-completion</li>
  421. <li>Signature help</li>
  422. <li>Real-time diagnostic display</li>
  423. <li>Go to declaration/definition (<code>GoTo</code>, etc.)</li>
  424. <li>Go to type definition (<code>GoToType</code>)</li>
  425. <li>Go to implementation (<code>GoToImplementation</code>)</li>
  426. <li>Automatically fix certain errors (<code>FixIt</code>)</li>
  427. <li>View documentation comments for identifiers (<code>GetDoc</code>)</li>
  428. <li>Type information for identifiers (<code>GetType</code>)</li>
  429. <li>Code formatting (<code>Format</code>)</li>
  430. <li>Management of <code>gopls</code> server instance</li>
  431. </ul><h3 id="javascript-and-typescript">JavaScript and TypeScript</h3><ul>
  432. <li>Semantic auto-completion with automatic import insertion</li>
  433. <li>Signature help</li>
  434. <li>Real-time diagnostic display</li>
  435. <li>Go to definition (<code>GoTo</code>, <code>GoToDefinition</code>, and <code>GoToDeclaration</code> are
  436. identical)</li>
  437. <li>Go to type definition (<code>GoToType</code>)</li>
  438. <li>Go to implementation (<code>GoToImplementation</code>)</li>
  439. <li>Find Symbol (<code>GoToSymbol</code>)</li>
  440. <li>Reference finding (<code>GoToReferences</code>)</li>
  441. <li>View documentation comments for identifiers (<code>GetDoc</code>)</li>
  442. <li>Type information for identifiers (<code>GetType</code>)</li>
  443. <li>Automatically fix certain errors (<code>FixIt</code>)</li>
  444. <li>Renaming symbols (<code>RefactorRename &lt;new name&gt;</code>)</li>
  445. <li>Code formatting (<code>Format</code>)</li>
  446. <li>Organize imports (<code>OrganizeImports</code>)</li>
  447. <li>Management of <code>TSServer</code> server instance</li>
  448. </ul><h3 id="rust">Rust</h3><ul>
  449. <li>Semantic auto-completion</li>
  450. <li>Real-time diagnostic display</li>
  451. <li>Go to declaration/definition (<code>GoTo</code>, etc.)</li>
  452. <li>Go to implementation (<code>GoToImplementation</code>)</li>
  453. <li>Reference finding (<code>GoToReferences</code>)</li>
  454. <li>View documentation comments for identifiers (<code>GetDoc</code>)</li>
  455. <li>Automatically fix certain errors (<code>FixIt</code>)</li>
  456. <li>Type information for identifiers (<code>GetType</code>)</li>
  457. <li>Renaming symbols (<code>RefactorRename &lt;new name&gt;</code>)</li>
  458. <li>Code formatting (<code>Format</code>)</li>
  459. <li>Execute custom server command (<code>ExecuteCommand &lt;args&gt;</code>)</li>
  460. <li>Management of <code>rls</code> server instance</li>
  461. </ul><h3 id="java">Java</h3><ul>
  462. <li>Semantic auto-completion with automatic import insertion</li>
  463. <li>Signature help</li>
  464. <li>Real-time diagnostic display</li>
  465. <li>Go to definition (<code>GoTo</code>, <code>GoToDefinition</code>, and <code>GoToDeclaration</code> are
  466. identical)</li>
  467. <li>Go to type definition (<code>GoToType</code>)</li>
  468. <li>Go to implementation (<code>GoToImplementation</code>)</li>
  469. <li>Find Symbol (<code>GoToSymbol</code>)</li>
  470. <li>Reference finding (<code>GoToReferences</code>)</li>
  471. <li>View documentation comments for identifiers (<code>GetDoc</code>)</li>
  472. <li>Type information for identifiers (<code>GetType</code>)</li>
  473. <li>Automatically fix certain errors including code generation (<code>FixIt</code>)</li>
  474. <li>Renaming symbols (<code>RefactorRename &lt;new name&gt;</code>)</li>
  475. <li>Code formatting (<code>Format</code>)</li>
  476. <li>Organize imports (<code>OrganizeImports</code>)</li>
  477. <li>Detection of java projects</li>
  478. <li>Execute custom server command (<code>ExecuteCommand &lt;args&gt;</code>)</li>
  479. <li>Management of <code>jdt.ls</code> server instance</li>
  480. </ul><h2 id="user-guide">User Guide</h2><h3 id="general-usage">General Usage</h3><p>If the offered completions are too broad, keep typing characters; YCM will
  481. continue refining the offered completions based on your input.</p><p>Filtering is "smart-case" and "smart-<a href="https://www.unicode.org/glossary/#diacritic">diacritic</a>" sensitive; if you are
  482. typing only lowercase letters, then it's case-insensitive. If your input
  483. contains uppercase letters, then the uppercase letters in your query must
  484. match uppercase letters in the completion strings (the lowercase letters still
  485. match both). On top of that, a letter with no diacritic marks will match that
  486. letter with or without marks:</p><table>
  487. <tbody>
  488. <tr>
  489. <th>matches</th>
  490. <th>foo</th>
  491. <th>fôo</th>
  492. <th>fOo</th>
  493. <th>fÔo</th>
  494. </tr>
  495. <tr>
  496. <th>foo</th>
  497. <td>✔️</td>
  498. <td>✔️</td>
  499. <td>✔️</td>
  500. <td>✔️</td>
  501. </tr>
  502. <tr>
  503. <th>fôo</th>
  504. <td>❌</td>
  505. <td>✔️</td>
  506. <td>❌</td>
  507. <td>✔️</td>
  508. </tr>
  509. <tr>
  510. <th>fOo</th>
  511. <td>❌</td>
  512. <td>❌</td>
  513. <td>✔️</td>
  514. <td>✔️</td>
  515. </tr>
  516. <tr>
  517. <th>fÔo</th>
  518. <td>❌</td>
  519. <td>❌</td>
  520. <td>❌</td>
  521. <td>✔️</td>
  522. </tr>
  523. </tbody>
  524. </table><p>Use the TAB key to accept a completion and continue pressing TAB to cycle
  525. through the completions. Use Shift-TAB to cycle backwards. Note that if you're
  526. using console Vim (that is, not Gvim or MacVim) then it's likely that the
  527. Shift-TAB binding will not work because the console will not pass it to Vim.
  528. You can remap the keys; see the <a href="#options">Options</a> section below.</p><p>Knowing a little bit about how YCM works internally will prevent confusion. YCM
  529. has several completion engines: an identifier-based completer that collects all
  530. of the identifiers in the current file and other files you visit (and your tags
  531. files) and searches them when you type (identifiers are put into per-filetype
  532. groups).</p><p>There are also several semantic engines in YCM. There are libclang-based and
  533. clangd-based completers that provide semantic completion for C-family languages.
  534. There's a Jedi-based completer for semantic completion for Python. There's also
  535. an omnifunc-based completer that uses data from Vim's omnicomplete system to
  536. provide semantic completions when no native completer exists for that language
  537. in YCM.</p><p>There are also other completion engines, like the UltiSnips completer and the
  538. filepath completer.</p><p>YCM automatically detects which completion engine would be the best in any
  539. situation. On occasion, it queries several of them at once, merges the
  540. outputs and presents the results to you.</p><h3 id="client-server-architecture">Client-Server Architecture</h3><p>YCM has a client-server architecture; the Vim part of YCM is only a thin client
  541. that talks to the <a href="https://github.com/ycm-core/ycmd">ycmd HTTP+JSON server</a> that has the vast majority of
  542. YCM logic and functionality. The server is started and stopped automatically as
  543. you start and stop Vim.</p><h3 id="completion-string-ranking">Completion String Ranking</h3><p>The subsequence filter removes any completions that do not match the input, but
  544. then the sorting system kicks in. It's actually very complicated and uses lots
  545. of factors, but suffice it to say that "word boundary" (WB) subsequence
  546. character matches are "worth" more than non-WB matches. In effect, this means
  547. given an input of "gua", the completion "getUserAccount" would be ranked higher
  548. in the list than the "Fooguxa" completion (both of which are subsequence
  549. matches). A word-boundary character are all capital characters, characters
  550. preceded by an underscore and the first letter character in the completion
  551. string.</p><h3 id="signature-help">Signature Help</h3><p>Signature help is an <strong>experimental</strong> feature for which we value your feedback.
  552. Valid signatures are displayed in a second popup menu and the current signature
  553. is highlighed along with the current arguemnt.</p><p>Signature help is triggered in insert mode automatically when
  554. <code>g:ycm_auto_trigger</code> is enabled and is not supported when it is not enabled.</p><p>The signatures popup is hidden when there are no matching signatures or when you
  555. leave insert mode. There is no key binding to clear the popup.</p><p>For more details on this feature and a few demos, check out the
  556. <a href="https://github.com/ycm-core/ycmd/pull/1255">PR that proposed it</a>.</p><h3 id="general-semantic-completion">General Semantic Completion</h3><p>You can use Ctrl+Space to trigger the completion suggestions anywhere, even
  557. without a string prefix. This is useful to see which top-level functions are
  558. available for use.</p><h3 id="c-family-semantic-completion">C-family Semantic Completion</h3><p><strong>NOTE:</strong> YCM originally used the <code>libclang</code> based engine for C-family, but
  559. users should migrate to clangd, as it provides more features and better
  560. performance. Users who rely on <code>override_filename</code> in their <code>.ycm_extra_conf.py</code>
  561. will need to stay on the old <code>libclang</code> engine. Instructions on how to stay on
  562. the old engine are available on <a href="https://github.com/ycm-core/YouCompleteMe/wiki/C-family-Semantic-Completion-through-libclang">the wiki</a>.</p><p>Advantages of clangd over libclang include:</p><ul>
  563. <li><strong>Project wide indexing</strong>: Clangd has both dynamic and static index support.
  564. The dynamic index stores up-to-date symbols coming from any files you are
  565. currently editing, whereas static index contains project-wide symbol
  566. information. This symbol information is used for code completion and code
  567. navigation. Whereas libclang is limited to the current translation unit(TU).</li>
  568. <li><strong>Code navigation</strong>: Clangd provides all the GoTo requests libclang provides and it
  569. improves those using the above mentioned index information to contain
  570. project-wide information rather than just the current TU.</li>
  571. <li><strong>Rename</strong>: Clangd can perform semantic rename operations on the current
  572. file, whereas libclang doesn’t support such functionality.</li>
  573. <li><strong>Code Completion</strong>: Clangd can perform code completions at a lower latency
  574. than libclang; also, it has information about all the symbols in your
  575. project so it can suggest items outside your current TU and also provides
  576. proper <code>#include</code> insertions for those items.</li>
  577. <li><strong>Signature help</strong>: Clangd provides signature help so that you can see the
  578. names and types of arguments when calling functions.</li>
  579. <li><strong>Format Code</strong>: Clangd provides code formatting either for the selected
  580. lines or the whole file, whereas libclang doesn’t have such functionality.</li>
  581. <li><strong>Performance</strong>: Clangd has faster reparse and code completion times
  582. compared to libclang.</li>
  583. </ul><p>In order to perform semantic analysis such as code completion, <code>GoTo</code> and
  584. diagnostics, YouCompleteMe uses <code>clangd</code>, which makes use of
  585. clang compiler, sometimes also referred to as llvm. Like any compiler,
  586. clang also requires a set of compile flags in order to parse your code. Simply
  587. put: If clang can't parse your code, YouCompleteMe can't provide semantic
  588. analysis.</p><p>There are 2 methods which can be used to provide compile flags to clang:</p><h4 id="option-1-use-a-compilation-database">Option 1: Use a <a href="https://clang.llvm.org/docs/JSONCompilationDatabase.html">compilation database</a></h4><p>The easiest way to get YCM to compile your code is to use a compilation
  589. database. A compilation database is usually generated by your build system
  590. (e.g. <code>CMake</code>) and contains the compiler invocation for each compilation unit in
  591. your project.</p><p>For information on how to generate a compilation database, see the <a href="https://clang.llvm.org/docs/JSONCompilationDatabase.html">clang
  592. documentation</a>. In short:</p><ul>
  593. <li>If using CMake, add <code>-DCMAKE_EXPORT_COMPILE_COMMANDS=ON</code> when configuring (or
  594. add <code>set( CMAKE_EXPORT_COMPILE_COMMANDS ON )</code> to <code>CMakeLists.txt</code>) and copy or
  595. symlink the generated database to the root of your project.</li>
  596. <li>If using Ninja, check out the <code>compdb</code> tool (<code>-t compdb</code>) in its
  597. <a href="https://ninja-build.org/manual.html">docs</a>.</li>
  598. <li>If using GNU make, check out <a href="https://pypi.org/project/compiledb/">compiledb</a> or <a href="https://github.com/rizsotto/Bear">Bear</a>.</li>
  599. <li>For other build systems, check out
  600. <a href="#option-2-provide-the-flags-manually"><code>.ycm_extra_conf.py</code></a> below.</li>
  601. </ul><p>If no <a href="#option-2-provide-the-flags-manually"><code>.ycm_extra_conf.py</code></a> is found,
  602. YouCompleteMe automatically tries to load a compilation database if there is
  603. one.</p><p>YCM looks for a file named <code>compile_commands.json</code> in the directory of the
  604. opened file or in any directory above it in the hierarchy (recursively); when
  605. the file is found before a local <code>.ycm_extra_conf.py</code>, YouCompleteMe stops
  606. searching the directories and lets clangd take over and handle the flags.</p><h4 id="option-2-provide-the-flags-manually">Option 2: Provide the flags manually</h4><p>If you don't have a compilation database, or aren't able to generate one,
  607. you have to tell YouCompleteMe how to compile your code some other way.</p><p>Every C-family project is different. It is not possible for YCM to guess what
  608. compiler flags to supply for your project. Fortunately, YCM provides a mechanism
  609. for you to generate the flags for a particular file with <em>arbitrary complexity</em>.
  610. This is achieved by requiring you to provide a Python module which implements a
  611. trivial function which, given the file name as argument, returns a list of
  612. compiler flags to use to compile that file.</p><p>YCM looks for a <code>.ycm_extra_conf.py</code> file in the directory of the opened file or
  613. in any directory above it in the hierarchy (recursively); when the file is
  614. found, it is loaded (only once!) as a Python module. YCM calls a <code>Settings</code>
  615. method in that module which should provide it with the information necessary to
  616. compile the current file. You can also provide a path to a global configuration
  617. file with the
  618. <a href="#the-gycm_global_ycm_extra_conf-option"><code>g:ycm_global_ycm_extra_conf</code></a> option,
  619. which will be used as a fallback. To prevent the execution of malicious code
  620. from a file you didn't write YCM will ask you once per <code>.ycm_extra_conf.py</code> if
  621. it is safe to load. This can be disabled and you can white-/blacklist files. See
  622. the <a href="#the-gycm_confirm_extra_conf-option"><code>g:ycm_confirm_extra_conf</code></a> and
  623. <a href="#the-gycm_extra_conf_globlist-option"><code>g:ycm_extra_conf_globlist</code></a> options
  624. respectively.</p><p>This system was designed this way so that the user can perform any arbitrary
  625. sequence of operations to produce a list of compilation flags YCM should hand
  626. to Clang.</p><p><strong>NOTE</strong>: It is highly recommended to include <code>-x &lt;language&gt;</code> flag to libclang.
  627. This is so that the correct language is detected, particularly for header files.
  628. Common values are <code>-x c</code> for C, <code>-x c++</code> for C++, <code>-x objc</code> for Objective-C, and
  629. <code>-x cuda</code> for CUDA.</p><p>To give you an impression, if your C++ project is trivial, and your usual
  630. compilation command is: <code>g++ -Wall -Wextra -Werror -o FILE.o FILE.cc</code>, then the
  631. following <code>.ycm_extra_conf.py</code> is enough to get semantic analysis from
  632. YouCompleteMe:</p><pre><code class="python">def Settings( **kwargs ):
  633. return {
  634. 'flags': [ '-x', 'c++', '-Wall', '-Wextra', '-Werror' ],
  635. }
  636. </code></pre><p>As you can see from the trivial example, YCM calls the <code>Settings</code> method which
  637. returns a dictionary with a single element <code>'flags'</code>. This element is a <code>list</code>
  638. of compiler flags to pass to libclang for the current file. The absolute path of
  639. that file is accessible under the <code>filename</code> key of the <code>kwargs</code> dictionary.
  640. That's it! This is actually enough for most projects, but for complex projects
  641. it is not uncommon to integrate directly with an existing build system using the
  642. full power of the Python language.</p><p>For a more elaborate example,
  643. <a href="https://raw.githubusercontent.com/ycm-core/ycmd/66030cd94299114ae316796f3cad181cac8a007c/.ycm_extra_conf.py">see ycmd's own <code>.ycm_extra_conf.py</code></a>. You should be able to
  644. use it <em>as a starting point</em>. <strong>Don't</strong> just copy/paste that file somewhere and
  645. expect things to magically work; <strong>your project needs different flags</strong>. Hint:
  646. just replace the strings in the <code>flags</code> variable with compilation flags
  647. necessary for your project. That should be enough for 99% of projects.</p><p>You could also consider using <a href="https://github.com/rdnetto/YCM-Generator">YCM-Generator</a> to generate the
  648. <code>ycm_extra_conf.py</code> file.</p><h4 id="errors-during-compilation">Errors during compilation</h4><p>If Clang encounters errors when compiling the header files that your file
  649. includes, then it's probably going to take a long time to get completions. When
  650. the completion menu finally appears, it's going to have a large number of
  651. unrelated completion strings (type/function names that are not actually
  652. members). This is because Clang fails to build a precompiled preamble for your
  653. file if there are any errors in the included headers and that preamble is key to
  654. getting fast completions.</p><p>Call the <code>:YcmDiags</code> command to see if any errors or warnings were detected in
  655. your file.</p><h3 id="java-semantic-completion">Java Semantic Completion</h3><h4 id="java-quick-start">Java quick Start</h4><ol>
  656. <li>
  657. <p>Ensure that you have enabled the Java completer. See the
  658. <a href="#installation">installation guide</a> for details.</p>
  659. </li>
  660. <li>
  661. <p>Create a project file (gradle or maven) file in the root directory of your
  662. Java project, by following the instructions below.</p>
  663. </li>
  664. <li>
  665. <p>(Optional) <a href="#lsp-configuration">Configure the LSP server</a>. The <a href="https://github.com/eclipse/eclipse.jdt.ls/blob/master/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java">jdt.ls
  666. configuration options</a> can be found in their codebase.</p>
  667. </li>
  668. <li>
  669. <p>If you previously used Eclim or Syntastic for Java, disable them for Java.</p>
  670. </li>
  671. <li>
  672. <p>Edit a Java file from your project.</p>
  673. </li>
  674. </ol><p>For the best experience, we highly recommend at least Vim 8.1.1875 when using
  675. Java support with YouCompleteMe.</p><h4 id="java-project-files">Java Project Files</h4><p>In order to provide semantic analysis, the Java completion engine requires
  676. knowledge of your project structure. In particular it needs to know the class
  677. path to use, when compiling your code. Fortunately <a href="https://github.com/eclipse/eclipse.jdt.ls">jdt.ls</a>
  678. supports <a href="https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fproject_description_file.html">eclipse project files</a>,
  679. <a href="https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html">maven projects</a> and <a href="https://docs.gradle.org/current/userguide/tutorial_java_projects.html">gradle projects</a>.</p><p><strong>NOTE:</strong> Our recommendation is to use either maven or gradle projects.</p><h4 id="diagnostic-display---syntastic">Diagnostic display - Syntastic</h4><p>The native support for Java includes YCM's native realtime diagnostics display.
  680. This can conflict with other diagnostics plugins like Syntastic, so when
  681. enabling Java support, please <strong>manually disable Syntastic Java diagnostics</strong>.</p><p>Add the following to your <code>vimrc</code>:</p><pre><code class="viml">let g:syntastic_java_checkers = []
  682. </code></pre><h4 id="diagnostic-display---eclim">Diagnostic display - Eclim</h4><p>The native support for Java includes YCM's native realtime diagnostics display.
  683. This can conflict with other diagnostics plugins like Eclim, so when enabling
  684. Java support, please <strong>manually disable Eclim Java diagnostics</strong>.</p><p>Add the following to your <code>vimrc</code>:</p><pre><code class="viml">let g:EclimFileTypeValidate = 0
  685. </code></pre><p><strong>NOTE</strong>: We recommend disabling Eclim entirely when editing Java with YCM's
  686. native Java support. This can be done temporarily with <code>:EclimDisable</code>.</p><h4 id="eclipse-projects">Eclipse Projects</h4><p>Eclipse style projects require two files: <a href="https://help.eclipse.org/oxygen/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fproject_description_file.html">.project</a> and
  687. <a href="https://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fjdt%2Fcore%2FIClasspathEntry.html">.classpath</a>.</p><p>If your project already has these files due to previously being set up within
  688. eclipse, then no setup is required. <a href="https://github.com/eclipse/eclipse.jdt.ls">jdt.ls</a> should load the project just
  689. fine (it's basically eclipse after all).</p><p>However, if not, it is possible (easy in fact) to craft them manually, though it
  690. is not recommended. You're better off using gradle or maven (see below).</p><p><a href="https://github.com/ycm-core/ycmd/tree/3602f38ef7a762fc765afd75e562aec9a134711e/ycmd/tests/java/testdata/simple_eclipse_project">A simple eclipse style project example</a> can be found in
  691. the ycmd test directory. Normally all that is required is to copy these files to
  692. the root of your project and to edit the <code>.classpath</code> to add additional
  693. libraries, such as:</p><pre><code class="xml"> &lt;classpathentry kind="lib" path="/path/to/external/jar" /&gt;
  694. &lt;classpathentry kind="lib" path="/path/to/external/java/source" /&gt;
  695. </code></pre><p>It may also be necessary to change the directory in which your source files are
  696. located (paths are relative to the .project file itself):</p><pre><code class="xml"> &lt;classpathentry kind="src" output="target/classes" path="path/to/src/" /&gt;
  697. </code></pre><p><strong>NOTE</strong>: The eclipse project and classpath files are not a public interface
  698. and it is highly recommended to use Maven or Gradle project definitions if you
  699. don't already use eclipse to manage your projects.</p><h4 id="maven-projects">Maven Projects</h4><p>Maven needs a file named <a href="https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html">pom.xml</a> in the root of the project.
  700. Once again a simple <a href="https://github.com/ycm-core/ycmd/blob/3602f38ef7a762fc765afd75e562aec9a134711e/ycmd/tests/java/testdata/simple_maven_project/pom.xml">pom.xml</a> can be found in ycmd source.</p><p>The format of <a href="https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html">pom.xml</a> files is way beyond the scope of this
  701. document, but we do recommend using the various tools that can generate them for
  702. you, if you're not familiar with them already.</p><h4 id="gradle-projects">Gradle Projects</h4><p>Gradle projects require a <a href="https://docs.gradle.org/current/userguide/tutorial_java_projects.html">build.gradle</a>. Again, there is a
  703. <a href="https://github.com/ycm-core/ycmd/tree/3602f38ef7a762fc765afd75e562aec9a134711e/ycmd/tests/java/testdata/simple_gradle_project">trivial example in ycmd's tests</a>.</p><p>The format of <a href="https://docs.gradle.org/current/userguide/tutorial_java_projects.html">build.gradle</a> files is way beyond the scope of
  704. this document, but we do recommend using the various tools that can generate
  705. them for you, if you're not familiar with them already.</p><h4 id="troubleshooting">Troubleshooting</h4><p>If you're not getting completions or diagnostics, check the server health:</p><ul>
  706. <li>The Java completion engine takes a while to start up and parse your project.
  707. You should be able to see its progress in the command line, and
  708. <code>:YcmDebugInfo</code>. Ensure that the following lines are present:</li>
  709. </ul><pre><code>-- jdt.ls Java Language Server running
  710. -- jdt.ls Java Language Server Startup Status: Ready
  711. </code></pre><ul>
  712. <li>If the above lines don't appear after a few minutes, check the jdt.ls and ycmd
  713. log files using <a href="#the-ycmtogglelogs-command"><code>:YcmToggleLogs</code> </a>. The jdt.ls
  714. log file is called <code>.log</code> (for some reason).</li>
  715. </ul><p>If you get a message about "classpath is incomplete", then make sure you have
  716. correctly configured the <a href="#java-project-files">project files</a>.</p><p>If you get messages about unresolved imports, then make sure you have
  717. correctly configured the <a href="#java-project-files">project files</a>, in particular
  718. check that the classpath is set correctly.</p><h3 id="c-semantic-completion">C# Semantic Completion</h3><p>YCM relies on <a href="https://github.com/OmniSharp/omnisharp-roslyn">OmniSharp-Roslyn</a> to provide completion and code navigation.
  719. OmniSharp-Roslyn needs a solution file for a C# project and there are two ways
  720. of letting YCM know about your solution files.</p><h4 id="automaticly-discovered-solution-files">Automaticly discovered solution files</h4><p>YCM will scan all parent directories of the file currently being edited and look
  721. for file with <code>.sln</code> extension.</p><h4 id="manually-specified-solution-files">Manually specified solution files</h4><p>If YCM loads <code>.ycm_extra_conf.py</code> which contains <code>CSharpSolutionFile</code> function,
  722. YCM will try to use that to determine the solution file. This is useful when one
  723. wants to override the default behaviour and specify a solution file that is not
  724. in any of the parent directories of the currently edited file. Example:</p><pre><code class="python">def CSharpSolutionFile( filepath ):
  725. # `filepath` is the path of the file user is editing
  726. return '/path/to/solution/file' # Can be relative to the `.ycm_extra_conf.py`
  727. </code></pre><p>If the path returned by <code>CSharpSolutionFile</code> is not an actual file, YCM will
  728. fall back to the other way of finding the file.</p><h3 id="python-semantic-completion">Python Semantic Completion</h3><p>YCM relies on the <a href="https://github.com/davidhalter/jedi">Jedi</a> engine to provide completion and code navigation. By
  729. default, it will pick the version of Python running the <a href="https://github.com/ycm-core/ycmd">ycmd server</a> and
  730. use its <code>sys.path</code>. While this is fine for simple projects, this needs to be
  731. configurable when working with virtual environments or in a project with
  732. third-party packages. The next sections explain how to do that.</p><h4 id="working-with-virtual-environments">Working with virtual environments</h4><p>A common practice when working on a Python project is to install its
  733. dependencies in a virtual environment and develop the project inside that
  734. environment. To support this, YCM needs to know the interpreter path of the
  735. virtual environment. You can specify it by creating a <code>.ycm_extra_conf.py</code> file
  736. at the root of your project with the following contents:</p><pre><code class="python">def Settings( **kwargs ):
  737. return {
  738. 'interpreter_path': '/path/to/virtual/environment/python'
  739. }
  740. </code></pre><p>where <code>/path/to/virtual/environment/python</code> is the path to the Python used
  741. by the virtual environment you are working in. Typically, the executable can be
  742. found in the <code>Scripts</code> folder of the virtual environment directory on Windows
  743. and in the <code>bin</code> folder on other platforms.</p><p>If you don't like having to create a <code>.ycm_extra_conf.py</code> file at the root of
  744. your project and would prefer to specify the interpreter path with a Vim option,
  745. read the <a href="#configuring-through-vim-options">Configuring through Vim options</a>
  746. section.</p><h4 id="working-with-third-party-packages">Working with third-party packages</h4><p>Another common practice is to put the dependencies directly into the project and
  747. add their paths to <code>sys.path</code> at runtime in order to import them. YCM needs to
  748. be told about this path manipulation to support those dependencies. This can be
  749. done by creating a <code>.ycm_extra_conf.py</code> file at the root of the project. This
  750. file must define a <code>Settings( **kwargs )</code> function returning a dictionary with
  751. the list of paths to prepend to <code>sys.path</code> under the <code>sys_path</code> key. For
  752. instance, the following <code>.ycm_extra_conf.py</code></p><pre><code class="python">def Settings( **kwargs ):
  753. return {
  754. 'sys_path': [
  755. '/path/to/some/third_party/package',
  756. '/path/to/another/third_party/package'
  757. ]
  758. }
  759. </code></pre><p>adds the paths <code>/path/to/some/third_party/package</code> and
  760. <code>/path/to/another/third_party/package</code> at the start of <code>sys.path</code>.</p><p>If you would rather prepend paths to <code>sys.path</code> with a Vim option, read the
  761. <a href="#configuring-through-vim-options">Configuring through Vim options</a> section.</p><p>If you need further control on how to add paths to <code>sys.path</code>, you should define
  762. the <code>PythonSysPath( **kwargs )</code> function in the <code>.ycm_extra_conf.py</code> file. Its
  763. keyword arguments are <code>sys_path</code> which contains the default <code>sys.path</code>, and
  764. <code>interpreter_path</code> which is the path to the Python interpreter. Here's a trivial
  765. example that insert the <code>/path/to/third_party/package</code> path at the second
  766. position of <code>sys.path</code>:</p><pre><code class="python">def PythonSysPath( **kwargs ):
  767. sys_path = kwargs[ 'sys_path' ]
  768. sys_path.insert( 1, '/path/to/third_party/package' )
  769. return sys_path
  770. </code></pre><p>A more advanced example can be found in <a href="https://github.com/ycm-core/YouCompleteMe/blob/master/.ycm_extra_conf.py">YCM's own
  771. <code>.ycm_extra_conf.py</code></a>.</p><h4 id="configuring-through-vim-options">Configuring through Vim options</h4><p>You may find inconvenient to have to create a <code>.ycm_extra_conf.py</code> file at the
  772. root of each one of your projects in order to set the path to the Python
  773. interpreter and/or add paths to <code>sys.path</code> and would prefer to be able to
  774. configure those through Vim options. Don't worry, this is possible by using the
  775. <a href="#the-gycm_extra_conf_vim_data-option"><code>g:ycm_extra_conf_vim_data</code></a> option and
  776. creating a global extra configuration file. Let's take an example. Suppose that
  777. you want to set the interpreter path with the <code>g:ycm_python_interpreter_path</code>
  778. option and prepend paths to <code>sys.path</code> with the <code>g:ycm_python_sys_path</code> option.
  779. Suppose also that you want to name the global extra configuration file
  780. <code>global_extra_conf.py</code> and that you want to put it in your HOME folder. You
  781. should then add the following lines to your vimrc:</p><pre><code class="viml">let g:ycm_python_interpreter_path = ''
  782. let g:ycm_python_sys_path = []
  783. let g:ycm_extra_conf_vim_data = [
  784. \ 'g:ycm_python_interpreter_path',
  785. \ 'g:ycm_python_sys_path'
  786. \]
  787. let g:ycm_global_ycm_extra_conf = '~/global_extra_conf.py'
  788. </code></pre><p>and create the <code>~/global_extra_conf.py</code> file with the following contents:</p><pre><code class="python">def Settings( **kwargs ):
  789. client_data = kwargs[ 'client_data' ]
  790. return {
  791. 'interpreter_path': client_data[ 'g:ycm_python_interpreter_path' ],
  792. 'sys_path': client_data[ 'g:ycm_python_sys_path' ]
  793. }
  794. </code></pre><p>That's it. You are done. Note that you don't need to restart the server when
  795. setting one of the options. YCM will automatically pick the new values.</p><h3 id="rust-semantic-completion">Rust Semantic Completion</h3><p>Completions and GoTo commands within the current crate and its dependencies
  796. should work out of the box with no additional configuration (provided that you
  797. built YCM with the <code>--rust-completer</code> flag; see the <a href="#installation"><em>Installation</em>
  798. section</a> for details). The install script takes care of
  799. installing <a href="https://www.rust-lang.org/downloads.html">the Rust source code</a>, so no configuration is necessary.</p><p>To <a href="#lsp-configuration">configure RLS</a> look up [rls configuration options][
  800. rls-preferences]. The value of the <code>ls</code> key must be structured as in the
  801. following example:</p><pre><code class="python">def Settings( **kwargs ):
  802. if kwargs[ 'language' ] == 'rust':
  803. return {
  804. 'ls': {
  805. 'rust': {
  806. 'features': ['http2','spnego'],
  807. 'all_targets': False,
  808. 'wait_to_build': 1500,
  809. }
  810. }
  811. }
  812. </code></pre><p>That is to say, <code>ls</code> should be paired with a dictionary containing a key <code>rust</code>,
  813. which should be paired with another dictionary in which the keys are RLS
  814. options.</p><p>Also, for the time being, if you make changes to your <code>Cargo.toml</code> that RLS
  815. doesn't seem to recognize, you may need to restart it manually with
  816. <code>:YcmCompleter RestartServer</code>.</p><h3 id="go-semantic-completion">Go Semantic Completion</h3><p>Completions and GoTo commands should work out of the box (provided that you
  817. built YCM with the <code>--go-completer</code> flag; see the <a href="#installation"><em>Installation</em>
  818. section</a> for details). The server only works for projects with
  819. the "canonical" layout.</p><p>While YCM can configure <a href="#lsp-configuration">a LSP server</a>, currently <code>gopls</code>
  820. doesn't implement <a href="https://github.com/golang/tools/blob/master/internal/lsp/server.go#L120">the required notification</a>.</p><h3 id="javascript-and-typescript-semantic-completion">JavaScript and TypeScript Semantic Completion</h3><p><strong>NOTE:</strong> YCM originally used the <a href="https://ternjs.net">Tern</a> engine for JavaScript but due to
  821. <a href="https://ternjs.net">Tern</a> not being maintained anymore by its main author and the <a href="https://github.com/Microsoft/TypeScript/tree/master/src/server">TSServer</a>
  822. engine offering more features, YCM is moving to <a href="https://github.com/Microsoft/TypeScript/tree/master/src/server">TSServer</a>. This won't affect
  823. you if you were already using <a href="https://ternjs.net">Tern</a> but you are encouraged to do the switch
  824. by deleting the <code>third_party/ycmd/third_party/tern_runtime/node_modules</code>
  825. directory in YCM folder. If you are a new user but still want to use <a href="https://ternjs.net">Tern</a>,
  826. you should pass the <code>--js-completer</code> option to the <code>install.py</code> script during
  827. installation. Further instructions on how to setup YCM with <a href="https://ternjs.net">Tern</a> are
  828. available on <a href="https://github.com/ycm-core/YouCompleteMe/wiki/JavaScript-Semantic-Completion-through-Tern">the wiki</a>.</p><p>All JavaScript and TypeScript features are provided by the <a href="https://github.com/Microsoft/TypeScript/tree/master/src/server">TSServer</a> engine,
  829. which is included in the TypeScript SDK. To enable these features, install
  830. <a href="https://docs.npmjs.com/getting-started/installing-node#1-install-nodejs--npm">Node.js and npm</a> and call the <code>install.py</code> script with the
  831. <code>--ts-completer</code> flag.</p><p><a href="https://github.com/Microsoft/TypeScript/tree/master/src/server">TSServer</a> relies on <a href="https://code.visualstudio.com/docs/languages/jsconfig">the <code>jsconfig.json</code> file</a> for JavaScript
  832. and <a href="https://www.typescriptlang.org/docs/handbook/tsconfig-json.html">the <code>tsconfig.json</code> file</a> for TypeScript to analyze your
  833. project. Ensure the file exists at the root of your project.</p><p>To get diagnostics in JavaScript, set the <code>checkJs</code> option to <code>true</code> in your
  834. <code>jsconfig.json</code> file:</p><pre><code class="json">{
  835. "compilerOptions": {
  836. "checkJs": true
  837. }
  838. }
  839. </code></pre><h3 id="semantic-completion-for-other-languages">Semantic Completion for Other Languages</h3><p>C-family, C#, Go, Java, Python, Rust, and JavaScript/TypeScript languages are
  840. supported natively by YouCompleteMe using the <a href="https://clang.llvm.org/">Clang</a>, <a href="https://github.com/OmniSharp/omnisharp-roslyn">OmniSharp-Roslyn</a>,
  841. <a href="https://github.com/golang/go/wiki/gopls">Gopls</a>, <a href="https://github.com/eclipse/eclipse.jdt.ls">jdt.ls</a>, <a href="https://github.com/davidhalter/jedi">Jedi</a>, <a href="https://github.com/rust-lang/rls">rls</a>, and <a href="https://github.com/Microsoft/TypeScript/tree/master/src/server">TSServer</a> engines,
  842. respectively. Check the <a href="#installation">installation</a> section for instructions
  843. to enable these features if desired.</p><h4 id="plugging-an-arbitrary-lsp-server">Plugging an arbitrary LSP server</h4><p>Similar to other LSP clients, YCM can use an arbitrary LSP server with the help
  844. of <a href="#the-gycm_language_server-option"><code>g:ycm_language_server</code></a> option. An
  845. example of a value of this option would be:</p><pre><code class="viml">let g:ycm_language_server =
  846. \ [
  847. \ {
  848. \ 'name': 'yaml',
  849. \ 'cmdline': [ '/path/to/yaml/server/yaml-language-server', '--stdio' ],
  850. \ 'filetypes': [ 'yaml' ]
  851. \ },
  852. \ {
  853. \ 'name': 'rust',
  854. \ 'cmdline': [ 'ra_lsp_server' ],
  855. \ 'filetypes': [ 'rust' ],
  856. \ 'project_root_files': [ 'Cargo.toml' ]
  857. \ }
  858. \ ]
  859. </code></pre><p><code>project_root_files</code> is an optional key, since not all servers need it.</p><p>When <a href="#lsp-configuration">configuring a LSP server</a> the value of the <code>name</code> key
  860. will be used as the <code>kwargs[ 'language' ]</code>.</p><p>See <a href="https://github.com/ycm-core/lsp-examples">the LSP Examples</a> project for more
  861. examples of configuring the likes of PHP, Ruby, Kotlin, and D.</p><h4 id="lsp-configuration">LSP Configuration</h4><p>Many LSP servers allow some level of user configuration. YCM enables this with
  862. the help of <code>.ycm_extra_conf.py</code> files. Here's an example of jdt.ls user
  863. configuration.</p><pre><code class="python">def Settings( **kwargs ):
  864. if kwargs[ 'language' ] == 'java':
  865. return { 'ls': { 'java.format.onType.enabled': True } }
  866. </code></pre><p>The <code>ls</code> key tells YCM that the dictionary should be passed to thet LSP server.
  867. For each of the LSP server's configuration you should look up the respective
  868. server's documentation.</p><h4 id="using-omnifunc-for-semantic-completion">Using <code>omnifunc</code> for semantic completion</h4><p>YCM will use your <code>omnifunc</code> (see <code>:h omnifunc</code> in Vim) as a source for semantic
  869. completions if it does not have a native semantic completion engine for your
  870. file's filetype. Vim comes with okayish omnifuncs for various languages like
  871. Ruby, PHP, etc. It depends on the language.</p><p>You can get a stellar omnifunc for Ruby with <a href="http://eclim.org/">Eclim</a>. Just make sure you have
  872. the <em>latest</em> Eclim installed and configured (this means Eclim <code>&gt;= 2.2.*</code> and
  873. Eclipse <code>&gt;= 4.2.*</code>).</p><p>After installing Eclim remember to create a new Eclipse project within your
  874. application by typing <code>:ProjectCreate &lt;path-to-your-project&gt; -n ruby</code> inside vim
  875. and don't forget to have <code>let g:EclimCompletionMethod = 'omnifunc'</code> in your
  876. vimrc. This will make YCM and Eclim play nice; YCM will use Eclim's omnifuncs as
  877. the data source for semantic completions and provide the auto-triggering and
  878. subsequence-based matching (and other YCM features) on top of it.</p><h3 id="writing-new-semantic-completers">Writing New Semantic Completers</h3><p>You have two options here: writing an <code>omnifunc</code> for Vim's omnicomplete system
  879. that YCM will then use through its omni-completer, or a custom completer for YCM
  880. using the <a href="https://github.com/ycm-core/ycmd/blob/master/ycmd/completers/completer.py">Completer API</a>.</p><p>Here are the differences between the two approaches:</p><ul>
  881. <li>You have to use VimScript to write the omnifunc, but get to use Python to
  882. write for the Completer API; this by itself should make you want to use the
  883. API.</li>
  884. <li>The Completer API is a <em>much</em> more powerful way to integrate with YCM and it
  885. provides a wider set of features. For instance, you can make your Completer
  886. query your semantic back-end in an asynchronous fashion, thus not blocking
  887. Vim's GUI thread while your completion system is processing stuff. This is
  888. impossible with VimScript. All of YCM's completers use the Completer API.</li>
  889. <li>Performance with the Completer API is better since Python executes faster than
  890. VimScript.</li>
  891. </ul><p>If you want to use the <code>omnifunc</code> system, see the relevant Vim docs with <code>:h
  892. complete-functions</code>. For the Completer API, see <a href="https://github.com/ycm-core/ycmd/blob/master/ycmd/completers/completer.py">the API docs</a>.</p><p>If you want to upstream your completer into YCM's source, you should use the
  893. Completer API.</p><h3 id="diagnostic-display">Diagnostic Display</h3><p>YCM will display diagnostic notifications for the C-family, C#, Go, Java,
  894. JavaScript, Rust and TypeScript languages. Since YCM continuously recompiles
  895. your file as you type, you'll get notified of errors and warnings in your file
  896. as fast as possible.</p><p>Here are the various pieces of the diagnostic UI:</p><ul>
  897. <li>Icons show up in the Vim gutter on lines that have a diagnostic.</li>
  898. <li>Regions of text related to diagnostics are highlighted (by default, a red
  899. wavy underline in <code>gvim</code> and a red background in <code>vim</code>).</li>
  900. <li>Moving the cursor to a line with a diagnostic echoes the diagnostic text.</li>
  901. <li>Vim's location list is automatically populated with diagnostic data (off by
  902. default, see options).</li>
  903. </ul><p>The new diagnostics (if any) will be displayed the next time you press any key
  904. on the keyboard. So if you stop typing and just wait for the new diagnostics to
  905. come in, that <em>will not work</em>. You need to press some key for the GUI to update.</p><p>Having to press a key to get the updates is unfortunate, but cannot be changed
  906. due to the way Vim internals operate; there is no way that a background task can
  907. update Vim's GUI after it has finished running. You <em>have to</em> press a key. This
  908. will make YCM check for any pending diagnostics updates.</p><p>You <em>can</em> force a full, blocking compilation cycle with the
  909. <code>:YcmForceCompileAndDiagnostics</code> command (you may want to map that command to a
  910. key; try putting <code>nnoremap &lt;F5&gt; :YcmForceCompileAndDiagnostics&lt;CR&gt;</code> in your
  911. vimrc). Calling this command will force YCM to immediately recompile your file
  912. and display any new diagnostics it encounters. Do note that recompilation with
  913. this command may take a while and during this time the Vim GUI <em>will</em> be
  914. blocked.</p><p>YCM will display a short diagnostic message when you move your cursor to the
  915. line with the error. You can get a detailed diagnostic message with the
  916. <code>&lt;leader&gt;d</code> key mapping (can be changed in the options) YCM provides when your
  917. cursor is on the line with the diagnostic.</p><p>You can also see the full diagnostic message for all the diagnostics in the
  918. current file in Vim's <code>locationlist</code>, which can be opened with the <code>:lopen</code> and
  919. <code>:lclose</code> commands (make sure you have set <code>let
  920. g:ycm_always_populate_location_list = 1</code> in your vimrc). A good way to toggle
  921. the display of the <code>locationlist</code> with a single key mapping is provided by
  922. another (very small) Vim plugin called <a href="https://github.com/Valloric/ListToggle">ListToggle</a> (which also makes it
  923. possible to change the height of the <code>locationlist</code> window), also written by
  924. yours truly.</p><h4 id="diagnostic-highlighting-groups">Diagnostic Highlighting Groups</h4><p>You can change the styling for the highlighting groups YCM uses. For the signs
  925. in the Vim gutter, the relevant groups are:</p><ul>
  926. <li><code>YcmErrorSign</code>, which falls back to group <code>SyntasticErrorSign</code> and then
  927. <code>error</code> if they exist</li>
  928. <li><code>YcmWarningSign</code>, which falls back to group <code>SyntasticWarningSign</code> and then
  929. <code>todo</code> if they exist</li>
  930. </ul><p>You can also style the line that has the warning/error with these groups:</p><ul>
  931. <li><code>YcmErrorLine</code>, which falls back to group <code>SyntasticErrorLine</code> if it exists</li>
  932. <li><code>YcmWarningLine</code>, which falls back to group <code>SyntasticWarningLine</code> if it
  933. exists</li>
  934. </ul><p>Note that the line highlighting groups only work when the
  935. <a href="#the-gycm_enable_diagnostic_signs-option"><code>g:ycm_enable_diagnostic_signs</code></a>
  936. option is set. If you want highlighted lines but no signs in the Vim gutter,
  937. ensure that your Vim version is 7.4.2201 or later and set the <code>signcolumn</code>
  938. option to <code>off</code> in your vimrc:</p><pre><code class="viml">set signcolumn=off
  939. </code></pre><p>The syntax groups used to highlight regions of text with errors/warnings:
  940. - <code>YcmErrorSection</code>, which falls back to group <code>SyntasticError</code> if it exists and
  941. then <code>SpellBad</code>
  942. - <code>YcmWarningSection</code>, which falls back to group <code>SyntasticWarning</code> if it exists
  943. and then <code>SpellCap</code></p><p>Here's how you'd change the style for a group:</p><pre><code class="viml">highlight YcmErrorLine guibg=#3f0000
  944. </code></pre><h2 id="commands">Commands</h2><h3 id="the-ycmrestartserver-command">The <code>:YcmRestartServer</code> command</h3><p>If the <a href="https://github.com/ycm-core/ycmd">ycmd completion server</a> suddenly stops for some reason, you can
  945. restart it with this command.</p><h3 id="the-ycmforcecompileanddiagnostics-command">The <code>:YcmForceCompileAndDiagnostics</code> command</h3><p>Calling this command will force YCM to immediately recompile your file
  946. and display any new diagnostics it encounters. Do note that recompilation with
  947. this command may take a while and during this time the Vim GUI <em>will</em> be
  948. blocked.</p><p>You may want to map this command to a key; try putting <code>nnoremap &lt;F5&gt;
  949. :YcmForceCompileAndDiagnostics&lt;CR&gt;</code> in your vimrc.</p><h3 id="the-ycmdiags-command">The <code>:YcmDiags</code> command</h3><p>Calling this command will fill Vim's <code>locationlist</code> with errors or warnings if
  950. any were detected in your file and then open it. If a given error or warning can
  951. be fixed by a call to <code>:YcmCompleter FixIt</code>, then <code>(FixIt available)</code> is
  952. appended to the error or warning text. See the <code>FixIt</code> completer subcommand for
  953. more information.</p><p><strong>NOTE:</strong> The absence of <code>(FixIt available)</code> does not strictly imply a fix-it
  954. is not available as not all completers are able to provide this indication. For
  955. example, the c-sharp completer provides many fix-its but does not add this
  956. additional indication.</p><p>The <code>g:ycm_open_loclist_on_ycm_diags</code> option can be used to prevent the location
  957. list from opening, but still have it filled with new diagnostic data. See the
  958. <em>Options</em> section for details.</p><h3 id="the-ycmshowdetaileddiagnostic-command">The <code>:YcmShowDetailedDiagnostic</code> command</h3><p>This command shows the full diagnostic text when the user's cursor is on the
  959. line with the diagnostic.</p><h3 id="the-ycmdebuginfo-command">The <code>:YcmDebugInfo</code> command</h3><p>This will print out various debug information for the current file. Useful to
  960. see what compile commands will be used for the file if you're using the semantic
  961. completion engine.</p><h3 id="the-ycmtogglelogs-command">The <code>:YcmToggleLogs</code> command</h3><p>This command presents the list of logfiles created by YCM, the <a href="https://github.com/ycm-core/ycmd">ycmd
  962. server</a>, and the semantic engine server for the current filetype, if any.
  963. One of these logfiles can be opened in the editor (or closed if already open) by
  964. entering the corresponding number or by clicking on it with the mouse.
  965. Additionally, this command can take the logfile names as arguments. Use the
  966. <code>&lt;TAB&gt;</code> key (or any other key defined by the <code>wildchar</code> option) to complete the
  967. arguments or to cycle through them (depending on the value of the <code>wildmode</code>
  968. option). Each logfile given as an argument is directly opened (or closed if
  969. already open) in the editor. Only for debugging purposes.</p><h3 id="the-ycmcompleter-command">The <code>:YcmCompleter</code> command</h3><p>This command gives access to a number of additional <a href="#quick-feature-summary">IDE-like
  970. features</a> in YCM, for things like semantic GoTo, type
  971. information, FixIt and refactoring.</p><p>This command accepts a range that can either be specified through a selection in
  972. one of Vim's visual modes (see <code>:h visual-use</code>) or on the command line. For
  973. instance, <code>:2,5YcmCompleter</code> will apply the command from line 2 to line 5. This
  974. is useful for <a href="#the-format-subcommand">the <code>Format</code> subcommand</a>.</p><p>Call <code>YcmCompleter</code> without further arguments for a list of the commands you can
  975. call for the current completer.</p><p>See the <a href="#quick-feature-summary">file type feature summary</a> for an overview of
  976. the features available for each file type. See the <em>YcmCompleter subcommands</em>
  977. section for more information on the available subcommands and their usage.</p><h2 id="ycmcompleter-subcommands">YcmCompleter Subcommands</h2><p><strong>NOTE:</strong> See the docs for the <code>YcmCompleter</code> command before tackling this
  978. section.</p><p>The invoked subcommand is automatically routed to the currently active semantic
  979. completer, so <code>:YcmCompleter GoToDefinition</code> will invoke the <code>GoToDefinition</code>
  980. subcommand on the Python semantic completer if the currently active file is a
  981. Python one and on the Clang completer if the currently active file is a C-family
  982. language one.</p><p>You may also want to map the subcommands to something less verbose; for
  983. instance, <code>nnoremap &lt;leader&gt;jd :YcmCompleter GoTo&lt;CR&gt;</code>
  984. maps the <code>&lt;leader&gt;jd</code> sequence to the longer subcommand invocation.</p><h3 id="goto-commands">GoTo Commands</h3><p>These commands are useful for jumping around and exploring code. When moving
  985. the cursor, the subcommands add entries to Vim's <code>jumplist</code> so you can use
  986. <code>CTRL-O</code> to jump back to where you were before invoking the command (and
  987. <code>CTRL-I</code> to jump forward; see <code>:h jumplist</code> for details). If there is more
  988. than one destination, the quickfix list (see <code>:h quickfix</code>) is populated with
  989. the available locations and opened to full width at the bottom of the screen.
  990. You can change this behavior by using <a href="#the-ycmquickfixopened-autocommand">the <code>YcmQuickFixOpened</code>
  991. autocommand</a>.</p><h4 id="the-gotoinclude-subcommand">The <code>GoToInclude</code> subcommand</h4><p>Looks up the current line for a header and jumps to it.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda</code></p><h4 id="the-gotodeclaration-subcommand">The <code>GoToDeclaration</code> subcommand</h4><p>Looks up the symbol under the cursor and jumps to its declaration.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda, cs, go, java, javascript,
  992. python, rust, typescript</code></p><h4 id="the-gotodefinition-subcommand">The <code>GoToDefinition</code> subcommand</h4><p>Looks up the symbol under the cursor and jumps to its definition.</p><p><strong>NOTE:</strong> For C-family languages <strong>this only works in certain situations</strong>,
  993. namely when the definition of the symbol is in the current translation unit. A
  994. translation unit consists of the file you are editing and all the files you are
  995. including with <code>#include</code> directives (directly or indirectly) in that file.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda, cs, go, java, javascript,
  996. python, rust, typescript</code></p><h4 id="the-goto-subcommand">The <code>GoTo</code> subcommand</h4><p>This command tries to perform the "most sensible" GoTo operation it can.
  997. Currently, this means that it tries to look up the symbol under the cursor and
  998. jumps to its definition if possible; if the definition is not accessible from
  999. the current translation unit, jumps to the symbol's declaration. For
  1000. C-family languages, it first tries to look up the current line for a header and
  1001. jump to it. For C#, implementations are also considered and preferred.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda, cs, go, java, javascript,
  1002. python, rust, typescript</code></p><h4 id="the-gotoimprecise-subcommand">The <code>GoToImprecise</code> subcommand</h4><p>WARNING: This command trades correctness for speed!</p><p>Same as the <code>GoTo</code> command except that it doesn't recompile the file with
  1003. libclang before looking up nodes in the AST. This can be very useful when you're
  1004. editing files that take long to compile but you know that you haven't made any
  1005. changes since the last parse that would lead to incorrect jumps. When you're
  1006. just browsing around your codebase, this command can spare you quite a bit of
  1007. latency.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda</code></p><h4 id="the-gotosymbol-symbol-query-subcommand">The <code>GoToSymbol &lt;symbol query&gt;</code> subcommand</h4><p>Finds the definition of all symbols matching a specified string. Note that this
  1008. does not use any sort of smart/fuzzy matching.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda, cs, java, javascript, python, typescript</code></p><h4 id="the-gotoreferences-subcommand">The <code>GoToReferences</code> subcommand</h4><p>This command attempts to find all of the references within the project to the
  1009. identifier under the cursor and populates the quickfix list with those
  1010. locations.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda, java, javascript, python, typescript, rust</code></p><h4 id="the-gotoimplementation-subcommand">The <code>GoToImplementation</code> subcommand</h4><p>Looks up the symbol under the cursor and jumps to its implementation (i.e.
  1011. non-interface). If there are multiple implementations, instead provides a list
  1012. of implementations to choose from.</p><p>Supported in filetypes: <code>cs, go, java, rust, typescript, javascript</code></p><h4 id="the-gotoimplementationelsedeclaration-subcommand">The <code>GoToImplementationElseDeclaration</code> subcommand</h4><p>Looks up the symbol under the cursor and jumps to its implementation if one,
  1013. else jump to its declaration. If there are multiple implementations, instead
  1014. provides a list of implementations to choose from.</p><p>Supported in filetypes: <code>cs</code></p><h4 id="the-gototype-subcommand">The <code>GoToType</code> subcommand</h4><p>Looks up the symbol under the cursor and jumps to the definition of its type
  1015. e.g. if the symbol is an object, go to the definition of its class.</p><p>Supported in filetypes: <code>go, java, javascript, typescript</code></p><h3 id="semantic-information-commands">Semantic Information Commands</h3><p>These commands are useful for finding static information about the code, such
  1016. as the types of variables, viewing declarations and documentation strings.</p><h4 id="the-gettype-subcommand">The <code>GetType</code> subcommand</h4><p>Echos the type of the variable or method under the cursor, and where it differs,
  1017. the derived type.</p><p>For example:</p><pre><code class="c++"> std::string s;
  1018. </code></pre><p>Invoking this command on <code>s</code> returns <code>std::string =&gt; std::basic_string&lt;char&gt;</code></p><p><strong>NOTE:</strong> Causes re-parsing of the current translation unit.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda, java, javascript,
  1019. go, python, typescript, rust</code></p><h4 id="the-gettypeimprecise-subcommand">The <code>GetTypeImprecise</code> subcommand</h4><p>WARNING: This command trades correctness for speed!</p><p>Same as the <code>GetType</code> command except that it doesn't recompile the file with
  1020. libclang before looking up nodes in the AST. This can be very useful when you're
  1021. editing files that take long to compile but you know that you haven't made any
  1022. changes since the last parse that would lead to incorrect type. When you're
  1023. just browsing around your codebase, this command can spare you quite a bit of
  1024. latency.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda</code></p><h4 id="the-getparent-subcommand">The <code>GetParent</code> subcommand</h4><p>Echos the semantic parent of the point under the cursor.</p><p>The semantic parent is the item that semantically contains the given position.</p><p>For example:</p><pre><code class="c++">class C {
  1025. void f();
  1026. };
  1027. void C::f() {
  1028. }
  1029. </code></pre><p>In the out-of-line definition of <code>C::f</code>, the semantic parent is the class <code>C</code>,
  1030. of which this function is a member.</p><p>In the example above, both declarations of <code>C::f</code> have <code>C</code> as their semantic
  1031. context, while the lexical context of the first <code>C::f</code> is <code>C</code> and the lexical
  1032. context of the second <code>C::f</code> is the translation unit.</p><p>For global declarations, the semantic parent is the translation unit.</p><p><strong>NOTE:</strong> Causes re-parsing of the current translation unit.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda</code></p><h4 id="the-getdoc-subcommand">The <code>GetDoc</code> subcommand</h4><p>Displays the preview window populated with quick info about the identifier
  1033. under the cursor. Depending on the file type, this includes things like:</p><ul>
  1034. <li>The type or declaration of identifier,</li>
  1035. <li>Doxygen/javadoc comments,</li>
  1036. <li>Python docstrings,</li>
  1037. <li>etc.</li>
  1038. </ul><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda, cs, go, java, javascript,
  1039. python, typescript, rust</code></p><h4 id="the-getdocimprecise-subcommand">The <code>GetDocImprecise</code> subcommand</h4><p>WARNING: This command trades correctness for speed!</p><p>Same as the <code>GetDoc</code> command except that it doesn't recompile the file with
  1040. libclang before looking up nodes in the AST. This can be very useful when you're
  1041. editing files that take long to compile but you know that you haven't made any
  1042. changes since the last parse that would lead to incorrect docs. When you're
  1043. just browsing around your codebase, this command can spare you quite a bit of
  1044. latency.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda</code></p><h3 id="refactoring-commands">Refactoring Commands</h3><p>These commands make changes to your source code in order to perform refactoring
  1045. or code correction. YouCompleteMe does not perform any action which cannot be
  1046. undone, and never saves or writes files to the disk.</p><h4 id="the-fixit-subcommand">The <code>FixIt</code> subcommand</h4><p>Where available, attempts to make changes to the buffer to correct diagnostics
  1047. on the current line. Where multiple suggestions are available (such as when
  1048. there are multiple ways to resolve a given warning, or where multiple
  1049. diagnostics are reported for the current line), the options are presented
  1050. and one can be selected.</p><p>Completers which provide diagnostics may also provide trivial modifications to
  1051. the source in order to correct the diagnostic. Examples include syntax errors
  1052. such as missing trailing semi-colons, spurious characters, or other errors which
  1053. the semantic engine can deterministically suggest corrections.</p><p>If no fix-it is available for the current line, or there is no diagnostic on the
  1054. current line, this command has no effect on the current buffer. If any
  1055. modifications are made, the number of changes made to the buffer is echo'd and
  1056. the user may use the editor's undo command to revert.</p><p>When a diagnostic is available, and <code>g:ycm_echo_current_diagnostic</code> is set to 1,
  1057. then the text <code>(FixIt)</code> is appended to the echo'd diagnostic when the
  1058. completer is able to add this indication. The text <code>(FixIt available)</code> is
  1059. also appended to the diagnostic text in the output of the <code>:YcmDiags</code> command
  1060. for any diagnostics with available fix-its (where the completer can provide this
  1061. indication).</p><p><strong>NOTE:</strong> Causes re-parsing of the current translation unit.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda, cs, go, java, javascript,
  1062. rust, typescript</code></p><h4 id="the-refactorrename-new-name-subcommand">The <code>RefactorRename &lt;new name&gt;</code> subcommand</h4><p>In supported file types, this command attempts to perform a semantic rename of
  1063. the identifier under the cursor. This includes renaming declarations,
  1064. definitions and usages of the identifier, or any other language-appropriate
  1065. action. The specific behavior is defined by the semantic engine in use.</p><p>Similar to <code>FixIt</code>, this command applies automatic modifications to your source
  1066. files. Rename operations may involve changes to multiple files, which may or may
  1067. not be open in Vim buffers at the time. YouCompleteMe handles all of this for
  1068. you. The behavior is described in <a href="#multi-file-refactor">the following section</a>.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda, java, javascript, typescript, rust, cs</code></p><h4 id="multi-file-refactor">Multi-file Refactor</h4><p>When a Refactor or FixIt command touches multiple files, YouCompleteMe attempts
  1069. to apply those modifications to any existing open, visible buffer in the current
  1070. tab. If no such buffer can be found, YouCompleteMe opens the file in a new
  1071. small horizontal split at the top of the current window, applies the change,
  1072. and then <em>hides</em> the window. <strong>NOTE:</strong> The buffer remains open, and must be
  1073. manually saved. A confirmation dialog is opened prior to doing this to remind
  1074. you that this is about to happen.</p><p>Once the modifications have been made, the quickfix list (see <code>:help quickfix</code>)
  1075. is populated with the locations of all modifications. This can be used to review
  1076. all automatic changes made by using <code>:copen</code>. Typically, use the <code>CTRL-W
  1077. &lt;enter&gt;</code> combination to open the selected file in a new split. It is possible to
  1078. customize how the quickfix window is opened by using <a href="#the-ycmquickfixopened-autocommand">the <code>YcmQuickFixOpened</code>
  1079. autocommand</a>.</p><p>The buffers are <em>not</em> saved automatically. That is, you must save the modified
  1080. buffers manually after reviewing the changes from the quickfix list. Changes
  1081. can be undone using Vim's powerful undo features (see <code>:help undo</code>). Note
  1082. that Vim's undo is per-buffer, so to undo all changes, the undo commands must
  1083. be applied in each modified buffer separately.</p><p><strong>NOTE:</strong> While applying modifications, Vim may find files which are already
  1084. open and have a swap file. The command is aborted if you select Abort or Quit in
  1085. any such prompts. This leaves the Refactor operation partially complete and must
  1086. be manually corrected using Vim's undo features. The quickfix list is <em>not</em>
  1087. populated in this case. Inspect <code>:buffers</code> or equivalent (see <code>:help buffers</code>)
  1088. to see the buffers that were opened by the command.</p><h4 id="the-format-subcommand">The <code>Format</code> subcommand</h4><p>This command formats the whole buffer or some part of it according to the value
  1089. of the Vim options <code>shiftwidth</code> and <code>expandtab</code> (see <code>:h 'sw'</code> and <code>:h et</code>
  1090. respectively). To format a specific part of your document, you can either select
  1091. it in one of Vim's visual modes (see <code>:h visual-use</code>) and run the command or
  1092. directly enter the range on the command line, e.g. <code>:2,5YcmCompleter Format</code> to
  1093. format it from line 2 to line 5.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda, java, javascript, go, typescript, rust, cs</code></p><h4 id="the-organizeimports-subcommand">The <code>OrganizeImports</code> subcommand</h4><p>This command removes unused imports and sorts imports in the current file. It
  1094. can also group imports from the same module in TypeScript and resolves imports
  1095. in Java.</p><p>Supported in filetypes: <code>java, javascript, typescript</code></p><h3 id="miscellaneous-commands">Miscellaneous Commands</h3><p>These commands are for general administration, rather than IDE-like features.
  1096. They cover things like the semantic engine server instance and compilation
  1097. flags.</p><h4 id="the-executecommand-args-subcommand">The <code>ExecuteCommand &lt;args&gt;</code> subcommand</h4><p>Some LSP completers (currently Rust and Java completers) support executing
  1098. server specific commands. Consult the <a href="https://github.com/rust-lang/rls">rls</a> and <a href="https://github.com/eclipse/eclipse.jdt.ls">jdt.ls</a> respective
  1099. documentations to find out what commands are supported and which arguments are
  1100. expected.</p><p>The support for <code>ExecuteCommand</code> was implemented to support plugins like
  1101. <a href="https://github.com/puremourning/vimspector">vimspector</a> to debug java, but isn't limited to that specific use case.</p><h4 id="the-restartserver-subcommand">The <code>RestartServer</code> subcommand</h4><p>Restarts the semantic-engine-as-localhost-server for those semantic engines that
  1102. work as separate servers that YCM talks to.</p><p>Supported in filetypes: <code>c, cpp, objc, objcpp, cuda, cs, go, java, javascript, rust, typescript</code></p><h4 id="the-reloadsolution-subcommand">The <code>ReloadSolution</code> subcommand</h4><p>Instruct the Omnisharp-Roslyn server to clear its cache and reload all files
  1103. from disk. This is useful when files are added, removed, or renamed in the
  1104. solution, files are changed outside of Vim, or whenever Omnisharp-Roslyn cache
  1105. is out-of-sync.</p><p>Supported in filetypes: <code>cs</code></p><h2 id="functions">Functions</h2><h3 id="the-youcompletemegeterrorcount-function">The <code>youcompleteme#GetErrorCount</code> function</h3><p>Get the number of YCM Diagnostic errors. If no errors are present, this function
  1106. returns 0.</p><p>For example:</p><pre><code class="viml"> call youcompleteme#GetErrorCount()
  1107. </code></pre><p>Both this function and <code>youcompleteme#GetWarningCount</code> can be useful when
  1108. integrating YCM with other Vim plugins. For example, a <a href="https://github.com/itchyny/lightline.vim">lightline</a> user could
  1109. add a diagnostics section to their statusline which would display the number of
  1110. errors and warnings.</p><h3 id="the-youcompletemegetwarningcount-function">The <code>youcompleteme#GetWarningCount</code> function</h3><p>Get the number of YCM Diagnostic warnings. If no warnings are present, this
  1111. function returns 0.</p><p>For example:</p><pre><code class="viml"> call youcompleteme#GetWarningCount()
  1112. </code></pre><h3 id="the-youcompletemegetcommandresponse---function">The <code>youcompleteme#GetCommandResponse( ... )</code> function</h3><p>Run a <a href="#ycmcompleter-subcommands">completer subcommand</a> and return the result as
  1113. a string. This can be useful for example to display the <code>GetGoc</code> output in a
  1114. popup window, e.g.:</p><pre><code class="viml">let s:ycm_hover_popup = -1
  1115. function s:Hover()
  1116. let response = youcompleteme#GetCommandResponse( 'GetDoc' )
  1117. if response == ''
  1118. return
  1119. endif
  1120. call popup_hide( s:ycm_hover_popup )
  1121. let s:ycm_hover_popup = popup_atcursor( balloon_split( response ), {} )
  1122. endfunction
  1123. " CursorHold triggers in normal mode after a delay
  1124. autocmd CursorHold * call s:Hover()
  1125. " Or, if you prefer, a mapping:
  1126. nnoremap &lt;silent&gt; &lt;leader&gt;D :call &lt;SID&gt;Hover()&lt;CR&gt;
  1127. </code></pre><p><strong>NOTE</strong>: This is only an example, for real hover support, see
  1128. <a href="#the-gycm_auto_hover-option"><code>g:ycm_auto_hover</code></a>.</p><p>If the completer subcommand result is not a string (for example, it's a FixIt or
  1129. a Location), or if the completer subcommand raises an error, an empty string is
  1130. returned, so that calling code does not have to check for complex error
  1131. conditions.</p><p>The arguments to the function are the same as the arguments to the
  1132. <code>:YcmCompleter</code> ex command, e.g. the name of the subcommand, followed by any
  1133. additional subcommand arguments. As with the <code>YcmCompleter</code> command, if the
  1134. first argument is <code>ft=&lt;filetype&gt;</code> the request is targetted at the specified
  1135. filetype completer. This is an advanced usage and not necessary in most cases.</p><p>NOTE: The request is run synchronously and blocks Vim until the response is
  1136. received, so we do not recommend running this as part of an autocommand that
  1137. triggers frequently.</p><h2 id="autocommands">Autocommands</h2><h3 id="the-ycmlocationopened-autocommand">The <code>YcmLocationOpened</code> autocommand</h3><p>This <code>User</code> autocommand is fired when YCM opens the location list window in
  1138. response to the <code>YcmDiags</code> command. By default, the location list window is
  1139. opened to the bottom of the current window and its height is set to fit all
  1140. entries. This behavior can be overridden by using the <code>YcmLocationOpened</code>
  1141. autocommand which is triggered while the cursor is in the location list window.
  1142. For instance:</p><pre><code class="viml">function! s:CustomizeYcmLocationWindow()
  1143. " Move the window to the top of the screen.
  1144. wincmd K
  1145. " Set the window height to 5.
  1146. 5wincmd _
  1147. " Switch back to working window.
  1148. wincmd p
  1149. endfunction
  1150. autocmd User YcmLocationOpened call s:CustomizeYcmLocationWindow()
  1151. </code></pre><h3 id="the-ycmquickfixopened-autocommand">The <code>YcmQuickFixOpened</code> autocommand</h3><p>This <code>User</code> autocommand is fired when YCM opens the quickfix window in response
  1152. to the <code>GoTo*</code> and <code>RefactorRename</code> subcommands. By default, the quickfix window
  1153. is opened to full width at the bottom of the screen and its height is set to fit
  1154. all entries. This behavior can be overridden by using the <code>YcmQuickFixOpened</code>
  1155. autocommand which is triggered while the cursor is in the quickfix window. For
  1156. instance:</p><pre><code class="viml">function! s:CustomizeYcmQuickFixWindow()
  1157. " Move the window to the top of the screen.
  1158. wincmd K
  1159. " Set the window height to 5.
  1160. 5wincmd _
  1161. endfunction
  1162. autocmd User YcmQuickFixOpened call s:CustomizeYcmQuickFixWindow()
  1163. </code></pre><h2 id="options">Options</h2><p>All options have reasonable defaults so if the plug-in works after installation
  1164. you don't need to change any options. These options can be configured in your
  1165. <a href="https://vimhelp.appspot.com/starting.txt.html#vimrc">vimrc script</a> by including a line like this:</p><pre><code class="viml">let g:ycm_min_num_of_chars_for_completion = 1
  1166. </code></pre><p>Note that after changing an option in your <a href="https://vimhelp.appspot.com/starting.txt.html#vimrc">vimrc script</a> you have to
  1167. restart <a href="https://github.com/ycm-core/ycmd">ycmd</a> with the <code>:YcmRestartServer</code> command for the changes to take
  1168. effect.</p><h3 id="the-gycm_min_num_of_chars_for_completion-option">The <code>g:ycm_min_num_of_chars_for_completion</code> option</h3><p>This option controls the number of characters the user needs to type before
  1169. identifier-based completion suggestions are triggered. For example, if the
  1170. option is set to <code>2</code>, then when the user types a second alphanumeric character
  1171. after a whitespace character, completion suggestions will be triggered. This
  1172. option is NOT used for semantic completion.</p><p>Setting this option to a high number like <code>99</code> effectively turns off the
  1173. identifier completion engine and just leaves the semantic engine.</p><p>Default: <code>2</code></p><pre><code class="viml">let g:ycm_min_num_of_chars_for_completion = 2
  1174. </code></pre><h3 id="the-gycm_min_num_identifier_candidate_chars-option">The <code>g:ycm_min_num_identifier_candidate_chars</code> option</h3><p>This option controls the minimum number of characters that a completion
  1175. candidate coming from the identifier completer must have to be shown in the
  1176. popup menu.</p><p>A special value of <code>0</code> means there is no limit.</p><p><strong>NOTE:</strong> This option only applies to the identifier completer; it has no effect
  1177. on the various semantic completers.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_min_num_identifier_candidate_chars = 0
  1178. </code></pre><h3 id="the-gycm_max_num_candidates-option">The <code>g:ycm_max_num_candidates</code> option</h3><p>This option controls the maximum number of semantic completion suggestions shown
  1179. in the completion menu. This only applies to suggestions from semantic
  1180. completion engines; see <a href="#the-gycm_max_num_identifier_candidates-option">the <code>g:ycm_max_identifier_candidates</code>
  1181. option</a> to limit the number of
  1182. suggestions from the identifier-based engine.</p><p>A special value of <code>0</code> means there is no limit.</p><p><strong>NOTE:</strong> Setting this option to <code>0</code> or to a value greater than <code>100</code> is not
  1183. recommended as it will slow down completion when there are a very large number
  1184. of suggestions.</p><p>Default: <code>50</code></p><pre><code class="viml">let g:ycm_max_num_candidates = 50
  1185. </code></pre><h3 id="the-gycm_max_num_identifier_candidates-option">The <code>g:ycm_max_num_identifier_candidates</code> option</h3><p>This option controls the maximum number of completion suggestions from the
  1186. identifier-based engine shown in the completion menu.</p><p>A special value of <code>0</code> means there is no limit.</p><p><strong>NOTE:</strong> Setting this option to <code>0</code> or to a value greater than <code>100</code> is not
  1187. recommended as it will slow down completion when there are a very large number
  1188. of suggestions.</p><p>Default: <code>10</code></p><pre><code class="viml">let g:ycm_max_num_identifier_candidates = 10
  1189. </code></pre><h3 id="the-gycm_auto_trigger-option">The <code>g:ycm_auto_trigger</code> option</h3><p>When set to <code>0</code>, this option turns off YCM's identifier completer (the
  1190. as-you-type popup) <em>and</em> the semantic triggers (the popup you'd get after typing
  1191. <code>.</code> or <code>-&gt;</code> in say C++). You can still force semantic completion with the
  1192. <code>&lt;C-Space&gt;</code> shortcut.</p><p>If you want to just turn off the identifier completer but keep the semantic
  1193. triggers, you should set <code>g:ycm_min_num_of_chars_for_completion</code> to a high
  1194. number like <code>99</code>.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_auto_trigger = 1
  1195. </code></pre><h3 id="the-gycm_filetype_whitelist-option">The <code>g:ycm_filetype_whitelist</code> option</h3><p>This option controls for which Vim filetypes (see <code>:h filetype</code>) should YCM be
  1196. turned on. The option value should be a Vim dictionary with keys being filetype
  1197. strings (like <code>python</code>, <code>cpp</code>, etc.) and values being unimportant (the
  1198. dictionary is used like a hash set, meaning that only the keys matter).</p><p>The <code>*</code> key is special and matches all filetypes. By default, the whitelist
  1199. contains only this <code>*</code> key.</p><p>YCM also has a <code>g:ycm_filetype_blacklist</code> option that lists filetypes for which
  1200. YCM shouldn't be turned on. YCM will work only in filetypes that both the
  1201. whitelist and the blacklist allow (the blacklist "allows" a filetype by <em>not</em>
  1202. having it as a key).</p><p>For example, let's assume you want YCM to work in files with the <code>cpp</code> filetype.
  1203. The filetype should then be present in the whitelist either directly (<code>cpp</code> key
  1204. in the whitelist) or indirectly through the special <code>*</code> key. It should <em>not</em> be
  1205. present in the blacklist.</p><p>Filetypes that are blocked by the either of the lists will be completely ignored
  1206. by YCM, meaning that neither the identifier-based completion engine nor the
  1207. semantic engine will operate in them.</p><p>You can get the filetype of the current file in Vim with <code>:set ft?</code>.</p><p>Default: <code>{'*': 1}</code></p><pre><code class="viml">let g:ycm_filetype_whitelist = {'*': 1}
  1208. </code></pre><h3 id="the-gycm_filetype_blacklist-option">The <code>g:ycm_filetype_blacklist</code> option</h3><p>This option controls for which Vim filetypes (see <code>:h filetype</code>) should YCM be
  1209. turned off. The option value should be a Vim dictionary with keys being filetype
  1210. strings (like <code>python</code>, <code>cpp</code>, etc.) and values being unimportant (the
  1211. dictionary is used like a hash set, meaning that only the keys matter).</p><p>See the <code>g:ycm_filetype_whitelist</code> option for more details on how this works.</p><p>Default: <code>[see next line]</code></p><pre><code class="viml">let g:ycm_filetype_blacklist = {
  1212. \ 'tagbar': 1,
  1213. \ 'notes': 1,
  1214. \ 'markdown': 1,
  1215. \ 'netrw': 1,
  1216. \ 'unite': 1,
  1217. \ 'text': 1,
  1218. \ 'vimwiki': 1,
  1219. \ 'pandoc': 1,
  1220. \ 'infolog': 1,
  1221. \ 'leaderf': 1,
  1222. \ 'mail': 1
  1223. \}
  1224. </code></pre><h3 id="the-gycm_filetype_specific_completion_to_disable-option">The <code>g:ycm_filetype_specific_completion_to_disable</code> option</h3><p>This option controls for which Vim filetypes (see <code>:h filetype</code>) should the YCM
  1225. semantic completion engine be turned off. The option value should be a Vim
  1226. dictionary with keys being filetype strings (like <code>python</code>, <code>cpp</code>, etc.) and
  1227. values being unimportant (the dictionary is used like a hash set, meaning that
  1228. only the keys matter). The listed filetypes will be ignored by the YCM semantic
  1229. completion engine, but the identifier-based completion engine will still trigger
  1230. in files of those filetypes.</p><p>Note that even if semantic completion is not turned off for a specific filetype,
  1231. you will not get semantic completion if the semantic engine does not support
  1232. that filetype.</p><p>You can get the filetype of the current file in Vim with <code>:set ft?</code>.</p><p>Default: <code>[see next line]</code></p><pre><code class="viml">let g:ycm_filetype_specific_completion_to_disable = {
  1233. \ 'gitcommit': 1
  1234. \}
  1235. </code></pre><h3 id="the-gycm_filepath_blacklist-option">The <code>g:ycm_filepath_blacklist</code> option</h3><p>This option controls for which Vim filetypes (see <code>:h filetype</code>) should filepath
  1236. completion be disabled. The option value should be a Vim dictionary with keys
  1237. being filetype strings (like <code>python</code>, <code>cpp</code>, etc.) and values being unimportant
  1238. (the dictionary is used like a hash set, meaning that only the keys matter).</p><p>The <code>*</code> key is special and matches all filetypes. Use this key if you want to
  1239. completely disable filepath completion:</p><pre><code class="viml">let g:ycm_filepath_blacklist = {'*': 1}
  1240. </code></pre><p>You can get the filetype of the current file in Vim with <code>:set ft?</code>.</p><p>Default: <code>[see next line]</code></p><pre><code class="viml">let g:ycm_filepath_blacklist = {
  1241. \ 'html': 1,
  1242. \ 'jsx': 1,
  1243. \ 'xml': 1,
  1244. \}
  1245. </code></pre><h3 id="the-gycm_show_diagnostics_ui-option">The <code>g:ycm_show_diagnostics_ui</code> option</h3><p>When set, this option turns on YCM's diagnostic display features. See the
  1246. <em>Diagnostic display</em> section in the <em>User Manual</em> for more details.</p><p>Specific parts of the diagnostics UI (like the gutter signs, text highlighting,
  1247. diagnostic echo and auto location list population) can be individually turned on
  1248. or off. See the other options below for details.</p><p>Note that YCM's diagnostics UI is only supported for C-family languages.</p><p>When set, this option also makes YCM remove all Syntastic checkers set for the
  1249. <code>c</code>, <code>cpp</code>, <code>objc</code>, <code>objcpp</code>, and <code>cuda</code> filetypes since this would conflict
  1250. with YCM's own diagnostics UI.</p><p>If you're using YCM's identifier completer in C-family languages but cannot use
  1251. the clang-based semantic completer for those languages <em>and</em> want to use the GCC
  1252. Syntastic checkers, unset this option.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_show_diagnostics_ui = 1
  1253. </code></pre><h3 id="the-gycm_error_symbol-option">The <code>g:ycm_error_symbol</code> option</h3><p>YCM will use the value of this option as the symbol for errors in the Vim
  1254. gutter.</p><p>This option is part of the Syntastic compatibility layer; if the option is not
  1255. set, YCM will fall back to the value of the <code>g:syntastic_error_symbol</code> option
  1256. before using this option's default.</p><p>Default: <code>&gt;&gt;</code></p><pre><code class="viml">let g:ycm_error_symbol = '&gt;&gt;'
  1257. </code></pre><h3 id="the-gycm_warning_symbol-option">The <code>g:ycm_warning_symbol</code> option</h3><p>YCM will use the value of this option as the symbol for warnings in the Vim
  1258. gutter.</p><p>This option is part of the Syntastic compatibility layer; if the option is not
  1259. set, YCM will fall back to the value of the <code>g:syntastic_warning_symbol</code> option
  1260. before using this option's default.</p><p>Default: <code>&gt;&gt;</code></p><pre><code class="viml">let g:ycm_warning_symbol = '&gt;&gt;'
  1261. </code></pre><h3 id="the-gycm_enable_diagnostic_signs-option">The <code>g:ycm_enable_diagnostic_signs</code> option</h3><p>When this option is set, YCM will put icons in Vim's gutter on lines that have a
  1262. diagnostic set. Turning this off will also turn off the <code>YcmErrorLine</code> and
  1263. <code>YcmWarningLine</code> highlighting.</p><p>This option is part of the Syntastic compatibility layer; if the option is not
  1264. set, YCM will fall back to the value of the <code>g:syntastic_enable_signs</code> option
  1265. before using this option's default.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_enable_diagnostic_signs = 1
  1266. </code></pre><h3 id="the-gycm_enable_diagnostic_highlighting-option">The <code>g:ycm_enable_diagnostic_highlighting</code> option</h3><p>When this option is set, YCM will highlight regions of text that are related to
  1267. the diagnostic that is present on a line, if any.</p><p>This option is part of the Syntastic compatibility layer; if the option is not
  1268. set, YCM will fall back to the value of the <code>g:syntastic_enable_highlighting</code>
  1269. option before using this option's default.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_enable_diagnostic_highlighting = 1
  1270. </code></pre><h3 id="the-gycm_echo_current_diagnostic-option">The <code>g:ycm_echo_current_diagnostic</code> option</h3><p>When this option is set, YCM will echo the text of the diagnostic present on the
  1271. current line when you move your cursor to that line. If a <code>FixIt</code> is available
  1272. for the current diagnostic, then <code>(FixIt)</code> is appended.</p><p>This option is part of the Syntastic compatibility layer; if the option is not
  1273. set, YCM will fall back to the value of the <code>g:syntastic_echo_current_error</code>
  1274. option before using this option's default.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_echo_current_diagnostic = 1
  1275. </code></pre><h3 id="the-gycm_auto_hover-option">The <code>g:ycm_auto_hover</code> option</h3><p>This option controls whether or not YCM shows documentation in a popup at the
  1276. cursor location after a short delay. Only supported in Vim.</p><p>When this option is set to <code>'CursorHold'</code>, the popup is displayed on the
  1277. <code>CursorHold</code> autocommand. See <code>:help CursorHold</code> for the details, but this means
  1278. that it is displayed after <code>updatetime</code> milliseconds. When set to an empty
  1279. string, the popup is not automatically displayed.</p><p>In addition to this setting, there is the <code>&lt;plug&gt;(YCMHover)</code> mapping, which can
  1280. be used to manually trigger or hide the popup (it works like a toggle).
  1281. For example:</p><pre><code class="viml">nmap &lt;leader&gt;D &lt;plug&gt;(YCMHover)
  1282. </code></pre><p>After dismissing the popup with this mapping, it will not be automatically
  1283. triggered again until the cursor is moved (i.e. <code>CursorMoved</code> autocommand).</p><p>The displayed documentation depends on what the completer for the current
  1284. language supports. It's selected heuristically in this order of preference:</p><ol>
  1285. <li><code>GetHover</code> with <code>markdown</code> syntax</li>
  1286. <li><code>GetDoc</code> with no syntax</li>
  1287. <li><code>GetType</code> with the syntax of the current file. </li>
  1288. </ol><p>You can customise this by manually setting up <code>b:ycm_hover</code> to your liking. This
  1289. buffer-local variable can be set to a dictionary with the following keys:</p><ul>
  1290. <li><code>command</code>: The YCM completer subcommand which should be run on hover</li>
  1291. <li><code>syntax</code>: The syntax to use (as in <code>set syntax=</code>) in the popup window for
  1292. highlighting.</li>
  1293. </ul><p>For example, to use C/C++ syntax highlighting in the popup for C-family
  1294. languages, add something like this to your vimrc:</p><pre><code class="viml">augroup MyYCMCustom
  1295. autocmd!
  1296. autocmd FileType c,cpp let b:ycm_hover = {
  1297. \ 'command': 'GetDoc',
  1298. \ 'syntax': &amp;filetype
  1299. \ }
  1300. augroup END
  1301. </code></pre><p>Default: <code>'CursorHold'</code></p><h3 id="the-gycm_filter_diagnostics-option">The <code>g:ycm_filter_diagnostics</code> option</h3><p>This option controls which diagnostics will be rendered by YCM. This option
  1302. holds a dictionary of key-values, where the keys are Vim's filetype strings
  1303. delimited by commas and values are dictionaries describing the filter.</p><p>A filter is a dictionary of key-values, where the keys are the type of filter,
  1304. and the value is a list of arguments to that filter. In the case of just a
  1305. single item in the list, you may omit the brackets and just provide the argument
  1306. directly. If any filter matches a diagnostic, it will be dropped and YCM will
  1307. not render it.</p><p>The following filter types are supported:</p><ul>
  1308. <li>"regex": Accepts a string <a href="https://docs.python.org/2/library/re.html#regular-expression-syntax">regular expression</a>. This type matches
  1309. when the regex (treated as case-insensitive) is found in the diagnostic text.</li>
  1310. <li>"level": Accepts a string level, either "warning" or "error." This type
  1311. matches when the diagnostic has the same level.</li>
  1312. </ul><p><strong>NOTE:</strong> The regex syntax is <strong>NOT</strong> Vim's, it's <a href="https://docs.python.org/2/library/re.html#regular-expression-syntax">Python's</a>.</p><p>Default: <code>{}</code></p><pre><code class="viml">let g:ycm_filter_diagnostics = {
  1313. \ "java": {
  1314. \ "regex": [ ".*taco.*", ... ],
  1315. \ "level": "error",
  1316. \ ...
  1317. \ }
  1318. \ }
  1319. </code></pre><h3 id="the-gycm_always_populate_location_list-option">The <code>g:ycm_always_populate_location_list</code> option</h3><p>When this option is set, YCM will populate the location list automatically every
  1320. time it gets new diagnostic data. This option is off by default so as not to
  1321. interfere with other data you might have placed in the location list.</p><p>See <code>:help location-list</code> in Vim to learn more about the location list.</p><p>This option is part of the Syntastic compatibility layer; if the option is not
  1322. set, YCM will fall back to the value of the
  1323. <code>g:syntastic_always_populate_loc_list</code> option before using this option's
  1324. default.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_always_populate_location_list = 0
  1325. </code></pre><h3 id="the-gycm_open_loclist_on_ycm_diags-option">The <code>g:ycm_open_loclist_on_ycm_diags</code> option</h3><p>When this option is set, <code>:YcmDiags</code> will automatically open the location list
  1326. after forcing a compilation and filling the list with diagnostic data.</p><p>See <code>:help location-list</code> in Vim to learn more about the location list.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_open_loclist_on_ycm_diags = 1
  1327. </code></pre><h3 id="the-gycm_complete_in_comments-option">The <code>g:ycm_complete_in_comments</code> option</h3><p>When this option is set to <code>1</code>, YCM will show the completion menu even when
  1328. typing inside comments.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_complete_in_comments = 0
  1329. </code></pre><h3 id="the-gycm_complete_in_strings-option">The <code>g:ycm_complete_in_strings</code> option</h3><p>When this option is set to <code>1</code>, YCM will show the completion menu even when
  1330. typing inside strings.</p><p>Note that this is turned on by default so that you can use the filename
  1331. completion inside strings. This is very useful for instance in C-family files
  1332. where typing <code>#include "</code> will trigger the start of filename completion. If you
  1333. turn off this option, you will turn off filename completion in such situations
  1334. as well.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_complete_in_strings = 1
  1335. </code></pre><h3 id="the-gycm_collect_identifiers_from_comments_and_strings-option">The <code>g:ycm_collect_identifiers_from_comments_and_strings</code> option</h3><p>When this option is set to <code>1</code>, YCM's identifier completer will also collect
  1336. identifiers from strings and comments. Otherwise, the text in comments and
  1337. strings will be ignored.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_collect_identifiers_from_comments_and_strings = 0
  1338. </code></pre><h3 id="the-gycm_collect_identifiers_from_tags_files-option">The <code>g:ycm_collect_identifiers_from_tags_files</code> option</h3><p>When this option is set to <code>1</code>, YCM's identifier completer will also collect
  1339. identifiers from tags files. The list of tags files to examine is retrieved from
  1340. the <code>tagfiles()</code> Vim function which examines the <code>tags</code> Vim option. See <code>:h
  1341. 'tags'</code> for details.</p><p>YCM will re-index your tags files if it detects that they have been modified.</p><p>The only supported tag format is the <a href="http://ctags.sourceforge.net/FORMAT">Exuberant Ctags format</a>. The
  1342. format from "plain" ctags is NOT supported. Ctags needs to be called with the
  1343. <code>--fields=+l</code> option (that's a lowercase <code>L</code>, not a one) because YCM needs the
  1344. <code>language:&lt;lang&gt;</code> field in the tags output.</p><p>See the <em>FAQ</em> for pointers if YCM does not appear to read your tag files.</p><p>This option is off by default because it makes Vim slower if your tags are on a
  1345. network directory.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_collect_identifiers_from_tags_files = 0
  1346. </code></pre><h3 id="the-gycm_seed_identifiers_with_syntax-option">The <code>g:ycm_seed_identifiers_with_syntax</code> option</h3><p>When this option is set to <code>1</code>, YCM's identifier completer will seed its
  1347. identifier database with the keywords of the programming language you're
  1348. writing.</p><p>Since the keywords are extracted from the Vim syntax file for the filetype, all
  1349. keywords may not be collected, depending on how the syntax file was written.
  1350. Usually at least 95% of the keywords are successfully extracted.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_seed_identifiers_with_syntax = 0
  1351. </code></pre><h3 id="the-gycm_extra_conf_vim_data-option">The <code>g:ycm_extra_conf_vim_data</code> option</h3><p>If you're using semantic completion for C-family files, this option might come
  1352. handy; it's a way of sending data from Vim to your <code>Settings</code> function in
  1353. your <code>.ycm_extra_conf.py</code> file.</p><p>This option is supposed to be a list of VimScript expression strings that are
  1354. evaluated for every request to the <a href="https://github.com/ycm-core/ycmd">ycmd server</a> and then passed to your
  1355. <code>Settings</code> function as a <code>client_data</code> keyword argument.</p><p>For instance, if you set this option to <code>['v:version']</code>, your <code>Settings</code>
  1356. function will be called like this:</p><pre><code class="python"># The '801' value is of course contingent on Vim 8.1; in 8.0 it would be '800'
  1357. Settings( ..., client_data = { 'v:version': 801 } )
  1358. </code></pre><p>So the <code>client_data</code> parameter is a dictionary mapping Vim expression strings to
  1359. their values at the time of the request.</p><p>The correct way to define parameters for your <code>Settings</code> function:</p><pre><code class="python">def Settings( **kwargs ):
  1360. </code></pre><p>You can then get to <code>client_data</code> with <code>kwargs['client_data']</code>.</p><p>Default: <code>[]</code></p><pre><code class="viml">let g:ycm_extra_conf_vim_data = []
  1361. </code></pre><h3 id="the-gycm_server_python_interpreter-option">The <code>g:ycm_server_python_interpreter</code> option</h3><p>YCM will by default search for an appropriate Python interpreter on your system.
  1362. You can use this option to override that behavior and force the use of a
  1363. specific interpreter of your choosing.</p><p><strong>NOTE:</strong> This interpreter is only used for the <a href="https://github.com/ycm-core/ycmd">ycmd server</a>. The YCM
  1364. client running inside Vim always uses the Python interpreter that's embedded
  1365. inside Vim.</p><p>Default: <code>''</code></p><pre><code class="viml">let g:ycm_server_python_interpreter = ''
  1366. </code></pre><h3 id="the-gycm_keep_logfiles-option">The <code>g:ycm_keep_logfiles</code> option</h3><p>When this option is set to <code>1</code>, YCM and the <a href="https://github.com/ycm-core/ycmd">ycmd completion server</a> will
  1367. keep the logfiles around after shutting down (they are deleted on shutdown by
  1368. default).</p><p>To see where the logfiles are, call <code>:YcmDebugInfo</code>.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_keep_logfiles = 0
  1369. </code></pre><h3 id="the-gycm_log_level-option">The <code>g:ycm_log_level</code> option</h3><p>The logging level that YCM and the <a href="https://github.com/ycm-core/ycmd">ycmd completion server</a> use. Valid
  1370. values are the following, from most verbose to least verbose:
  1371. - <code>debug</code>
  1372. - <code>info</code>
  1373. - <code>warning</code>
  1374. - <code>error</code>
  1375. - <code>critical</code></p><p>Note that <code>debug</code> is <em>very</em> verbose.</p><p>Default: <code>info</code></p><pre><code class="viml">let g:ycm_log_level = 'info'
  1376. </code></pre><h3 id="the-gycm_auto_start_csharp_server-option">The <code>g:ycm_auto_start_csharp_server</code> option</h3><p>When set to <code>1</code>, the OmniSharp-Roslyn server will be automatically started
  1377. (once per Vim session) when you open a C# file.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_auto_start_csharp_server = 1
  1378. </code></pre><h3 id="the-gycm_auto_stop_csharp_server-option">The <code>g:ycm_auto_stop_csharp_server</code> option</h3><p>When set to <code>1</code>, the OmniSharp-Roslyn server will be automatically stopped upon
  1379. closing Vim.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_auto_stop_csharp_server = 1
  1380. </code></pre><h3 id="the-gycm_csharp_server_port-option">The <code>g:ycm_csharp_server_port</code> option</h3><p>When g:ycm_auto_start_csharp_server is set to <code>1</code>, specifies the port for
  1381. the OmniSharp-Roslyn server to listen on. When set to <code>0</code> uses an unused port provided
  1382. by the OS.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_csharp_server_port = 0
  1383. </code></pre><h3 id="the-gycm_csharp_insert_namespace_expr-option">The <code>g:ycm_csharp_insert_namespace_expr</code> option</h3><p>By default, when YCM inserts a namespace, it will insert the <code>using</code> statement
  1384. under the nearest <code>using</code> statement. You may prefer that the <code>using</code> statement is
  1385. inserted somewhere, for example, to preserve sorting. If so, you can set this
  1386. option to override this behavior.</p><p>When this option is set, instead of inserting the <code>using</code> statement itself, YCM
  1387. will set the global variable <code>g:ycm_namespace_to_insert</code> to the namespace to
  1388. insert, and then evaluate this option's value as an expression. The option's
  1389. expression is responsible for inserting the namespace - the default insertion
  1390. will not occur.</p><p>Default: ''</p><pre><code class="viml">let g:ycm_csharp_insert_namespace_expr = ''
  1391. </code></pre><h3 id="the-gycm_add_preview_to_completeopt-option">The <code>g:ycm_add_preview_to_completeopt</code> option</h3><p>When this option is set to <code>1</code>, YCM will add the <code>preview</code> string to Vim's
  1392. <code>completeopt</code> option (see <code>:h completeopt</code>). If your <code>completeopt</code> option
  1393. already has <code>preview</code> set, there will be no effect. Alternatively, when set to
  1394. <code>popup</code> and your version of Vim supports popup windows (see <code>:help popup</code>), the
  1395. <code>popup</code> string will be used instead. You can see the current state of your
  1396. <code>completeopt</code> setting with <code>:set completeopt?</code> (yes, the question mark is
  1397. important).</p><p>When <code>preview</code> is present in <code>completeopt</code>, YCM will use the <code>preview</code> window at
  1398. the top of the file to store detailed information about the current completion
  1399. candidate (but only if the candidate came from the semantic engine). For
  1400. instance, it would show the full function prototype and all the function
  1401. overloads in the window if the current completion is a function name.</p><p>When <code>popup</code> is present in <code>completeopt</code>, YCM will instead use a <code>popup</code>
  1402. window to the side of the completion popup for storing detailed information
  1403. about the current completion candidate. In addition, YCM may truncate the
  1404. detailed completion information in order to give the popup sufficient room
  1405. to display that detailed information.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_add_preview_to_completeopt = 0
  1406. </code></pre><h3 id="the-gycm_autoclose_preview_window_after_completion-option">The <code>g:ycm_autoclose_preview_window_after_completion</code> option</h3><p>When this option is set to <code>1</code>, YCM will auto-close the <code>preview</code> window after
  1407. the user accepts the offered completion string. If there is no <code>preview</code> window
  1408. triggered because there is no <code>preview</code> string in <code>completeopt</code>, this option is
  1409. irrelevant. See the <code>g:ycm_add_preview_to_completeopt</code> option for more details.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_autoclose_preview_window_after_completion = 0
  1410. </code></pre><h3 id="the-gycm_autoclose_preview_window_after_insertion-option">The <code>g:ycm_autoclose_preview_window_after_insertion</code> option</h3><p>When this option is set to <code>1</code>, YCM will auto-close the <code>preview</code> window after
  1411. the user leaves insert mode. This option is irrelevant if
  1412. <code>g:ycm_autoclose_preview_window_after_completion</code> is set or if no <code>preview</code>
  1413. window is triggered. See the <code>g:ycm_add_preview_to_completeopt</code> option for more
  1414. details.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_autoclose_preview_window_after_insertion = 0
  1415. </code></pre><h3 id="the-gycm_max_diagnostics_to_display-option">The <code>g:ycm_max_diagnostics_to_display</code> option</h3><p>This option controls the maximum number of diagnostics shown to the user when
  1416. errors or warnings are detected in the file. This option is only relevant for
  1417. the C-family, C#, Java, JavaScript, and TypeScript languages.</p><p>A special value of <code>0</code> means there is no limit.</p><p>Default: <code>30</code></p><pre><code class="viml">let g:ycm_max_diagnostics_to_display = 30
  1418. </code></pre><h3 id="the-gycm_key_list_select_completion-option">The <code>g:ycm_key_list_select_completion</code> option</h3><p>This option controls the key mappings used to select the first completion
  1419. string. Invoking any of them repeatedly cycles forward through the completion
  1420. list.</p><p>Some users like adding <code>&lt;Enter&gt;</code> to this list.</p><p>Default: <code>['&lt;TAB&gt;', '&lt;Down&gt;']</code></p><pre><code class="viml">let g:ycm_key_list_select_completion = ['&lt;TAB&gt;', '&lt;Down&gt;']
  1421. </code></pre><h3 id="the-gycm_key_list_previous_completion-option">The <code>g:ycm_key_list_previous_completion</code> option</h3><p>This option controls the key mappings used to select the previous completion
  1422. string. Invoking any of them repeatedly cycles backwards through the completion
  1423. list.</p><p>Note that one of the defaults is <code>&lt;S-TAB&gt;</code> which means Shift-TAB. That mapping
  1424. will probably only work in GUI Vim (Gvim or MacVim) and not in plain console Vim
  1425. because the terminal usually does not forward modifier key combinations to Vim.</p><p>Default: <code>['&lt;S-TAB&gt;', '&lt;Up&gt;']</code></p><pre><code class="viml">let g:ycm_key_list_previous_completion = ['&lt;S-TAB&gt;', '&lt;Up&gt;']
  1426. </code></pre><h3 id="the-gycm_key_list_stop_completion-option">The <code>g:ycm_key_list_stop_completion</code> option</h3><p>This option controls the key mappings used to close the completion menu. This is
  1427. useful when the menu is blocking the view, when you need to insert the <code>&lt;TAB&gt;</code>
  1428. character, or when you want to expand a snippet from <a href="https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt">UltiSnips</a> and navigate
  1429. through it.</p><p>Default: <code>['&lt;C-y&gt;']</code></p><pre><code class="viml">let g:ycm_key_list_stop_completion = ['&lt;C-y&gt;']
  1430. </code></pre><h3 id="the-gycm_key_invoke_completion-option">The <code>g:ycm_key_invoke_completion</code> option</h3><p>This option controls the key mapping used to invoke the completion menu for
  1431. semantic completion. By default, semantic completion is triggered automatically
  1432. after typing <code>.</code>, <code>-&gt;</code> and <code>::</code> in insert mode (if semantic completion support
  1433. has been compiled in). This key mapping can be used to trigger semantic
  1434. completion anywhere. Useful for searching for top-level functions and classes.</p><p>Console Vim (not Gvim or MacVim) passes <code>&lt;Nul&gt;</code> to Vim when the user types
  1435. <code>&lt;C-Space&gt;</code> so YCM will make sure that <code>&lt;Nul&gt;</code> is used in the map command when
  1436. you're editing in console Vim, and <code>&lt;C-Space&gt;</code> in GUI Vim. This means that you
  1437. can just press <code>&lt;C-Space&gt;</code> in both console and GUI Vim and YCM will do the right
  1438. thing.</p><p>Setting this option to an empty string will make sure no mapping is created.</p><p>Default: <code>&lt;C-Space&gt;</code></p><pre><code class="viml">let g:ycm_key_invoke_completion = '&lt;C-Space&gt;'
  1439. </code></pre><h3 id="the-gycm_key_detailed_diagnostics-option">The <code>g:ycm_key_detailed_diagnostics</code> option</h3><p>This option controls the key mapping used to show the full diagnostic text when
  1440. the user's cursor is on the line with the diagnostic. It basically calls
  1441. <code>:YcmShowDetailedDiagnostic</code>.</p><p>Setting this option to an empty string will make sure no mapping is created.</p><p>Default: <code>&lt;leader&gt;d</code></p><pre><code class="viml">let g:ycm_key_detailed_diagnostics = '&lt;leader&gt;d'
  1442. </code></pre><h3 id="the-gycm_global_ycm_extra_conf-option">The <code>g:ycm_global_ycm_extra_conf</code> option</h3><p>Normally, YCM searches for a <code>.ycm_extra_conf.py</code> file for compilation flags
  1443. (see the User Guide for more details on how this works). This option specifies
  1444. a fallback path to a config file which is used if no <code>.ycm_extra_conf.py</code> is
  1445. found.</p><p>You can place such a global file anywhere in your filesystem.</p><p>Default: <code>''</code></p><pre><code class="viml">let g:ycm_global_ycm_extra_conf = ''
  1446. </code></pre><h3 id="the-gycm_confirm_extra_conf-option">The <code>g:ycm_confirm_extra_conf</code> option</h3><p>When this option is set to <code>1</code> YCM will ask once per <code>.ycm_extra_conf.py</code> file
  1447. if it is safe to be loaded. This is to prevent execution of malicious code
  1448. from a <code>.ycm_extra_conf.py</code> file you didn't write.</p><p>To selectively get YCM to ask/not ask about loading certain <code>.ycm_extra_conf.py</code>
  1449. files, see the <code>g:ycm_extra_conf_globlist</code> option.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_confirm_extra_conf = 1
  1450. </code></pre><h3 id="the-gycm_extra_conf_globlist-option">The <code>g:ycm_extra_conf_globlist</code> option</h3><p>This option is a list that may contain several globbing patterns. If a pattern
  1451. starts with a <code>!</code> all <code>.ycm_extra_conf.py</code> files matching that pattern will be
  1452. blacklisted, that is they won't be loaded and no confirmation dialog will be
  1453. shown. If a pattern does not start with a <code>!</code> all files matching that pattern
  1454. will be whitelisted. Note that this option is not used when confirmation is
  1455. disabled using <code>g:ycm_confirm_extra_conf</code> and that items earlier in the list
  1456. will take precedence over the later ones.</p><p>Rules:</p><ul>
  1457. <li><code>*</code> matches everything</li>
  1458. <li><code>?</code> matches any single character</li>
  1459. <li><code>[seq]</code> matches any character in seq</li>
  1460. <li><code>[!seq]</code> matches any char not in seq</li>
  1461. </ul><p>Example:</p><pre><code class="viml">let g:ycm_extra_conf_globlist = ['~/dev/*','!~/*']
  1462. </code></pre><ul>
  1463. <li>The first rule will match everything contained in the <code>~/dev</code> directory so
  1464. <code>.ycm_extra_conf.py</code> files from there will be loaded.</li>
  1465. <li>The second rule will match everything in the home directory so a
  1466. <code>.ycm_extra_conf.py</code> file from there won't be loaded.</li>
  1467. <li>As the first rule takes precedence everything in the home directory excluding
  1468. the <code>~/dev</code> directory will be blacklisted.</li>
  1469. </ul><p><strong>NOTE:</strong> The glob pattern is first expanded with Python's
  1470. <code>os.path.expanduser()</code> and then resolved with <code>os.path.abspath()</code> before being
  1471. matched against the filename.</p><p>Default: <code>[]</code></p><pre><code class="viml">let g:ycm_extra_conf_globlist = []
  1472. </code></pre><h3 id="the-gycm_filepath_completion_use_working_dir-option">The <code>g:ycm_filepath_completion_use_working_dir</code> option</h3><p>By default, YCM's filepath completion will interpret relative paths like <code>../</code>
  1473. as being relative to the folder of the file of the currently active buffer.
  1474. Setting this option will force YCM to always interpret relative paths as being
  1475. relative to Vim's current working directory.</p><p>Default: <code>0</code></p><pre><code class="viml">let g:ycm_filepath_completion_use_working_dir = 0
  1476. </code></pre><h3 id="the-gycm_semantic_triggers-option">The <code>g:ycm_semantic_triggers</code> option</h3><p>This option controls the character-based triggers for the various semantic
  1477. completion engines. The option holds a dictionary of key-values, where the keys
  1478. are Vim's filetype strings delimited by commas and values are lists of strings,
  1479. where the strings are the triggers.</p><p>Setting key-value pairs on the dictionary <em>adds</em> semantic triggers to the
  1480. internal default set (listed below). You cannot remove the default triggers,
  1481. only add new ones.</p><p>A "trigger" is a sequence of one or more characters that trigger semantic
  1482. completion when typed. For instance, C++ (<code>cpp</code> filetype) has <code>.</code> listed as a
  1483. trigger. So when the user types <code>foo.</code>, the semantic engine will trigger and
  1484. serve <code>foo</code>'s list of member functions and variables. Since C++ also has <code>-&gt;</code>
  1485. listed as a trigger, the same thing would happen when the user typed <code>foo-&gt;</code>.</p><p>It's also possible to use a regular expression as a trigger. You have to prefix
  1486. your trigger with <code>re!</code> to signify it's a regex trigger. For instance,
  1487. <code>re!\w+\.</code> would only trigger after the <code>\w+\.</code> regex matches.</p><p><strong>NOTE:</strong> The regex syntax is <strong>NOT</strong> Vim's, it's <a href="https://docs.python.org/2/library/re.html#regular-expression-syntax">Python's</a>.</p><p>Default: <code>[see next line]</code></p><pre><code class="viml">let g:ycm_semantic_triggers = {
  1488. \ 'c': ['-&gt;', '.'],
  1489. \ 'objc': ['-&gt;', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s',
  1490. \ 're!\[.*\]\s'],
  1491. \ 'ocaml': ['.', '#'],
  1492. \ 'cpp,cuda,objcpp': ['-&gt;', '.', '::'],
  1493. \ 'perl': ['-&gt;'],
  1494. \ 'php': ['-&gt;', '::'],
  1495. \ 'cs,d,elixir,go,groovy,java,javascript,julia,perl6,python,scala,typescript,vb': ['.'],
  1496. \ 'ruby,rust': ['.', '::'],
  1497. \ 'lua': ['.', ':'],
  1498. \ 'erlang': [':'],
  1499. \ }
  1500. </code></pre><h3 id="the-gycm_cache_omnifunc-option">The <code>g:ycm_cache_omnifunc</code> option</h3><p>Some omnicompletion engines do not work well with the YCM cache—in particular,
  1501. they might not produce all possible results for a given prefix. By unsetting
  1502. this option you can ensure that the omnicompletion engine is re-queried on every
  1503. keypress. That will ensure all completions will be presented, but might cause
  1504. stuttering and lagginess if the omnifunc is slow.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_cache_omnifunc = 1
  1505. </code></pre><h3 id="the-gycm_use_ultisnips_completer-option">The <code>g:ycm_use_ultisnips_completer</code> option</h3><p>By default, YCM will query the UltiSnips plugin for possible completions of
  1506. snippet triggers. This option can turn that behavior off.</p><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_use_ultisnips_completer = 1
  1507. </code></pre><h3 id="the-gycm_goto_buffer_command-option">The <code>g:ycm_goto_buffer_command</code> option</h3><p>Defines where <code>GoTo*</code> commands result should be opened. Can take one of the
  1508. following values: <code>'same-buffer'</code>, <code>'split'</code>, or <code>'split-or-existing-window'</code>.
  1509. If this option is set to the <code>'same-buffer'</code> but current buffer can not be
  1510. switched (when buffer is modified and <code>nohidden</code> option is set), then result
  1511. will be opened in a split. When the option is set to
  1512. <code>'split-or-existing-window'</code>, if the result is already open in a window of the
  1513. current tab page (or any tab pages with the <code>:tab</code> modifier; see below), it will
  1514. jump to that window. Otherwise, the result will be opened in a split as if the
  1515. option was set to <code>'split'</code>.</p><p>To customize the way a new window is split, prefix the <code>GoTo*</code> command with one
  1516. of the following modifiers: <code>:aboveleft</code>, <code>:belowright</code>, <code>:botright</code>,
  1517. <code>:leftabove</code>, <code>:rightbelow</code>, <code>:topleft</code>, and <code>:vertical</code>. For instance, to
  1518. split vertically to the right of the current window, run the command:</p><pre><code class="viml">:rightbelow vertical YcmCompleter GoTo
  1519. </code></pre><p>To open in a new tab page, use the <code>:tab</code> modifier with the <code>'split'</code> or
  1520. <code>'split-or-existing-window'</code> options e.g.:</p><pre><code class="viml">:tab YcmCompleter GoTo
  1521. </code></pre><p><strong>NOTE:</strong> command modifiers were added in Vim 7.4.1898. If you are using an
  1522. older version, you can still configure this by setting the option to one of the
  1523. deprecated values: <code>'vertical-split'</code>, <code>'new-tab'</code>, or <code>'new-or-existing-tab'</code>.</p><p>Default: <code>'same-buffer'</code></p><pre><code class="viml">let g:ycm_goto_buffer_command = 'same-buffer'
  1524. </code></pre><h3 id="the-gycm_disable_for_files_larger_than_kb-option">The <code>g:ycm_disable_for_files_larger_than_kb</code> option</h3><p>Defines the max size (in Kb) for a file to be considered for completion. If this
  1525. option is set to 0 then no check is made on the size of the file you're opening.</p><p>Default: 1000</p><pre><code class="viml">let g:ycm_disable_for_files_larger_than_kb = 1000
  1526. </code></pre><h3 id="the-gycm_use_clangd-option">The <code>g:ycm_use_clangd</code> option</h3><p>This option controls whether <strong>clangd</strong> should be used as completion engine for
  1527. C-family languages. Can take one of the following values: <code>1</code>, <code>0</code>, with
  1528. meanings:</p><ul>
  1529. <li><code>1</code>: YCM will use clangd if clangd binary exists in third party or it was
  1530. provided with <code>ycm_clangd_binary_path</code> option.</li>
  1531. <li><code>0</code>: YCM will never use clangd completer.</li>
  1532. </ul><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_use_clangd = 1
  1533. </code></pre><h3 id="the-gycm_clangd_binary_path-option">The <code>g:ycm_clangd_binary_path</code> option</h3><p>When <code>ycm_use_clangd</code> option is set to <code>1</code>, this option sets the path to
  1534. <strong>clangd</strong> binary.</p><p>Default: <code>''</code></p><pre><code class="viml">let g:ycm_clangd_binary_path = ''
  1535. </code></pre><h3 id="the-gycm_clangd_args-option">The <code>g:ycm_clangd_args</code> option</h3><p>This option controls the command line arguments passed to the clangd binary. It
  1536. appends new options and overrides the existing ones.</p><p>Default: <code>[]</code></p><pre><code class="viml">let g:ycm_clangd_args = []
  1537. </code></pre><h3 id="the-gycm_clangd_uses_ycmd_caching-option">The <code>g:ycm_clangd_uses_ycmd_caching</code> option</h3><p>This option controls which ranking and filtering algorithm to use for completion
  1538. items. It can take values:</p><ul>
  1539. <li><code>1</code>: Uses ycmd's caching and filtering logic.</li>
  1540. <li><code>0</code>: Uses clangd's caching and filtering logic.</li>
  1541. </ul><p>Default: <code>1</code></p><pre><code class="viml">let g:ycm_clangd_uses_ycmd_caching = 1
  1542. </code></pre><h3 id="the-gycm_language_server-option">The <code>g:ycm_language_server</code> option</h3><p>This option lets YCM use an arbitrary LSP server, not unlike coc.nvim and others.
  1543. However, the officially supported completers are favoured over custom LSP ones,
  1544. so overriding an existing completer means first making sure YCM won't choose
  1545. that existing completer in the first place.</p><p>A simple working example of this option can be found in the section called
  1546. <a href="#semantic-completion-for-other-languages">"Semantic Completion for Other Languages"</a>.</p><p>Default: <code>[]</code></p><pre><code class="viml">let g:ycm_language_server = []
  1547. </code></pre><h3 id="the-gycm_disable_signature_help-option">The <code>g:ycm_disable_signature_help</code> option</h3><p>This option allows you to disable all signature help for all completion engines.
  1548. There is no way to disable it per-completer. This option is <em>reserved</em>, meaning
  1549. that while signature help support remains experimental, its values and meaning
  1550. may change and it may be removed in a future version.</p><p>Default: <code>0</code></p><pre><code class="viml">" Disable signature help
  1551. let g:ycm_disable_signature_help = 1
  1552. </code></pre><h3 id="the-gycm_gopls_binary_path-option">The <code>g:ycm_gopls_binary_path</code> option</h3><p>In case the system-wide <code>gopls</code> binary is newer than the bundled one, setting
  1553. this option to the path of the system-wide <code>gopls</code> would make YCM use that one
  1554. instead.</p><p>If the path is just <code>gopls</code>, YCM will search in <code>$PATH</code>.</p><h3 id="the-gycm_gopls_args-option">The <code>g:ycm_gopls_args</code> option</h3><p>Similar to <a href="#the-gycm-clangd-args">the <code>g:ycm_clangd_args</code></a>, this option allows
  1555. passing additional flags to the <code>gopls</code> command line.</p><p>Default: <code>[]</code></p><pre><code class="viml">let g:ycm_gopls_args = []
  1556. </code></pre><h3 id="the-gycm_rls_binary_path-and-gycm_rustc_binary_path-options">The <code>g:ycm_rls_binary_path</code> and <code>g:ycm_rustc_binary_path</code> options</h3><p>Similar to <a href="#the-gycm-gopls-binaty-path">the <code>gopls</code> path</a>, these two options
  1557. tell YCM which <code>rls</code> and <code>rustc</code> to use.</p><p>NOTE: You <em>need</em> to either set both or none of these two.</p><h3 id="the-gycm_tsserver_binary_path-option">The <code>g:ycm_tsserver_binary_path</code> option</h3><p>Similar to <a href="#the-gycm-gopls-binaty-path">the <code>gopls</code> path</a>, this option
  1558. tells YCM where is the TSServer executable located.</p><h3 id="the-gycm_roslyn_binary_path-option">The <code>g:ycm_roslyn_binary_path</code> option</h3><p>Similar to <a href="#the-gycm-gopls-binaty-path">the <code>gopls</code> path</a>, this option
  1559. tells YCM where is the Omnisharp-Roslyn executable located.</p><h2 id="faq">FAQ</h2><p>The FAQ section has been moved to the <a href="https://github.com/ycm-core/YouCompleteMe/wiki/FAQ">wiki</a>.</p><h2 id="contributor-code-of-conduct">Contributor Code of Conduct</h2><p>Please note that this project is released with a <a href="https://github.com/ycm-core/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md">Contributor Code of
  1560. Conduct</a>. By participating in this project you agree to abide by its
  1561. terms.</p><h2 id="contact">Contact</h2><p>If you have questions about the plugin or need help, please join the <a href="https://gitter.im/Valloric/YouCompleteMe">Gitter
  1562. room</a> or use the <a href="https://groups.google.com/forum/?hl=en#!forum/ycm-users">ycm-users</a> mailing list.</p><p>If you have bug reports or feature suggestions, please use the <a href="https://github.com/ycm-core/YouCompleteMe/issues?state=open">issue
  1563. tracker</a>. Before you do, please carefully read
  1564. <a href="https://github.com/ycm-core/YouCompleteMe/blob/master/CONTRIBUTING.md">CONTRIBUTING.md</a> as this asks for important diagnostics which
  1565. the team will use to help get you going.</p><p>The latest version of the plugin is available at
  1566. <a href="https://ycm-core.github.io/YouCompleteMe/">https://ycm-core.github.io/YouCompleteMe/</a>.</p><p>The author's homepage is <a href="https://val.markovic.io">https://val.markovic.io</a>.</p><p>Please do <strong>NOT</strong> go to #vim on freenode for support. Please contact the
  1567. YouCompleteMe maintainers directly using the <a href="#contact">contact details</a>.</p><h2 id="license">License</h2><p>This software is licensed under the <a href="https://www.gnu.org/copyleft/gpl.html">GPL v3 license</a>.
  1568. © 2015-2018 YouCompleteMe contributors</p></div>
  1569. </section>
  1570. </div>
  1571. <!--[if !IE]><script>fixScale(document);</script><![endif]-->
  1572. <script type="text/javascript">
  1573. var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
  1574. document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
  1575. </script>
  1576. <script type="text/javascript">
  1577. try {
  1578. var pageTracker = _gat._getTracker("UA-34688172-3");
  1579. pageTracker._trackPageview();
  1580. } catch(err) {}
  1581. </script>
  1582. <a href="https://github.com/Valloric/YouCompleteMe"><img alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png" src="https://camo.githubusercontent.com/e7bbb0521b397edbd5fe43e7f760759336b5e05f/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f677265656e5f3030373230302e706e67" style="position: absolute; top: 0; right: 0; border: 0;"/></a>
  1583. </body></html>