-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathREADME.md
4015 lines (2977 loc) · 148 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
YouCompleteMe: a code-completion engine for Vim
===============================================
[![Gitter room](https://img.shields.io/gitter/room/Valloric/YouCompleteMe.svg)](https://gitter.im/Valloric/YouCompleteMe)
[![Build status](https://dev.azure.com/YouCompleteMe/YCM/_apis/build/status/ycm-core.YouCompleteMe?branchName=master)](https://dev.azure.com/YouCompleteMe/YCM/_build?definitionId=3&branchName=master)
[![Coverage status](https://img.shields.io/codecov/c/github/ycm-core/YouCompleteMe/master.svg)](https://codecov.io/gh/ycm-core/YouCompleteMe)
Help, Advice, Support
---------------------
Looking for help, advice, or support? Having problems getting YCM to work?
First carefully read the [installation instructions](#installation) for your OS.
We recommend you use the supplied `install.py` - the "full" installation guide
is for rare, advanced use cases and most users should use `install.py`.
If the server isn't starting and you're getting a "YouCompleteMe unavailable"
error, check the [Troubleshooting][wiki-troubleshooting] guide.
Next, check the [User Guide](#user-guide) section on the semantic completer that
you are using. For C/C++/Objective-C/Objective-C++/CUDA, you _must_ read [this
section](#c-family-semantic-completion).
Finally, check the [FAQ][wiki-faq].
If, after reading the installation and user guides, and checking the FAQ, you're
still having trouble, check the [contacts](#contact) section below for how to
get in touch.
Please do **NOT** go to #vim on Freenode for support. Please contact the
YouCompleteMe maintainers directly using the [contact details](#contact) below.
# Vundle
Please note that the below instructions suggest using Vundle. Currently there
are problems with Vundle, so here are some [alternative instructions](https://github.com/ycm-core/YouCompleteMe/issues/4134#issuecomment-1446235584) using Vim packages.
Contents
--------
- [Intro](#intro)
- [Installation](#installation)
- [Requirements](#requirements)
- [macOS](#macos)
- [Linux 64-bit](#linux-64-bit)
- [Windows](#windows)
- [Full Installation Guide](#full-installation-guide)
- [Quick Feature Summary](#quick-feature-summary)
- [User Guide](#user-guide)
- [General Usage](#general-usage)
- [Client-Server Architecture](#client-server-architecture)
- [Completion String Ranking](#completion-string-ranking)
- [General Semantic Completion](#general-semantic-completion)
- [Signature Help](#signature-help)
- [Semantic Highlighting](#semantic-highlighting)
- [Inlay Hints](#inlay-hints)
- [C-family Semantic Completion](#c-family-semantic-completion)
- [Java Semantic Completion](#java-semantic-completion)
- [C# Semantic Completion](#c-semantic-completion)
- [Python Semantic Completion](#python-semantic-completion)
- [Rust Semantic Completion](#rust-semantic-completion)
- [Go Semantic Completion](#go-semantic-completion)
- [JavaScript and TypeScript Semantic Completion](#javascript-and-typescript-semantic-completion)
- [Semantic Completion for Other Languages](#semantic-completion-for-other-languages)
- [LSP Configuration](#lsp-configuration)
- [Writing New Semantic Completers](#writing-new-semantic-completers)
- [Diagnostic Display](#diagnostic-display)
- [Diagnostic Highlighting Groups](#diagnostic-highlighting-groups)
- [Symbol Search](#symbol-search)
- [Type/Call Hierarchy](#typecall-hierarchy)
- [Commands](#commands)
- [YcmCompleter subcommands](#ycmcompleter-subcommands)
- [GoTo Commands](#goto-commands)
- [Semantic Information Commands](#semantic-information-commands)
- [Refactoring Commands](#refactoring-commands)
- [Miscellaneous Commands](#miscellaneous-commands)
- [Functions](#functions)
- [Autocommands](#autocommands)
- [Options](#options)
- [FAQ](#faq)
- [Contributor Code of Conduct](#contributor-code-of-conduct)
- [Contact](#contact)
- [License](#license)
- [Sponsorship](#sponsorship)
Intro
-----
YouCompleteMe is a fast, as-you-type, fuzzy-search code completion,
comprehension and refactoring engine for [Vim][].
It has several completion engines built-in and supports any protocol-compliant
Language Server, so can work with practically any language. YouCompleteMe
contains:
- an identifier-based engine that works with every programming language,
- a powerful [clangd][]-based engine that provides native semantic code
completion for C/C++/Objective-C/Objective-C++/CUDA (from now on referred to
as "the C-family languages"),
- a [Jedi][]-based completion engine for Python 2 and 3,
- an [OmniSharp-Roslyn][]-based completion engine for C#,
- a [Gopls][]-based completion engine for Go,
- a [TSServer][]-based completion engine for JavaScript and TypeScript,
- a [rust-analyzer][]-based completion engine for Rust,
- a [jdt.ls][]-based completion engine for Java.
- a [generic Language Server Protocol implementation for any language](#plugging-an-arbitrary-lsp-server)
- and an omnifunc-based completer that uses data from Vim's omnicomplete system
to provide semantic completions for many other languages (Ruby, PHP, etc.).
![YouCompleteMe GIF completion demo](https://i.imgur.com/0OP4ood.gif)
Here's an explanation of what happened in the last GIF demo above.
First, realize that **no keyboard shortcuts had to be pressed** to get the list
of completion candidates at any point in the demo. The user just types and the
suggestions pop up by themselves. If the user doesn't find the completion
suggestions relevant and/or just wants to type, they can do so; the completion
engine will not interfere.
When the user sees a useful completion string being offered, they press the TAB
key to accept it. This inserts the completion string. Repeated presses of the
TAB key cycle through the offered completions.
If the offered completions are not relevant enough, the user can continue typing
to further filter out unwanted completions.
A critical thing to notice is that the completion **filtering is NOT based on
the input being a string prefix of the completion** (but that works too). The
input needs to be a _[subsequence][] match_ of a completion. This is a fancy way
of saying that any input characters need to be present in a completion string in
the order in which they appear in the input. So `abc` is a subsequence of
`xaybgc`, but not of `xbyxaxxc`. After the filter, a complicated sorting system
ranks the completion strings so that the most relevant ones rise to the top of
the menu (so you usually need to press TAB just once).
**All of the above works with any programming language** because of the
identifier-based completion engine. It collects all of the identifiers in the
current file and other files you visit (and your tags files) and searches them
when you type (identifiers are put into per-filetype groups).
The demo also shows the semantic engine in use. When the user presses `.`, `->`
or `::` while typing in insert mode (for C++; different triggers are used for
other languages), the semantic engine is triggered (it can also be triggered
with a keyboard shortcut; see the rest of the docs).
The last thing that you can see in the demo is YCM's diagnostic display features
(the little red X that shows up in the left gutter; inspired by [Syntastic][])
if you are editing a C-family file. As the completer engine compiles your file
and detects warnings or errors, they will be presented in various ways. You
don't need to save your file or press any keyboard shortcut to trigger this, it
"just happens" in the background.
**And that's not all...**
YCM might be the only Vim completion engine with the correct Unicode support.
Though we do assume UTF-8 everywhere.
![YouCompleteMe GIF unicode demo](https://user-images.githubusercontent.com/10026824/34471853-af9cf32a-ef53-11e7-8229-de534058ddc4.gif)
YCM also provides [semantic IDE-like features](#quick-feature-summary) in a
number of languages, including:
- displaying signature help (argument hints) when entering the arguments to a
function call (Vim only)
- [finding declarations, definitions, usages](#goto-commands), etc.
of identifiers, and an [interactive symbol finder](#symbol-search)
- [displaying type information](#the-gettype-subcommand) for classes,
variables, functions etc.,
- displaying documentation for methods, members, etc. in the [preview
window](#the-getdoc-subcommand), or in a
[popup next to the cursor](#the-gycm_auto_hover-option) (Vim only)
- [fixing common coding errors](#the-fixit-subcommand), like missing
semi-colons, typos, etc.,
- [semantic renaming](#the-refactorrename-subcommand) of variables across files,
- formatting code,
- removing unused imports, sorting imports, etc.
For example, here's a demo of signature help:
![Signature Help Early Demo](https://user-images.githubusercontent.com/10584846/58738348-5060da80-83fd-11e9-9537-d07fdbf4554c.gif)
Below we can see YCM being able to do a few things:
- Retrieve references across files
- Go to declaration/definition
- Expand `auto` in C++
- Fix some common errors, and provide refactorings, with `FixIt`
- Not shown in the GIF are `GoToImplementation` and `GoToType`
for servers that support it.
![YouCompleteMe GIF subcommands demo](https://i.imgur.com/nmUUbdl.gif)
And here's some documentation being shown in a hover popup, automatically and
manually:
![hover demo](https://user-images.githubusercontent.com/10584846/80312146-91af6500-87db-11ea-996b-7396f3134d1f.gif)
Features vary by file type, so make sure to check out the [file type feature
summary](#quick-feature-summary) and the
[full list of completer subcommands](#ycmcompleter-subcommands) to
find out what's available for your favourite languages.
You'll also find that YCM has filepath completers (try typing `./` in a file)
and a completer that integrates with [UltiSnips][].
Installation
------------
### Requirements
| Runtime | Min Version | Recommended Version (full support) | Python |
|---------|-------------|------------------------------------|--------|
| Vim | 8.2.3995 | 9.0.214 | 3.8 |
| Neovim | 0.5 | Vim 9.0.214 | 3.8 |
#### Supported Vim Versions
Our policy is to support the Vim version that's in the latest LTS of Ubuntu.
That's currently Ubuntu 22.04 which contains `vim-nox` at `v8.2.3995`.
Vim must have a [working Python 3 runtime](#supported-python-runtime).
For Neovim users, our policy is to require the latest released version.
Currently, Neovim 0.5.0 is required. Please note that some features are not
available in Neovim, and Neovim is not officially supported.
#### Supported Python runtime
YCM has two components: A server and a client. Both the server and client
require Python 3.8 or later 3.x release.
For the Vim client, Vim must be, compiled with `--enable-shared` (or
`--enable-framework` on macOS). You can check if this is working with `:py3
import sys; print( sys.version)`. It should say something like `3.8.2 (...)`.
For Neovim, you must have a python 3.8 runtime and the Neovim python
extensions. See Neovim's `:help provider-python` for how to set that up.
For the server, you must run the `install.py` script with a python 3.8 (or
later) runtime. Anaconda etc. are not supported. YCM will remember the runtime
you used to run `install.py` and will use that when launching the server, so if
you usually use anaconda, then make sure to use the full path to a real cpython3,
e.g. `/usr/bin/python3 install.py --all` etc.
Our policy is to support the python3 version that's available in the latest
Ubuntu LTS (similar to our Vim version policy). We don't increase the Python
runtime version without a reason, though. Typically, we do this when the current
python version we're using goes out of support. At that time we will typically
pick a version that will be supported for a number of years.
#### Supported Compilers
In order to provide the best possible performance and stability, ycmd has
updated its code to C++17. This requires a version bump of the minimum
supported compilers. The new requirements are:
| Compiler | Current Min |
|----------|----------------|
| GCC | 8 |
| Clang | 7 |
| MSVC | 15.7 (VS 2017) |
YCM requires CMake 3.13 or greater. If your CMake is too old, you may be able to
simply `pip install --user cmake` to get a really new version.
#### Individual completer requirements
When enabling language support for a particular language, there may be runtime
requirements, such as needing a very recent Java Development Kit for Java
support. In general, YCM is not in control of the required versions for the
downstream compilers, though we do our best to signal where we know them.
### macOS
#### Quick start, installing all completers
- Install YCM plugin via [Vundle][]
- Install CMake, MacVim and Python 3; Note that the pre-installed *macOS system*
Vim is not supported (due to it having broken Python integration).
```
$ brew install cmake python go nodejs
```
- Install mono from [Mono Project](mono-install-macos) (NOTE: on Intel Macs you
can also `brew install mono`. On arm Macs, you may require Rosetta)
- For Java support you must install a JDK, one way to do this is with Homebrew:
```
$ brew install java
$ sudo ln -sfn $(brew --prefix java)/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
```
- Pre-installed macOS *system* Vim does not support Python 3. So you need to
install either a Vim that supports Python 3 OR [MacVim][] with
[Homebrew][brew]:
- Option 1: Installing a Vim that supports Python 3
```
brew install vim
```
- Option 2: Installing [MacVim][]
```
brew install macvim
```
- Compile YCM.
- For Intel and arm64 Macs, the bundled libclang/clangd work:
```
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --all
```
- If you have troubles with finding system frameworks or C++ standard library,
try using the homebrew llvm:
```
brew install llvm
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --system-libclang --all
```
And edit your vimrc to add the following line to use the Homebrew llvm's
clangd:
```viml
" Use homebrew's clangd
let g:ycm_clangd_binary_path = trim(system('brew --prefix llvm')).'/bin/clangd'
```
- For using an arbitrary LSP server, check [the relevant
section](#plugging-an-arbitrary-lsp-server)
#### Explanation for the quick start
These instructions (using `install.py`) are the quickest way to install
YouCompleteMe, however they may not work for everyone. If the following
instructions don't work for you, check out the [full installation
guide](#full-installation-guide).
A supported Vim version with Python 3 is required. [MacVim][] is a good option,
even if you only use the terminal. YCM won't work with the pre-installed Vim
from Apple as its Python support is broken. If you don't already use a Vim
that supports Python 3 or [MacVim][], install it with [Homebrew][brew]. Install
CMake as well:
brew install vim cmake
OR
brew install macvim cmake
Install YouCompleteMe with [Vundle][].
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
using Vundle and the `ycm_core` library APIs have changed (happens
rarely), YCM will notify you to recompile it. You should then rerun the install
process.
**NOTE:** If you want C-family completion, you MUST have the latest Xcode
installed along with the latest Command Line Tools (they are installed
automatically when you run `clang` for the first time, or manually by running
`xcode-select --install`)
Compiling YCM **with** semantic support for C-family languages through
**clangd**:
```
cd ~/.vim/bundle/YouCompleteMe
./install.py --clangd-completer
```
Compiling YCM **without** semantic support for C-family languages:
```
cd ~/.vim/bundle/YouCompleteMe
./install.py
```
The following additional language support options are available:
- C# support: install by downloading the [Mono macOS package][mono-install-macos]
and add `--cs-completer` when calling `install.py`.
- Go support: install [Go][go-install] and add `--go-completer` when calling
`install.py`.
- JavaScript and TypeScript support: install [Node.js 18+ and npm][npm-install] and
add `--ts-completer` when calling `install.py`.
- Rust support: add `--rust-completer` when calling `install.py`.
- Java support: install [JDK 17][jdk-install] and add
`--java-completer` when calling `install.py`.
To simply compile with everything enabled, there's a `--all` flag. So, to
install with all language features, ensure `xbuild`, `go`, `node` and `npm`
tools are installed and in your `PATH`, then simply run:
```
cd ~/.vim/bundle/YouCompleteMe
./install.py --all
```
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
you will need to provide the compilation flags for your project to YCM. It's all
in the User Guide.
YCM comes with sane defaults for its options, but you still may want to take a
look at what's available for configuration. There are a few interesting options
that are conservatively turned off by default that you may want to turn on.
### Linux 64-bit
The following assume you're using Ubuntu 22.04.
#### Quick start, installing all completers
- Install YCM plugin via [Vundle][]
- Install CMake, Vim and Python
```
apt install build-essential cmake vim-nox python3-dev
```
- Install mono-complete, go, node, java, and npm
```
apt install mono-complete golang nodejs openjdk-17-jdk openjdk-17-jre npm
```
- Compile YCM
```
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --all
```
- For plugging an arbitrary LSP server, check [the relevant section](#plugging-an-arbitrary-lsp-server)
#### Explanation for the quick start
These instructions (using `install.py`) are the quickest way to install
YouCompleteMe, however they may not work for everyone. If the following
instructions don't work for you, check out the [full installation
guide](#full-installation-guide).
Make sure you have a supported version of Vim with Python 3 support and a
supported compiler. The latest LTS of Ubuntu is the minimum platform for simple
installation. For earlier releases or other distributions, you may have to do
some work to acquire the dependencies.
If your Vim version is too old, you may need to [compile Vim from
source][vim-build] (don't worry, it's easy).
Install YouCompleteMe with [Vundle][].
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
using Vundle and the `ycm_core` library APIs have changed (which happens rarely), YCM
will notify you to recompile it. You should then rerun the installation process.
Install development tools, CMake, and Python headers:
- Fedora-like distributions:
```
sudo dnf install cmake gcc-c++ make python3-devel
```
- Ubuntu LTS:
```
sudo apt install build-essential cmake3 python3-dev
```
Compiling YCM **with** semantic support for C-family languages through
**clangd**:
```
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --clangd-completer
```
Compiling YCM **without** semantic support for C-family languages:
```
cd ~/.vim/bundle/YouCompleteMe
python3 install.py
```
The following additional language support options are available:
- C# support: install [Mono][mono-install-linux] and add `--cs-completer`
when calling `install.py`.
- Go support: install [Go][go-install] and add `--go-completer` when calling
`install.py`.
- JavaScript and TypeScript support: install [Node.js 18+ and npm][npm-install] and
add `--ts-completer` when calling `install.py`.
- Rust support: add `--rust-completer` when calling `install.py`.
- Java support: install [JDK 17][jdk-install] and add
`--java-completer` when calling `install.py`.
To simply compile with everything enabled, there's a `--all` flag. So, to
install with all language features, ensure `xbuild`, `go`, `node`, and `npm`
tools are installed and in your `PATH`, then simply run:
```
cd ~/.vim/bundle/YouCompleteMe
python3 install.py --all
```
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
you will need to provide the compilation flags for your project to YCM. It's all
in the User Guide.
YCM comes with sane defaults for its options, but you still may want to take a
look at what's available for configuration. There are a few interesting options
that are conservatively turned off by default that you may want to turn on.
### Windows
#### Quick start, installing all completers
- Install YCM plugin via [Vundle][]
- Install [Visual Studio Build Tools 2019][visual-studio-download]
- Install CMake, Vim and Python
- Install go, node and npm
- Compile YCM
```
cd YouCompleteMe
python3 install.py --all
```
- Add `set encoding=utf-8` to your [vimrc][]
- For plugging an arbitrary LSP server, check [the relevant section](#plugging-an-arbitrary-lsp-server)
#### Explanation for the quick start
These instructions (using `install.py`) are the quickest way to install
YouCompleteMe, however they may not work for everyone. If the following
instructions don't work for you, check out the [full installation
guide](#full-installation-guide).
**Important:** we assume that you are using the `cmd.exe` command prompt and
that you know how to add an executable to the PATH environment variable.
Make sure you have a supported Vim version with Python 3 support. You
can check the version and which Python is supported by typing `:version` inside
Vim. Look at the features included: `+python3/dyn` for Python 3.
Take note of the Vim architecture, i.e. 32 or
64-bit. It will be important when choosing the Python installer. We recommend
using a 64-bit client. [Daily updated installers of 32-bit and 64-bit Vim with
Python 3 support][vim-win-download] are available.
Add the following line to your [vimrc][] if not already present.:
```viml
set encoding=utf-8
```
This option is required by YCM. Note that it does not prevent you from editing a
file in another encoding than UTF-8. You can do that by specifying [the `++enc`
argument][++enc] to the `:e` command.
Install YouCompleteMe with [Vundle][].
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
using Vundle and the `ycm_core` library APIs have changed (happens
rarely), YCM will notify you to recompile it. You should then rerun the install
process.
Download and install the following software:
- [Python 3][python-win-download]. Be sure to pick the version
corresponding to your Vim architecture. It is _Windows x86_ for a 32-bit Vim
and _Windows x86-64_ for a 64-bit Vim. We recommend installing Python 3.
Additionally, the version of Python you install must match up exactly with
the version of Python that Vim is looking for. Type `:version` and look at the
bottom of the page at the list of compiler flags. Look for flags that look
similar to `-DDYNAMIC_PYTHON3_DLL=\"python36.dll\"`. This indicates
that Vim is looking for Python 3.6. You'll need one or the other installed,
matching the version number exactly.
- [CMake][cmake-download]. Add CMake executable to the PATH environment
variable.
- [Build Tools for Visual Studio 2019][visual-studio-download]. During setup,
select _C++ build tools_ in _Workloads_.
Compiling YCM **with** semantic support for C-family languages through
**clangd**:
```
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
python install.py --clangd-completer
```
Compiling YCM **without** semantic support for C-family languages:
```
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
python install.py
```
The following additional language support options are available:
- C# support: add `--cs-completer` when calling `install.py`.
Be sure that [the build utility `msbuild` is in your PATH][add-msbuild-to-path].
- Go support: install [Go][go-install] and add `--go-completer` when calling
`install.py`.
- JavaScript and TypeScript support: install [Node.js 18+ and npm][npm-install] and
add `--ts-completer` when calling `install.py`.
- Rust support: add `--rust-completer` when calling `install.py`.
- Java support: install [JDK 17][jdk-install] and add
`--java-completer` when calling `install.py`.
To simply compile with everything enabled, there's a `--all` flag. So, to
install with all language features, ensure `msbuild`, `go`, `node` and `npm`
tools are installed and in your `PATH`, then simply run:
```
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
python install.py --all
```
You can specify the Microsoft Visual C++ (MSVC) version using the `--msvc`
option. YCM officially supports MSVC 15 (2017), MSVC 16 (Visual Studio 2019)
and MSVC 17 (Visual Studio 17 2022).
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
you will need to provide the compilation flags for your project to YCM. It's all
in the User Guide.
YCM comes with sane defaults for its options, but you still may want to take a
look at what's available for configuration. There are a few interesting options
that are conservatively turned off by default that you may want to turn on.
### Full Installation Guide
The [full installation guide][wiki-full-install] has been moved to the wiki.
Quick Feature Summary
-----
### General (all languages)
* Super-fast identifier completer including tags files and syntax elements
* Intelligent suggestion ranking and filtering
* File and path suggestions
* Suggestions from Vim's omnifunc
* UltiSnips snippet suggestions
### C-family languages (C, C++, Objective C, Objective C++, CUDA)
* Semantic auto-completion with automatic fixes
* Signature help
* Real-time diagnostic display
* Go to include/declaration/definition (`GoTo`, etc.)
* Go to alternate file (e.g. associated header `GoToAlternateFile`)
* Find Symbol (`GoToSymbol`), with interactive search
* Document outline (`GoToDocumentOutline`), with interactive search
* View documentation comments for identifiers (`GetDoc`)
* Type information for identifiers (`GetType`)
* Automatically fix certain errors (`FixIt`)
* Perform refactoring (`FixIt`)
* Reference finding (`GoToReferences`)
* Renaming symbols (`RefactorRename <new name>`)
* Code formatting (`Format`)
* Semantic highlighting
* Inlay hints
* Type hierarchy
* Call hierarchy
### C♯
* Semantic auto-completion
* Signature help
* Real-time diagnostic display
* Go to declaration/definition (`GoTo`, etc.)
* Go to implementation (`GoToImplementation`)
* Find Symbol (`GoToSymbol`), with interactive search
* View documentation comments for identifiers (`GetDoc`)
* Type information for identifiers (`GetType`)
* Automatically fix certain errors (`FixIt`)
* Perform refactoring (`FixIt`)
* Management of OmniSharp-Roslyn server instance
* Renaming symbols (`RefactorRename <new name>`)
* Code formatting (`Format`)
### Python
* Semantic auto-completion
* Signature help
* Go to definition (`GoTo`)
* Find Symbol (`GoToSymbol`), with interactive search
* Reference finding (`GoToReferences`)
* View documentation comments for identifiers (`GetDoc`)
* Type information for identifiers (`GetType`)
* Renaming symbols (`RefactorRename <new name>`)
### Go
* Semantic auto-completion
* Signature help
* Real-time diagnostic display
* Go to declaration/definition (`GoTo`, etc.)
* Go to type definition (`GoToType`)
* Go to implementation (`GoToImplementation`)
* Document outline (`GoToDocumentOutline`), with interactive search
* Automatically fix certain errors (`FixIt`)
* Perform refactoring (`FixIt`)
* View documentation comments for identifiers (`GetDoc`)
* Type information for identifiers (`GetType`)
* Code formatting (`Format`)
* Management of `gopls` server instance
* Inlay hints
* Call hierarchy
### JavaScript and TypeScript
* Semantic auto-completion with automatic import insertion
* Signature help
* Real-time diagnostic display
* Go to definition (`GoTo`, `GoToDefinition`, and `GoToDeclaration` are
identical)
* Go to type definition (`GoToType`)
* Go to implementation (`GoToImplementation`)
* Find Symbol (`GoToSymbol`), with interactive search
* Reference finding (`GoToReferences`)
* View documentation comments for identifiers (`GetDoc`)
* Type information for identifiers (`GetType`)
* Automatically fix certain errors and perform refactoring (`FixIt`)
* Perform refactoring (`FixIt`)
* Renaming symbols (`RefactorRename <new name>`)
* Code formatting (`Format`)
* Organize imports (`OrganizeImports`)
* Management of `TSServer` server instance
* Inlay hints
* Call hierarchy
### Rust
* Semantic auto-completion
* Real-time diagnostic display
* Go to declaration/definition (`GoTo`, etc.)
* Go to implementation (`GoToImplementation`)
* Reference finding (`GoToReferences`)
* Document outline (`GoToDocumentOutline`), with interactive search
* View documentation comments for identifiers (`GetDoc`)
* Automatically fix certain errors (`FixIt`)
* Perform refactoring (`FixIt`)
* Type information for identifiers (`GetType`)
* Renaming symbols (`RefactorRename <new name>`)
* Code formatting (`Format`)
* Management of `rust-analyzer` server instance
* Semantic highlighting
* Inlay hints
* Call hierarchy
### Java
* Semantic auto-completion with automatic import insertion
* Signature help
* Real-time diagnostic display
* Go to definition (`GoTo`, `GoToDefinition`, and `GoToDeclaration` are
identical)
* Go to type definition (`GoToType`)
* Go to implementation (`GoToImplementation`)
* Find Symbol (`GoToSymbol`), with interactive search
* Reference finding (`GoToReferences`)
* Document outline (`GoToDocumentOutline`), with interactive search
* View documentation comments for identifiers (`GetDoc`)
* Type information for identifiers (`GetType`)
* Automatically fix certain errors including code generation (`FixIt`)
* Renaming symbols (`RefactorRename <new name>`)
* Code formatting (`Format`)
* Organize imports (`OrganizeImports`)
* Detection of Java projects
* Execute custom server command (`ExecuteCommand <args>`)
* Management of `jdt.ls` server instance
* Semantic highlighting
* Inlay hints
* Type hierarchy
* Call hierarchy
User Guide
----------
### General Usage
If the offered completions are too broad, keep typing characters; YCM will
continue refining the offered completions based on your input.
Filtering is "smart-case" and "smart-[diacritic][]" sensitive; if you are
typing only lowercase letters, then it's case-insensitive. If your input
contains uppercase letters, then the uppercase letters in your query must
match uppercase letters in the completion strings (the lowercase letters still
match both). On top of that, a letter with no diacritic marks will match that
letter with or without marks:
<table>
<tbody>
<tr>
<th>matches</th>
<th>foo</th>
<th>fôo</th>
<th>fOo</th>
<th>fÔo</th>
</tr>
<tr>
<th>foo</th>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr>
<th>fôo</th>
<td>❌</td>
<td>✔️</td>
<td>❌</td>
<td>✔️</td>
</tr>
<tr>
<th>fOo</th>
<td>❌</td>
<td>❌</td>
<td>✔️</td>
<td>✔️</td>
</tr>
<tr>
<th>fÔo</th>
<td>❌</td>
<td>❌</td>
<td>❌</td>
<td>✔️</td>
</tr>
</tbody>
</table>
Use the TAB key to accept a completion and continue pressing TAB to cycle
through the completions. Use Shift-TAB to cycle backward. Note that if you're
using console Vim (that is, not gvim or MacVim) then it's likely that the
Shift-TAB binding will not work because the console will not pass it to Vim.
You can remap the keys; see the [Options](#options) section below.
Knowing a little bit about how YCM works internally will prevent confusion. YCM
has several completion engines: an identifier-based completer that collects all
of the identifiers in the current file and other files you visit (and your tags
files) and searches them when you type (identifiers are put into per-filetype
groups).
There are also several semantic engines in YCM. There are libclang-based and
clangd-based completers that provide semantic completion for C-family languages.
There's a Jedi-based completer for semantic completion for Python. There's also
an omnifunc-based completer that uses data from Vim's omnicomplete system to
provide semantic completions when no native completer exists for that language
in YCM.
There are also other completion engines, like the UltiSnips completer and the
filepath completer.
YCM automatically detects which completion engine would be the best in any
situation. On occasion, it queries several of them at once, merges the
outputs and presents the results to you.
### Client-Server Architecture
YCM has a client-server architecture; the Vim part of YCM is only a thin client
that talks to the [ycmd HTTP+JSON server][ycmd] that has the vast majority of
YCM logic and functionality. The server is started and stopped automatically as
you start and stop Vim.
### Completion String Ranking
The subsequence filter removes any completions that do not match the input, but
then the sorting system kicks in. It's actually very complicated and uses lots
of factors, but suffice it to say that "word boundary" (WB) subsequence
character matches are "worth" more than non-WB matches. In effect, this means
that given an input of "gua", the completion "getUserAccount" would be ranked higher
in the list than the "Fooguxa" completion (both of which are subsequence
matches). Word-boundary characters are all capital characters, characters
preceded by an underscore, and the first letter character in the completion
string.
### Signature Help
Valid signatures are displayed in a second popup menu and the current signature
is highlighted along with the current argument.
Signature help is triggered in insert mode automatically when
`g:ycm_auto_trigger` is enabled and is not supported when it is not enabled.
The signatures popup is hidden when there are no matching signatures or when you
leave insert mode. If you want to manually control when it is visible, you can
map something to `<plug>YCMToggleSignatureHelp` (see below).
For more details on this feature and a few demos, check out the
[PR that proposed it][signature-help-pr].
#### Dismiss signature help
The signature help popup sometimes gets in the way. You can toggle its
visibility with a mapping. YCM provides the "Plug" mapping
`<Plug>(YCMToggleSignatureHelp)` for this.
For example, to hide/show the signature help popup by pressing Ctrl+l in insert
mode: `imap <silent> <C-l> <Plug>(YCMToggleSignatureHelp)`.
_NOTE_: No default mapping is provided because insert mappings are very
difficult to create without breaking or overriding some existing functionality.
Ctrl-l is not a suggestion, just an example.
### Semantic highlighting
Semantic highlighting is the process where the buffer text is coloured according
to the underlying semantic type of the word, rather than classic syntax
highlighting based on regular expressions. This can be powerful additional data
that we can process very quickly.
This feature is only supported in Vim.
For example, here is a function with classic highlighting:
![highliting-classic](https://user-images.githubusercontent.com/10584846/173137003-a265e8b0-84db-4993-98f0-03ee81b9de94.png)
And here is the same function with semantic highlighting:
![highliting-semantic](https://user-images.githubusercontent.com/10584846/173137012-7547de0b-145f-45fa-ace3-18943acd2141.png)
As you can see, the function calls, macros, etc. are correctly identified.
This can be enabled globally with `let g:ycm_enable_semantic_highlighting=1` or
per buffer, by setting `b:ycm_enable_semantic_highlighting`.
#### Customising the highlight groups
YCM uses text properties (see `:help text-prop-intro`) for semantic
highlighting. In order to customise the coloring, you can define the text
properties that are used.
If you define a text property named `YCM_HL_<token type>`, then it will be used
in place of the defaults. The `<token type>` is defined as the Language Server
Protocol semantic token type, defined in the [LSP Spec](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_semanticTokens).
Some servers also use custom values. In this case, YCM prints a warning
including the token type name that you can customise.
For example, to render `parameter` tokens using the `Normal` highlight group,
you can do this:
```viml
call prop_type_add( 'YCM_HL_parameter', { 'highlight': 'Normal' } )
```
More generally, this pattern can be useful for customising the groups:
```viml
let MY_YCM_HIGHLIGHT_GROUP = {
\ 'typeParameter': 'PreProc',
\ 'parameter': 'Normal',
\ 'variable': 'Normal',
\ 'property': 'Normal',
\ 'enumMember': 'Normal',
\ 'event': 'Special',
\ 'member': 'Normal',
\ 'method': 'Normal',
\ 'class': 'Special',
\ 'namespace': 'Special',
\ }
for tokenType in keys( MY_YCM_HIGHLIGHT_GROUP )
call prop_type_add( 'YCM_HL_' . tokenType,
\ { 'highlight': MY_YCM_HIGHLIGHT_GROUP[ tokenType ] } )
endfor
```
## Inlay hints
**NOTE**: Highly experimental feature, requiring Vim 9.0.214 or later (not
supported in NeoVim).
When `g:ycm_enable_inlay_hints` (globally) or `b:ycm_enable_inlay_hints` (for a
specific buffer) is set to `1`, then YCM will insert inlay hints as supported by
the language semantic engine.
An inlay hint is text that is rendered on the screen that is not part of the buffer and
is often used to mark up the type or name of arguments, parameters, etc. which
help the developer understand the semantics of the code.
Here are some examples:
* C