forked from ycm-core/YouCompleteMe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyoucompleteme.txt
2017 lines (1611 loc) · 90.8 KB
/
youcompleteme.txt
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* YouCompleteMe: a code-completion engine for Vim
===============================================================================
Contents ~
1. Introduction |youcompleteme-introduction|
2. Mac OS X super-quick installation |youcompleteme-mac-os-x-super-quick-installation|
3. Ubuntu Linux x64 super-quick installation |youcompleteme-ubuntu-linux-x64-super-quick-installation|
4. Windows Installation |youcompleteme-windows-installation|
5. Full Installation Guide |youcompleteme-full-installation-guide|
6. User Guide |youcompleteme-user-guide|
1. General Usage |youcompleteme-general-usage|
2. Client-server architecture |youcompleteme-client-server-architecture|
3. Completion string ranking |youcompleteme-completion-string-ranking|
4. General Semantic Completion Engine Usage |youcompleteme-general-semantic-completion-engine-usage|
5. C-family Semantic Completion Engine Usage |youcompleteme-c-family-semantic-completion-engine-usage|
6. Python semantic completion |youcompleteme-python-semantic-completion|
7. C# semantic completion |youcompleteme-c-semantic-completion|
8. Semantic completion for other languages |youcompleteme-semantic-completion-for-other-languages|
9. Writing New Semantic Completers |youcompleteme-writing-new-semantic-completers|
10. Diagnostic display |youcompleteme-diagnostic-display|
1. Diagnostic highlighting groups |youcompleteme-diagnostic-highlighting-groups|
7. Commands |youcompleteme-commands|
1. The |:YcmRestartServer| command
2. The |:YcmForceCompileAndDiagnostics| command
3. The |:YcmDiags| command
4. The |:YcmShowDetailedDiagnostic| command
5. The |:YcmDebugInfo| command
6. The |:YcmCompleter| command
8. YcmCompleter subcommands |youcompleteme-ycmcompleter-subcommands|
1. The |GoToDeclaration| subcommand
2. The |GoToDefinition| subcommand
3. The |GoTo| subcommand
4. The |GoToImprecise| subcommand
5. The |ClearCompilationFlagCache| subcommand
6. The |StartServer| subcommand
7. The |StopServer| subcommand
8. The |RestartServer| subcommand
9. Options |youcompleteme-options|
1. The |g:ycm_min_num_of_chars_for_completion| option
2. The |g:ycm_min_num_identifier_candidate_chars| option
3. The |g:ycm_auto_trigger| option
4. The |g:ycm_filetype_whitelist| option
5. The |g:ycm_filetype_blacklist| option
6. The |g:ycm_filetype_specific_completion_to_disable| option
7. The |g:ycm_show_diagnostics_ui| option
8. The |g:ycm_error_symbol| option
9. The |g:ycm_warning_symbol| option
10. The |g:ycm_enable_diagnostic_signs| option
11. The |g:ycm_enable_diagnostic_highlighting| option
12. The |g:ycm_echo_current_diagnostic| option
13. The |g:ycm_always_populate_location_list| option
14. The |g:ycm_open_loclist_on_ycm_diags| option
15. The |g:ycm_allow_changing_updatetime| option
16. The |g:ycm_complete_in_comments| option
17. The |g:ycm_complete_in_strings| option
18. The |g:ycm_collect_identifiers_from_comments_and_strings| option
19. The |g:ycm_collect_identifiers_from_tags_files| option
20. The |g:ycm_seed_identifiers_with_syntax| option
21. The |g:ycm_extra_conf_vim_data| option
22. The |g:ycm_path_to_python_interpreter| option
23. The |g:ycm_server_use_vim_stdout| option
24. The |g:ycm_server_keep_logfiles| option
25. The |g:ycm_server_log_level| option
26. The |g:ycm_csharp_server_port| option
27. The |g:ycm_auto_start_csharp_server| option
28. The |g:ycm_auto_stop_csharp_server| option
29. The |g:ycm_add_preview_to_completeopt| option
30. The |g:ycm_autoclose_preview_window_after_completion| option
31. The |g:ycm_autoclose_preview_window_after_insertion| option
32. The |g:ycm_max_diagnostics_to_display| option
33. The |g:ycm_key_list_select_completion| option
34. The |g:ycm_key_list_previous_completion| option
35. The |g:ycm_key_invoke_completion| option
36. The |g:ycm_key_detailed_diagnostics| option
37. The |g:ycm_global_ycm_extra_conf| option
38. The |g:ycm_confirm_extra_conf| option
39. The |g:ycm_extra_conf_globlist| option
40. The |g:ycm_filepath_completion_use_working_dir| option
41. The |g:ycm_semantic_triggers| option
42. The |g:ycm_cache_omnifunc| option
43. The |g:ycm_use_ultisnips_completer| option
10. FAQ |youcompleteme-faq|
1. I used to be able to 'import vim' in '.ycm_extra_conf.py', but now can't |import-vim|
2. On very rare occasions Vim crashes when I tab through the completion menu |youcompleteme-on-very-rare-occasions-vim-crashes-when-i-tab-through-completion-menu|
3. I get a linker warning regarding |libpython| on Mac when compiling YCM
4. I get a weird window at the top of my file when I use the semantic engine |youcompleteme-i-get-weird-window-at-top-of-my-file-when-i-use-semantic-engine|
5. It appears that YCM is not working |youcompleteme-it-appears-that-ycm-is-not-working|
6. Sometimes it takes much longer to get semantic completions than normal |youcompleteme-sometimes-it-takes-much-longer-to-get-semantic-completions-than-normal|
7. YCM auto-inserts completion strings I don't want! |youcompleteme-ycm-auto-inserts-completion-strings-i-dont-want|
8. I get a 'E227: mapping already exists for <blah>' error when I start Vim |E227:-mapping-already-exists-for-blah|
9. I get "'GLIBC_2.XX' not found (required by libclang.so)" when starting Vim |GLIBC_2.XX-not-found()|
10. I'm trying to use a Homebrew Vim with YCM and I'm getting segfaults |youcompleteme-im-trying-to-use-homebrew-vim-with-ycm-im-getting-segfaults|
11. I have a Homebrew Python and/or MacVim; can't compile/SIGABRT when starting |youcompleteme-i-have-homebrew-python-and-or-macvim-cant-compile-sigabrt-when-starting|
12. Vim segfaults when I use the semantic completer in Ruby files |youcompleteme-vim-segfaults-when-i-use-semantic-completer-in-ruby-files|
13. I get 'LONG_BIT definition appears wrong for platform' when compiling |LONG_BIT-definition-appears-wrong-for-platform|
14. I get 'libpython2.7.a [...] relocation R_X86_64_32' when compiling |libpython2.7.a-...-relocation-R_X86_64_32|
15. I get 'Vim: Caught deadly signal SEGV' on Vim startup |Vim:-Caught-deadly-signal-SEGV|
16. YCM does not read identifiers from my tags files |youcompleteme-ycm-does-not-read-identifiers-from-my-tags-files|
17. 'CTRL-U' in insert mode does not work |CTRL-sub-U|
18. YCM conflicts with UltiSnips TAB key usage |youcompleteme-ycm-conflicts-with-ultisnips-tab-key-usage|
19. Why isn't YCM just written in plain VimScript, FFS? |youcompleteme-why-isnt-ycm-just-written-in-plain-vimscript-ffs|
20. Why does YCM demand such a recent version of Vim? |youcompleteme-why-does-ycm-demand-such-recent-version-of-vim|
21. I get annoying messages in Vim's status area when I type |youcompleteme-i-get-annoying-messages-in-vims-status-area-when-i-type|
22. Nasty bugs happen if I have the 'vim-autoclose' plugin installed |vim-sub-autoclose|
23. Is there some sort of YCM mailing list? I have questions |youcompleteme-is-there-sort-of-ycm-mailing-list-i-have-questions|
24. I get an internal compiler error when installing |youcompleteme-i-get-an-internal-compiler-error-when-installing|
25. I get weird errors when I press 'Ctrl-C' in Vim |Ctrl-sub-C|
26. Why did YCM stop using Syntastic for diagnostics display? |youcompleteme-why-did-ycm-stop-using-syntastic-for-diagnostics-display|
27. Completion doesn't work with the C++ standard library headers |youcompleteme-completion-doesnt-work-with-c-standard-library-headers|
11. Contact |youcompleteme-contact|
12. Project Management |youcompleteme-project-management|
13. License |youcompleteme-license|
14. References |youcompleteme-references|
===============================================================================
*youcompleteme-introduction*
Introduction ~
Image: Build Status [1]
YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for
Vim. It has several completion engines: an identifier-based engine that works
with every programming language, a semantic, Clang [3]-based engine that
provides native semantic code completion for C/C++/Objective-C/Objective-C++
(from now on referred to as "the C-family languages"), a Jedi [4]-based
completion engine for Python, an OmniSharp [5]-based completion engine for C#
and an omnifunc-based completer that uses data from Vim's omnicomplete system
to provide semantic completions for many other languages (Ruby, PHP etc.).
Image: YouCompleteMe GIF demo (see reference [6])
Here's an explanation of what happens in the short GIF demo above.
First, realize that **no keyboard shortcuts had to be pressed** to get the list
of completion candidates at any point in the demo. The user just types and the
suggestions pop up by themselves. If the user doesn't find the completion
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 [7] 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 [8]) if you are editing a C-family file. As Clang 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.
In essence, YCM obsoletes the following Vim plugins because it has all of their
features plus extra:
- clang_complete
- AutoComplPop
- Supertab
- neocomplcache
YCM also provides semantic go-to-definition/declaration commands for C-family
languages & Python. Expect more IDE features powered by the various YCM
semantic engines in the future.
You'll also find that YCM has filepath completers (try typing './' in a file)
and a completer that integrates with UltiSnips [9].
===============================================================================
*youcompleteme-mac-os-x-super-quick-installation*
Mac OS X super-quick installation ~
Please refer to the full Installation Guide below; the following commands are
provided on a best-effort basis and may not work for you.
Install the latest version of MacVim [10]. Yes, MacVim. And yes, the _latest_.
If you don't use the MacVim GUI, it is recommended to use the Vim binary that
is inside the MacVim.app package ('MacVim.app/Contents/MacOS/Vim'). To ensure
it works correctly copy the 'mvim' script from the MacVim [10] download to your
local binary folder (for example '/usr/local/bin/mvim') and then symlink it:
>
ln -s /usr/local/bin/mvim vim
<
Install YouCompleteMe with Vundle [11].
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
using Vundle and the ycm_support_libs library APIs have changed (happens
rarely), YCM will notify you to recompile it. You should then rerun the install
process.
It's recommended that you have the latest Xcode installed along with the latest
Command Line Tools (that you install from within Xcode).
Install CMake. Preferably with Homebrew [12], but here's the stand-alone CMake
installer [13].
_If_ you have installed a Homebrew Python and/or Homebrew MacVim, see the _FAQ_
for details.
Compiling YCM **with** semantic support for C-family languages:
>
cd ~/.vim/bundle/YouCompleteMe
./install.sh --clang-completer
<
Compiling YCM **without** semantic support for C-family languages:
>
cd ~/.vim/bundle/YouCompleteMe
./install.sh
<
If you want semantic C# support, you should add '--omnisharp-completer' to the
install script as well.
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.
===============================================================================
*youcompleteme-ubuntu-linux-x64-super-quick-installation*
Ubuntu Linux x64 super-quick installation ~
Please refer to the full Installation Guide below; the following commands are
provided on a best-effort basis and may not work for you.
Make sure you have Vim 7.3.584 with python2 support. At the time of writing,
the version of Vim shipping with Ubuntu is too old. You may need to compile Vim
from source [14] (don't worry, it's easy).
Install YouCompleteMe with Vundle [11].
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
using Vundle and the ycm_support_libs library APIs have changed (happens
rarely), YCM will notify you to recompile it. You should then rerun the install
process.
Install development tools and CMake: 'sudo apt-get install build-essential
cmake'
Make sure you have Python headers installed: 'sudo apt-get install python-dev'.
Compiling YCM **with** semantic support for C-family languages:
>
cd ~/.vim/bundle/YouCompleteMe
./install.sh --clang-completer
<
Compiling YCM **without** semantic support for C-family languages:
>
cd ~/.vim/bundle/YouCompleteMe
./install.sh
<
If you want semantic C# support, you should add '--omnisharp-completer' to the
install script as well.
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.
===============================================================================
*youcompleteme-windows-installation*
Windows Installation ~
YCM has **no official support for Windows**, but that doesn't mean you can't
get it to work there. See the Windows Installation Guide [15] wiki page. Feel
free to add to it.
===============================================================================
*youcompleteme-full-installation-guide*
Full Installation Guide ~
These are the steps necessary to get YCM working on a Unix OS like Linux or Mac
OS X. My apologies to Windows users, but I don't have a guide for them. The
code is platform agnostic, so if everything is configured correctly, YCM
_should_ work on Windows without issues (but as of writing, it's untested on
that platform).
See the _FAQ_ if you have any issues.
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
using Vundle and the ycm_support_libs library APIs have changed (happens
rarely), YCM will notify you to recompile it. You should then rerun the install
process.
**Please follow the instructions carefully. Read EVERY WORD.**
1. **Ensure that your version of Vim is _at least_ 7.3.584 _and_ that it has
support for python2 scripting**.
Inside Vim, type ':version'. Look at the first two to three lines of
output; it should say 'Vi IMproved 7.3' and then below that, 'Included
patches: 1-X', where X will be some number. That number needs to be 584
or higher.
If your version of Vim is not recent enough, you may need to compile Vim
from source [14] (don't worry, it's easy).
After you have made sure that you have Vim 7.3.584+, type the following
in Vim: ":echo has('python')". The output should be 1. If it's 0, then
get a version of Vim with Python support.
2. **Install YCM** with Vundle [11] (or Pathogen [16], but Vundle is a
better idea). With Vundle, this would mean adding a "Bundle
'Valloric/YouCompleteMe'" line to your vimrc [17].
If you don't install YCM with Vundle, make sure you have run 'git
submodule update --init --recursive' after checking out the YCM
repository (Vundle will do this for you) to fetch YCM's dependencies.
3. [Complete this step ONLY if you care about semantic completion support
for C-family languages. Otherwise it's not neccessary.]
**Download the latest version of 'libclang'**. Clang is an open-source
compiler that can compile C/C++/Objective-C/Objective-C++. The 'libclang'
library it provides is used to power the YCM semantic completion engine
for those languages. YCM is designed to work with libclang version 3.4 or
higher, but can in theory work with any 3.2+ version as well.
You can use the system libclang _only if you are sure it is version 3.3
or higher_, otherwise don't. Even if it is, I recommend using the
official binaries from llvm.org [18] if at all possible. Make sure you
download the correct archive file for your OS.
4. **Compile the 'ycm_support_libs' libraries** that YCM needs. These libs
are the C++ engines that YCM uses to get fast completions.
You will need to have 'cmake' installed in order to generate the required
makefiles. Linux users can install cmake with their package manager
('sudo apt-get install cmake' for Ubuntu) whereas other users can
download and install [13] cmake from its project site. Mac users can also
get it through Homebrew [12] with 'brew install cmake'.
You also need to make sure you have Python headers installed. On a
Debian-like Linux distro, this would be 'sudo apt-get install python-
dev'. On Mac they should already be present.
Here we'll assume you installed YCM with Vundle. That means that the top-
level YCM directory is in '~/.vim/bundle/YouCompleteMe'.
We'll create a new folder where build files will be placed. Run the
following:
>
cd ~
mkdir ycm_build
cd ycm_build
<
Now we need to generate the makefiles. If you DON'T care about semantic
support for C-family languages, run the following command in the
'ycm_build' directory:
>
cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/cpp
<
If you DO care about semantic support for C-family languages, then your
'cmake' call will be a bit more complicated. We'll assume you downloaded
a binary distribution of LLVM+Clang from llvm.org in step 3 and that you
extracted the archive file to folder '~/ycm_temp/llvm_root_dir' (with
'bin', 'lib', 'include' etc. folders right inside that folder). With that
in mind, run the following command in the 'ycm_build' directory:
>
cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/cpp
<
Now that makefiles have been generated, simply run:
>
make ycm_support_libs
<
For those who want to use the system version of libclang, you would pass
'-DUSE_SYSTEM_LIBCLANG=ON' to cmake _instead of_ the
'-DPATH_TO_LLVM_ROOT=...' flag.
You could also force the use of a custom libclang library with
'-DEXTERNAL_LIBCLANG_PATH=/path/to/libclang.so' flag (the library would
end with '.dylib' on a Mac). Again, this flag would be used _instead of_
the other flags.
Running the 'make' command will also place the 'libclang.[so|dylib]' in
the 'YouCompleteMe/python' folder for you if you compiled with clang
support (it needs to be there for YCM to work).
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.
===============================================================================
*youcompleteme-user-guide*
User Guide ~
-------------------------------------------------------------------------------
*youcompleteme-general-usage*
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" 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).
So, "foo" matches "Foo" and "foo", "Foo" matches "Foo" and "FOO" but not
"foo".
- Use the TAB key to accept a completion and continue pressing TAB to cycle
through the completions. Use Shift-TAB to cycle backwards. Note that if
you're using console Vim (that is, not Gvim or MacVim) then it's likely
that the Shift-TAB binding will not work because the console will not pass
it to Vim. You can remap the keys; see the _Options_ 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's a libclang-based
completer that provides 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.
-------------------------------------------------------------------------------
*youcompleteme-client-server-architecture*
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 that has the vast majority of YCM
logic and functionality. The server is started and stopped automatically as you
start and stop Vim.
-------------------------------------------------------------------------------
*youcompleteme-completion-string-ranking*
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
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). A word-boundary character are all capital characters, characters
preceded by an underscore and the first letter character in the completion
string.
-------------------------------------------------------------------------------
*youcompleteme-general-semantic-completion-engine-usage*
General Semantic Completion Engine Usage ~
- You can use Ctrl+Space to trigger the completion suggestions anywhere, even
without a string prefix. This is useful to see which top-level functions
are available for use.
-------------------------------------------------------------------------------
*youcompleteme-c-family-semantic-completion-engine-usage*
C-family Semantic Completion Engine Usage ~
YCM looks for a '.ycm_extra_conf.py' file in the directory of the opened file
or in any directory above it in the hierarchy (recursively); when the file is
found, it is loaded (only once!) as a Python module. YCM calls a 'FlagsForFile'
method in that module which should provide it with the information necessary to
compile the current file. You can also provide a path to a global
'.ycm_extra_conf.py' file, which will be used as a fallback. To prevent the
execution of malicious code from a file you didn't write YCM will ask you once
per '.ycm_extra_conf.py' if it is safe to load. This can be disabled and you
can white-/blacklist files. See the _Options_ section for more details.
This system was designed this way so that the user can perform any arbitrary
sequence of operations to produce a list of compilation flags YCM should hand
to Clang.
See YCM's own '.ycm_extra_conf.py' [19] for details on how this works. You
should be able to use it _as a starting point_. **Don't** just copy/paste that
file somewhere and expect things to magically work; **your project needs
different flags**. Hint: just replace the strings in the 'flags' variable with
compilation flags necessary for your project. That should be enough for 99% of
projects.
Yes, Clang's 'CompilationDatabase' system [20] is also supported. Again, see
the above linked example file.
If Clang encounters errors when compiling the header files that your file
includes, then it's probably going to take a long time to get completions. When
the completion menu finally appears, it's going to have a large number of
unrelated completion strings (type/function names that are not actually
members). This is because Clang fails to build a precompiled preamble for your
file if there are any errors in the included headers and that preamble is key
to getting fast completions.
Call the |:YcmDiags| command to see if any errors or warnings were detected in
your file.
-------------------------------------------------------------------------------
*youcompleteme-python-semantic-completion*
Python semantic completion ~
YCM uses Jedi [4] to power its semantic completion for Python. This should
"just work" without any configuration from the user. You do NOT need to install
Jedi yourself; YCM uses it as a git subrepo. If you're installing YCM with
Vundle (which is the recommended way) then Vundle will make sure that the
subrepo is checked out when you do ':BundleInstall'. If you're installing YCM
by hand, then you need to run 'git submodule update --init --recursive' when
you're checking out the YCM repository. That's it.
But again, installing YCM with Vundle takes care of all of this for you.
In the future expect to see features like go-to-definition for Python as well.
-------------------------------------------------------------------------------
*youcompleteme-c-semantic-completion*
C# semantic completion ~
YCM uses OmniSharp [5] to provide semantic completion for C#. It's used as a
git subrepo. If you're installing YCM with Vundle (which is the recommended
way) then Vundle will make sure that the subrepo is checked out when you do
':BundleInstall'. If you're installing YCM by hand, then you need to run 'git
submodule update --init --recursive' when you're checking out the YCM
repository.
OmniSharp is written in C# and has to be compiled. The 'install.sh' script
takes care of this if you pass '--omnisharp-completer' as an argument.
-------------------------------------------------------------------------------
*youcompleteme-semantic-completion-for-other-languages*
Semantic completion for other languages ~
YCM will use your 'omnifunc' (see ':h omnifunc' in Vim) as a source for
semantic completions if it does not have a native semantic completion engine
for your file's filetype. Vim comes with okayish omnifuncs for various
languages like Ruby, PHP etc. It depends on the language.
You can get stellar omnifuncs for Java and Ruby with Eclim [21]. Just make sure
you have the _latest_ Eclim installed and configured (this means Eclim '>=
2.2.*' and Eclipse '>= 4.2.*').
After installing Eclim remember to create a new Eclipse project within your
application by typing ':ProjectCreate <path-to-your-project> -n ruby' (or '-n
java') inside vim and don't forget to have "let g:EclimCompletionMethod =
'omnifunc'" in your vimrc. This will make YCM and Eclim play nice; YCM will use
Eclim's omnifuncs as the data source for semantic completions and provide the
auto-triggering and subsequence-based matching (and other YCM features) on top
of it.
-------------------------------------------------------------------------------
*youcompleteme-writing-new-semantic-completers*
Writing New Semantic Completers ~
You have two options here: writing an 'omnifunc' for Vim's omnicomplete system
that YCM will then use through its omni-completer, or a custom completer for
YCM using the Completer API [22].
Here are the differences between the two approaches:
- You have to use VimScript to write the omnifunc, but get to use Python to
write for the Completer API; this by itself should make you want to use the
API.
- The Completer API is a _much_ more powerful way to integrate with YCM and
it provides a wider set of features. For instance, you can make your
Completer query your semantic back-end in an asynchronous fashion, thus not
blocking Vim's GUI thread while your completion system is processing stuff.
This is impossible with VimScript. All of YCM's completers use the
Completer API.
- Performance with the Completer API is better since Python executes faster
than VimScript.
If you want to use the 'omnifunc' system, see the relevant Vim docs with ':h
complete-functions'. For the Completer API, see the API docs [22].
If you want to upstream your completer into YCM's source, you should use the
Completer API.
-------------------------------------------------------------------------------
*youcompleteme-diagnostic-display*
Diagnostic display ~
YCM will display diagnostic notifications if you compiled YCM with Clang
support. Since YCM continuously recompiles your file as you type, you'll get
notified of errors and warnings in your file as fast as possible.
Here are the various pieces of the diagnostic UI:
- Icons show up in the Vim gutter on lines that have a diagnostic.
- Regions of text related to diagnostics are highlighted (by default, a red
wavy underline in 'gvim' and a red background in 'vim').
- Moving the cursor to a line with a diagnostic echoes the diagnostic text.
- Vim's location list is automatically populated with diagnostic data (off by
default, see options).
The new diagnostics (if any) will be displayed the next time you press any key
on the keyboard. So if you stop typing and just wait for the new diagnostics to
come in, that _will not work_. You need to press some key for the GUI to
update.
Having to press a key to get the updates is unfortunate, but cannot be changed
due to the way Vim internals operate; there is no way that a background task
can update Vim's GUI after it has finished running. You _have to_ press a key.
This will make YCM check for any pending diagnostics updates.
You _can_ force a full, blocking compilation cycle with the
|:YcmForceCompileAndDiagnostics| command (you may want to map that command to a
key; try putting 'nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>' in your
vimrc). Calling this command will force YCM to immediately recompile your file
and display any new diagnostics it encounters. Do note that recompilation with
this command may take a while and during this time the Vim GUI _will_ be
blocked.
YCM will display a short diagnostic message when you move your cursor to the
line with the error. You can get a detailed diagnostic message with the
'<leader>d' key mapping (can be changed in the options) YCM provides when your
cursor is on the line with the diagnostic.
You can also see the full diagnostic message for all the diagnostics in the
current file in Vim's 'locationlist', which can be opened with the ':lopen' and
':lclose' commands (make sure you have set 'let
g:ycm_always_populate_location_list = 1' in your vimrc). A good way to toggle
the display of the 'locationlist' with a single key mapping is provided by
another (very small) Vim plugin called ListToggle [23] (which also makes it
possible to change the height of the 'locationlist' window), also written by
yours truly.
-------------------------------------------------------------------------------
*youcompleteme-diagnostic-highlighting-groups*
Diagnostic highlighting groups ~
You can change the styling for the highlighting groups YCM uses. For the signs
in the Vim gutter, the relevant groups are:
- 'YcmErrorSign', which falls back to group 'SyntasticErrorSign' and then
'error' if they exist
- 'YcmWarningSign', which falls back to group 'SyntasticWarningSign' and then
'todo' if they exist
You can also style the line that has the warning/error with these groups:
- 'YcmErrorLine', which falls back to group 'SyntasticErrorLine' if it exists
- 'YcmWarningLine', which falls back to group 'SyntasticWarningLine' if it
exists
Note that the line highlighting groups only work when gutter signs are turned
on.
Here's how you'd change the style for a group:
>
highlight YcmErrorLine guibg=#3f0000
<
===============================================================================
*youcompleteme-commands*
Commands ~
-------------------------------------------------------------------------------
The *:YcmRestartServer* command
If the 'ycmd' completion server suddenly stops for some reason, you can restart
it with this command.
-------------------------------------------------------------------------------
The *:YcmForceCompileAndDiagnostics* command
Calling this command will force YCM to immediately recompile your file and
display any new diagnostics it encounters. Do note that recompilation with this
command may take a while and during this time the Vim GUI _will_ be blocked.
You may want to map this command to a key; try putting 'nnoremap <F5>
:YcmForceCompileAndDiagnostics<CR>' in your vimrc.
-------------------------------------------------------------------------------
The *:YcmDiags* command
Calling this command will fill Vim's 'locationlist' with errors or warnings if
any were detected in your file and then open it.
The |g:ycm_open_loclist_on_ycm_diags| option can be used to prevent the
location list from opening, but still have it filled with new diagnostic data.
See the _Options_ section for details.
-------------------------------------------------------------------------------
The *:YcmShowDetailedDiagnostic* command
This command shows the full diagnostic text when the user's cursor is on the
line with the diagnostic.
-------------------------------------------------------------------------------
The *:YcmDebugInfo* command
This will print out various debug information for the current file. Useful to
see what compile commands will be used for the file if you're using the
semantic completion engine.
-------------------------------------------------------------------------------
The *:YcmCompleter* command
This command can be used to invoke completer-specific commands. If the first
argument is of the form 'ft=...' the completer for that file type will be used
(for example 'ft=cpp'), else the native completer of the current buffer will be
used. Call 'YcmCompleter' without further arguments for information about the
commands you can call for the selected completer.
See the _YcmCompleter subcommands_ section for more information on the
available subcommands.
===============================================================================
*youcompleteme-ycmcompleter-subcommands*
YcmCompleter subcommands ~
[See the docs for the 'YcmCompleter' command before tackling this section.]
The invoked subcommand is automatically routed to the currently active semantic
completer, so ':YcmCompleter GoToDefinition' will invoke the |GoToDefinition|
subcommand on the Python semantic completer if the currently active file is a
Python one and on the Clang completer if the currently active file is a
C/C++/Objective-C one.
You may also want to map the subcommands to something less verbose; for
instance, 'nnoremap <leader>jd :YcmCompleter GoTo<CR>' maps the '<leader>jd'
sequence to the longer subcommand invocation.
The various 'GoTo*' subcommands add entries to Vim's 'jumplist' so you can use
'CTRL-O' to jump back to where you where before invoking the command (and
'CTRL-I' to jump forward; see ':h jumplist' for details).
-------------------------------------------------------------------------------
The *GoToDeclaration* subcommand
Looks up the symbol under the cursor and jumps to its declaration.
Supported in filetypes: 'c, cpp, objc, objcpp, python, cs'
-------------------------------------------------------------------------------
The *GoToDefinition* subcommand
Looks up the symbol under the cursor and jumps to its definition.
NOTE: For C-family languages **this only works in certain situations**, namely
when the definition of the symbol is in the current translation unit. A
translation unit consists of the file you are editing and all the files you are
including with '#include' directives (directly or indirectly) in that file.
Supported in filetypes: 'c, cpp, objc, objcpp, python, cs'
-------------------------------------------------------------------------------
The *GoTo* subcommand
This command tries to perform the "most sensible" GoTo operation it can.
Currently, this means that it tries to look up the symbol under the cursor and
jumps to its definition if possible; if the definition is not accessible from
the current translation unit, jumps to the symbol's declaration.
Supported in filetypes: 'c, cpp, objc, objcpp, python, cs'
-------------------------------------------------------------------------------
The *GoToImprecise* subcommand
WARNING: This command trades correctness for speed!
Same as the |GoTo| command except that it doesn't recompile the file with
libclang before looking up nodes in the AST. This can be very useful when
you're editing files that take long to compile but you know that you haven't
made any changes since the last parse that would lead to incorrect jumps. When
you're just browsing around your codebase, this command can spare you quite a
bit of latency.
Supported in filetypes: 'c, cpp, objc, objcpp'
-------------------------------------------------------------------------------
The *ClearCompilationFlagCache* subcommand
YCM caches the flags it gets from the 'FlagsForFile' function in your
'ycm_extra_conf.py' file if you return them with the 'do_cache' parameter set
to 'True'. The cache is in memory and is never invalidated (unless you restart
Vim of course).
This command clears that cache entirely. YCM will then re-query your
'FlagsForFile' function as needed in the future.
Supported in filetypes: 'c, cpp, objc, objcpp'
-------------------------------------------------------------------------------
The *StartServer* subcommand
Starts the semantic-engine-as-localhost-server for those semantic engines that
work as separate servers that YCM talks to.
Supported in filetypes: 'cs'
-------------------------------------------------------------------------------
The *StopServer* subcommand
Stops the semantic-engine-as-localhost-server for those semantic engines that
work as separate servers that YCM talks to.
Supported in filetypes: 'cs'
-------------------------------------------------------------------------------
The *RestartServer* subcommand
Restarts the semantic-engine-as-localhost-server for those semantic engines
that work as separate servers that YCM talks to.
Supported in filetypes: 'cs'
===============================================================================
*youcompleteme-options*
Options ~
All options have reasonable defaults so if the plug-in works after installation
you don't need to change any options. These options can be configured in your
vimrc script [17] by including a line like this:
>
let g:ycm_min_num_of_chars_for_completion = 1
<
Note that after changing an option in your vimrc script [17] you have to
restart Vim for the changes to take effect.
-------------------------------------------------------------------------------
The *g:ycm_min_num_of_chars_for_completion* option
This option controls the number of characters the user needs to type before
identifier-based completion suggestions are triggered. For example, if the
option is set to '2', then when the user types a second alphanumeric character
after a whitespace character, completion suggestions will be triggered. This
option is NOT used for semantic completion.
Setting this option to a high number like '99' effectively turns off the
identifier completion engine and just leaves the semantic engine.
Default: '2'
>
let g:ycm_min_num_of_chars_for_completion = 2
<
-------------------------------------------------------------------------------
The *g:ycm_min_num_identifier_candidate_chars* option
This option controls the minimum number of characters that a completion
candidate coming from the identifier completer must have to be shown in the
popup menu.
A special value of '0' means there is no limit.
NOTE: This option only applies to the identifier completer; it has no effect on
the various semantic completers.
Default: '0'
>
let g:ycm_min_num_identifier_candidate_chars = 0
<
-------------------------------------------------------------------------------
The *g:ycm_auto_trigger* option
When set to '0', this option turns off YCM's identifier completer (the as-you-
type popup) _and_ the semantic triggers (the popup you'd get after typing '.'
or '->' in say C++). You can still force semantic completion with the
'<C-Space>' shortcut.
If you want to just turn off the identifier completer but keep the semantic
triggers, you should set |g:ycm_min_num_of_chars_for_completion| to a high
number like '99'.
Default: '1'
>
let g:ycm_auto_trigger = 1
<
-------------------------------------------------------------------------------
The *g:ycm_filetype_whitelist* option
This option controls for which Vim filetypes (see ':h filetype') should YCM be
turned on. The option value should be a Vim dictionary with keys being filetype
strings (like 'python', 'cpp' etc) and values being unimportant (the dictionary
is used like a hash set, meaning that only the keys matter).
The '*' key is special and matches all filetypes. By default, the whitelist
contains only this '*' key.
YCM also has a |g:ycm_filetype_blacklist| option that lists filetypes for which
YCM shouldn't be turned on. YCM will work only in filetypes that both the
whitelist and the blacklist allow (the blacklist "allows" a filetype by _not_
having it as a key).
For example, let's assume you want YCM to work in files with the 'cpp'
filetype. The filetype should then be present in the whitelist either directly
('cpp' key in the whitelist) or indirectly through the special '*' key. It
should _not_ be present in the blacklist.
Filetypes that are blocked by the either of the lists will be completely
ignored by YCM, meaning that neither the identifier-based completion engine nor
the semantic engine will operate in them.
You can get the filetype of the current file in Vim with ':set ft?'.
Default: "{'*' : 1}"
>
let g:ycm_filetype_whitelist = { '*': 1 }
<
-------------------------------------------------------------------------------
The *g:ycm_filetype_blacklist* option
This option controls for which Vim filetypes (see ':h filetype') should YCM be
turned off. The option value should be a Vim dictionary with keys being
filetype strings (like 'python', 'cpp' etc) and values being unimportant (the
dictionary is used like a hash set, meaning that only the keys matter).
See the |g:ycm_filetype_whitelist| option for more details on how this works.
Default: '[see next line]'
>
let g:ycm_filetype_blacklist = {
\ 'tagbar' : 1,
\ 'qf' : 1,
\ 'notes' : 1,
\ 'markdown' : 1,
\ 'unite' : 1,
\ 'text' : 1,
\ 'vimwiki' : 1,
\ 'pandoc' : 1,
\ 'mail' : 1
\}
<
-------------------------------------------------------------------------------
The *g:ycm_filetype_specific_completion_to_disable* option
This option controls for which Vim filetypes (see ':h filetype') should the YCM
semantic completion engine be turned off. The option value should be a Vim
dictionary with keys being filetype strings (like 'python', 'cpp' etc) and
values being unimportant (the dictionary is used like a hash set, meaning that
only the keys matter). The listed filetypes will be ignored by the YCM semantic
completion engine, but the identifier-based completion engine will still
trigger in files of those filetypes.
Note that even if semantic completion is not turned off for a specific
filetype, you will not get semantic completion if the semantic engine does not
support that filetype.
You can get the filetype of the current file in Vim with ':set ft?'.
Default: '{}'
>
let g:ycm_filetype_specific_completion_to_disable = {}
<
-------------------------------------------------------------------------------
The *g:ycm_show_diagnostics_ui* option
When set, this option turns on YCM's diagnostic display features. See the
_Diagnostic display_ section in the _User Manual_ for more details.
Specific parts of the diagnostics UI (like the gutter signs, text highlighting,
diagnostic echo and auto location list population) can be individually turned
on or off. See the other options below for details.
Note that YCM's diagnostics UI is only supported for C-family languages.
When set, this option also makes YCM remove all Syntastic checkers set for the
'c', 'cpp', 'objc' and 'objcpp' filetypes since this would conflict with YCM's
own diagnostics UI.
If you're using YCM's identifier completer in C-family languages but cannot use
the clang-based semantic completer for those languages _and_ want to use the
GCC Syntastic checkers, unset this option.
Default: '1'
>
let g:ycm_show_diagnostics_ui = 1