From 581f58add69298b5e2275c0fa0b9ba3c11d685a9 Mon Sep 17 00:00:00 2001 From: Andrea Cedraro Date: Wed, 20 Jan 2016 21:52:02 +0100 Subject: [PATCH] Update documentation of latest python completer --- README.md | 54 +++++- doc/youcompleteme.txt | 375 ++++++++++++++++++++++++------------------ third_party/ycmd | 2 +- 3 files changed, 265 insertions(+), 166 deletions(-) diff --git a/README.md b/README.md index 073b98ab..c291c965 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ YouCompleteMe: a code-completion engine for Vim - [C-family semantic completion](#c-family-semantic-completion-engine-usage) - [JavaScript semantic completion](#javascript-semantic-completion) - [Rust semantic completion](#rust-semantic-completion) + - [Python semantic completion](#python-semantic-completion) - [Semantic completion for other languages](#semantic-completion-for-other-languages) - [Writing new semantic completers](#writing-new-semantic-completers) - [Diagnostic display](#diagnostic-display) @@ -44,7 +45,7 @@ YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for - a [Clang][]-based engine that provides native semantic code completion for C/C++/Objective-C/Objective-C++ (from now on referred to as "the C-family languages"), -- a [Jedi][]-based completion engine for Python, +- a [Jedi][]-based completion engine for Python 2 and 3 (using the [JediHTTP][] wrapper), - an [OmniSharp][]-based completion engine for C#, - a [Gocode][]-based completion engine for Go, - a [TSServer][]-based completion engine for TypeScript, @@ -659,11 +660,12 @@ Quick Feature Summary * Management of OmniSharp server instance * View documentation comments for identifiers (`GetDoc`) -### Python 2 +### Python * Intelligent auto-completion -* Go to declaration/definition (`GoTo`, etc.) +* Go to declaration/definition, find references (`GoTo`, `GoToReferences`) * View documentation comments for identifiers (`GetDoc`) +* Restart [JediHTTP][] server using a different Python interpreter ### Go @@ -907,6 +909,20 @@ locate it. let g:ycm_rust_src_path = '/usr/local/rust/rustc-1.5.0/src' ``` +### Python semantic completion + +Completion and GoTo commands work out of the box with no additional +configuration. Those features are provided by the [jedi][] library which +supports a variety of python versions (2.6, 2.7, 3.2, 3.3 or 3.4) as long as it +runs in the corresponding python interpreter. By default YCM runs [jedi][] with +the same python interpreter used by [ycmd][], so if you would like to use a +different interpreter, use the following option specifying the python binary to +use. For example, to provide Python 3 completion in your project, set: + +```viml +let g:ycm_python_binary_path = '/usr/bin/python3' +``` + ### Semantic completion for other languages Python, C#, Go, Rust, and TypeScript are supported natively by YouCompleteMe @@ -1181,7 +1197,7 @@ This command attempts to find all of the references within the project to the identifier under the cursor and populates the quickfix list with those locations. -Supported in filetypes: `javascript` +Supported in filetypes: `javascript, python` ### The `ClearCompilationFlagCache` subcommand @@ -1323,7 +1339,14 @@ Supported in filetypes: `cs, javascript, go, rust` Restarts the semantic-engine-as-localhost-server for those semantic engines that work as separate servers that YCM talks to. -Supported in filetypes: `cs, rust` +An additional optional argument may be supplied for Python, specifying the +python binary to use to restart the Python semantic engine. + +```viml +:YcmCompleter RestartServer /usr/bin/python3.4 +``` + +Supported in filetypes: `cs, rust, python` ### The `ReloadSolution` subcommand @@ -2196,6 +2219,19 @@ Default: 1000 let g:ycm_disable_for_files_larger_than_kb = 1000 ``` +### The `g:ycm_python_binary_path` option + +This option specifies the Python interpreter to use to run the [jedi][] +completion library. Specify the python interpreter to use to get completions. +By default the python under which [ycmd][] runs is used ([ycmd][] only runs +under Python 2.6 or 2.7). + +Default: `''` + +```viml +let g:ycm_python_binary_path = '/usr/bin/python3' +``` + FAQ --- @@ -2610,6 +2646,13 @@ os.environ['PATH'] = ';'.join(path) EOF ``` +### I hear that YCM only supports Python 2, is that true? + +No. The Vim client and the [ycmd][] server only run under Python 2 but if you +work on a Python 3 project then just set the `g:ycm_python_binary_path` to the +Python interpreter you use for your project and you will get completions for +that version of Python. + Contributor Code of Conduct --------------------------- @@ -2695,3 +2738,4 @@ This software is licensed under the [GPL v3 license][gpl]. [add-msbuild-to-path]: http://stackoverflow.com/questions/6319274/how-do-i-run-msbuild-from-the-command-line-using-windows-sdk-7-1 [identify-R6034-cause]: http://stackoverflow.com/questions/14552348/runtime-error-r6034-in-embedded-python-application/34696022 [ccoc]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md +[JediHTTP]: https://github.com/vheon/JediHTTP diff --git a/doc/youcompleteme.txt b/doc/youcompleteme.txt index b0b07ed2..34e25061 100644 --- a/doc/youcompleteme.txt +++ b/doc/youcompleteme.txt @@ -16,7 +16,7 @@ Contents ~ 1. General (all languages) |youcompleteme-general| 2. C-family languages (C, C++, Objective C, Objective C++) |youcompleteme-c-family-languages| 3. C♯ |youcompleteme-c| - 4. Python 2 |youcompleteme-python-2| + 4. Python |youcompleteme-python| 5. Go |youcompleteme-go| 6. TypeScript |youcompleteme-typescript| 7. JavaScript |youcompleteme-javascript| @@ -34,9 +34,10 @@ Contents ~ 1. Configuring Tern for node support |youcompleteme-configuring-tern-for-node-support| 2. Configuring Tern for requirejs support |youcompleteme-configuring-tern-for-requirejs-support| 7. Rust semantic completion |youcompleteme-rust-semantic-completion| - 8. Semantic completion for other languages |youcompleteme-semantic-completion-for-other-languages| - 9. Writing New Semantic Completers |youcompleteme-writing-new-semantic-completers| - 10. Diagnostic display |youcompleteme-diagnostic-display| + 8. Python semantic completion |youcompleteme-python-semantic-completion| + 9. Semantic completion for other languages |youcompleteme-semantic-completion-for-other-languages| + 10. Writing New Semantic Completers |youcompleteme-writing-new-semantic-completers| + 11. Diagnostic display |youcompleteme-diagnostic-display| 1. C# Diagnostic Support |youcompleteme-c-diagnostic-support| 2. Diagnostic highlighting groups |youcompleteme-diagnostic-highlighting-groups| 6. Commands |youcompleteme-commands| @@ -114,6 +115,7 @@ Contents ~ 43. The |g:ycm_use_ultisnips_completer| option 44. The |g:ycm_goto_buffer_command| option 45. The |g:ycm_disable_for_files_larger_than_kb| option + 46. The |g:ycm_python_binary_path| option 10. FAQ |youcompleteme-faq| 1. I used to be able to 'import vim' in '.ycm_extra_conf.py', but now can't |import-vim| 2. On very rare occasions Vim crashes when I tab through the completion menu |youcompleteme-on-very-rare-occasions-vim-crashes-when-i-tab-through-completion-menu| @@ -142,7 +144,7 @@ Contents ~ 25. I get weird errors when I press 'Ctrl-C' in Vim |Ctrl-sub-C| 26. Why did YCM stop using Syntastic for diagnostics display? |youcompleteme-why-did-ycm-stop-using-syntastic-for-diagnostics-display| 27. Completion doesn't work with the C++ standard library headers |youcompleteme-completion-doesnt-work-with-c-standard-library-headers| - 28. Install YCM with NeoBundle [52] |youcompleteme-install-ycm-with-neobundle-52| + 28. Install YCM with NeoBundle [53] |youcompleteme-install-ycm-with-neobundle-53| 29. When I open a JavaScript file, I get an annoying warning about '.tern-project' file |.tern-sub-project| 30. When I run install.py I get a LINK error saying "fatal error LNK1104: cannot @@ -150,6 +152,7 @@ open file '\bundle\YouCompleteMe\third_party\ycmd\ycm_clien t_support.pyd'" |fatal-error-LNK1104:-cannot-open-file-path_to_vim_folder-bundle-YouCompleteMe-third_party-ycmd-ycm_client_support.pyd| 31. When I start vim I get a runtime error saying 'R6034 An application has made an attempt to load the C runtime library incorrectly.' |R6034-An-application-has-made-an-attempt-to-load-the-C-runtime-library-incorrectly.| + 32. I hear that YCM only supports Python 2, is that true? |youcompleteme-i-hear-that-ycm-only-supports-python-2-is-that-true| 11. Contributor Code of Conduct |youcompleteme-contributor-code-of-conduct| 12. Contact |youcompleteme-contact| 13. License |youcompleteme-license| @@ -181,6 +184,7 @@ Image: Build Status [1] Image: Build status [3] - C-family semantic completion - JavaScript semantic completion - Rust semantic completion + - Python semantic completion - Semantic completion for other languages - Writing new semantic completers - Diagnostic display @@ -205,20 +209,29 @@ YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for Vim. It has several completion engines: - an identifier-based engine that works with every programming language, + - a Clang [5]-based engine that provides native semantic code completion for C/C++/Objective-C/Objective-C++ (from now on referred to as "the C-family languages"), -- a Jedi [6]-based completion engine for Python, -- an OmniSharp [7]-based completion engine for C#, -- a Gocode [8]-based completion engine for Go, -- a TSServer [9]-based completion engine for TypeScript, -- a Tern [10]-based completion engine for JavaScript, -- a racer [11]-based completion engine for Rust, + +- a Jedi [6]-based completion engine for Python 2 and 3 (using the JediHTTP + [7] wrapper), + +- an OmniSharp [8]-based completion engine for C#, + +- a Gocode [9]-based completion engine for Go, + +- a TSServer [10]-based completion engine for TypeScript, + +- a Tern [11]-based completion engine for JavaScript, + +- a racer [12]-based completion engine for Rust, + - and an omnifunc-based completer that uses data from Vim's omnicomplete system to provide semantic completions for many other languages (Ruby, PHP etc.). - Image: YouCompleteMe GIF demo (see reference [12]) + Image: YouCompleteMe GIF demo (see reference [13]) Here's an explanation of what happens in the short GIF demo above. @@ -237,7 +250,7 @@ typing to further filter out unwanted completions. A critical thing to notice is that the completion **filtering is NOT based on the input being a string prefix of the completion** (but that works too). The -input needs to be a _subsequence [13] match_ of a completion. This is a fancy +input needs to be a _subsequence [14] match_ of a completion. This is a fancy way of saying that any input characters need to be present in a completion string in the order in which they appear in the input. So 'abc' is a subsequence of 'xaybgc', but not of 'xbyxaxxc'. After the filter, a complicated @@ -256,7 +269,7 @@ with a keyboard shortcut; see the rest of the docs). The last thing that you can see in the demo is YCM's diagnostic display features (the little red X that shows up in the left gutter; inspired by -Syntastic [14]) if you are editing a C-family file. As Clang compiles your file +Syntastic [15]) if you are editing a C-family file. As Clang compiles your file and detects warnings or errors, they will be presented in various ways. You don't need to save your file or press any keyboard shortcut to trigger this, it "just happens" in the background. @@ -274,7 +287,7 @@ languages & Python. Expect more IDE features powered by the various YCM semantic engines in the future. You'll also find that YCM has filepath completers (try typing './' in a file) -and a completer that integrates with UltiSnips [15]. +and a completer that integrates with UltiSnips [16]. =============================================================================== *youcompleteme-installation* @@ -287,16 +300,16 @@ Mac OS X Installation ~ Please refer to the full Installation Guide below; the following commands are provided on a best-effort basis and may not work for you. -Install the latest version of MacVim [16]. Yes, MacVim. And yes, the _latest_. +Install the latest version of MacVim [17]. Yes, MacVim. And yes, the _latest_. If you don't use the MacVim GUI, it is recommended to use the Vim binary that is inside the MacVim.app package ('MacVim.app/Contents/MacOS/Vim'). To ensure -it works correctly copy the 'mvim' script from the MacVim [16] download to your +it works correctly copy the 'mvim' script from the MacVim [17] download to your local binary folder (for example '/usr/local/bin/mvim') and then symlink it: > ln -s /usr/local/bin/mvim vim < -Install YouCompleteMe with Vundle [17]. +Install YouCompleteMe with Vundle [18]. **Remember:** YCM is a plugin with a compiled component. If you **update** YCM using Vundle and the ycm_support_libs library APIs have changed (happens @@ -308,8 +321,8 @@ installed along with the latest Command Line Tools (they are installed automatically when you run 'clang' for the first time, or manually by running 'xcode-select --install') -Install CMake. Preferably with Homebrew [18], but here's the stand-alone CMake -installer [19]. +Install CMake. Preferably with Homebrew [19], but here's the stand-alone CMake +installer [20]. _If_ you have installed a Homebrew Python and/or Homebrew MacVim, see the _FAQ_ for details. @@ -330,13 +343,13 @@ The following additional language support options are available: - Go support: ensure go is installed and add '--gocode-completer' -- TypeScript support: install nodejs and npm [20] then install the TypeScript +- TypeScript support: install nodejs and npm [21] then install the TypeScript SDK with 'npm install -g typescript'. -- JavaScript support: install nodejs and npm [20] and add '--tern-completer' +- JavaScript support: install nodejs and npm [21] and add '--tern-completer' to './install.py' -- Rust support: install rustc and cargo [21] and add '--racer-completer' to +- Rust support: install rustc and cargo [22] and add '--racer-completer' to './install.py' For example, to install with all language features, ensure npm, go, mono, rust, @@ -365,9 +378,9 @@ provided on a best-effort basis and may not work for you. Make sure you have Vim 7.3.598 with python2 support. Ubuntu 14.04 and later have a Vim that's recent enough. You can see the version of Vim installed by running 'vim --version'. If the version is too old, you may need to compile Vim -from source [22] (don't worry, it's easy). +from source [23] (don't worry, it's easy). -Install YouCompleteMe with Vundle [17]. +Install YouCompleteMe with Vundle [18]. **Remember:** YCM is a plugin with a compiled component. If you **update** YCM using Vundle and the ycm_support_libs library APIs have changed (happens @@ -395,13 +408,13 @@ The following additional language support options are available: - Go support: ensure go is installed and add '--gocode-completer' -- TypeScript support: install nodejs and npm [20] then install the TypeScript +- TypeScript support: install nodejs and npm [21] then install the TypeScript SDK with 'npm install -g typescript'. -- JavaScript support: install nodejs and npm [20] and add '--tern-completer' +- JavaScript support: install nodejs and npm [21] and add '--tern-completer' to './install.py' -- Rust support: install rustc and cargo [21] and add '--racer-completer' to +- Rust support: install rustc and cargo [22] and add '--racer-completer' to './install.py' For example, to install with all language features, ensure npm, go, mono, rust, @@ -430,9 +443,9 @@ provided on a best-effort basis and may not work for you. Make sure you have Vim 7.3.598 with python2 support. Fedora 21 and later have a Vim that's recent enough. You can see the version of Vim installed by running 'vim --version'. If the version is too old, you may need to compile Vim from -source [22] (don't worry, it's easy). +source [23] (don't worry, it's easy). -Install YouCompleteMe with Vundle [17]. +Install YouCompleteMe with Vundle [18]. **Remember:** YCM is a plugin with a compiled component. If you **update** YCM using Vundle and the ycm_support_libs library APIs have changed (happens @@ -460,13 +473,13 @@ The following additional language support options are available: - Go support: ensure go is installed and add '--gocode-completer' -- TypeScript support: install nodejs and npm [20] then install the TypeScript +- TypeScript support: install nodejs and npm [21] then install the TypeScript SDK with 'npm install -g typescript'. -- JavaScript support: install nodejs and npm [20] and add '--tern-completer' +- JavaScript support: install nodejs and npm [21] and add '--tern-completer' to './install.py' -- Rust support: install rustc and cargo [21] and add '--racer-completer' to +- Rust support: install rustc and cargo [22] and add '--racer-completer' to './install.py' For example, to install with all language features, ensure npm, go, mono, rust, @@ -499,9 +512,9 @@ Make sure you have at least Vim 7.3.598 with python2 support. You can check the version by typing ':version' inside Vim. Take note of the Vim architecture, i.e. 32 or 64-bit. It will be important when choosing the python2 installer. We recommend using a 64-bit client. Don't worry, a frequently updated copy of -64-bit Vim [23] is available. +64-bit Vim [24] is available. -Install YouCompleteMe with Vundle [17]. +Install YouCompleteMe with Vundle [18]. **Remember:** YCM is a plugin with a compiled component. If you **update** YCM using Vundle and the ycm_support_libs library APIs have changed (happens @@ -510,16 +523,16 @@ process. Download and install the following software: -- python2 [24]. Be sure to pick the version corresponding to your Vim +- python2 [25]. Be sure to pick the version corresponding to your Vim architecture. It is _Windows x86-64 MSI installer_ if you are using the Vim previously linked. -- CMake [19]. Add CMake executable to the PATH environment variable. +- CMake [20]. Add CMake executable to the PATH environment variable. -- Visual Studio [25]. Download the community edition. During setup, choose +- Visual Studio [26]. Download the community edition. During setup, choose _Custom_ as the installation type and select the _Visual C++_ component. -- 7-zip [26]. Required to build YCM with semantic support for C-family +- 7-zip [27]. Required to build YCM with semantic support for C-family languages. Compiling YCM **with** semantic support for C-family languages: @@ -535,17 +548,17 @@ Compiling YCM **without** semantic support for C-family languages: The following additional language support options are available: - C# support: add '--omnisharp-completer' to 'install.py'. Be sure that the - build utility 'msbuild' is in your PATH [27]. + build utility 'msbuild' is in your PATH [28]. - Go support: ensure go is installed and add '--gocode-completer'. -- TypeScript support: install nodejs and npm [20] then install the TypeScript +- TypeScript support: install nodejs and npm [21] then install the TypeScript SDK with 'npm install -g typescript'. -- JavaScript support: install nodejs and npm [20] and add '--tern-completer' +- JavaScript support: install nodejs and npm [21] and add '--tern-completer' to 'install.py'. -- Rust support: install rustc and cargo [21] and add '--racer-completer' to +- Rust support: install rustc and cargo [22] and add '--racer-completer' to 'install.py'. For example, to install with all language features, ensure npm, go, mono, rust, @@ -585,7 +598,7 @@ FreeBSD 10.x comes with clang compiler but not the libraries needed to install. pkg install llvm35 boost-all boost-python-libs clang35 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/llvm35/lib/ < -Install YouCompleteMe with Vundle [17]. +Install YouCompleteMe with Vundle [18]. **Remember:** YCM is a plugin with a compiled component. If you **update** YCM using Vundle and the ycm_support_libs library APIs have changed (happens @@ -610,13 +623,13 @@ The following additional language support options are available: - Go support: ensure go is installed and add '--gocode-completer' -- TypeScript support: install nodejs and npm [20] then install the TypeScript +- TypeScript support: install nodejs and npm [21] then install the TypeScript SDK with 'npm install -g typescript'. -- JavaScript support: install nodejs and npm [20] and add '--tern-completer' +- JavaScript support: install nodejs and npm [21] and add '--tern-completer' to './install.py' -- Rust support: install rustc and cargo [21] and add '--racer-completer' to +- Rust support: install rustc and cargo [22] and add '--racer-completer' to './install.py' For example, to install with all language features, ensure npm, go, mono, rust, @@ -666,7 +679,7 @@ process. 1-Z', where Z will be some number. That number needs to be 598 or higher. If your version of Vim is not recent enough, you may need to compile Vim - from source [22] (don't worry, it's easy). + from source [23] (don't worry, it's easy). After you have made sure that you have Vim 7.3.598+, type the following in Vim: ":echo has('python')". The output should be 1. If it's 0, then @@ -676,9 +689,9 @@ process. critical because it must match the python2 and the YCM libraries architectures. We recommend using a 64-bit Vim. -2. **Install YCM** with Vundle [17] (or Pathogen [28], but Vundle is a +2. **Install YCM** with Vundle [18] (or Pathogen [29], but Vundle is a better idea). With Vundle, this would mean adding a "Plugin - 'Valloric/YouCompleteMe'" line to your vimrc [29]. + 'Valloric/YouCompleteMe'" line to your vimrc [30]. If you don't install YCM with Vundle, make sure you have run 'git submodule update --init --recursive' after checking out the YCM @@ -695,7 +708,7 @@ process. You can use the system libclang _only if you are sure it is version 3.3 or higher_, otherwise don't. Even if it is, we recommend using the - official binaries from llvm.org [30] if at all possible. Make sure you + official binaries from llvm.org [31] if at all possible. Make sure you download the correct archive file for your OS. We **STRONGLY recommend AGAINST use** of the system libclang instead of @@ -708,17 +721,17 @@ process. You will need to have 'cmake' installed in order to generate the required makefiles. Linux users can install cmake with their package manager ('sudo apt-get install cmake' for Ubuntu) whereas other users can - download and install [19] cmake from its project site. Mac users can also - get it through Homebrew [18] with 'brew install cmake'. + download and install [20] cmake from its project site. Mac users can also + get it through Homebrew [19] with 'brew install cmake'. On a Unix OS, you 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. - On Windows, you need to download and install python2 [24]. Pick the + On Windows, you need to download and install python2 [25]. Pick the version corresponding to your Vim architecture. You will also need Microsoft Visual C++ (MSVC) to build YCM. You can obtain it by installing - Visual Studio [25]. MSVC 11 (Visual Studio 2012), 12 (2013), and 14 + Visual Studio [26]. MSVC 11 (Visual Studio 2012), 12 (2013), and 14 (2015) are officially supported. Here we'll assume you installed YCM with Vundle. That means that the top- @@ -761,7 +774,7 @@ process. extracted the archive file to folder '~/ycm_temp/llvm_root_dir' (with 'bin', 'lib', 'include' etc. folders right inside that folder). On Windows, you can extract the files from the LLVM+Clang installer using - 7-zip [26]. + 7-zip [27]. NOTE: This _only_ works with a _downloaded_ LLVM binary package, not a custom-built LLVM! See docs below for 'EXTERNAL_LIBCLANG_PATH' when using @@ -806,20 +819,20 @@ process. 'YouCompleteMe/third_party/ycmd/third_party/OmniSharpServer' and run 'msbuild' (Windows) or 'xbuild' (other platforms, using mono) depending on your platform. If mono is not installed, install it. When on Windows, - be sure that the build utility 'msbuild' is in your PATH [27]. + be sure that the build utility 'msbuild' is in your PATH [28]. 7. Go support: If go is not installed on your system, install it and add it to your path. Navigate to 'YouCompleteMe/third_party/ycmd/third_party/gocode' and run 'go build'. 8. TypeScript support: As with the quick installation, simply 'npm install - -g typescript' after successfully installing nodejs and npm [20]. + -g typescript' after successfully installing nodejs and npm [21]. -9. JavaScript support: Install nodejs and npm [20]. Then navigate to +9. JavaScript support: Install nodejs and npm [21]. Then navigate to 'YouCompleteMe/third_party/ycmd/third_party/tern' and run 'npm install --production' -10. Rust support: Install rustc and cargo [21]. Navigate to +10. Rust support: Install rustc and cargo [22]. Navigate to 'YouCompleteMe/third_party/ycmd/third_party/racerd' and run 'cargo build --release'. @@ -870,12 +883,13 @@ C♯ ~ - View documentation comments for identifiers (|GetDoc|) ------------------------------------------------------------------------------- - *youcompleteme-python-2* -Python 2 ~ + *youcompleteme-python* +Python ~ - Intelligent auto-completion -- Go to declaration/definition (|GoTo|, etc.) +- Go to declaration/definition, find references (|GoTo|, |GoToReferences|) - View documentation comments for identifiers (|GetDoc|) +- Restart JediHTTP [7] server using a different Python interpreter ------------------------------------------------------------------------------- *youcompleteme-go* @@ -934,7 +948,7 @@ General Usage ~ 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 [31]_ section below. + it to Vim. You can remap the keys; see the _Options [32]_ section below. Knowing a little bit about how YCM works internally will prevent confusion. YCM has several completion engines: an identifier-based completer that collects all @@ -1005,20 +1019,20 @@ This system was designed this way so that the user can perform any arbitrary sequence of operations to produce a list of compilation flags YCM should hand to Clang. -See YCM's own '.ycm_extra_conf.py' [32] for details on how this works. You +See YCM's own '.ycm_extra_conf.py' [33] for details on how this works. You should be able to use it _as a starting point_. **Don't** just copy/paste that file somewhere and expect things to magically work; **your project needs different flags**. Hint: just replace the strings in the 'flags' variable with compilation flags necessary for your project. That should be enough for 99% of projects. -Yes, Clang's 'CompilationDatabase' system [33] is also supported. Again, see +Yes, Clang's 'CompilationDatabase' system [34] is also supported. Again, see the above linked example file. You can get CMake to generate this file for you by adding 'set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )' to your project's 'CMakeLists.txt' file (if using CMake). If you're not using CMake, you could -use something like Bear [34] to generate the 'compile_commands.json' file. +use something like Bear [35] to generate the 'compile_commands.json' file. -Consider using YCM-Generator [35] to generate the 'ycm_extra_conf.py' file. +Consider using YCM-Generator [36] to generate the 'ycm_extra_conf.py' file. If Clang encounters errors when compiling the header files that your file includes, then it's probably going to take a long time to get completions. When @@ -1043,7 +1057,7 @@ Quick start ~ guide for details. 2. Create a '.tern-project' file in the root directory of your JavaScript - project, by following the instructions [36] in the Tern [10] + project, by following the instructions [37] in the Tern [11] documentation. 3. Make sure that Vim's working directory is a descendent of that directory @@ -1053,14 +1067,14 @@ Quick start ~ *youcompleteme-explanation* Explanation ~ -JavaScript completion is based on Tern [10]. This completion engine requires a -file named '.tern-project' [36] to exist in the current working directory or a +JavaScript completion is based on Tern [11]. This completion engine requires a +file named '.tern-project' [37] to exist in the current working directory or a directory which is an ancestor of the current working directory when the tern server is started. YCM starts the Tern server the first time a JavaScript file is edited, so Vim's working directory at that time needs to be a descendent of the directory containing the '.tern-project' file (or that directory itself). -Alternatively, as described in the Tern documentation [37], a global '.tern- +Alternatively, as described in the Tern documentation [38], a global '.tern- config' file may be used. Multiple Tern servers, are not supported. To switch to a different JavaScript @@ -1082,9 +1096,9 @@ Tips and tricks ~ This section contains some advice for configuring '.tern-project' and working with JavaScript files. The canonical reference for correctly configuring Tern -is the Tern documentation [37]. Any issues, improvements, advice, etc. should -be sought from the Tern [10] project. For example, see the list of tern plugins -[38] for the list of plugins which can be enabled in the 'plugins' section of +is the Tern documentation [38]. Any issues, improvements, advice, etc. should +be sought from the Tern [11] project. For example, see the list of tern plugins +[39] for the list of plugins which can be enabled in the 'plugins' section of the '.tern-project' file. ------------------------------------------------------------------------------- @@ -1136,19 +1150,33 @@ Completions and GoTo commands within the current crate and its dependencies should work out of the box with no additional configuration (provided that you built YCM with the '--racer-completer' flag; see the _Installation_ section for details). For semantic analysis inclusive of the standard library, you must -have a local copy of the rust source code [39]. You also need to set the +have a local copy of the rust source code [40]. You also need to set the following option so YouCompleteMe can locate it. > " In this example, the rust source code zip has been extracted to " /usr/local/rust/rustc-1.5.0 let g:ycm_rust_src_path = '/usr/local/rust/rustc-1.5.0/src' < +------------------------------------------------------------------------------- + *youcompleteme-python-semantic-completion* +Python semantic completion ~ + +Completion and GoTo commands work out of the box with no additional +configuration. Those features are provided by the jedi [6] library which +supports a variety of python versions (2.6, 2.7, 3.2, 3.3 or 3.4) as long as it +runs in the corresponding python interpreter. By default YCM runs jedi [6] with +the same python interpreter used by [ycmd][], so if you would like to use a +different interpreter, use the following option specifying the python binary to +use. For example, to provide Python 3 completion in your project, set: +> + let g:ycm_python_binary_path = '/usr/bin/python3' +< ------------------------------------------------------------------------------- *youcompleteme-semantic-completion-for-other-languages* Semantic completion for other languages ~ Python, C#, Go, Rust, and TypeScript are supported natively by YouCompleteMe -using the Jedi [6], Omnisharp [7], Gocode [8], racer [11], and TSServer [9] +using the Jedi [6], Omnisharp [8], Gocode [9], racer [12], and TSServer [10] engines, respectively. Check the installation section for instructions to enable these features if desired. @@ -1157,7 +1185,7 @@ semantic completions if it does not have a native semantic completion engine for your file's filetype. Vim comes with okayish omnifuncs for various languages like Ruby, PHP etc. It depends on the language. -You can get stellar omnifuncs for Java and Ruby with Eclim [40]. Just make sure +You can get stellar omnifuncs for Java and Ruby with Eclim [41]. Just make sure you have the _latest_ Eclim installed and configured (this means Eclim '>= 2.2.*' and Eclipse '>= 4.2.*'). @@ -1175,7 +1203,7 @@ Writing New Semantic Completers ~ You have two options here: writing an 'omnifunc' for Vim's omnicomplete system that YCM will then use through its omni-completer, or a custom completer for -YCM using the Completer API [41]. +YCM using the Completer API [42]. Here are the differences between the two approaches: @@ -1194,7 +1222,7 @@ Here are the differences between the two approaches: than VimScript. If you want to use the 'omnifunc' system, see the relevant Vim docs with ':h -complete-functions'. For the Completer API, see the API docs [41]. +complete-functions'. For the Completer API, see the API docs [42]. If you want to upstream your completer into YCM's source, you should use the Completer API. @@ -1245,7 +1273,7 @@ current file in Vim's 'locationlist', which can be opened with the ':lopen' and ':lclose' commands (make sure you have set 'let g:ycm_always_populate_location_list = 1' in your vimrc). A good way to toggle the display of the 'locationlist' with a single key mapping is provided by -another (very small) Vim plugin called ListToggle [42] (which also makes it +another (very small) Vim plugin called ListToggle [43] (which also makes it possible to change the height of the 'locationlist' window), also written by yours truly. @@ -1444,7 +1472,7 @@ This command attempts to find all of the references within the project to the identifier under the cursor and populates the quickfix list with those locations. -Supported in filetypes: 'javascript' +Supported in filetypes: 'javascript, python' ------------------------------------------------------------------------------- The *ClearCompilationFlagCache* subcommand @@ -1589,7 +1617,12 @@ 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, rust' +An additional optional argument may be supplied for Python, specifying the +python binary to use to restart the Python semantic engine. +> + :YcmCompleter RestartServer /usr/bin/python3.4 +< +Supported in filetypes: 'cs, rust, python' ------------------------------------------------------------------------------- The *ReloadSolution* subcommand @@ -1633,7 +1666,7 @@ For example: call youcompleteme#GetErrorCount() < Both this function and |youcompleteme#GetWarningCount| can be useful when -integrating YCM with other Vim plugins. For example, a lightline [43] user +integrating YCM with other Vim plugins. For example, a lightline [44] user could add a diagnostics section to their statusline which would display the number of errors and warnings. @@ -1653,11 +1686,11 @@ Options ~ All options have reasonable defaults so if the plug-in works after installation you don't need to change any options. These options can be configured in your -vimrc script [29] by including a line like this: +vimrc script [30] by including a line like this: > let g:ycm_min_num_of_chars_for_completion = 1 < -Note that after changing an option in your vimrc script [29] you have to +Note that after changing an option in your vimrc script [30] you have to restart Vim for the changes to take effect. ------------------------------------------------------------------------------- @@ -1978,7 +2011,7 @@ from the 'tagfiles()' Vim function which examines the 'tags' Vim option. See YCM will re-index your tags files if it detects that they have been modified. -The only supported tag format is the Exuberant Ctags format [44]. The format +The only supported tag format is the Exuberant Ctags format [45]. The format 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 'language:' field in the tags output. @@ -2345,7 +2378,7 @@ It's also possible to use a regular expression as a trigger. You have to prefix your trigger with 're!' to signify it's a regex trigger. For instance, 're!\w+\.' would only trigger after the '\w+\.' regex matches. -NOTE: The regex syntax is **NOT** Vim's, it's Python's [45]. +NOTE: The regex syntax is **NOT** Vim's, it's Python's [46]. Default: '[see next line]' > @@ -2410,6 +2443,18 @@ Default: 1000 > let g:ycm_disable_for_files_larger_than_kb = 1000 < +------------------------------------------------------------------------------- +The *g:ycm_python_binary_path* option + +This option specifies the Python interpreter to use to run the jedi [6] +completion library. Specify the python interpreter to use to get completions. +By default the python under which [ycmd][] runs is used ([ycmd][] only runs +under Python 2.6 or 2.7). + +Default: "''" +> + let g:ycm_python_binary_path = '/usr/bin/python3' +< =============================================================================== *youcompleteme-faq* FAQ ~ @@ -2530,7 +2575,7 @@ produced. See the full installation guide for help. 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 -and builds Vim. I recommend using MacVim [16]. Even if you don't like the +and builds Vim. I recommend using MacVim [17]. 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. @@ -2540,7 +2585,7 @@ I have a Homebrew Python and/or MacVim; can't compile/SIGABRT when starting ~ 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 -then. If you still get problems with this, see issue #18 [46] for suggestions. +then. If you still get problems with this, see issue #18 [47] for suggestions. ------------------------------------------------------------------------------- *youcompleteme-vim-segfaults-when-i-use-semantic-completer-in-ruby-files* @@ -2625,15 +2670,15 @@ YCM does not read identifiers from my tags files ~ First, put 'let g:ycm_collect_identifiers_from_tags_files = 1' in your vimrc. -Make sure you are using Exuberant Ctags [47] to produce your tags files since -the only supported tag format is the Exuberant Ctags format [44]. The format +Make sure you are using Exuberant Ctags [48] to produce your tags files since +the only supported tag format is the Exuberant Ctags format [45]. The format from "plain" ctags is NOT supported. The output of 'ctags --version' should list "Exuberant Ctags". Ctags needs to be called with the '--fields=+l' (that's a lowercase 'L', not a one) option because YCM needs the 'language:' field in the tags output. -NOTE: Exuberant Ctags [47] by default sets language tag for '*.h' files as +NOTE: Exuberant Ctags [48] by default sets language tag for '*.h' files as 'C++'. If you have C (not C++) project, consider giving parameter '-- langmap=c:.c.h' to ctags to see tags from '*.h' files. @@ -2704,7 +2749,7 @@ and similar, then just update to Vim 7.4.314 (or later) and they'll go away. *vim-sub-autoclose* Nasty bugs happen if I have the 'vim-autoclose' plugin installed ~ -Use the delimitMate [48] plugin instead. It does the same thing without +Use the delimitMate [49] plugin instead. It does the same thing without conflicting with YCM. ------------------------------------------------------------------------------- @@ -2712,7 +2757,7 @@ conflicting with YCM. 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 -[49] mailing list, _don't_ create issues on the tracker. The tracker is for bug +[50] mailing list, _don't_ create issues on the tracker. The tracker is for bug reports and feature requests. ------------------------------------------------------------------------------- @@ -2766,7 +2811,7 @@ mismatch in assumptions causes performance problems since Syntastic code isn't optimized for this use case of constant diagnostic refreshing. Poor support for this use case also led to crash bugs in Vim caused by -Syntastic-Vim interactions (issue #593 [50]) and other problems, like random +Syntastic-Vim interactions (issue #593 [51]) and other problems, like random Vim flickering. Attempts were made to resolve these issues in Syntastic, but ultimately some of them failed (for various reasons). @@ -2802,13 +2847,13 @@ paths, prepend '-isystem' to each individual path and append them all to the list of flags you return from your 'FlagsForFile' function in your '.ycm_extra_conf.py' file. -See issue #303 [51] for details. +See issue #303 [52] for details. ------------------------------------------------------------------------------- - *youcompleteme-install-ycm-with-neobundle-52* -Install YCM with NeoBundle [52] ~ + *youcompleteme-install-ycm-with-neobundle-53* +Install YCM with NeoBundle [53] ~ -NeoBundle [52] can do the compilation for you; just add the following to your +NeoBundle [53] can do the compilation for you; just add the following to your vimrc: > NeoBundle 'Valloric/YouCompleteMe', { @@ -2852,14 +2897,14 @@ When I start vim I get a runtime error saying 'R6034 An application has made ~ an attempt to load the C runtime library incorrectly.' ~ CMake and other things seem to screw up the PATH with their own msvcrXX.dll -versions. [53] Add the following to the very top of your vimrc to remove these +versions. [54] Add the following to the very top of your vimrc to remove these entries from the path. > python << EOF import os import re path = os.environ['PATH'].split(';') - + def contains_msvcr_lib(folder): try: for item in os.listdir(folder): @@ -2868,27 +2913,36 @@ entries from the path. except: pass return False - + path = [folder for folder in path if not contains_msvcr_lib(folder)] os.environ['PATH'] = ';'.join(path) EOF < +------------------------------------------------------------------------------- + *youcompleteme-i-hear-that-ycm-only-supports-python-2-is-that-true* +I hear that YCM only supports Python 2, is that true? ~ + +No. The Vim client and the [ycmd][] server only run under Python 2 but if you +work on a Python 3 project then just set the |g:ycm_python_binary_path| to the +Python interpreter you use for your project and you will get completions for +that version of Python. + =============================================================================== *youcompleteme-contributor-code-of-conduct* Contributor Code of Conduct ~ Please note that this project is released with a Contributor Code of Conduct -[54]. By participating in this project you agree to abide by its terms. +[55]. By participating in this project you agree to abide by its terms. =============================================================================== *youcompleteme-contact* Contact ~ If you have questions about the plugin or need help, please use the ycm-users -[49] mailing list. +[50] mailing list. If you have bug reports or feature suggestions, please use the issue tracker -[55]. +[56]. The latest version of the plugin is available at http://valloric.github.io/YouCompleteMe/. @@ -2899,10 +2953,10 @@ The author's homepage is http://val.markovic.io. *youcompleteme-license* License ~ -This software is licensed under the GPL v3 license [56]. © 2015 YouCompleteMe +This software is licensed under the GPL v3 license [57]. © 2015 YouCompleteMe contributors - Image: Bitdeli Badge [57] + Image: Bitdeli Badge [58] =============================================================================== *youcompleteme-references* @@ -2914,57 +2968,58 @@ References ~ [4] https://ci.appveyor.com/api/projects/status/ag9uqwi8s6btwjd8/branch/master?svg=true [5] http://clang.llvm.org/ [6] https://github.com/davidhalter/jedi -[7] https://github.com/OmniSharp/omnisharp-server -[8] https://github.com/nsf/gocode -[9] https://github.com/Microsoft/TypeScript/tree/master/src/server -[10] http://ternjs.net -[11] https://github.com/phildawes/racer -[12] http://i.imgur.com/0OP4ood.gif -[13] https://en.wikipedia.org/wiki/Subsequence -[14] https://github.com/scrooloose/syntastic -[15] https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt -[16] https://github.com/macvim-dev/macvim/releases -[17] https://github.com/VundleVim/Vundle.vim#about -[18] http://brew.sh -[19] https://cmake.org/download/ -[20] https://docs.npmjs.com/getting-started/installing-node -[21] https://www.rust-lang.org/ -[22] https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source -[23] https://bintray.com/veegee/generic/vim_x64 -[24] https://www.python.org/downloads/windows/ -[25] https://www.visualstudio.com/products/free-developer-offers-vs.aspx -[26] http://www.7-zip.org/download.html -[27] http://stackoverflow.com/questions/6319274/how-do-i-run-msbuild-from-the-command-line-using-windows-sdk-7-1 -[28] https://github.com/tpope/vim-pathogen#pathogenvim -[29] http://vimhelp.appspot.com/starting.txt.html#vimrc -[30] http://llvm.org/releases/download.html -[31] https://github.com/Valloric/YouCompleteMe#options -[32] https://github.com/Valloric/ycmd/blob/master/cpp/ycm/.ycm_extra_conf.py -[33] http://clang.llvm.org/docs/JSONCompilationDatabase.html -[34] https://github.com/rizsotto/Bear -[35] https://github.com/rdnetto/YCM-Generator -[36] http://ternjs.net/doc/manual.html#configuration -[37] http://ternjs.net/doc/manual.html#server -[38] http://ternjs.net/doc/manual.html#plugins -[39] https://www.rust-lang.org/downloads.html -[40] http://eclim.org/ -[41] https://github.com/Valloric/ycmd/blob/master/ycmd/completers/completer.py -[42] https://github.com/Valloric/ListToggle -[43] https://github.com/itchyny/lightline.vim -[44] http://ctags.sourceforge.net/FORMAT -[45] https://docs.python.org/2/library/re.html#regular-expression-syntax -[46] https://github.com/Valloric/YouCompleteMe/issues/18 -[47] http://ctags.sourceforge.net/ -[48] https://github.com/Raimondi/delimitMate -[49] https://groups.google.com/forum/?hl=en#!forum/ycm-users -[50] https://github.com/Valloric/YouCompleteMe/issues/593 -[51] https://github.com/Valloric/YouCompleteMe/issues/303 -[52] https://github.com/Shougo/neobundle.vim -[53] http://stackoverflow.com/questions/14552348/runtime-error-r6034-in-embedded-python-application/34696022 -[54] https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md -[55] https://github.com/Valloric/YouCompleteMe/issues?state=open -[56] http://www.gnu.org/copyleft/gpl.html -[57] https://bitdeli.com/free -[58] https://d2weczhvl823v0.cloudfront.net/Valloric/youcompleteme/trend.png +[7] https://github.com/vheon/JediHTTP +[8] https://github.com/OmniSharp/omnisharp-server +[9] https://github.com/nsf/gocode +[10] https://github.com/Microsoft/TypeScript/tree/master/src/server +[11] http://ternjs.net +[12] https://github.com/phildawes/racer +[13] http://i.imgur.com/0OP4ood.gif +[14] https://en.wikipedia.org/wiki/Subsequence +[15] https://github.com/scrooloose/syntastic +[16] https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt +[17] https://github.com/macvim-dev/macvim/releases +[18] https://github.com/VundleVim/Vundle.vim#about +[19] http://brew.sh +[20] https://cmake.org/download/ +[21] https://docs.npmjs.com/getting-started/installing-node +[22] https://www.rust-lang.org/ +[23] https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source +[24] https://bintray.com/veegee/generic/vim_x64 +[25] https://www.python.org/downloads/windows/ +[26] https://www.visualstudio.com/products/free-developer-offers-vs.aspx +[27] http://www.7-zip.org/download.html +[28] http://stackoverflow.com/questions/6319274/how-do-i-run-msbuild-from-the-command-line-using-windows-sdk-7-1 +[29] https://github.com/tpope/vim-pathogen#pathogenvim +[30] http://vimhelp.appspot.com/starting.txt.html#vimrc +[31] http://llvm.org/releases/download.html +[32] https://github.com/Valloric/YouCompleteMe#options +[33] https://github.com/Valloric/ycmd/blob/master/cpp/ycm/.ycm_extra_conf.py +[34] http://clang.llvm.org/docs/JSONCompilationDatabase.html +[35] https://github.com/rizsotto/Bear +[36] https://github.com/rdnetto/YCM-Generator +[37] http://ternjs.net/doc/manual.html#configuration +[38] http://ternjs.net/doc/manual.html#server +[39] http://ternjs.net/doc/manual.html#plugins +[40] https://www.rust-lang.org/downloads.html +[41] http://eclim.org/ +[42] https://github.com/Valloric/ycmd/blob/master/ycmd/completers/completer.py +[43] https://github.com/Valloric/ListToggle +[44] https://github.com/itchyny/lightline.vim +[45] http://ctags.sourceforge.net/FORMAT +[46] https://docs.python.org/2/library/re.html#regular-expression-syntax +[47] https://github.com/Valloric/YouCompleteMe/issues/18 +[48] http://ctags.sourceforge.net/ +[49] https://github.com/Raimondi/delimitMate +[50] https://groups.google.com/forum/?hl=en#!forum/ycm-users +[51] https://github.com/Valloric/YouCompleteMe/issues/593 +[52] https://github.com/Valloric/YouCompleteMe/issues/303 +[53] https://github.com/Shougo/neobundle.vim +[54] http://stackoverflow.com/questions/14552348/runtime-error-r6034-in-embedded-python-application/34696022 +[55] https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md +[56] https://github.com/Valloric/YouCompleteMe/issues?state=open +[57] http://www.gnu.org/copyleft/gpl.html +[58] https://bitdeli.com/free +[59] https://d2weczhvl823v0.cloudfront.net/Valloric/youcompleteme/trend.png vim: ft=help diff --git a/third_party/ycmd b/third_party/ycmd index f982f625..bf023017 160000 --- a/third_party/ycmd +++ b/third_party/ycmd @@ -1 +1 @@ -Subproject commit f982f6251c5ff85e3abe6e862aad8bcd19e85ece +Subproject commit bf023017bf66ff97d3f478c9ccbfefbeea6f6fb1