2013-10-26 19:29:12 -04:00
*youcompleteme* YouCompleteMe: a code-completion engine for Vim
2013-02-02 16:47:08 -05:00
===============================================================================
Contents ~
2013-05-31 21:27:39 -04:00
1. Introduction |youcompleteme-introduction|
2013-02-02 16:47:08 -05:00
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|
2013-05-31 21:27:39 -04:00
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|
2013-10-24 15:41:56 -04:00
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. Syntastic integration |youcompleteme-syntastic-integration|
2013-05-31 21:27:39 -04:00
7. Commands |youcompleteme-commands|
2013-10-24 15:41:56 -04:00
1. The |:YcmRestartServer| command
2. The |:YcmForceCompileAndDiagnostics| command
3. The |:YcmDiags| command
4. The |:YcmShowDetailedDiagnostic| command
5. The |:YcmDebugInfo| command
6. The |:YcmCompleter| command
2013-05-31 21:27:39 -04:00
8. YcmCompleter subcommands |youcompleteme-ycmcompleter-subcommands|
2013-07-17 23:02:40 -04:00
1. The |GoToDeclaration| subcommand
2. The |GoToDefinition| subcommand
3. The |GoToDefinitionElseDeclaration| subcommand
4. The |ClearCompilationFlagCache| subcommand
2013-08-12 23:58:21 -04:00
5. The |StartServer| subcommand
6. The |StopServer| subcommand
7. The |RestartServer| subcommand
2013-05-31 21:27:39 -04:00
9. Options |youcompleteme-options|
2013-07-17 23:02:40 -04:00
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_filetype_whitelist| option
4. The |g:ycm_filetype_blacklist| option
5. The |g:ycm_filetype_specific_completion_to_disable| option
6. The |g:ycm_register_as_syntastic_checker| option
7. The |g:ycm_allow_changing_updatetime| option
8. The |g:ycm_complete_in_comments| option
9. The |g:ycm_complete_in_strings| option
10. The |g:ycm_collect_identifiers_from_comments_and_strings| option
11. The |g:ycm_collect_identifiers_from_tags_files| option
12. The |g:ycm_seed_identifiers_with_syntax| option
2013-10-26 19:29:12 -04:00
13. The |g:ycm_extra_conf_vim_data| option
2013-11-15 22:13:56 -05:00
14. The |g:ycm_path_to_python_interpreter| option
15. The |g:ycm_server_use_vim_stdout| option
16. The |g:ycm_server_keep_logfiles| option
17. The |g:ycm_server_log_level| option
18. The |g:ycm_server_idle_suicide_seconds| option
19. The |g:ycm_csharp_server_port| option
20. The |g:ycm_auto_start_csharp_server| option
21. The |g:ycm_auto_stop_csharp_server| option
22. The |g:ycm_add_preview_to_completeopt| option
23. The |g:ycm_autoclose_preview_window_after_completion| option
24. The |g:ycm_autoclose_preview_window_after_insertion| option
25. The |g:ycm_max_diagnostics_to_display| option
26. The |g:ycm_key_list_select_completion| option
27. The |g:ycm_key_list_previous_completion| option
28. The |g:ycm_key_invoke_completion| option
29. The |g:ycm_key_detailed_diagnostics| option
30. The |g:ycm_global_ycm_extra_conf| option
31. The |g:ycm_confirm_extra_conf| option
32. The |g:ycm_extra_conf_globlist| option
33. The |g:ycm_filepath_completion_use_working_dir| option
34. The |g:ycm_semantic_triggers| option
35. The |g:ycm_cache_omnifunc| option
36. The |g:ycm_use_ultisnips_completer| option
2013-05-31 21:27:39 -04:00
10. FAQ |youcompleteme-faq|
2013-10-26 19:29:12 -04:00
1. I used to be able to 'import vim' in '.ycm_extra_conf.py', but now can't |import-vim|
2. I get a linker warning regarding |libpython| on Mac when compiling YCM
3. 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|
4. It appears that YCM is not working |youcompleteme-it-appears-that-ycm-is-not-working|
5. I cannot get the Syntastic integration to work |youcompleteme-i-cannot-get-syntastic-integration-to-work|
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. Vim flickers every time I move the cursor or moving the cursor is slow |youcompleteme-vim-flickers-every-time-i-move-cursor-or-moving-cursor-is-slow|
8. YCM auto-inserts completion strings I don't want! |youcompleteme-ycm-auto-inserts-completion-strings-i-dont-want|
9. I get a 'E227: mapping already exists for <blah>' error when I start Vim |E227:-mapping-already-exists-for-blah|
10. I get "'GLIBC_2.XX' not found (required by libclang.so)" when starting Vim |GLIBC_2.XX-not-found()|
11. 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|
12. 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|
13. Vim segfaults when I use the semantic completer in Ruby files |youcompleteme-vim-segfaults-when-i-use-semantic-completer-in-ruby-files|
14. I get 'LONG_BIT definition appears wrong for platform' when compiling |LONG_BIT-definition-appears-wrong-for-platform|
15. I get 'libpython2.7.a [...] relocation R_X86_64_32' when compiling |libpython2.7.a-...-relocation-R_X86_64_32|
16. I get 'Vim: Caught deadly signal SEGV' on Vim startup |Vim:-Caught-deadly-signal-SEGV|
17. YCM does not read identifiers from my tags files |youcompleteme-ycm-does-not-read-identifiers-from-my-tags-files|
18. 'CTRL-U' in insert mode does not work |CTRL-sub-U|
19. YCM conflicts with UltiSnips TAB key usage |youcompleteme-ycm-conflicts-with-ultisnips-tab-key-usage|
20. Why isn't YCM just written in plain VimScript, FFS? |youcompleteme-why-isnt-ycm-just-written-in-plain-vimscript-ffs|
21. Why does YCM demand such a recent version of Vim? |youcompleteme-why-does-ycm-demand-such-recent-version-of-vim|
22. I get annoying messages in Vim's status area when I type |youcompleteme-i-get-annoying-messages-in-vims-status-area-when-i-type|
23. Nasty bugs happen if I have the 'vim-autoclose' plugin installed |vim-sub-autoclose|
24. Is there some sort of YCM mailing list? I have questions |youcompleteme-is-there-sort-of-ycm-mailing-list-i-have-questions|
2013-11-15 22:13:56 -05:00
25. I get an internal compiler error when installing |youcompleteme-i-get-an-internal-compiler-error-when-installing|
2013-05-31 21:27:39 -04:00
11. Contact |youcompleteme-contact|
12. License |youcompleteme-license|
13. References |youcompleteme-references|
2013-02-02 16:47:08 -05:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-introduction*
2013-02-02 16:47:08 -05:00
Introduction ~
2013-05-31 21:27:39 -04:00
Image: Build Status [1]
2013-04-30 13:18:15 -04:00
2013-02-02 16:47:08 -05:00
YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for
2013-02-12 23:34:58 -05:00
Vim. It has several completion engines: an identifier-based engine that works
2013-04-30 13:18:15 -04:00
with every programming language, a semantic, Clang [3]-based engine that
2013-02-12 23:34:58 -05:00
provides native semantic code completion for C/C++/Objective-C/Objective-C++
2013-04-30 13:18:15 -04:00
(from now on referred to as "the C-family languages"), a Jedi [4]-based
2013-07-17 23:02:40 -04:00
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.).
2013-02-02 16:47:08 -05:00
2013-07-17 23:02:40 -04:00
Image: YouCompleteMe GIF demo (see reference [6])
2013-02-02 16:47:08 -05:00
Here's an explanation of what happens in the short GIF demo above.
2013-05-31 21:27:39 -04:00
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
2013-02-02 16:47:08 -05:00
suggestions pop up by themselves. If the user doesn't find the completion
2013-05-28 22:02:04 -04:00
suggestions relevant and/or just wants to type, they can do so; the completion
2013-02-02 16:47:08 -05:00
engine will not interfere.
2013-05-31 21:27:39 -04:00
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.
2013-02-02 16:47:08 -05:00
If the offered completions are not relevant enough, the user can continue
typing to further filter out unwanted completions.
2013-05-31 21:27:39 -04:00
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
2013-07-17 23:02:40 -04:00
input needs to be a _subsequence [7] match_ of a completion. This is a fancy
2013-05-31 21:27:39 -04:00
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).
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
**All of the above works with any programming language** because of the
2013-02-02 16:47:08 -05:00
identifier-based completion engine. It collects all of the identifiers in the
2013-05-26 17:00:56 -04:00
current file and other files you visit (and your tags files) and searches them
when you type (identifiers are put into per-filetype groups).
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
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).
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
The last thing that you can see in the demo is YCM's integration with Syntastic
2013-07-17 23:02:40 -04:00
[8] (the little red X that shows up in the left gutter) if you are editing a
2013-05-31 21:27:39 -04:00
C-family file. As Clang compiles your file and detects warnings or errors, they
will be piped to Syntastic for display. You don't need to save your file or
press any keyboard shortcut to trigger this, it "just happens" in the
background.
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
In essence, YCM obsoletes the following Vim plugins because it has all of their
features plus extra:
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
- clang_complete
- AutoComplPop
- Supertab
- neocomplcache
2013-02-02 16:47:08 -05:00
2013-04-10 23:49:44 -04:00
YCM also provides semantic go-to-definition/declaration commands for C-family
2013-05-05 13:19:05 -04:00
languages & Python. Expect more IDE features powered by the various YCM
semantic engines in the future.
2013-04-10 23:49:44 -04:00
2013-04-30 13:18:15 -04:00
You'll also find that YCM has filepath completers (try typing './' in a file)
2013-07-17 23:02:40 -04:00
and a completer that integrates with UltiSnips [9].
2013-04-30 13:18:15 -04:00
2013-02-02 16:47:08 -05:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-mac-os-x-super-quick-installation*
2013-02-02 16:47:08 -05:00
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.
2013-07-17 23:02:40 -04:00
Install the latest version of MacVim [10]. Yes, MacVim. And yes, the _latest_.
2013-02-02 16:47:08 -05:00
2013-02-06 23:08:04 -05:00
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
2013-07-17 23:02:40 -04:00
it works correctly copy the 'mvim' script from the MacVim [10] download to your
2013-02-06 23:08:04 -05:00
local binary folder (for example '/usr/local/bin/mvim') and then symlink it:
>
2013-05-31 21:27:39 -04:00
ln -s /usr/local/bin/mvim vim
<
2013-07-17 23:02:40 -04:00
Install YouCompleteMe with Vundle [11].
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
2013-10-24 15:41:56 -04:00
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.
2013-02-12 23:34:58 -05:00
2013-05-31 21:27:39 -04:00
It's recommended that you have the latest Xcode installed along with the latest
Command Line Tools (that you install from within Xcode).
2013-02-16 17:21:18 -05:00
2013-07-17 23:02:40 -04:00
Install CMake. Preferably with Homebrew [12], but here's the stand-alone CMake
installer [13].
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
_If_ you have installed a Homebrew Python and/or Homebrew MacVim, see the _FAQ_
2013-02-06 23:08:04 -05:00
for details.
2013-05-31 21:27:39 -04:00
Compiling YCM **with** semantic support for C-family languages:
2013-02-02 16:47:08 -05:00
>
2013-05-31 21:27:39 -04:00
cd ~/.vim/bundle/YouCompleteMe
./install.sh --clang-completer
<
Compiling YCM **without** semantic support for C-family languages:
2013-02-02 16:47:08 -05:00
>
2013-05-31 21:27:39 -04:00
cd ~/.vim/bundle/YouCompleteMe
./install.sh
<
2013-07-17 23:02:40 -04:00
If you want semantic C# support, you should add '--omnisharp-completer' to the
install script as well.
2013-05-31 21:27:39 -04:00
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
2013-02-02 16:47:08 -05:00
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
2013-05-31 21:27:39 -04:00
look at what's available for configuration. There are a few interesting options
that are conservatively turned off by default that you may want to turn on.
2013-02-02 16:47:08 -05:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-ubuntu-linux-x64-super-quick-installation*
2013-02-02 16:47:08 -05:00
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,
2013-05-31 21:27:39 -04:00
the version of Vim shipping with Ubuntu is too old. You may need to compile Vim
2013-07-17 23:02:40 -04:00
from source [14] (don't worry, it's easy).
2013-02-02 16:47:08 -05:00
2013-07-17 23:02:40 -04:00
Install YouCompleteMe with Vundle [11].
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
2013-10-24 15:41:56 -04:00
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.
2013-02-12 23:34:58 -05:00
2013-03-01 21:40:02 -05:00
Install development tools and CMake: 'sudo apt-get install build-essential
cmake'
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
Make sure you have Python headers installed: 'sudo apt-get install python-dev'.
2013-02-12 23:34:58 -05:00
2013-05-31 21:27:39 -04:00
Compiling YCM **with** semantic support for C-family languages:
2013-02-02 16:47:08 -05:00
>
2013-05-31 21:27:39 -04:00
cd ~/.vim/bundle/YouCompleteMe
./install.sh --clang-completer
<
Compiling YCM **without** semantic support for C-family languages:
2013-02-02 16:47:08 -05:00
>
2013-05-31 21:27:39 -04:00
cd ~/.vim/bundle/YouCompleteMe
./install.sh
<
2013-07-17 23:02:40 -04:00
If you want semantic C# support, you should add '--omnisharp-completer' to the
install script as well.
2013-05-31 21:27:39 -04:00
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
2013-02-02 16:47:08 -05:00
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
2013-05-31 21:27:39 -04:00
look at what's available for configuration. There are a few interesting options
that are conservatively turned off by default that you may want to turn on.
2013-02-02 16:47:08 -05:00
2013-03-01 21:40:02 -05:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-windows-installation*
2013-03-01 21:40:02 -05:00
Windows Installation ~
2013-05-31 21:27:39 -04:00
YCM has **no official support for Windows**, but that doesn't mean you can't
2013-07-17 23:02:40 -04:00
get it to work there. See the Windows Installation Guide [15] wiki page. Feel
2013-05-31 21:27:39 -04:00
free to add to it.
2013-03-01 21:40:02 -05:00
2013-02-02 16:47:08 -05:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-full-installation-guide*
2013-02-02 16:47:08 -05:00
Full Installation Guide ~
2013-05-31 21:27:39 -04:00
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
2013-02-02 16:47:08 -05:00
that platform).
2013-05-31 21:27:39 -04:00
See the _FAQ_ if you have any issues.
**Remember:** YCM is a plugin with a compiled component. If you **update** YCM
2013-10-24 15:41:56 -04:00
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.
2013-05-31 21:27:39 -04:00
**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
2013-07-17 23:02:40 -04:00
from source [14] (don't worry, it's easy).
2013-05-31 21:27:39 -04:00
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.
2013-07-17 23:02:40 -04:00
2. **Install YCM** with Vundle [11] (or Pathogen [16], but Vundle is a
2013-05-31 21:27:39 -04:00
better idea). With Vundle, this would mean adding a "Bundle
2013-07-17 23:02:40 -04:00
'Valloric/YouCompleteMe'" line to your vimrc [17].
2013-05-31 21:27:39 -04:00
2013-10-26 19:29:12 -04:00
If you don't install YCM with Vundle, make sure you have run 'git
submodule update --init --recursive' after checking out the YCM
repository (Vundle will do this for you) to fetch YCM's dependencies.
2013-05-31 21:27:39 -04:00
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
2013-07-17 23:02:40 -04:00
for those languages. YCM is designed to work with libclang version 3.3 or
higher, but can in theory work with 3.2 as well.
2013-05-31 21:27:39 -04:00
2013-07-17 23:02:40 -04:00
You can use the system libclang _only if you are sure it is version 3.3
2013-05-31 21:27:39 -04:00
or higher_, otherwise don't. Even if it is, I recommend using the
2013-07-17 23:02:40 -04:00
official binaries from llvm.org [18] if at all possible. Make sure you
2013-05-31 21:27:39 -04:00
download the correct archive file for your OS.
2013-10-24 15:41:56 -04:00
4. **Compile the 'ycm_support_libs' libraries** that YCM needs. These libs
are the C++ engines that YCM uses to get fast completions.
2013-05-31 21:27:39 -04:00
You will need to have 'cmake' installed in order to generate the required
makefiles. Linux users can install cmake with their package manager
('sudo apt-get install cmake' for Ubuntu) whereas other users can
2013-07-17 23:02:40 -04:00
download and install [13] cmake from its project site. Mac users can also
get it through Homebrew [12] with 'brew install cmake'.
2013-05-31 21:27:39 -04:00
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
2013-07-17 23:02:40 -04:00
'ycm_build' directory:
>
cmake -G "Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/cpp
<
2013-02-12 23:34:58 -05:00
If you DO care about semantic support for C-family languages, then your
2013-05-31 21:27:39 -04:00
'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
2013-02-12 23:34:58 -05:00
extracted the archive file to folder '~/ycm_temp/llvm_root_dir' (with
'bin', 'lib', 'include' etc. folders right inside that folder). With that
2013-07-17 23:02:40 -04:00
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:
>
2013-10-24 15:41:56 -04:00
make ycm_support_libs
2013-07-17 23:02:40 -04:00
<
2013-05-31 21:27:39 -04:00
For those who want to use the system version of libclang, you would pass
'-DUSE_SYSTEM_LIBCLANG=ON' to cmake _instead of_ the
'-DPATH_TO_LLVM_ROOT=...' flag.
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.
2013-02-02 16:47:08 -05:00
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
2013-05-31 21:27:39 -04:00
look at what's available for configuration. There are a few interesting options
that are conservatively turned off by default that you may want to turn on.
2013-02-02 16:47:08 -05:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-user-guide*
2013-02-02 16:47:08 -05:00
User Guide ~
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-general-usage*
2013-02-02 16:47:08 -05:00
General Usage ~
2013-05-31 21:27:39 -04:00
- If the offered completions are too broad, keep typing characters; YCM will
continue refining the offered completions based on your input.
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
- Filtering is "smart-case" sensitive; if you are typing only lowercase
2013-08-12 23:58:21 -04:00
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".
2013-03-10 13:37:23 -04:00
2013-05-31 21:27:39 -04:00
- Use the TAB key to accept a completion and continue pressing TAB to cycle
through the completions. Use Shift-TAB to cycle backwards. Note that if
you're using console Vim (that is, not Gvim or MacVim) then it's likely
that the Shift-TAB binding will not work because the console will not pass
it to Vim. You can remap the keys; see the _Options_ section below.
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
Knowing a little bit about how YCM works internally will prevent confusion. YCM
has several completion engines: an identifier-based completer that collects all
of the identifiers in the current file and other files you visit (and your tags
files) and searches them when you type (identifiers are put into per-filetype
groups).
2013-05-26 17:00:56 -04:00
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.
2013-10-24 15:41:56 -04:00
-------------------------------------------------------------------------------
*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.
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-completion-string-ranking*
2013-02-02 16:47:08 -05:00
Completion string ranking ~
2013-05-31 21:27:39 -04:00
The subsequence filter removes any completions that do not match the input, but
then the sorting system kicks in. It's actually very complicated and uses lots
of factors, but suffice it to say that "word boundary" (WB) subsequence
2013-02-02 16:47:08 -05:00
character matches are "worth" more than non-WB matches. In effect, this means
2013-05-31 21:27:39 -04:00
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.
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-general-semantic-completion-engine-usage*
2013-02-12 23:34:58 -05:00
General Semantic Completion Engine Usage ~
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
- You can use Ctrl+Space to trigger the completion suggestions anywhere, even
without a string prefix. This is useful to see which top-level functions
are available for use.
2013-02-02 16:47:08 -05:00
2013-02-12 23:34:58 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-c-family-semantic-completion-engine-usage*
2013-02-12 23:34:58 -05:00
C-family Semantic Completion Engine Usage ~
2013-07-17 23:02:40 -04:00
- You _really_ also want to install the latest version of the Syntastic [8]
2013-05-31 21:27:39 -04:00
Vim plugin. It has support for YCM and together they will provide you with
compile errors/warnings practically instantly and without saving the file.
2013-02-02 16:47:08 -05:00
YCM looks for a '.ycm_extra_conf.py' file in the directory of the opened file
or in any directory above it in the hierarchy (recursively); when the file is
2013-05-31 21:27:39 -04:00
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.
2013-02-02 16:47:08 -05:00
This system was designed this way so that the user can perform any arbitrary
sequence of operations to produce a list of compilation flags YCM should hand
to Clang.
2013-07-17 23:02:40 -04:00
See YCM's own '.ycm_extra_conf.py' [19] for details on how this works. You
2013-05-31 21:27:39 -04:00
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.
2013-02-02 16:47:08 -05:00
2013-07-17 23:02:40 -04:00
Yes, Clang's 'CompilationDatabase' system [20] is also supported. Again, see
2013-02-02 16:47:08 -05:00
the above linked example file.
If Clang encounters errors when compiling the header files that your file
2013-05-31 21:27:39 -04:00
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
2013-02-02 16:47:08 -05:00
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.
2013-07-17 23:02:40 -04:00
Call the |:YcmDiags| command to see if any errors or warnings were detected in
2013-02-02 16:47:08 -05:00
your file. Even better, use Syntastic.
2013-03-25 22:51:42 -04:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-python-semantic-completion*
2013-03-25 22:51:42 -04:00
Python semantic completion ~
2013-04-30 13:18:15 -04:00
YCM uses Jedi [4] to power its semantic completion for Python. This should
2013-05-31 21:27:39 -04:00
"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
2013-04-10 23:49:44 -04:00
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.
2013-03-25 22:51:42 -04:00
In the future expect to see features like go-to-definition for Python as well.
2013-07-17 23:02:40 -04:00
-------------------------------------------------------------------------------
*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.
2013-03-25 22:51:42 -04:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-semantic-completion-for-other-languages*
2013-03-25 22:51:42 -04:00
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.
2013-07-17 23:02:40 -04:00
You can get stellar omnifuncs for Java and Ruby with Eclim [21]. Just make sure
2013-05-31 21:27:39 -04:00
you have the _latest_ Eclim installed and configured (this means Eclim '>=
2013-05-20 21:17:30 -04:00
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
2013-05-31 21:27:39 -04:00
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
2013-05-20 21:17:30 -04:00
Eclim's omnifuncs as the data source for semantic completions and provide the
auto-triggering and subsequence-based matching (and other YCM features) on top
of it.
2013-03-25 22:51:42 -04:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-writing-new-semantic-completers*
2013-03-25 22:51:42 -04:00
Writing New Semantic Completers ~
You have two options here: writing an 'omnifunc' for Vim's omnicomplete system
that YCM will then use through its omni-completer, or a custom completer for
2013-07-17 23:02:40 -04:00
YCM using the Completer API [22].
2013-03-25 22:51:42 -04:00
Here are the differences between the two approaches:
2013-05-31 21:27:39 -04:00
- 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.
2013-03-25 22:51:42 -04:00
2013-05-31 21:27:39 -04:00
- 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.
2013-03-25 22:51:42 -04:00
2013-05-31 21:27:39 -04:00
- Performance with the Completer API is better since Python executes faster
than VimScript.
2013-03-25 22:51:42 -04:00
If you want to use the 'omnifunc' system, see the relevant Vim docs with ':h
2013-07-17 23:02:40 -04:00
complete-functions'. For the Completer API, see the API docs [22].
2013-03-25 22:51:42 -04:00
If you want to upstream your completer into YCM's source, you should use the
Completer API.
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-syntastic-integration*
2013-02-02 16:47:08 -05:00
Syntastic integration ~
2013-07-17 23:02:40 -04:00
YCM has explicit support for Syntastic [8] (and vice-versa) if you compiled YCM
2013-05-31 21:27:39 -04:00
with Clang support; this means that any diagnostics (errors or warnings) that
Clang encounters while compiling your file will be fed back to Syntastic for
display.
2013-02-02 16:47:08 -05:00
YCM will recompile your file in the background 'updatetime' (see ':h
updatetime' in Vim) milliseconds after you stop typing (to be specific, on
'CursorHold' and 'CursorHoldI' Vim events). YCM will change your 'updatetime'
2013-05-31 21:27:39 -04:00
value to be '2000' milliseconds (there's an option to tell it not to do this if
you wish).
2013-02-02 16:47:08 -05:00
The new diagnostics (if any) will be fed back to Syntastic the next time you
press any key on the keyboard. So if you stop typing and just wait for the new
2013-05-31 21:27:39 -04:00
diagnostics to come in, that _will not work_. You need to press some key for
the GUI to update.
2013-02-02 16:47:08 -05:00
Having to press a key to get the updates is unfortunate, but cannot be changed
due to the way Vim internals operate; there is no way that a background task
2013-05-31 21:27:39 -04:00
can update Vim's GUI after it has finished running. You _have to_ press a key.
2013-02-02 16:47:08 -05:00
This will make YCM check for any pending diagnostics updates.
2013-05-31 21:27:39 -04:00
You _can_ force a full, blocking compilation cycle with the
2013-07-17 23:02:40 -04:00
|:YcmForceCompileAndDiagnostics| command (you may want to map that command to a
2013-05-31 21:27:39 -04:00
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.
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
After the errors are displayed by Syntastic, it will display a short diagnostic
message when you move your cursor to the line with the error. You can get a
detailed diagnostic message with the '<leader>d' key mapping (can be changed in
the options) YCM provides when your cursor is on the line with the diagnostic.
2013-02-02 16:47:08 -05:00
You can also see the full diagnostic message for all the diagnostics in the
2013-05-31 21:27:39 -04:00
current file in Vim's 'locationlist', which can be opened with the ':lopen' and
':lclose' commands (make sure you have set 'let
g:syntastic_always_populate_loc_list = 1' in your vimrc). A good way to toggle
the display of the 'locationlist' with a single key mapping is provided by
2013-07-17 23:02:40 -04:00
another (very small) Vim plugin called ListToggle [23] (which also makes it
2013-05-31 21:27:39 -04:00
possible to change the height of the 'locationlist' window), also written by
yours truly.
2013-02-02 16:47:08 -05:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-commands*
2013-02-02 16:47:08 -05:00
Commands ~
2013-10-24 15:41:56 -04:00
-------------------------------------------------------------------------------
The *:YcmRestartServer* command
If the 'ycmd' completion server suddenly stops for some reason, you can restart
it with this command.
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *:YcmForceCompileAndDiagnostics* command
2013-02-02 16:47:08 -05:00
Calling this command will force YCM to immediately recompile your file and
2013-05-31 21:27:39 -04:00
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.
2013-02-02 16:47:08 -05:00
You may want to map this command to a key; try putting 'nnoremap <F5>
:YcmForceCompileAndDiagnostics<CR>' in your vimrc.
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *:YcmDiags* command
2013-02-02 16:47:08 -05:00
Calling this command will fill Vim's 'locationlist' with errors or warnings if
any were detected in your file and then open it.
A better option would be to use Syntastic which will keep your 'locationlist'
up to date automatically and will also show error/warning notifications in
Vim's gutter.
2013-02-06 23:08:04 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *:YcmShowDetailedDiagnostic* command
2013-02-06 23:08:04 -05:00
This command shows the full diagnostic text when the user's cursor is on the
line with the diagnostic.
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *:YcmDebugInfo* command
2013-02-02 16:47:08 -05:00
This will print out various debug information for the current file. Useful to
see what compile commands will be used for the file if you're using the
semantic completion engine.
2013-03-01 21:40:02 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *:YcmCompleter* command
2013-03-01 21:40:02 -05:00
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
2013-05-31 21:27:39 -04:00
(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.
2013-03-01 21:40:02 -05:00
2013-05-31 21:27:39 -04:00
See the _YcmCompleter subcommands_ section for more information on the
available subcommands.
2013-04-10 23:49:44 -04:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-ycmcompleter-subcommands*
2013-04-10 23:49:44 -04:00
YcmCompleter subcommands ~
2013-05-20 21:17:30 -04:00
[See the docs for the 'YcmCompleter' command before tackling this section.]
2013-04-10 23:49:44 -04:00
2013-05-31 21:27:39 -04:00
The invoked subcommand is automatically routed to the currently active semantic
2013-07-17 23:02:40 -04:00
completer, so ':YcmCompleter GoToDefinition' will invoke the |GoToDefinition|
2013-05-31 21:27:39 -04:00
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.
2013-04-10 23:49:44 -04:00
You may also want to map the subcommands to something less verbose; for
instance, 'nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<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).
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *GoToDeclaration* subcommand
2013-04-10 23:49:44 -04:00
Looks up the symbol under the cursor and jumps to its declaration.
2013-10-24 15:41:56 -04:00
Supported in filetypes: 'c, cpp, objc, objcpp, python, cs'
2013-04-10 23:49:44 -04:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *GoToDefinition* subcommand
2013-04-10 23:49:44 -04:00
Looks up the symbol under the cursor and jumps to its definition.
2013-05-31 21:27:39 -04:00
NOTE: For C-family languages **this only works in certain situations**, namely
2013-04-10 23:49:44 -04:00
when the definition of the symbol is in the current translation unit. A
2013-05-31 21:27:39 -04:00
translation unit consists of the file you are editing and all the files you are
including with '#include' directives (directly or indirectly) in that file.
2013-04-10 23:49:44 -04:00
2013-10-24 15:41:56 -04:00
Supported in filetypes: 'c, cpp, objc, objcpp, python, cs'
2013-04-10 23:49:44 -04:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *GoToDefinitionElseDeclaration* subcommand
2013-04-10 23:49:44 -04:00
Looks up the symbol under the cursor and jumps to its definition if possible;
2013-05-31 21:27:39 -04:00
if the definition is not accessible from the current translation unit, jumps to
the symbol's declaration.
2013-04-10 23:49:44 -04:00
2013-10-24 15:41:56 -04:00
Supported in filetypes: 'c, cpp, objc, objcpp, python, cs'
2013-04-10 23:49:44 -04:00
2013-05-26 17:00:56 -04:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *ClearCompilationFlagCache* subcommand
2013-05-26 17:00:56 -04:00
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'
2013-08-12 23:58:21 -04:00
-------------------------------------------------------------------------------
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'
2013-02-02 16:47:08 -05:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-options*
2013-02-02 16:47:08 -05:00
Options ~
2013-05-31 21:27:39 -04:00
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
2013-07-17 23:02:40 -04:00
vimrc script [17] by including a line like this:
2013-02-02 16:47:08 -05:00
>
2013-05-31 21:27:39 -04:00
let g:ycm_min_num_of_chars_for_completion = 1
<
2013-07-17 23:02:40 -04:00
Note that after changing an option in your vimrc script [17] you have to
2013-02-02 16:47:08 -05:00
restart Vim for the changes to take effect.
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_min_num_of_chars_for_completion* option
2013-02-02 16:47:08 -05:00
This option controls the number of characters the user needs to type before
2013-04-30 13:18:15 -04:00
identifier-based completion suggestions are triggered. For example, if the
option is set to '2', then when the user types a second alphanumeric character
after a whitespace character, completion suggestions will be triggered. This
option is NOT used for semantic completion.
Setting this option to a high number like '99' effectively turns off the
identifier completion engine and just leaves the semantic engine.
2013-02-02 16:47:08 -05:00
Default: '2'
>
2013-05-31 21:27:39 -04:00
let g:ycm_min_num_of_chars_for_completion = 2
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_min_num_identifier_candidate_chars* option
This option controls the minimum number of characters that a completion
candidate coming from the identifier completer must have to be shown in the
popup menu.
A special value of '0' means there is no limit.
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_filetype_whitelist* option
2013-02-02 16:47:08 -05:00
This option controls for which Vim filetypes (see ':h filetype') should YCM be
2013-05-31 21:27:39 -04:00
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).
2013-03-10 13:37:23 -04:00
The '*' key is special and matches all filetypes. By default, the whitelist
contains only this '*' key.
2013-07-17 23:02:40 -04:00
YCM also has a |g:ycm_filetype_blacklist| option that lists filetypes for which
2013-05-31 21:27:39 -04:00
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).
2013-03-10 13:37:23 -04:00
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
2013-05-31 21:27:39 -04:00
should _not_ be present in the blacklist.
2013-03-10 13:37:23 -04:00
Filetypes that are blocked by the either of the lists will be completely
2013-05-31 21:27:39 -04:00
ignored by YCM, meaning that neither the identifier-based completion engine nor
the semantic engine will operate in them.
2013-02-02 16:47:08 -05:00
You can get the filetype of the current file in Vim with ':set ft?'.
2013-05-31 21:27:39 -04:00
Default: "{'*' : 1}"
2013-03-10 13:37:23 -04:00
>
2013-05-31 21:27:39 -04:00
let g:ycm_filetype_whitelist = { '*': 1 }
<
2013-03-10 13:37:23 -04:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_filetype_blacklist* option
2013-03-10 13:37:23 -04:00
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).
2013-07-17 23:02:40 -04:00
See the |g:ycm_filetype_whitelist| option for more details on how this works.
2013-03-10 13:37:23 -04:00
2013-10-29 22:12:51 -04:00
Default: '[see next line]'
2013-02-02 16:47:08 -05:00
>
2013-05-31 21:27:39 -04:00
let g:ycm_filetype_blacklist = {
2013-10-29 22:12:51 -04:00
\ 'tagbar' : 1,
\ 'qf' : 1,
2013-05-31 21:27:39 -04:00
\ 'notes' : 1,
\ 'markdown' : 1,
2013-08-12 23:58:21 -04:00
\ 'unite' : 1,
2013-10-29 22:12:51 -04:00
\ 'text' : 1,
\ 'vimwiki' : 1,
2013-05-31 21:27:39 -04:00
\}
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_filetype_specific_completion_to_disable* option
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
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
2013-02-02 16:47:08 -05:00
dictionary with keys being filetype strings (like 'python', 'cpp' etc) and
values being unimportant (the dictionary is used like a hash set, meaning that
2013-05-31 21:27:39 -04:00
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.
2013-02-02 16:47:08 -05:00
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
2013-03-10 13:37:23 -04:00
support that filetype.
2013-02-02 16:47:08 -05:00
You can get the filetype of the current file in Vim with ':set ft?'.
Default: '{}'
>
2013-05-31 21:27:39 -04:00
let g:ycm_filetype_specific_completion_to_disable = {}
<
2013-03-25 22:51:42 -04:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_register_as_syntastic_checker* option
2013-03-25 22:51:42 -04:00
When set, this option makes YCM register itself as the Syntastic checker for
the 'c', 'cpp', 'objc' and 'objcpp' filetypes. This enables the YCM-Syntastic
integration.
2013-05-31 21:27:39 -04:00
If you're using YCM's identifier completer in C-family languages but cannot use
the clang-based semantic completer for those languages _and_ want to use the
2013-03-25 22:51:42 -04:00
GCC Syntastic checkers, unset this option.
Don't unset this option unless you're sure you know what you're doing.
Default: '1'
>
2013-05-31 21:27:39 -04:00
let g:ycm_register_as_syntastic_checker = 1
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_allow_changing_updatetime* option
2013-02-02 16:47:08 -05:00
When this option is set to '1', YCM will change the 'updatetime' Vim option to
'2000' (see ':h updatetime'). This may conflict with some other plugins you
2013-05-31 21:27:39 -04:00
have (but it's unlikely). The 'updatetime' option is the number of milliseconds
that have to pass before Vim's 'CursorHold' (see ':h CursorHold') event fires.
YCM runs the completion engines' "file comprehension" systems in the background
on every such event; the identifier-based engine collects the identifiers
whereas the semantic engine compiles the file to build an AST.
2013-02-02 16:47:08 -05:00
The Vim default of '4000' for 'updatetime' is a bit long, so YCM reduces this.
Set this option to '0' to force YCM to leave your 'updatetime' setting alone.
Default: '1'
>
2013-05-31 21:27:39 -04:00
let g:ycm_allow_changing_updatetime = 1
<
2013-02-16 17:21:18 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_complete_in_comments* option
2013-02-16 17:21:18 -05:00
When this option is set to '1', YCM will show the completion menu even when
2013-04-30 13:18:15 -04:00
typing inside comments.
2013-02-16 17:21:18 -05:00
Default: '0'
>
2013-05-31 21:27:39 -04:00
let g:ycm_complete_in_comments = 0
<
2013-04-30 13:18:15 -04:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_complete_in_strings* option
2013-04-30 13:18:15 -04:00
When this option is set to '1', YCM will show the completion menu even when
typing inside strings.
Note that this is turned on by default so that you can use the filename
completion inside strings. This is very useful for instance in C-family files
2013-05-31 21:27:39 -04:00
where typing '#include "' will trigger the start of filename completion. If you
turn off this option, you will turn off filename completion in such situations
as well.
2013-04-30 13:18:15 -04:00
Default: '1'
>
2013-05-31 21:27:39 -04:00
let g:ycm_complete_in_strings = 1
<
2013-02-16 17:21:18 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_collect_identifiers_from_comments_and_strings* option
2013-02-16 17:21:18 -05:00
When this option is set to '1', YCM's identifier completer will also collect
identifiers from strings and comments. Otherwise, the text in comments and
strings will be ignored.
Default: '0'
>
2013-05-31 21:27:39 -04:00
let g:ycm_collect_identifiers_from_comments_and_strings = 0
<
2013-05-26 17:00:56 -04:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_collect_identifiers_from_tags_files* option
2013-05-26 17:00:56 -04:00
When this option is set to '1', YCM's identifier completer will also collect
identifiers from tags files. The list of tags files to examine is retrieved
from the 'tagfiles()' Vim function which examines the 'tags' Vim option. See
2013-05-31 21:27:39 -04:00
":h 'tags'" for details.
2013-05-26 17:00:56 -04:00
YCM will re-index your tags files if it detects that they have been modified.
2013-07-17 23:02:40 -04:00
The only supported tag format is the Exuberant Ctags format [24]. The format
2013-05-31 21:27:39 -04:00
from "plain" ctags is NOT supported. Ctags needs to be called with the '--
fields=+l' option (that's a lowercase 'L', not a one) because YCM needs the
2013-05-28 22:02:04 -04:00
'language:<lang>' field in the tags output.
2013-05-26 17:00:56 -04:00
2013-05-31 21:27:39 -04:00
See the _FAQ_ for pointers if YCM does not appear to read your tag files.
2013-05-28 22:02:04 -04:00
2013-05-31 21:27:39 -04:00
This option is off by default because it makes Vim slower if your tags are on a
network directory.
2013-05-28 22:02:04 -04:00
Default: '0'
2013-05-26 17:00:56 -04:00
>
2013-05-31 21:27:39 -04:00
let g:ycm_collect_identifiers_from_tags_files = 0
<
2013-05-27 14:03:39 -04:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_seed_identifiers_with_syntax* option
2013-05-27 14:03:39 -04:00
When this option is set to '1', YCM's identifier completer will seed its
identifier database with the keywords of the programming language you're
writing.
2013-05-31 21:27:39 -04:00
Since the keywords are extracted from the Vim syntax file for the filetype, all
keywords may not be collected, depending on how the syntax file was written.
Usually at least 95% of the keywords are successfully extracted.
2013-05-27 14:03:39 -04:00
Default: '0'
>
2013-05-31 21:27:39 -04:00
let g:ycm_seed_identifiers_with_syntax = 0
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-10-26 19:29:12 -04:00
The *g:ycm_extra_conf_vim_data* option
If you're using semantic completion for C-family files, this option might come
handy; it's a way of sending data from Vim to your 'FlagsForFile' function in
your '.ycm_extra_conf.py' file.
This option is supposed to be a list of VimScript expression strings that are
evaluated for every request to the 'ycmd' server and then passed to your
'FlagsForFile' function as a 'client_data' keyword argument.
For instance, if you set this option to "['v:version']", your 'FlagsForFile'
function will be called like this:
>
# The '704' value is of course contingent on Vim 7.4; in 7.3 it would be '703'
FlagsForFile(filename, client_data = {'v:version': 704})
<
So the 'client_data' parameter is a dictionary mapping Vim expression strings
to their values at the time of the request.
2013-11-15 22:13:56 -05:00
The correct way to define parameters for your 'FlagsForFile' function:
>
def FlagsForFile(filename, **kwargs):
<
You can then get to 'client_data' with "kwargs['client_data']".
2013-10-26 19:29:12 -04:00
Default: '[]'
>
let g:ycm_extra_conf_vim_data = []
<
-------------------------------------------------------------------------------
2013-11-15 22:13:56 -05:00
The *g:ycm_path_to_python_interpreter* option
YCM will by default search for an appropriate Python interpreter on your
system. You can use this option to override that behavior and force the use of
a specific interpreter of your choosing.
NOTE: This interpreter is only used for the 'ycmd' server. The YCM client
running inside Vim always uses the Python interpreter that's embedded inside
Vim.
Default: "''"
>
let g:ycm_path_to_python_interpreter = ''
<
-------------------------------------------------------------------------------
2013-10-24 15:41:56 -04:00
The *g:ycm_server_use_vim_stdout* option
By default, the 'ycmd' completion server writes logs to logfiles. When this
option is set to '1', the server writes logs to Vim's stdout (so you'll see
them in the console).
Default: '0'
>
let g:ycm_server_use_vim_stdout = 0
<
-------------------------------------------------------------------------------
The *g:ycm_server_keep_logfiles* option
When this option is set to '1', the 'ycmd' completion server will keep the
logfiles around after shutting down (they are deleted on shutdown by default).
To see where the logfiles are, call |:YcmDebugInfo|.
Default: '0'
>
let g:ycm_server_keep_logfiles = 0
<
-------------------------------------------------------------------------------
The *g:ycm_server_log_level* option
The logging level that the 'ycmd' completion server uses. Valid values are the
following, from most verbose to least verbose: - 'debug' - 'info' - 'warning' -
'error' - 'critical'
Note that 'debug' is _very_ verbose.
Default: 'info'
>
let g:ycm_server_log_level = 'info'
<
-------------------------------------------------------------------------------
The *g:ycm_server_idle_suicide_seconds* option
This option sets the number of seconds of 'ycmd' server idleness (no requests
received) after which the server stops itself. NOTE: the YCM Vim client sends a
shutdown request to the server when Vim is shutting down.
If your Vim crashes for instance, 'ycmd' never gets the shutdown command and
becomes a zombie process. This option prevents such zombies from sticking
around forever.
The default option is '43200' seconds which is 12 hours. The reason for the
interval being this long is to prevent the server from shutting down if you
leave your computer (and Vim) turned on during the night.
2013-11-15 22:13:56 -05:00
A setting of '0' turns off the timer.
2013-10-24 15:41:56 -04:00
The server "heartbeat" that checks whether this interval has passed occurs
every 10 minutes.
Default: '43200'
>
let g:ycm_server_idle_suicide_seconds = 43200
<
-------------------------------------------------------------------------------
2013-08-12 23:58:21 -04:00
The *g:ycm_csharp_server_port* option
The port number (on 'localhost') on which the OmniSharp server should be
started.
Default: '2000'
>
let g:ycm_csharp_server_port = 2000
<
-------------------------------------------------------------------------------
The *g:ycm_auto_start_csharp_server* option
When set to '1', the OmniSharp server will be automatically started (once per
Vim session) when you open a C# file.
Default: '1'
>
let g:ycm_auto_start_csharp_server = 1
<
-------------------------------------------------------------------------------
The *g:ycm_auto_stop_csharp_server* option
When set to '1', the OmniSharp server will be automatically stopped upon
closing Vim.
Default: '1'
>
let g:ycm_auto_stop_csharp_server = 1
<
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_add_preview_to_completeopt* option
2013-02-02 16:47:08 -05:00
When this option is set to '1', YCM will add the 'preview' string to Vim's
'completeopt' option (see ':h completeopt'). If your 'completeopt' option
already has 'preview' set, there will be no effect. You can see the current
2013-05-31 21:27:39 -04:00
state of your 'completeopt' setting with ':set completeopt?' (yes, the question
mark is important).
2013-02-02 16:47:08 -05:00
When 'preview' is present in 'completeopt', YCM will use the 'preview' window
at the top of the file to store detailed information about the current
2013-05-31 21:27:39 -04:00
completion candidate (but only if the candidate came from the semantic engine).
For instance, it would show the full function prototype and all the function
overloads in the window if the current completion is a function name.
2013-02-02 16:47:08 -05:00
Default: '0'
>
2013-05-31 21:27:39 -04:00
let g:ycm_add_preview_to_completeopt = 0
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_autoclose_preview_window_after_completion* option
2013-02-02 16:47:08 -05:00
When this option is set to '1', YCM will auto-close the 'preview' window after
2013-05-31 21:27:39 -04:00
the user accepts the offered completion string. If there is no 'preview' window
triggered because there is no 'preview' string in 'completeopt', this option is
2013-07-17 23:02:40 -04:00
irrelevant. See the |g:ycm_add_preview_to_completeopt| option for more details.
2013-02-02 16:47:08 -05:00
Default: '0'
>
2013-05-31 21:27:39 -04:00
let g:ycm_autoclose_preview_window_after_completion = 0
<
2013-03-25 22:51:42 -04:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_autoclose_preview_window_after_insertion* option
2013-03-25 22:51:42 -04:00
When this option is set to '1', YCM will auto-close the 'preview' window after
the user leaves insert mode. This option is irrelevant if
2013-07-17 23:02:40 -04:00
|g:ycm_autoclose_preview_window_after_completion| is set or if no 'preview'
window is triggered. See the |g:ycm_add_preview_to_completeopt| option for more
2013-05-31 21:27:39 -04:00
details.
2013-03-25 22:51:42 -04:00
Default: '0'
>
2013-05-31 21:27:39 -04:00
let g:ycm_autoclose_preview_window_after_insertion = 0
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_max_diagnostics_to_display* option
2013-02-02 16:47:08 -05:00
This option controls the maximum number of diagnostics shown to the user when
errors or warnings are detected in the file. This option is only relevant if
you are using the semantic completion engine and have installed the version of
the Syntastic plugin that supports YCM.
Default: '30'
>
2013-05-31 21:27:39 -04:00
let g:ycm_max_diagnostics_to_display = 30
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_key_list_select_completion* option
2013-02-12 23:34:58 -05:00
This option controls the key mappings used to select the first completion
string. Invoking any of them repeatedly cycles forward through the completion
list.
2013-02-02 16:47:08 -05:00
2013-02-12 23:34:58 -05:00
Some users like adding '<Enter>' to this list.
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
Default: "['<TAB>', '<Down>']"
2013-02-02 16:47:08 -05:00
>
2013-05-31 21:27:39 -04:00
let g:ycm_key_list_select_completion = ['<TAB>', '<Down>']
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_key_list_previous_completion* option
2013-02-02 16:47:08 -05:00
2013-02-12 23:34:58 -05:00
This option controls the key mappings used to select the previous completion
2013-05-31 21:27:39 -04:00
string. Invoking any of them repeatedly cycles backwards through the completion
list.
2013-02-02 16:47:08 -05:00
2013-02-12 23:34:58 -05:00
Note that one of the defaults is '<S-TAB>' which means Shift-TAB. That mapping
will probably only work in GUI Vim (Gvim or MacVim) and not in plain console
Vim because the terminal usually does not forward modifier key combinations to
Vim.
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
Default: "['<S-TAB>', '<Up>']"
2013-02-02 16:47:08 -05:00
>
2013-05-31 21:27:39 -04:00
let g:ycm_key_list_previous_completion = ['<S-TAB>', '<Up>']
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_key_invoke_completion* option
2013-02-02 16:47:08 -05:00
This option controls the key mapping used to invoke the completion menu for
semantic completion. By default, semantic completion is trigged automatically
after typing '.', '->' and '::' in insert mode (if semantic completion support
has been compiled in). This key mapping can be used to trigger semantic
completion anywhere. Useful for searching for top-level functions and classes.
2013-04-30 13:18:15 -04:00
Console Vim (not Gvim or MacVim) passes '<Nul>' to Vim when the user types
'<C-Space>' so YCM will make sure that '<Nul>' is used in the map command when
you're editing in console Vim, and '<C-Space>' in GUI Vim. This means that you
can just press '<C-Space>' in both console and GUI Vim and YCM will do the
right thing.
2013-02-02 16:47:08 -05:00
2013-02-06 23:08:04 -05:00
Setting this option to an empty string will make sure no mapping is created.
2013-02-02 16:47:08 -05:00
Default: '<C-Space>'
>
2013-05-31 21:27:39 -04:00
let g:ycm_key_invoke_completion = '<C-Space>'
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_key_detailed_diagnostics* option
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
This option controls the key mapping used to show the full diagnostic text when
the user's cursor is on the line with the diagnostic. It basically calls
2013-07-17 23:02:40 -04:00
|:YcmShowDetailedDiagnostic|.
2013-02-06 23:08:04 -05:00
Setting this option to an empty string will make sure no mapping is created.
2013-02-02 16:47:08 -05:00
Default: '<leader>d'
>
2013-05-31 21:27:39 -04:00
let g:ycm_key_detailed_diagnostics = '<leader>d'
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_global_ycm_extra_conf* option
2013-02-02 16:47:08 -05:00
Normally, YCM searches for a '.ycm_extra_conf.py' file for compilation flags
2013-02-15 09:01:18 -05:00
(see the User Guide for more details on how this works). This option specifies
a fallback path to a config file which is used if no '.ycm_extra_conf.py' is
found.
2013-02-02 16:47:08 -05:00
You can place such a global file anywhere in your filesystem.
2013-05-31 21:27:39 -04:00
Default: "''"
2013-02-02 16:47:08 -05:00
>
2013-05-31 21:27:39 -04:00
let g:ycm_global_ycm_extra_conf = ''
<
2013-03-01 21:40:02 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_confirm_extra_conf* option
2013-03-01 21:40:02 -05:00
When this option is set to '1' YCM will ask once per '.ycm_extra_conf.py' file
2013-05-31 21:27:39 -04:00
if it is safe to be loaded. This is to prevent execution of malicious code from
a '.ycm_extra_conf.py' file you didn't write.
2013-03-01 21:40:02 -05:00
2013-08-12 23:58:21 -04:00
To selectively get YCM to ask/not ask about loading certain
'.ycm_extra_conf.py' files, see the |g:ycm_extra_conf_globlist| option.
2013-03-01 21:40:02 -05:00
Default: '1'
>
2013-05-31 21:27:39 -04:00
let g:ycm_confirm_extra_conf = 1
<
2013-03-01 21:40:02 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_extra_conf_globlist* option
2013-03-01 21:40:02 -05:00
This option is a list that may contain several globbing patterns. If a pattern
starts with a '!' all '.ycm_extra_conf.py' files matching that pattern will be
blacklisted, that is they won't be loaded and no confirmation dialog will be
shown. If a pattern does not start with a '!' all files matching that pattern
will be whitelisted. Note that this option is not used when confirmation is
2013-07-17 23:02:40 -04:00
disabled using |g:ycm_confirm_extra_conf| and that items earlier in the list
2013-03-01 21:40:02 -05:00
will take precedence over the later ones.
Rules:
2013-05-31 21:27:39 -04:00
- '*' matches everything
- '?' matches any single character
- '[seq]' matches any character in seq
- '[!seq]' matches any char not in seq
2013-03-01 21:40:02 -05:00
Example:
>
2013-05-31 21:27:39 -04:00
let g:ycm_extra_conf_globlist = ['~/dev/*','!~/*']
<
- The first rule will match everything contained in the '~/dev' directory so
'.ycm_extra_conf.py' files from there will be loaded.
2013-03-01 21:40:02 -05:00
2013-05-31 21:27:39 -04:00
- The second rule will match everything in the home directory so a
'.ycm_extra_conf.py' file from there won't be loaded.
2013-03-01 21:40:02 -05:00
2013-05-31 21:27:39 -04:00
- As the first rule takes precedence everything in the home directory
excluding the '~/dev' directory will be blacklisted.
2013-03-01 21:40:02 -05:00
Default: '[]'
>
2013-05-31 21:27:39 -04:00
let g:ycm_extra_conf_globlist = []
<
2013-04-30 13:18:15 -04:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_filepath_completion_use_working_dir* option
2013-04-30 13:18:15 -04:00
By default, YCM's filepath completion will interpret relative paths like '../'
as being relative to the folder of the file of the currently active buffer.
Setting this option will force YCM to always interpret relative paths as being
relative to Vim's current working directory.
Default: '0'
>
2013-05-31 21:27:39 -04:00
let g:ycm_filepath_completion_use_working_dir = 0
<
2013-02-12 23:34:58 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_semantic_triggers* option
2013-02-12 23:34:58 -05:00
This option controls the character-based triggers for the various semantic
2013-05-31 21:27:39 -04:00
completion engines. The option holds a dictionary of key-values, where the keys
are Vim's filetype strings delimited by commas and values are lists of strings,
where the strings are the triggers.
2013-02-12 23:34:58 -05:00
2013-07-17 23:02:40 -04:00
Setting key-value pairs on the dictionary _adds_ semantic triggers to the
internal default set (listed below). You cannot remove the default triggers,
only add new ones.
2013-02-12 23:34:58 -05:00
A "trigger" is a sequence of one or more characters that trigger semantic
completion when typed. For instance, C++ ('cpp' filetype) has '.' listed as a
trigger. So when the user types 'foo.', the semantic engine will trigger and
serve 'foo''s list of member functions and variables. Since C++ also has '->'
listed as a trigger, the same thing would happen when the user typed 'foo->'.
Default: '[see next line]'
>
2013-05-31 21:27:39 -04:00
let g:ycm_semantic_triggers = {
\ 'c' : ['->', '.'],
\ 'objc' : ['->', '.'],
\ 'ocaml' : ['.', '#'],
\ 'cpp,objcpp' : ['->', '.', '::'],
\ 'perl' : ['->'],
\ 'php' : ['->', '::'],
2013-07-17 23:02:40 -04:00
\ 'cs,java,javascript,d,vim,python,perl6,scala,vb,elixir,go' : ['.'],
\ 'ruby' : ['.', '::'],
2013-05-31 21:27:39 -04:00
\ 'lua' : ['.', ':'],
\ 'erlang' : [':'],
\ }
<
2013-04-30 13:18:15 -04:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
The *g:ycm_cache_omnifunc* option
2013-04-30 13:18:15 -04:00
2013-08-12 23:58:21 -04:00
Some omnicompletion engines do not work well with the YCM cache—in particular,
they might not produce all possible results for a given prefix. By unsetting
this option you can ensure that the omnicompletion engine is requeried on every
keypress. That will ensure all completions will be presented, but might cause
stuttering and lagginess if the omnifunc is slow.
2013-04-30 13:18:15 -04:00
Default: '1'
>
2013-05-31 21:27:39 -04:00
let g:ycm_cache_omnifunc = 1
<
2013-11-15 22:13:56 -05:00
-------------------------------------------------------------------------------
The *g:ycm_use_ultisnips_completer* option
By default, YCM will query the UltiSnips plugin for possible completions of
snippet triggers. This option can turn that behavior off.
Default: '1'
>
let g:ycm_use_ultisnips_completer = 1
<
2013-02-02 16:47:08 -05:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-faq*
2013-02-02 16:47:08 -05:00
FAQ ~
2013-10-26 19:29:12 -04:00
-------------------------------------------------------------------------------
*import-vim*
I used to be able to 'import vim' in '.ycm_extra_conf.py', but now can't ~
YCM was rewritten to use a client-server architecture where most of the logic
is in the 'ycmd' server. So the magic 'vim' module you could have previously
imported in your '.ycm_extra_conf.py' files doesn't exist anymore.
To be fair, importing the magic 'vim' module in extra conf files was never
supported in the first place; it only ever worked by accident and was never a
part of the extra conf API.
But fear not, you should be able to tweak your extra conf files to continue
working by using the |g:ycm_extra_conf_vim_data| option. See the docs on that
option for details.
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-07-17 23:02:40 -04:00
I get a linker warning regarding *libpython* on Mac when compiling YCM
2013-02-02 16:47:08 -05:00
2013-05-31 21:27:39 -04:00
If the warning is "ld: warning: path '/usr/lib/libpython2.7.dylib' following -L
not a directory", then feel free to ignore it; it's caused by a limitation of
CMake and is not an issue. Everything should still work fine.
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-i-get-weird-window-at-top-of-my-file-when-i-use-semantic-engine*
2013-02-02 16:47:08 -05:00
I get a weird window at the top of my file when I use the semantic engine ~
2013-05-31 21:27:39 -04:00
This is Vim's 'preview' window. Vim uses it to show you extra information about
something if such information is available. YCM provides Vim with such extra
information. For instance, when you select a function in the completion list,
the 'preview' window will hold that function's prototype and the prototypes of
any overloads of the function. It will stay there after you select the
completion so that you can use the information about the parameters and their
types to write the function call.
2013-02-02 16:47:08 -05:00
If you would like this window to auto-close after you select a completion
2013-07-17 23:02:40 -04:00
string, set the |g:ycm_autoclose_preview_window_after_completion| option to '1'
2013-05-31 21:27:39 -04:00
in your 'vimrc' file. Similarly, the
2013-07-17 23:02:40 -04:00
|g:ycm_autoclose_preview_window_after_insertion| option can be set to close the
2013-05-31 21:27:39 -04:00
'preview' window after leaving insert mode.
2013-02-02 16:47:08 -05:00
If you don't want this window to ever show up, add 'set completeopt-=preview'
2013-07-17 23:02:40 -04:00
to your 'vimrc'. Also make sure that the |g:ycm_add_preview_to_completeopt|
2013-02-02 16:47:08 -05:00
option is set to '0'.
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-it-appears-that-ycm-is-not-working*
2013-02-02 16:47:08 -05:00
It appears that YCM is not working ~
In Vim, run ':messages' and carefully read the output. YCM will echo messages
to the message log if it encounters problems. It's likely you misconfigured
something and YCM is complaining about it.
2013-07-17 23:02:40 -04:00
Also, you may want to run the |:YcmDebugInfo| command; it will make YCM spew
2013-02-02 16:47:08 -05:00
out various debugging information, including the compile flags for the file if
the file is a C-family language file and you have compiled in Clang support.
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-i-cannot-get-syntastic-integration-to-work*
2013-02-02 16:47:08 -05:00
I cannot get the Syntastic integration to work ~
2013-05-31 21:27:39 -04:00
Try to update your version of Syntastic. At the time of writing (Jan 2013), the
YCM integration is very recent and it's likely that your version of Syntastic
does not have it.
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-sometimes-it-takes-much-longer-to-get-semantic-completions-than-normal*
2013-02-02 16:47:08 -05:00
Sometimes it takes much longer to get semantic completions than normal ~
This means that libclang (which YCM uses for C-family semantic completion)
2013-02-06 23:08:04 -05:00
failed to pre-compile your file's preamble. In other words, there was an error
2013-02-02 16:47:08 -05:00
compiling some of the source code you pulled in through your header files. I
2013-07-17 23:02:40 -04:00
suggest calling the |:YcmDiags| command to see what they were (even better,
2013-02-02 16:47:08 -05:00
have Syntastic installed and call ':lopen').
2013-02-06 23:08:04 -05:00
Bottom line, if libclang can't pre-compile your file's preamble because there
were errors in it, you're going to get slow completions because there's no AST
cache.
2013-03-25 22:51:42 -04:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-vim-flickers-every-time-i-move-cursor-or-moving-cursor-is-slow*
2013-03-25 22:51:42 -04:00
Vim flickers every time I move the cursor or moving the cursor is slow ~
You probably have an old version of Syntastic installed. If you are using
2013-05-31 21:27:39 -04:00
Vundle, make sure that your bundle command is "Bundle 'scrooloose/syntastic'"
and **not** "Bundle 'Syntastic'". The first command pulls in the latest version
of Syntastic from GitHub while the second one pulls in an old version from
2013-03-25 22:51:42 -04:00
vim.org.
2013-07-17 23:02:40 -04:00
Because of a Vundle bug [25], make sure you have completely removed everything
in your Vundle bundle directory ('~/.vim/bundle' by default) before switching
from one Syntastic bundle command to the other.
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-ycm-auto-inserts-completion-strings-i-dont-want*
2013-02-02 16:47:08 -05:00
YCM auto-inserts completion strings I don't want! ~
This means you probably have some mappings that interfere with YCM's internal
ones. Make sure you don't have something mapped to '<C-p>', '<C-x>' or '<C-u>'
(in insert mode).
2013-05-31 21:27:39 -04:00
YCM _never_ selects something for you; it just shows you a menu and the user
has to explicitly select something. If something is being selected
automatically, this means there's a bug or a misconfiguration somewhere.
2013-02-02 16:47:08 -05:00
2013-02-06 23:08:04 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*E227:-mapping-already-exists-for-blah*
2013-02-06 23:08:04 -05:00
I get a 'E227: mapping already exists for <blah>' error when I start Vim ~
This means that YCM tried to set up a key mapping but failed because you
already had something mapped to that key combination. The '<blah>' part of the
message will tell you what was the key combination that failed.
2013-05-31 21:27:39 -04:00
Look in the _Options_ section and see if any of the default mappings conflict
2013-02-06 23:08:04 -05:00
with your own. Then change that option value to something else so that the
conflict goes away.
2013-04-30 13:18:15 -04:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*GLIBC_2.XX-not-found()*
I get "'GLIBC_2.XX' not found (required by libclang.so)" when starting Vim ~
2013-04-30 13:18:15 -04:00
Your system is too old for the precompiled binaries from llvm.org. Compile
Clang on your machine and then link against the 'libclang.so' you just
produced. See the full installation guide for help.
2013-02-06 23:08:04 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-im-trying-to-use-homebrew-vim-with-ycm-im-getting-segfaults*
2013-02-06 23:08:04 -05:00
I'm trying to use a Homebrew Vim with YCM and I'm getting segfaults ~
Something (I don't know what) is wrong with the way that Homebrew configures
2013-07-17 23:02:40 -04:00
and builds Vim. I recommend using MacVim [10]. Even if you don't like the
MacVim GUI, you can use the Vim binary that is inside the MacVim.app package
(it's 'MacVim.app/Contents/MacOS/Vim') and get the Vim console experience.
2013-02-06 23:08:04 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-i-have-homebrew-python-and-or-macvim-cant-compile-sigabrt-when-starting*
2013-02-06 23:08:04 -05:00
I have a Homebrew Python and/or MacVim; can't compile/SIGABRT when starting ~
2013-05-31 21:27:39 -04:00
You should probably run 'brew rm python; brew install python' to get the latest
fixes that should make YCM work with such a configuration. Also rebuild Macvim
2013-07-17 23:02:40 -04:00
then. If you still get problems with this, see issue #18 [26] for suggestions.
2013-02-06 23:08:04 -05:00
2013-03-25 22:51:42 -04:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-vim-segfaults-when-i-use-semantic-completer-in-ruby-files*
2013-03-25 22:51:42 -04:00
Vim segfaults when I use the semantic completer in Ruby files ~
This was caused by a Vim bug. Update your version of Vim (Vim 7.3.874 is known
to work, earlier versions may also fix this issue).
2013-02-12 23:34:58 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*LONG_BIT-definition-appears-wrong-for-platform*
2013-02-12 23:34:58 -05:00
I get 'LONG_BIT definition appears wrong for platform' when compiling ~
Look at the output of your CMake call. There should be a line in it like the
following (with '.dylib' in place of '.so' on a Mac):
2013-05-31 21:27:39 -04:00
>
-- Found PythonLibs: /usr/lib/libpython2.7.so (Required is at least version "2.5")
<
That would be the **correct** output. An example of **incorrect** output would
be the following:
>
-- Found PythonLibs: /usr/lib/libpython2.7.so (found suitable version "2.5.1", minimum required is "2.5")
<
2013-02-12 23:34:58 -05:00
Notice how there's an extra bit of output there, the 'found suitable version
"<version>"' part, where '<version>' is not the same as the version of the
dynamic library. In the example shown, the library is version 2.7 but the
second string is version '2.5.1'.
This means that CMake found one version of Python headers and a different
version for the library. This is wrong. It can happen when you have multiple
versions of Python installed on your machine.
You should probably add the following flags to your cmake call (again, 'dylib'
instead of 'so' on a Mac):
2013-05-31 21:27:39 -04:00
>
-DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so
<
2013-02-12 23:34:58 -05:00
This will force the paths to the Python include directory and the Python
2013-05-31 21:27:39 -04:00
library to use. You may need to set these flags to something else, but you need
to make sure you use the same version of Python that your Vim binary is built
against, which is highly likely to be the system's default Python.
2013-02-12 23:34:58 -05:00
2013-07-17 23:02:40 -04:00
-------------------------------------------------------------------------------
*libpython2.7.a-...-relocation-R_X86_64_32*
I get 'libpython2.7.a [...] relocation R_X86_64_32' when compiling ~
The error is usually encountered when compiling YCM on Centos or RHEL. The full
error looks something like the following:
>
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC
<
It's possible to get a slightly different error that's similar to the one
above. Here's the problem and how you solve it:
Your 'libpython2.7.a' was not compiled with '-fPIC' so it can't be linked into
'ycm_core.so'. Use the '-DPYTHON_LIBRARY=' CMake flag to point it to a '.so'
version of libpython on your machine (for instance,
'-DPYTHON_LIBRARY=/usr/lib/libpython2.7.so'). Naturally, this means you'll have
to go through the full installation guide by hand.
2013-03-01 21:40:02 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*Vim:-Caught-deadly-signal-SEGV*
2013-03-01 21:40:02 -05:00
I get 'Vim: Caught deadly signal SEGV' on Vim startup ~
2013-05-31 21:27:39 -04:00
This can happen on some Linux distros. If you encounter this situation, run Vim
under 'gdb'. You'll probably see something like this in the output when Vim
crashes:
>
undefined symbol: clang_CompileCommands_dispose
<
This means that Vim is trying to load a 'libclang.so' that is too old. You need
at least a 3.2 libclang. Some distros ship with a system 'libclang.so' that
identifies itself as 3.2 but is not; it was cut from the upstream sources
2013-03-01 21:40:02 -05:00
before the official 3.2 release and some API changes (like the addition of the
CompileCommands API) were added after their cut.
2013-05-31 21:27:39 -04:00
So just go through the installation guide and make sure you are using a correct
'libclang.so'. I recommend downloading prebuilt binaries from llvm.org.
2013-03-01 21:40:02 -05:00
2013-05-26 17:00:56 -04:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-ycm-does-not-read-identifiers-from-my-tags-files*
2013-05-26 17:00:56 -04:00
YCM does not read identifiers from my tags files ~
2013-05-28 22:02:04 -04:00
First, put 'let g:ycm_collect_identifiers_from_tags_files = 1' in your vimrc.
2013-07-17 23:02:40 -04:00
Make sure you are using Exuberant Ctags [27] to produce your tags files since
the only supported tag format is the Exuberant Ctags format [24]. The format
2013-05-26 17:00:56 -04:00
from "plain" ctags is NOT supported. The output of 'ctags --version' should
list "Exuberant Ctags".
2013-05-28 22:02:04 -04:00
Ctags needs to be called with the '--fields=+l' (that's a lowercase 'L', not a
one) option because YCM needs the 'language:<lang>' field in the tags output.
2013-05-26 17:00:56 -04:00
NOTE: Mac OS X comes with "plain" ctags installed by default. 'brew install
ctags' will get you the Exuberant Ctags version.
2013-05-31 21:27:39 -04:00
Also make sure that your Vim 'tags' option is set correctly. See ":h 'tags'"
2013-05-26 17:00:56 -04:00
for details. If you want to see which tag files YCM will read for a given
buffer, run ':echo tagfiles()' with the relevant buffer active. Note that that
function will only list tag files that already exist.
2013-03-25 22:51:42 -04:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*CTRL-sub-U*
'CTRL-U' in insert mode does not work ~
2013-03-25 22:51:42 -04:00
YCM keeps you in a 'completefunc' completion mode when you're typing in insert
mode and Vim disables '<C-U>' in completion mode as a "feature." Sadly there's
nothing I can do about this.
2013-07-17 23:02:40 -04:00
-------------------------------------------------------------------------------
*youcompleteme-ycm-conflicts-with-ultisnips-tab-key-usage*
YCM conflicts with UltiSnips TAB key usage ~
YCM comes with support for UltiSnips (snippet suggestions in the popup menu),
but you'll have to change the UltiSnips mappings. See ':h UltiSnips-triggers'
in Vim for details. You'll probably want to change some/all of the following
options:
>
g:UltiSnipsExpandTrigger
g:UltiSnipsJumpForwardTrigger
g:UltiSnipsJumpBackwardTrigger
<
2013-02-02 16:47:08 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-why-isnt-ycm-just-written-in-plain-vimscript-ffs*
2013-02-02 16:47:08 -05:00
Why isn't YCM just written in plain VimScript, FFS? ~
Because of the identifier completion engine and subsequence-based filtering.
2013-05-31 21:27:39 -04:00
Let's say you have _many_ dozens of files open in a single Vim instance (I
often do); the identifier-based engine then needs to store thousands (if not
tens of thousands) of identifiers in its internal data-structures. When the
user types, YCM needs to perform subsequence-based filtering on _all_ of those
2013-02-02 16:47:08 -05:00
identifiers (every single one!) in less than 10 milliseconds.
I'm sorry, but that level of performance is just plain impossible to achieve
with VimScript. I've tried, and the language is just too slow. No, you can't
get acceptable performance even if you limit yourself to just the identifiers
in the current file and simple prefix-based fitering.
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-why-does-ycm-demand-such-recent-version-of-vim*
2013-02-02 16:47:08 -05:00
Why does YCM demand such a recent version of Vim? ~
2013-07-17 23:02:40 -04:00
During YCM's development several show-stopper bugs were encountered in Vim.
2013-02-02 16:47:08 -05:00
Those needed to be fixed upstream (and were). A few months after those bugs
were fixed, Vim trunk landed the 'pyeval()' function which improved YCM
performance even more since less time was spent serializing and deserializing
data between Vim and the embedded Python interpreter. A few critical bugfixes
for 'pyeval()' landed in Vim 7.3.584 (and a few commits before that).
2013-02-12 23:34:58 -05:00
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*youcompleteme-i-get-annoying-messages-in-vims-status-area-when-i-type*
2013-02-12 23:34:58 -05:00
I get annoying messages in Vim's status area when I type ~
2013-05-31 21:27:39 -04:00
If you're referring to the 'User defined completion <bla bla> back at original'
and similar, then sadly there's no fix for those. Vim will emit them no matter
how hard I try to silence them.
2013-02-12 23:34:58 -05:00
You'll have to learn to ignore them. It's a shitty "solution", I know.
-------------------------------------------------------------------------------
2013-05-31 21:27:39 -04:00
*vim-sub-autoclose*
Nasty bugs happen if I have the 'vim-autoclose' plugin installed ~
2013-02-12 23:34:58 -05:00
2013-07-17 23:02:40 -04:00
Use the delimitMate [28] plugin instead. It does the same thing without
2013-02-12 23:34:58 -05:00
conflicting with YCM.
2013-07-17 23:02:40 -04:00
-------------------------------------------------------------------------------
*youcompleteme-is-there-sort-of-ycm-mailing-list-i-have-questions*
Is there some sort of YCM mailing list? I have questions ~
If you have questions about the plugin or need help, please use the ycm-users
[29] mailing list, _don't_ create issues on the tracker. The tracker is for bug
reports and feature requests.
2013-11-15 22:13:56 -05:00
-------------------------------------------------------------------------------
*youcompleteme-i-get-an-internal-compiler-error-when-installing*
I get an internal compiler error when installing ~
This can be a problem on virtual servers with limited memory. A possible
solution is to add more swap memory.
2013-02-02 16:47:08 -05:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-contact*
2013-02-02 16:47:08 -05:00
Contact ~
2013-07-17 23:02:40 -04:00
If you have questions about the plugin or need help, please use the ycm-users
[29] mailing list.
If you have bug reports or feature suggestions, please use the issue tracker
[30].
The latest version of the plugin is available at
2013-05-31 21:27:39 -04:00
http://valloric.github.io/YouCompleteMe/.
2013-02-02 16:47:08 -05:00
The author's homepage is http://val.markovic.io.
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-license*
2013-02-02 16:47:08 -05:00
License ~
2013-08-12 23:58:21 -04:00
This software is licensed under the GPL v3 license [31]. © 2012 Strahinja Val
2013-05-31 21:27:39 -04:00
Markovic <val@markovic.io>.
2013-02-02 16:47:08 -05:00
2013-10-24 15:41:56 -04:00
Image: Bitdeli Badge [32]
2013-02-02 16:47:08 -05:00
===============================================================================
2013-05-31 21:27:39 -04:00
*youcompleteme-references*
2013-02-02 16:47:08 -05:00
References ~
2013-04-30 13:18:15 -04:00
[1] https://travis-ci.org/Valloric/YouCompleteMe
[2] https://travis-ci.org/Valloric/YouCompleteMe.png?branch=travis
[3] http://clang.llvm.org/
[4] https://github.com/davidhalter/jedi
2013-07-17 23:02:40 -04:00
[5] https://github.com/nosami/OmniSharpServer
[6] http://i.imgur.com/0OP4ood.gif
[7] http://en.wikipedia.org/wiki/Subsequence
[8] https://github.com/scrooloose/syntastic
[9] https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt
[10] http://code.google.com/p/macvim/#Download
[11] https://github.com/gmarik/vundle#about
[12] http://mxcl.github.com/homebrew/
[13] http://www.cmake.org/cmake/resources/software.html
[14] https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source
[15] https://github.com/Valloric/YouCompleteMe/wiki/Windows-Installation-Guide
[16] https://github.com/tpope/vim-pathogen#pathogenvim
[17] http://vimhelp.appspot.com/starting.txt.html#vimrc
[18] http://llvm.org/releases/download.html#3.3
[19] https://github.com/Valloric/YouCompleteMe/blob/master/cpp/ycm/.ycm_extra_conf.py
[20] http://clang.llvm.org/docs/JSONCompilationDatabase.html
[21] http://eclim.org/
[22] https://github.com/Valloric/YouCompleteMe/blob/master/python/ycm/completers/completer.py
[23] https://github.com/Valloric/ListToggle
[24] http://ctags.sourceforge.net/FORMAT
[25] https://github.com/gmarik/vundle/issues/48
[26] https://github.com/Valloric/YouCompleteMe/issues/18
[27] http://ctags.sourceforge.net/
[28] https://github.com/Raimondi/delimitMate
[29] https://groups.google.com/forum/?hl=en#!forum/ycm-users
[30] https://github.com/Valloric/YouCompleteMe/issues?state=open
[31] http://www.gnu.org/copyleft/gpl.html
2013-10-24 15:41:56 -04:00
[32] https://bitdeli.com/free
[33] https://d2weczhvl823v0.cloudfront.net/Valloric/youcompleteme/trend.png
2013-02-02 16:47:08 -05:00
vim: ft=help