Commit 6b940637 authored by Onur Aslan's avatar Onur Aslan

Imported Upstream version 0+20160109+git21b6ced

parent 00af0381
......@@ -47,23 +47,21 @@ Here are the things you should do when creating an issue:
2. Put the following options in your vimrc:
```viml
let g:ycm_server_use_vim_stdout = 1
let g:ycm_server_keep_logfiles = 1
let g:ycm_server_log_level = 'debug'
```
Then, if possible, start gvim/macvim (not console vim) from the console.
As you use Vim, you'll see the `ycmd` debug output stream in the console.
If you can not use gvim/macvim, run `:YcmDebugInfo` in vim to see what
temporary files (listed under "Server logfiles") the debug output streams
are written to. Attach the debug output stream to your issue.
3. **Create a test case for your issue**. This is critical. Don't talk about how
Run `:YcmToggleLogs stderr` in vim to open the logfile. Attach the contents
of this file to your issue.
3. Add the output of the `:YcmDebugInfo` command.
4. **Create a test case for your issue**. This is critical. Don't talk about how
"when I have X in my file" or similar, _create a file with X in it_ and put
the contents inside code blocks in your issue description. Try to make this
test file _as small as possible_. Don't just paste a huge, 500 line source
file you were editing and present that as a test. _Minimize_ the file so that
the problem is reproduced with the smallest possible amount of test data.
4. **Include your OS and OS version.**
5. **Include the output of `vim --version`.**
5. **Include your OS and OS version.**
6. **Include the output of `vim --version`.**
Creating good pull requests
......
......@@ -19,6 +19,8 @@ YouCompleteMe: a code-completion engine for Vim
- [Completion string ranking](#completion-string-ranking)
- [General semantic completion](#general-semantic-completion-engine-usage)
- [C-family semantic completion](#c-family-semantic-completion-engine-usage)
- [JavaScript semantic completion](#javascript-semantic-completion)
- [Rust semantic completion](#rust-semantic-completion)
- [Semantic completion for other languages](#semantic-completion-for-other-languages)
- [Writing new semantic completers](#writing-new-semantic-completers)
- [Diagnostic display](#diagnostic-display)
......@@ -45,6 +47,8 @@ YouCompleteMe is a fast, as-you-type, fuzzy-search code completion engine for
- an [OmniSharp][]-based completion engine for C#,
- a [Gocode][]-based completion engine for Go,
- a [TSServer][]-based completion engine for TypeScript,
- a [Tern][]-based completion engine for JavaScript,
- a [racer][]-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.).
......@@ -131,8 +135,9 @@ rarely), YCM will notify you to recompile it. You should then rerun the install
process.
**NOTE:** If you want C-family completion, you MUST have the latest Xcode
installed along with the latest Command Line Tools (they are installed when you
start Xcode for the first time).
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][brew], but here's the [stand-alone
CMake installer][cmake-download].
......@@ -150,11 +155,23 @@ Compiling YCM **without** semantic support for C-family languages:
cd ~/.vim/bundle/YouCompleteMe
./install.py
If you want semantic C# support, you should add `--omnisharp-completer` to the
install script as well. If you want Go support, you should add
`--gocode-completer`. If you want semantic TypeScript support, install the
TypeScript SDK with `npm install -g typescript` (you'll need to install
[nodejs and npm][npm-install]).
The following additional language support options are available:
- C# support: add `--omnisharp-completer` to `./install.py`
- Go support: ensure go is installed and add `--gocode-completer`
- TypeScript support: install [nodejs and npm][npm-install] then install the
TypeScript SDK with `npm install -g typescript`.
- JavaScript support: install [nodejs and npm][npm-install] and add
`--tern-completer` to `./install.py`
- Rust support: install [rustc and cargo][rust-install] and add
`--racer-completer` to `./install.py`
For example, to install with all language features, ensure npm, go, mono, rust,
and typescript API are installed and in your PATH, then:
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer --omnisharp-completer --gocode-completer \
--tern-completer --racer-completer
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
......@@ -196,11 +213,23 @@ Compiling YCM **without** semantic support for C-family languages:
cd ~/.vim/bundle/YouCompleteMe
./install.py
If you want semantic C# support, you should add `--omnisharp-completer` to the
install script as well. If you want Go support, you should add
`--gocode-completer`. If you want semantic TypeScript support, install the
TypeScript SDK with `npm install -g typescript` (you'll need to install
[nodejs and npm][npm-install]).
The following additional language support options are available:
- C# support: add `--omnisharp-completer` to `./install.py`
- Go support: ensure go is installed and add `--gocode-completer`
- TypeScript support: install [nodejs and npm][npm-install] then install the
TypeScript SDK with `npm install -g typescript`.
- JavaScript support: install [nodejs and npm][npm-install] and add
`--tern-completer` to `./install.py`
- Rust support: install [rustc and cargo][rust-install] and add
`--racer-completer` to `./install.py`
For example, to install with all language features, ensure npm, go, mono, rust,
and typescript API are installed and in your PATH, then:
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer --omnisharp-completer --gocode-completer \
--tern-completer --racer-completer
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
......@@ -242,11 +271,23 @@ Compiling YCM **without** semantic support for C-family languages:
cd ~/.vim/bundle/YouCompleteMe
./install.py
If you want semantic C# support, you should add `--omnisharp-completer` to the
install script as well. If you want Go support, you should add
`--gocode-completer`. If you want semantic TypeScript support, install the
TypeScript SDK with `npm install -g typescript` (you'll need to install
[nodejs and npm][npm-install]).
The following additional language support options are available:
- C# support: add `--omnisharp-completer` to `./install.py`
- Go support: ensure go is installed and add `--gocode-completer`
- TypeScript support: install [nodejs and npm][npm-install] then install the
TypeScript SDK with `npm install -g typescript`.
- JavaScript support: install [nodejs and npm][npm-install] and add
`--tern-completer` to `./install.py`
- Rust support: install [rustc and cargo][rust-install] and add
`--racer-completer` to `./install.py`
For example, to install with all language features, ensure npm, go, mono, rust,
and typescript API are installed and in your PATH, then:
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer --omnisharp-completer --gocode-completer \
--tern-completer --racer-completer
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
......@@ -301,11 +342,22 @@ Compiling YCM **without** semantic support for C-family languages:
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
install.py
If you want semantic C# support, you should add `--omnisharp-completer` to the
install script as well. If you want Go support, you should add
`--gocode-completer`. If you want semantic TypeScript support, install the
TypeScript SDK with `npm install -g typescript` (you'll need to install
[nodejs and npm][npm-install]).
The following additional language support options are available:
- C# support: add `--omnisharp-completer` to `install.py`
- Go support: ensure go is installed and add `--gocode-completer`
- TypeScript support: install [nodejs and npm][npm-install] then install the
TypeScript SDK with `npm install -g typescript`.
- JavaScript support: install [nodejs and npm][npm-install] and add
`--tern-completer` to `install.py`
- Rust support: install [rustc and cargo][rust-install] and add
`--racer-completer` to `install.py`
For example, to install with all language features, ensure npm, go, mono, rust,
and typescript API are installed and in your `%PATH%`, then:
cd %USERPROFILE%/vimfiles/bundle/YouCompleteMe
python install.py --clang-completer --omnisharp-completer --gocode-completer --tern-completer --racer-completer
You can specify the Microsoft Visual C++ (MSVC) version using the `--msvc`
option. YCM officially supports MSVC 11 (Visual Studio 2012), 12 (2013), and 14
......@@ -355,8 +407,23 @@ Compiling YCM **without** semantic support for C-family languages:
cd ~/.vim/bundle/YouCompleteMe
./install.py --system-boost
If you want semantic C# support, you should add `--omnisharp-completer` to the
install script as well. If you want Go support, you should add `--gocode-completer`.
The following additional language support options are available:
- C# support: add `--omnisharp-completer` to `./install.py`
- Go support: ensure go is installed and add `--gocode-completer`
- TypeScript support: install [nodejs and npm][npm-install] then install the
TypeScript SDK with `npm install -g typescript`.
- JavaScript support: install [nodejs and npm][npm-install] and add
`--tern-completer` to `./install.py`
- Rust support: install [rustc and cargo][rust-install] and add
`--racer-completer` to `./install.py`
For example, to install with all language features, ensure npm, go, mono, rust,
and typescript API are installed and in your PATH, then:
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer --omnisharp-completer --gocode-completer \
--tern-completer --racer-completer
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
......@@ -528,6 +595,28 @@ process.
the `YouCompleteMe/third_party/ycmd` folder for you if you compiled with
clang support (it needs to be there for YCM to work).
5. Set up support for additional languages, as desired:
- C# support: Navigate to
`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.
- 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`.
- TypeScript support: As with the quick installation, simply `npm install -g
typescript` after successfully installing [nodejs and npm][npm-install].
- JavaScript support: Install [nodejs and npm][npm-install]. Then navigate to
`YouCompleteMe/third_party/ycmd/third_party/tern` and run `npm install
--production`
- Rust support: Install [rustc and cargo][rust-install]. Navigate to
`YouCompleteMe/third_party/ycmd/third_party/racerd` and run
`cargo build --release`.
That's it. You're done. Refer to the _User Guide_ section on how to use YCM.
Don't forget that if you want the C-family semantic completion engine to work,
you will need to provide the compilation flags for your project to YCM. It's all
......@@ -585,6 +674,21 @@ Quick Feature Summary
* Semantic type information for identifiers (`GetType`)
* View documentation comments for identifiers (`GetDoc`)
### JavaScript
* Intelligent auto-completion
* Go to definition, find references (`GoToDefinition`, `GoToReferences`)
* Type information for identifiers (`GetType`)
* View documentation comments for identifiers (`GetDoc`)
* Management of `Tern` server instance
### Rust
* Semantic auto-completion
* Go to definition (`GoTo`, `GoToDefinition`, and `GoToDeclaration` are
identical)
* Management of `racer` server instance
User Guide
----------
......@@ -690,12 +794,120 @@ getting fast completions.
Call the `:YcmDiags` command to see if any errors or warnings were detected in
your file.
### JavaScript semantic completion
#### Quick start
1. Ensure that you have enabled the Tern completer. See the
[installation guide](#installation) for details.
2. Create a `.tern-project` file in the root directory of your JavaScript
project, by following the [instructions][tern-project] in the [Tern][]
documentation.
3. Make sure that Vim's working directory is a descendent of that directory (or
that directory itself) when working with JavaScript files.
#### Explanation
JavaScript completion is based on [Tern][]. This completion engine requires a
file named [`.tern-project`][tern-project] 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][tern-docs], a global
`.tern-config` file may be used.
Multiple Tern servers, are not supported. To switch to a different
JavaScript project, you can do one of the following:
- start a new instance of Vim from the new project's directory
- change Vim's working directory (`:cd /path/to/new/project`) and restart the
`ycmd` server (`:YcmRestartServer`)
- change Vim's working directory (`:cd /path/to/new/project`), open a JavaScript
file (or set filetype to JavaScript) and restart the Tern server using YCM
completer subcommands `:YcmCompleter StopServer` and `:YcmCompleter
StartServer`.
#### 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][tern-docs]. Any issues, improvements, advice, etc.
should be sought from the [Tern][] project. For example, see the [list of tern
plugins](http://ternjs.net/doc/manual.html#plugins) for the list of plugins
which can be enabled in the `plugins` section of the `.tern-project` file.
##### Configuring Tern for node support
The following simple example `.tern-project` file enables nodejs support:
```json
{
"plugins": {
"node": {}
}
}
```
##### Configuring Tern for requirejs support
The Tern requirejs plugin requires that all included "libraries" are rooted
under the same base directory. If that's not the case for your projects, then it
is possible to make it work with appropriate symbolic links. For example, create
a directory `ext_lib` within your project and populate it with symlinks to your
libraries. Then set up the `.tern-project` something like this:
```json
{
"plugins": {
"requirejs": {
"baseURL": "./ext_lib",
}
}
}
```
Then, given the following structure:
```
./ext_lib/mylib (symlink)
./ext_lib/anotherlib (symlink)
```
Can be used as follows:
```javascript
define( [ 'mylib/file1', 'anotherlib/anotherfile' ], function( f1, f2 ) {
// etc.
} );
```
### Rust semantic completion
Completions and GoTo* within the current crate and its dependencies should work
out of the box with no additional configuration. For semantic analysis inclusive
of the standard library, you must have a local copy of
[the rust source code][rust-src]. You also need to set the following option so
YouCompleteMe can locate it.
```viml
" 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'
```
### Semantic completion for other languages
Python, C#, Go, and TypeScript are supported natively by YouCompleteMe using the [Jedi][],
[Omnisharp][], [Gocode][], and [TSServer][] engines, respectively. Check the
[installation](#installation) section for instructions to enable these features
if desired.
Python, C#, Go, Rust, and TypeScript are supported natively by YouCompleteMe
using the [Jedi][], [Omnisharp][], [Gocode][], [racer][], and [TSServer][]
engines, respectively. Check the [installation](#installation) section for
instructions to enable these features if desired.
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
......@@ -871,6 +1083,14 @@ This will print out various debug information for the current file. Useful to
see what compile commands will be used for the file if you're using the semantic
completion engine.
### The `:YcmToggleLogs` command
This command automatically opens in windows the stdout and stderr logfiles
written by the `ycmd` server. If one or both logfiles are already opened, they
are automatically closed. `stderr` or `stdout` can be specified as an argument
of this command to only open the corresponding logfile instead of both. If this
logfile is already opened, it will be closed. Only for debugging purpose.
### The `:YcmCompleter` command
This command can be used to invoke completer-specific commands. If the first
......@@ -912,7 +1132,7 @@ Supported in filetypes: `c, cpp, objc, objcpp`
Looks up the symbol under the cursor and jumps to its declaration.
Supported in filetypes: `c, cpp, objc, objcpp, python, cs`
Supported in filetypes: `c, cpp, objc, objcpp, python, cs, rust`
### The `GoToDefinition` subcommand
......@@ -923,7 +1143,8 @@ the definition of the symbol is in the current translation unit. A translation
unit consists of the file you are editing and all the files you are including
with `#include` directives (directly or indirectly) in that file.
Supported in filetypes: `c, cpp, objc, objcpp, python, cs, typescript`
Supported in filetypes: `c, cpp, objc, objcpp, python, cs, typescript,
javascript, rust`
### The `GoTo` subcommand
......@@ -934,7 +1155,7 @@ the current translation unit, jumps to the symbol's declaration. For
C/C++/Objective-C, it first tries to look up the current line for a header and
jump to it. For C#, implementations are also considered and preferred.
Supported in filetypes: `c, cpp, objc, objcpp, python, cs`
Supported in filetypes: `c, cpp, objc, objcpp, python, cs, javascript, rust`
### The `GoToImprecise` subcommand
......@@ -949,6 +1170,14 @@ latency.
Supported in filetypes: `c, cpp, objc, objcpp`
### The `GoToReferences` subcommand
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`
### The `ClearCompilationFlagCache` subcommand
YCM caches the flags it gets from the `FlagsForFile` function in your
......@@ -988,9 +1217,9 @@ auto x = &s; // invoking on x or auto returns "auto";
std::cout << *x; // invoking on x returns "const char ** => const char **"
```
NOTE: Causes reparsing of the current translation unit.
NOTE: Causes re-parsing of the current translation unit.
Supported in filetypes: `c, cpp, objc, objcpp, typescript`
Supported in filetypes: `c, cpp, objc, objcpp, typescript, javascript`
### The `GetParent` subcommand
......@@ -1019,7 +1248,7 @@ context of the second `C::f` is the translation unit.
For global declarations, the semantic parent is the translation unit.
NOTE: Causes reparsing of the current translation unit.
NOTE: Causes re-parsing of the current translation unit.
Supported in filetypes: `c, cpp, objc, objcpp`
......@@ -1067,28 +1296,29 @@ under the cursor. This includes, depending on the language, things like:
* Python docstrings
* etc.
Supported in filetypes: `c, cpp, objc, objcpp, cs, python, typescript`
Supported in filetypes: `c, cpp, objc, objcpp, cs, python, typescript,
javascript`
### 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`
Supported in filetypes: `cs, javascript, go, rust`
### 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`
Supported in filetypes: `cs, javascript, go, rust`
### 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`
Supported in filetypes: `cs, rust`
### The `ReloadSolution` subcommand
......@@ -1114,6 +1344,35 @@ provides a list of implementations to choose from.
Supported in filetypes: `cs`
Functions
--------
### The `youcompleteme#GetErrorCount` function
Get the number of YCM Diagnostic errors. If no errors are present, this function
returns 0.
For example:
```viml
call youcompleteme#GetErrorCount()
```
Both this function and `youcompleteme#GetWarningCount` can be useful when
integrating YCM with other Vim plugins. For example, a [lightline][] user could
add a diagnostics section to their statusline which would display the number of
errors and warnings.
### The `youcompleteme#GetWarningCount` function
Get the number of YCM Diagnostic warnings. If no warnings are present, this
function returns 0.
For example:
```viml
call youcompleteme#GetWarningCount()
```
Options
-------
......@@ -1547,18 +1806,6 @@ Default: `''`
let g:ycm_path_to_python_interpreter = ''
```
### 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`
```viml
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
......@@ -1998,8 +2245,10 @@ the message log if it encounters problems. It's likely you misconfigured
something and YCM is complaining about it.
Also, you may want to run the `:YcmDebugInfo` command; it will make YCM spew 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.
various debugging information, including the `ycmd` logfile paths and the
compile flags for the current file if the file is a C-family language file and
you have compiled in Clang support. Logfiles can be automatically opened in the
editor using the `:YcmToggleLogs` command.
### Sometimes it takes much longer to get semantic completions than normal
......@@ -2318,6 +2567,17 @@ To increase the Neobundle timeout to 1500 seconds, add the following to your vim
let g:neobundle#install_process_timeout = 1500
```
### When I open a JavaScript file, I get an annoying warning about `.tern-project` file
Take a look at the [instructions for using the JavaScript
completer](#javascript-semantic-completion).
If this is still really annoying, and you have a good reason not to have a
`.tern-project` file, create an empty `.tern-config` file in your home directory
and YCM will stop complaining.
Contact
-------
......@@ -2344,16 +2604,17 @@ This software is licensed under the [GPL v3 license][gpl].
[vundle]: https://github.com/VundleVim/Vundle.vim#about
[pathogen]: https://github.com/tpope/vim-pathogen#pathogenvim
[clang-download]: http://llvm.org/releases/download.html
[brew]: http://mxcl.github.com/homebrew/
[cmake-download]: http://www.cmake.org/cmake/resources/software.html
[brew]: http://brew.sh
[cmake-download]: https://cmake.org/download/
[macvim]: https://github.com/macvim-dev/macvim/releases
[vimrc]: http://vimhelp.appspot.com/starting.txt.html#vimrc
[gpl]: http://www.gnu.org/copyleft/gpl.html
[vim]: http://www.vim.org/
[syntastic]: https://github.com/scrooloose/syntastic
[lightline]: https://github.com/itchyny/lightline.vim
[flags_example]: https://github.com/Valloric/ycmd/blob/master/cpp/ycm/.ycm_extra_conf.py
[compdb]: http://clang.llvm.org/docs/JSONCompilationDatabase.html
[subsequence]: http://en.wikipedia.org/wiki/Subsequence
[subsequence]: https://en.wikipedia.org/wiki/Subsequence
[listtoggle]: https://github.com/Valloric/ListToggle
[vim-build]: https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source
[tracker]: https://github.com/Valloric/YouCompleteMe/issues?state=open
......@@ -2365,9 +2626,9 @@ This software is licensed under the [GPL v3 license][gpl].
[ultisnips]: https://github.com/SirVer/ultisnips/blob/master/doc/UltiSnips.txt
[exuberant-ctags]: http://ctags.sourceforge.net/
[ctags-format]: http://ctags.sourceforge.net/FORMAT
[vundle-bug]: https://github.com/gmarik/vundle/issues/48
[vundle-bug]: https://github.com/VundleVim/Vundle.vim/issues/48
[ycm-users]: https://groups.google.com/forum/?hl=en#!forum/ycm-users
[omnisharp]: https://github.com/nosami/OmniSharpServer
[omnisharp]: https://github.com/OmniSharp/omnisharp-server
[issue-303]: https://github.com/Valloric/YouCompleteMe/issues/303
[issue-593]: https://github.com/Valloric/YouCompleteMe/issues/593
[issue-669]: https://github.com/Valloric/YouCompleteMe/issues/669
......@@ -2384,3 +2645,9 @@ This software is licensed under the [GPL v3 license][gpl].
[visual-studio-download]: https://www.visualstudio.com/products/free-developer-offers-vs.aspx
[7z-download]: http://www.7-zip.org/download.html
[npm-install]: https://docs.npmjs.com/getting-started/installing-node
[Tern]: http://ternjs.net
[tern-project]: http://ternjs.net/doc/manual.html#configuration
[tern-docs]: http://ternjs.net/doc/manual.html#server
[racer]: https://github.com/phildawes/racer
[rust-install]: https://www.rust-lang.org/
[rust-src]: https://www.rust-lang.org/downloads.html
......@@ -11,6 +11,6 @@ install:
- python C:\get-pip.py
- pip install -r python\test_requirements.txt
build_script:
- run_tests.py
- python run_tests.py
# Disable automatic tests
test: off
......@@ -22,6 +22,7 @@ set cpo&vim
" This needs to be called outside of a function
let s:script_folder_path = escape( expand( '<sfile>:p:h' ), '\' )
let s:omnifunc_mode = 0
let s:defer_omnifunc = 1
let s:old_cursor_position = []
let s:cursor_moved = 0
......@@ -88,6 +89,21 @@ function! youcompleteme#Enable()
autocmd CompleteDone * call s:OnCompleteDone()
augroup END
" Setting the omnifunc require us to ask the server if it has a Native
" Semantic Completer for the current buffer's filetype. When vim first start
" this mean that we have to wait for the server to be up and running which
" would block vim's GUI. To avoid this we defer setting the omnifunc the
" first time to when we enter Insert mode and then update it on every
" BufferVisit as normal.
if s:defer_omnifunc
augroup ycm_defer_omnifunc
autocmd!
autocmd InsertEnter * call s:SetOmnicompleteFunc()
\ | let s:defer_omnifunc = 0
\ | autocmd! ycm_defer_omnifunc
augroup END
endif
" Calling these once solves the problem of BufReadPre/BufRead/BufEnter not
" triggering for the first loaded file. This should be the last commands
" executed in this function!
......@@ -111,6 +127,16 @@ function! youcompleteme#DisableCursorMovedAutocommands()
endfunction
function! youcompleteme#GetErrorCount()
return pyeval( 'ycm_state.GetErrorCount()' )
endfunction
function! youcompleteme#GetWarningCount()
return pyeval( 'ycm_state.GetWarningCount()' )
endfunction
function! s:SetUpPython() abort
python << EOF
import sys
......@@ -310,6 +336,8 @@ function! s:SetUpCommands()
command! YcmRestartServer call s:RestartServer()
command! YcmShowDetailedDiagnostic call s:ShowDetailedDiagnostic()
command! YcmDebugInfo call s:DebugInfo()
command! -nargs=? -complete=custom,youcompleteme#LogsComplete
\ YcmToggleLogs call s:ToggleLogs(<f-args>)
command! -nargs=* -complete=custom,youcompleteme#SubCommandsComplete
\ YcmCompleter call s:CompleterCommand(<f-args>)
command! YcmForceCompileAndDiagnostics call s:ForceCompileAndDiagnostics()
......@@ -400,6 +428,11 @@ function! s:OnBufferVisit()
call s:SetUpCompleteopt()
call s:SetCompleteFunc()
if !s:defer_omnifunc
call s:SetOmnicompleteFunc()
endif
py ycm_state.OnBufferVisit()
call s:OnFileReadyToParse()
endfunction
......@@ -532,11 +565,6 @@ function! s:OnInsertEnter()
return
endif
if !get( b:, 'ycm_omnicomplete', 0 )
let b:ycm_omnicomplete = 1
call s:SetOmnicompleteFunc()
endif
let s:old_cursor_position = []
endfunction
......@@ -589,6 +617,7 @@ function! s:UpdateDiagnosticNotifications()
\ s:DiagnosticUiSupportedForCurrentFiletype()
if !should_display_diagnostics
py ycm_state.ValidateParseRequest()
return
endif
......@@ -763,6 +792,14 @@ function! s:DebugInfo()
endfunction
function! s:ToggleLogs(...)
let stderr = a:0 == 0 || a:1 !=? 'stdout'
let stdout = a:0 == 0 || a:1 !=? 'stderr'
py ycm_state.ToggleLogs( stdout = vimsupport.GetBoolValue( 'l:stdout' ),
\ stderr = vimsupport.GetBoolValue( 'l:stderr' ) )
endfunction
function! s:CompleterCommand(...)
" CompleterCommand will call the OnUserCommand function of a completer.
" If the first arguments is of the form "ft=..." it can be used to specify the
......@@ -796,6 +833,11 @@ function! youcompleteme#OpenGoToList()
endfunction
function! youcompleteme#LogsComplete( arglead, cmdline, cursorpos )
return "stdout\nstderr"
endfunction
function! youcompleteme#SubCommandsComplete( arglead, cmdline, cursorpos )
return join( pyeval( 'ycm_state.GetDefinedSubcommands()' ),
\ "\n")
......
......@@ -19,15 +19,24 @@ Contents ~
4. Python 2 |youcompleteme-python-2|
5. Go |youcompleteme-go|
6. TypeScript |youcompleteme-typescript|
7. JavaScript |youcompleteme-javascript|
8. Rust |youcompleteme-rust|
5. User Guide |youcompleteme-user-guide|
1. General Usage |youcompleteme-general-usage|
2. Client-server architecture |youcompleteme-client-server-architecture|
3. Completion string ranking |youcompleteme-completion-string-ranking|
4. General Semantic Completion Engine Usage |youcompleteme-general-semantic-completion-engine-usage|
5. C-family Semantic Completion Engine Usage |youcompleteme-c-family-semantic-completion-engine-usage|
6. Semantic completion for other languages |youcompleteme-semantic-completion-for-other-languages|
7. Writing New Semantic Completers |youcompleteme-writing-new-semantic-completers|
8. Diagnostic display |youcompleteme-diagnostic-display|
6. JavaScript semantic completion |youcompleteme-javascript-semantic-completion|
1. Quick start |youcompleteme-quick-start|
2. Explanation |youcompleteme-explanation|
3. Tips and tricks |youcompleteme-tips-tricks|
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|
1. C# Diagnostic Support |youcompleteme-c-diagnostic-support|
2. Diagnostic highlighting groups |youcompleteme-diagnostic-highlighting-groups|
6. Commands |youcompleteme-commands|
......@@ -36,25 +45,30 @@ Contents ~
3. The |:YcmDiags| command
4. The |:YcmShowDetailedDiagnostic| command
5. The |:YcmDebugInfo| command
6. The |:YcmCompleter| command
6. The |:YcmToggleLogs| command
7. The |:YcmCompleter| command
7. YcmCompleter subcommands |youcompleteme-ycmcompleter-subcommands|
1. The |GoToInclude| subcommand
2. The |GoToDeclaration| subcommand
3. The |GoToDefinition| subcommand
4. The |GoTo| subcommand
5. The |GoToImprecise| subcommand
6. The |ClearCompilationFlagCache| subcommand
7. The |GetType| subcommand
8. The |GetParent| subcommand
9. The |FixIt| subcommand
10. The |GetDoc| subcommand
11. The |StartServer| subcommand
12. The |StopServer| subcommand
13. The |RestartServer| subcommand