Commit 61a25ec7 authored by David Kalnischkies's avatar David Kalnischkies

New upstream version 0+20181228+gitc209cdb

parent 8e2f565b
......@@ -4,3 +4,21 @@
[submodule "third_party/ycmd"]
path = third_party/ycmd
url = https://github.com/Valloric/ycmd
[submodule "third_party/requests_deps/idna"]
path = third_party/requests_deps/idna
url = https://github.com/kjd/idna
[submodule "third_party/requests_deps/certifi"]
path = third_party/requests_deps/certifi
url = https://github.com/certifi/python-certifi
[submodule "third_party/requests_deps/chardet"]
path = third_party/requests_deps/chardet
url = https://github.com/chardet/chardet
[submodule "third_party/requests_deps/urllib3"]
path = third_party/requests_deps/urllib3
url = https://github.com/urllib3/urllib3
[submodule "third_party/requests_deps/requests"]
path = third_party/requests_deps/requests
url = https://github.com/kennethreitz/requests
[submodule "third_party/python-future"]
path = third_party/python-future
url = https://github.com/PythonCharmers/python-future
......@@ -28,18 +28,16 @@
#
# For more information, please refer to <http://unlicense.org/>
import os
import os.path as p
import subprocess
DIR_OF_THIS_SCRIPT = os.path.abspath( os.path.dirname( __file__ ) )
DIR_OF_THIRD_PARTY = os.path.join( DIR_OF_THIS_SCRIPT, 'third_party' )
DIR_OF_YCMD_THIRD_PARTY = os.path.join( DIR_OF_THIRD_PARTY,
'ycmd', 'third_party' )
DIR_OF_THIS_SCRIPT = p.abspath( p.dirname( __file__ ) )
DIR_OF_THIRD_PARTY = p.join( DIR_OF_THIS_SCRIPT, 'third_party' )
def GetStandardLibraryIndexInSysPath( sys_path ):
for index, path in enumerate( sys_path ):
if os.path.isfile( os.path.join( path, 'os.py' ) ):
if p.isfile( p.join( path, 'os.py' ) ):
return index
raise RuntimeError( 'Could not find standard library path in Python path.' )
......@@ -47,11 +45,17 @@ def GetStandardLibraryIndexInSysPath( sys_path ):
def PythonSysPath( **kwargs ):
sys_path = kwargs[ 'sys_path' ]
dependencies = [ os.path.join( DIR_OF_THIS_SCRIPT, 'python' ),
os.path.join( DIR_OF_THIRD_PARTY, 'requests-futures' ),
os.path.join( DIR_OF_THIRD_PARTY, 'ycmd' ),
os.path.join( DIR_OF_YCMD_THIRD_PARTY, 'frozendict' ),
os.path.join( DIR_OF_YCMD_THIRD_PARTY, 'requests' ) ]
dependencies = [ p.join( DIR_OF_THIS_SCRIPT, 'python' ),
p.join( DIR_OF_THIRD_PARTY, 'requests-futures' ),
p.join( DIR_OF_THIRD_PARTY, 'ycmd' ),
p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'idna' ),
p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'chardet' ),
p.join( DIR_OF_THIRD_PARTY,
'requests_deps',
'urllib3',
'src' ),
p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'certifi' ),
p.join( DIR_OF_THIRD_PARTY, 'requests_deps', 'requests' ) ]
# The concurrent.futures module is part of the standard library on Python 3.
interpreter_path = kwargs[ 'interpreter_path' ]
......@@ -59,11 +63,10 @@ def PythonSysPath( **kwargs ):
interpreter_path, '-c', 'import sys; print( sys.version_info[ 0 ] )' ]
).rstrip().decode( 'utf8' ) )
if major_version == 2:
dependencies.append( os.path.join( DIR_OF_THIRD_PARTY, 'pythonfutures' ) )
dependencies.append( p.join( DIR_OF_THIRD_PARTY, 'pythonfutures' ) )
sys_path[ 0:0 ] = dependencies
sys_path.insert( GetStandardLibraryIndexInSysPath( sys_path ) + 1,
os.path.join( DIR_OF_YCMD_THIRD_PARTY, 'python-future',
'src' ) )
p.join( DIR_OF_THIRD_PARTY, 'python-future', 'src' ) )
return sys_path
......@@ -213,8 +213,8 @@ The following additional language support options are available:
`install.py`.
- Go support: install [Go][go-install] and add `--go-completer` when calling
`install.py`.
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] then
install the TypeScript SDK with `npm install -g typescript`.
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] and
add `--ts-completer` when calling `install.py`.
- Rust support: install [Rust][rust-install] and add
`--rust-completer` when calling `install.py`.
- Java support: install [JDK8 (version 8 required)][jdk-install] and add
......@@ -286,8 +286,8 @@ The following additional language support options are available:
when calling `install.py`.
- Go support: install [Go][go-install] and add `--go-completer` when calling
`install.py`.
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] then
install the TypeScript SDK with `npm install -g typescript`.
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] and
add `--ts-completer` when calling `install.py`.
- Rust support: install [Rust][rust-install] and add `--rust-completer` when
calling `install.py`.
- Java support: install [JDK8 (version 8 required)][jdk-install] and add
......@@ -325,7 +325,7 @@ can check the version and which Python is supported by typing `:version` inside
Vim. Look at the features included: `+python/dyn` for Python 2 and
`+python3/dyn` for Python 3. Take note of the Vim architecture, i.e. 32 or
64-bit. It will be important when choosing the Python installer. We recommend
using a 64-bit client. [Daily updated copies of 32-bit and 64-bit Vim with
using a 64-bit client. [Daily updated installers of 32-bit and 64-bit Vim with
Python 2 and Python 3 support][vim-win-download] are available.
Add the line:
......@@ -377,8 +377,8 @@ The following additional language support options are available:
Be sure that [the build utility `msbuild` is in your PATH][add-msbuild-to-path].
- Go support: install [Go][go-install] and add `--go-completer` when calling
`install.py`.
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] then
install the TypeScript SDK with `npm install -g typescript`.
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] and
add `--ts-completer` when calling `install.py`.
- Rust support: install [Rust][rust-install] and add `--rust-completer` when
calling `install.py`.
- Java support: install [JDK8 (version 8 required)][jdk-install] and add
......@@ -449,8 +449,8 @@ The following additional language support options are available:
`./install.py`.
- Go support: install [Go][go-install] and add `--go-completer` when calling
`./install.py`.
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] then
install the TypeScript SDK with `npm install -g typescript`.
- JavaScript and TypeScript support: install [Node.js and npm][npm-install] and
add `--ts-completer` when calling `install.py`.
- Rust support: install [Rust][rust-install] and add `--rust-completer` when
calling `./install.py`.
- Java support: install [JDK8 (version 8 required)][jdk-install] and add
......@@ -525,9 +525,9 @@ process.
**Download the latest version of `libclang`**. Clang is an open-source
compiler that can compile C-family languages. The `libclang` library it
provides is used to power the YCM semantic completion engine for those
languages. YCM is designed to work with libclang version 3.9 or higher.
languages. YCM is designed to work with libclang version 7.0.0 or higher.
You can use the system libclang _only if you are sure it is version 3.9 or
You can use the system libclang _only if you are sure it is version 7.0.0 or
higher_, otherwise don't. Even if it is, we recommend using the [official
binaries from llvm.org][clang-download] if at all possible. Make sure you
download the correct archive file for your OS.
......@@ -659,9 +659,9 @@ process.
- Go support: install [Go][go-install] and add it to your path. Navigate to
`YouCompleteMe/third_party/ycmd/third_party/gocode` and run `go build`.
- JavaScript and TypeScript support: as with the quick installation, simply
`npm install -g typescript` after successfully installing [Node.js and
npm][npm-install].
- JavaScript and TypeScript support: install [Node.js and npm][npm-install],
navigate to `YouCompleteMe/third_party/ycmd` and run
`npm install -g --prefix third_party/tsserver typescript`.
- Rust support: install [Rust][rust-install]. Navigate to
`YouCompleteMe/third_party/ycmd/third_party/racerd` and run `cargo build
......@@ -696,7 +696,7 @@ Quick Feature Summary
### C-family languages (C, C++, Objective C, Objective C++, CUDA)
* Semantic auto-completion
* Semantic auto-completion with automatic fixes
* Real-time diagnostic display
* Go to include/declaration/definition (`GoTo`, etc.)
* Semantic type information for identifiers (`GetType`)
......@@ -1290,11 +1290,10 @@ installation. Further instructions on how to setup YCM with [Tern][] are
available on [the wiki][tern-instructions].
All JavaScript and TypeScript features are provided by the [TSServer][] engine,
which is included in the TypeScript SDK. To get the SDK, install [Node.js and
npm][npm-install] and run the command:
```
npm install -g typescript
```
which is included in the TypeScript SDK. To enable these features, install
[Node.js and npm][npm-install] and call the `install.py` script with the
`--ts-completer` flag.
[TSServer][] relies on [the `jsconfig.json` file][jsconfig.json] for JavaScript
and [the `tsconfig.json` file][tsconfig.json] for TypeScript to analyze your
project. Ensure the file exists at the root of your project.
......@@ -1309,11 +1308,6 @@ To get diagnostics in JavaScript, set the `checkJs` option to `true` in your
}
```
TypeScript 2.8.1 or later is recommended. Some features will be missing on older
versions. You can check which version you are currently using by looking at the
output of [`:YcmDebugInfo` ](#the-ycmdebuginfo-command). If the version is
`None`, your TypeScript is too old and should be updated.
### Semantic Completion for Other Languages
C-family, C#, Go, Java, Python, Rust, and JavaScript/TypeScript languages are
......@@ -3035,21 +3029,13 @@ 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.
### I get `Vim: Caught deadly signal SEGV` on Vim startup
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.9 libclang. Just go through the installation guide and make sure
you are using a correct `libclang.so`. We recommend downloading prebuilt
binaries from llvm.org.
### I see `undefined symbol: clang_getCompletionFixIt` in the server logs.
This means that the server is trying to load a version of libclang that is too
old. You need at least libclang 7.0.0. We recommend running the `install.py`
script without `--system-libclang` or downloading the [latest prebuilt binaries
from llvm.org][clang-download] when going through the [full installation
guide](#full-installation-guide).
### I get `Fatal Python error: PyThreadState_Get: no current thread` on startup
......@@ -3321,10 +3307,10 @@ augroup END
YCM relies on the `VimLeave` event to shut down the [ycmd server][ycmd]. Some
plugins prevent this event from triggering by exiting Vim through an autocommand
without using the `nested` keyword (see `:h autocmd-nested`). One of these
plugins is [vim-nerdtree-tabs][]. You should identify which plugin is
responsible for the issue and report it to the plugin author. Note that when
this happens, [ycmd][] will automatically shut itself down after 30 minutes.
without using the `nested` keyword (see `:h autocmd-nested`). You should
identify which plugin is responsible for the issue and report it to the plugin
author. Note that when this happens, [ycmd][] will automatically shut itself
down after 30 minutes.
### YCM does not work with my Anaconda Python setup
......@@ -3427,7 +3413,7 @@ This software is licensed under the [GPL v3 license][gpl].
[TSServer]: https://github.com/Microsoft/TypeScript/tree/master/src/server
[jsconfig.json]: https://code.visualstudio.com/docs/languages/jsconfig
[tsconfig.json]: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html
[vim-win-download]: https://bintray.com/micbou/generic/vim
[vim-win-download]: https://github.com/vim/vim-win32-installer/releases
[python-win-download]: https://www.python.org/downloads/windows/
[visual-studio-download]: https://www.visualstudio.com/downloads/
[7z-download]: http://www.7-zip.org/download.html
......@@ -3448,7 +3434,6 @@ This software is licensed under the [GPL v3 license][gpl].
[vim_win-python2.7.11-bug_workaround]: https://github.com/vim/vim-win32-installer/blob/a27bbdba9bb87fa0e44c8a00d33d46be936822dd/appveyor.bat#L86-L88
[gitter]: https://gitter.im/Valloric/YouCompleteMe
[ninja-compdb]: https://ninja-build.org/manual.html
[vim-nerdtree-tabs]: https://github.com/jistr/vim-nerdtree-tabs
[++enc]: http://vimdoc.sourceforge.net/htmldoc/editing.html#++enc
[rustup]: https://www.rustup.rs/
[contributing-md]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
......
......@@ -23,11 +23,9 @@ set cpo&vim
let s:script_folder_path = escape( expand( '<sfile>:p:h' ), '\' )
let s:force_semantic = 0
let s:completion_stopped = 0
let s:default_completion = {
\ 'start_column': -1,
\ 'candidates': []
\ }
let s:completion = s:default_completion
" These two variables are initialized in youcompleteme#Enable.
let s:default_completion = {}
let s:completion = {}
let s:previous_allowed_buffer_number = 0
let s:pollers = {
\ 'completion': {
......@@ -147,6 +145,9 @@ function! youcompleteme#Enable()
let s:pollers.server_ready.id = timer_start(
\ s:pollers.server_ready.wait_milliseconds,
\ function( 's:PollServerReady' ) )
let s:default_completion = s:Pyeval( 'vimsupport.NO_COMPLETIONS' )
let s:completion = s:default_completion
endfunction
......@@ -193,14 +194,19 @@ import vim
root_folder = p.normpath( p.join( vim.eval( 's:script_folder_path' ), '..' ) )
third_party_folder = p.join( root_folder, 'third_party' )
ycmd_third_party_folder = p.join( third_party_folder, 'ycmd', 'third_party' )
# Add dependencies to Python path.
dependencies = [ p.join( root_folder, 'python' ),
p.join( third_party_folder, 'requests-futures' ),
p.join( third_party_folder, 'ycmd' ),
p.join( ycmd_third_party_folder, 'frozendict' ),
p.join( ycmd_third_party_folder, 'requests' ) ]
p.join( third_party_folder, 'requests_deps', 'idna' ),
p.join( third_party_folder, 'requests_deps', 'chardet' ),
p.join( third_party_folder,
'requests_deps',
'urllib3',
'src' ),
p.join( third_party_folder, 'requests_deps', 'certifi' ),
p.join( third_party_folder, 'requests_deps', 'requests' ) ]
# The concurrent.futures module is part of the standard library on Python 3.
if sys.version_info[ 0 ] == 2:
......@@ -210,10 +216,15 @@ sys.path[ 0:0 ] = dependencies
# We enclose this code in a try/except block to avoid backtraces in Vim.
try:
def GetStandardLibraryIndexInSysPath():
for index, path in enumerate( sys.path ):
if p.isfile( p.join( path, 'os.py' ) ):
return index
raise RuntimeError( 'Could not find standard library path in Python path.' )
# The python-future module must be inserted after the standard library path.
from ycmd.server_utils import GetStandardLibraryIndexInSysPath
sys.path.insert( GetStandardLibraryIndexInSysPath() + 1,
p.join( ycmd_third_party_folder, 'python-future', 'src' ) )
p.join( third_party_folder, 'python-future', 'src' ) )
# Import the modules used in this file.
from ycm import base, vimsupport, youcompleteme
......@@ -811,11 +822,7 @@ function! s:PollCompletion( ... )
return
endif
let response = s:Pyeval( 'ycm_state.GetCompletionResponse()' )
let s:completion = {
\ 'start_column': response.completion_start_column,
\ 'candidates': response.completions
\ }
let s:completion = s:Pyeval( 'ycm_state.GetCompletionResponse()' )
call s:Complete()
endfunction
......@@ -824,16 +831,17 @@ function! s:Complete()
" Do not call user's completion function if the start column is after the
" current column or if there are no candidates. Close the completion menu
" instead. This avoids keeping the user in completion mode.
if s:completion.start_column > col( '.' ) || empty( s:completion.candidates )
if s:completion.completion_start_column > s:completion.column ||
\ empty( s:completion.completions )
call s:CloseCompletionMenu()
else
" <c-x><c-u> invokes the user's completion function (which we have set to
" youcompleteme#CompleteFunc), and <c-p> tells Vim to select the previous
" completion candidate. This is necessary because by default, Vim selects the
" first candidate when completion is invoked, and selecting a candidate
" automatically replaces the current text with it. Calling <c-p> forces Vim to
" deselect the first candidate and in turn preserve the user's current text
" until he explicitly chooses to replace it with a completion.
" completion candidate. This is necessary because by default, Vim selects
" the first candidate when completion is invoked, and selecting a candidate
" automatically replaces the current text with it. Calling <c-p> forces Vim
" to deselect the first candidate and in turn preserve the user's current
" text until he explicitly chooses to replace it with a completion.
call s:SendKeys( "\<C-X>\<C-U>\<C-P>" )
endif
endfunction
......@@ -841,9 +849,25 @@ endfunction
function! youcompleteme#CompleteFunc( findstart, base )
if a:findstart
return s:completion.start_column - 1
" When auto-wrapping is enabled, Vim wraps the current line after the
" completion request is sent but before calling this function. The starting
" column returned by the server is invalid in that case and must be
" recomputed.
if s:completion.line != line( '.' )
" Given
" scb: column where the completion starts before auto-wrapping
" cb: cursor column before auto-wrapping
" sca: column where the completion starts after auto-wrapping
" ca: cursor column after auto-wrapping
" we have
" ca - sca = cb - scb
" sca = scb + ca - cb
let s:completion.completion_start_column +=
\ col( '.' ) - s:completion.column
endif
return s:completion.completion_start_column - 1
endif
return s:completion.candidates
return s:completion.completions
endfunction
......
......@@ -18,5 +18,6 @@ python --version
appveyor DownloadFile https://bootstrap.pypa.io/get-pip.py
python get-pip.py
del get-pip.py
pip install -r python\test_requirements.txt
if %errorlevel% neq 0 exit /b %errorlevel%
This diff is collapsed.
......@@ -43,9 +43,10 @@ def Main():
old_libs = (
glob.glob( p.join( DIR_OF_OLD_LIBS, '*ycm_core.*' ) ) +
glob.glob( p.join( DIR_OF_OLD_LIBS, '*ycm_client_support.*' ) ) +
glob.glob( p.join( DIR_OF_OLD_LIBS, '*clang*.*') ) )
glob.glob( p.join( DIR_OF_OLD_LIBS, '*clang*.*' ) ) )
for lib in old_libs:
os.remove( lib )
if __name__ == "__main__":
Main()
......@@ -72,11 +72,26 @@ endif
let g:loaded_youcompleteme = 1
" NOTE: Most defaults are in third_party/ycmd/ycmd/default_settings.json. They
" are loaded into Vim globals with the 'ycm_' prefix if such a key does not
" already exist; thus, the user can override the defaults.
" The only defaults that are here are the ones that are only relevant to the YCM
" Vim client and not the ycmd server.
"
" List of YCM options.
"
let g:ycm_filetype_whitelist =
\ get( g:, 'ycm_filetype_whitelist', { "*": 1 } )
let g:ycm_filetype_blacklist =
\ get( g:, 'ycm_filetype_blacklist', {
\ 'tagbar': 1,
\ 'qf': 1,
\ 'notes': 1,
\ 'markdown': 1,
\ 'netrw': 1,
\ 'unite': 1,
\ 'text': 1,
\ 'vimwiki': 1,
\ 'pandoc': 1,
\ 'infolog': 1,
\ 'mail': 1
\ } )
let g:ycm_open_loclist_on_ycm_diags =
\ get( g:, 'ycm_open_loclist_on_ycm_diags', 1 )
......@@ -138,6 +153,9 @@ let g:ycm_echo_current_diagnostic =
\ get( g:, 'ycm_echo_current_diagnostic',
\ get( g:, 'syntastic_echo_current_error', 1 ) )
let g:ycm_filter_diagnostics =
\ get( g:, 'ycm_filter_diagnostics', {} )
let g:ycm_always_populate_location_list =
\ get( g:, 'ycm_always_populate_location_list',
\ get( g:, 'syntastic_always_populate_loc_list', 0 ) )
......@@ -150,12 +168,106 @@ let g:ycm_warning_symbol =
\ get( g:, 'ycm_warning_symbol',
\ get( g:, 'syntastic_warning_symbol', '>>' ) )
let g:ycm_complete_in_comments =
\ get( g:, 'ycm_complete_in_comments', 0 )
let g:ycm_complete_in_strings =
\ get( g:, 'ycm_complete_in_strings', 1 )
let g:ycm_collect_identifiers_from_tags_files =
\ get( g:, 'ycm_collect_identifiers_from_tags_files', 0 )
let g:ycm_seed_identifiers_with_syntax =
\ get( g:, 'ycm_seed_identifiers_with_syntax', 0 )
let g:ycm_goto_buffer_command =
\ get( g:, 'ycm_goto_buffer_command', 'same-buffer' )
let g:ycm_disable_for_files_larger_than_kb =
\ get( g:, 'ycm_disable_for_files_larger_than_kb', 1000 )
"
" List of ycmd options.
"
let g:ycm_filepath_completion_use_working_dir =
\ get( g:, 'ycm_filepath_completion_use_working_dir', 0 )
let g:ycm_auto_trigger =
\ get( g:, 'ycm_auto_trigger', 1 )
let g:ycm_min_num_of_chars_for_completion =
\ get( g:, 'ycm_min_num_of_chars_for_completion', 2 )
let g:ycm_min_identifier_candidate_chars =
\ get( g:, 'ycm_min_num_identifier_candidate_chars', 0 )
let g:ycm_semantic_triggers =
\ get( g:, 'ycm_semantic_triggers', {} )
let g:ycm_filetype_specific_completion_to_disable =
\ get( g:, 'ycm_filetype_specific_completion_to_disable',
\ { 'gitcommit': 1 } )
let g:ycm_collect_identifiers_from_comments_and_strings =
\ get( g:, 'ycm_collect_identifiers_from_comments_and_strings', 0 )
let g:ycm_max_num_identifier_candidates =
\ get( g:, 'ycm_max_num_identifier_candidates', 10 )
let g:ycm_max_num_candidates =
\ get( g:, 'ycm_max_num_candidates', 50 )
let g:ycm_extra_conf_globlist =
\ get( g:, 'ycm_extra_conf_globlist', [] )
let g:ycm_global_ycm_extra_conf =
\ get( g:, 'ycm_global_ycm_extra_conf', '' )
let g:ycm_confirm_extra_conf =
\ get( g:, 'ycm_confirm_extra_conf', 1 )
let g:ycm_max_diagnostics_to_display =
\ get( g:, 'ycm_max_diagnostics_to_display', 30 )
let g:ycm_filepath_blacklist =
\ get( g:, 'ycm_filepath_blacklist', {
\ 'html': 1,
\ 'jsx': 1,
\ 'xml': 1
\ } )
let g:ycm_auto_start_csharp_server =
\ get( g:, 'ycm_auto_start_csharp_server', 1 )
let g:ycm_auto_stop_csharp_server =
\ get( g:, 'ycm_auto_stop_csharp_server', 1 )
let g:ycm_use_ultisnips_completer =
\ get( g:, 'ycm_use_ultisnips_completer', 1 )
let g:ycm_csharp_server_port =
\ get( g:, 'ycm_csharp_server_port', 0 )
" These options are not documented.
let g:ycm_gocode_binary_path =
\ get( g:, 'ycm_gocode_binary_path', '' )
let g:ycm_godef_binary_path =
\ get( g:, 'ycm_godef_binary_path', '' )
let g:ycm_rust_src_path =
\ get( g:, 'ycm_rust_src_path', '' )
let g:ycm_racerd_binary_path =
\ get( g:, 'ycm_racerd_binary_path', '' )
let g:ycm_java_jdtls_use_clean_workspace =
\ get( g:, 'ycm_java_jdtls_use_clean_workspace', 1 )
" This option is deprecated.
let g:ycm_python_binary_path =
\ get( g:, 'ycm_python_binary_path', '' )
if has( 'vim_starting' ) " Loading at startup.
" We defer loading until after VimEnter to allow the gui to fork (see
" `:h gui-fork`) and avoid a deadlock situation, as explained here:
......
......@@ -22,38 +22,28 @@ from __future__ import absolute_import
# Not installing aliases from python-future; it's unreliable and slow.
from builtins import * # noqa
from future.utils import iteritems
from ycm import vimsupport
from ycmd import user_options_store
from ycmd import identifier_utils
YCM_VAR_PREFIX = 'ycm_'
def BuildServerConf():
def GetUserOptions():
"""Builds a dictionary mapping YCM Vim user options to values. Option names
don't have the 'ycm_' prefix."""
# We only evaluate the keys of the vim globals and not the whole dictionary
# to avoid unicode issues.
# See https://github.com/Valloric/YouCompleteMe/pull/2151 for details.
keys = vimsupport.GetVimGlobalsKeys()
server_conf = {}
user_options = {}
for key in keys:
if not key.startswith( YCM_VAR_PREFIX ):
continue
new_key = key[ len( YCM_VAR_PREFIX ): ]
new_value = vimsupport.VimExpressionToPythonType( 'g:' + key )
server_conf[ new_key ] = new_value
user_options[ new_key ] = new_value
return server_conf
def LoadJsonDefaultsIntoVim():
defaults = user_options_store.DefaultOptions()
for key, value in iteritems( defaults ):
new_key = 'g:ycm_' + key
if not vimsupport.VariableExists( new_key ):
vimsupport.SetVariableValue( new_key, value )
return user_options
def CurrentIdentifierFinished():
......@@ -113,7 +103,7 @@ def AdjustCandidateInsertionText( candidates ):
for candidate in candidates:
new_candidate = candidate.copy()
if 'abbr' not in new_candidate:
if not new_candidate.get( 'abbr' ):
new_candidate[ 'abbr' ] = new_candidate[ 'word' ]
new_candidate[ 'word' ] = NewCandidateInsertionText(
......
......@@ -34,10 +34,14 @@ def _EnsureBackwardsCompatibility( arguments ):
class CommandRequest( BaseRequest ):
def __init__( self, arguments, extra_data = None ):
def __init__( self,
arguments,
buffer_command = 'same-buffer',
extra_data = None ):
super( CommandRequest, self ).__init__()
self._arguments = _EnsureBackwardsCompatibility( arguments )
self._command = arguments and arguments[ 0 ]
self._buffer_command = buffer_command
self._extra_data = extra_data
self._response = None
......@@ -91,7 +95,8 @@ class CommandRequest( BaseRequest ):
vimsupport.JumpToLocation( self._response[ 'filepath' ],
self._response[ 'line_num' ],
self._response[ 'column_num' ],
modifiers )
modifiers,
self._buffer_command )
def _HandleFixitResponse( self ):
......@@ -129,8 +134,11 @@ class CommandRequest( BaseRequest ):
vimsupport.WriteToPreviewWindow( self._response[ 'detailed_info' ] )
def SendCommandRequest( arguments, modifiers, extra_data = None ):
request = CommandRequest( arguments, extra_data )
def SendCommandRequest( arguments,
modifiers,
buffer_command,
extra_data = None ):
request = CommandRequest( arguments, buffer_command, extra_data )
# This is a blocking call.
request.Start()
request.RunPostCommandActionsIfNeeded( modifiers )
......
......@@ -23,11 +23,11 @@ from __future__ import absolute_import
from builtins import * # noqa
import logging
from future.utils import iteritems
from ycmd.utils import ToUnicode
from ycm.client.base_request import ( BaseRequest, DisplayServerException,
MakeServerException )
from ycm import vimsupport
from ycm.vimsupport import NO_COMPLETIONS
_logger = logging.getLogger( __name__ )
......@@ -37,12 +37,6 @@ class CompletionRequest( BaseRequest ):
super( CompletionRequest, self ).__init__()
self.request_data = request_data
self._response_future = None
self._complete_done_hooks = {
'cs': self._OnCompleteDone_Csharp,
'java': self._OnCompleteDone_FixIt,
'javascript': self._OnCompleteDone_FixIt,
'typescript': self._OnCompleteDone_FixIt,
}
def Start( self ):
......@@ -54,14 +48,14 @@ class CompletionRequest( BaseRequest ):
return bool( self._response_future ) and self._response_future.done()
def RawResponse( self ):
def _RawResponse( self ):
if not self._response_future:
return { 'completions': [], 'completion_start_column': -1 }
return NO_COMPLETIONS
response = self.HandleFuture( self._response_future,
truncate_message = True )
if not response:
return { 'completions': [], 'completion_start_column': -1 }
return NO_COMPLETIONS
# Vim may not be able to convert the 'errors' entry to its internal format
# so we remove it from the response.
......@@ -71,11 +65,13 @@ class CompletionRequest( BaseRequest ):
_logger.error( exception )
DisplayServerException( exception, truncate_message = True )
response[ 'line' ] = self.request_data[ 'line_num' ]
response[ 'column' ] = self.request_data[ 'column_num' ]
return response
def Response( self ):
response = self.RawResponse()
response = self._RawResponse()
response[ 'completions' ] = _ConvertCompletionDatasToVimDatas(
response[ 'completions' ] )
return response
......@@ -85,16 +81,10 @@ class CompletionRequest( BaseRequest ):
if not self.Done():
return
complete_done_actions = self._GetCompleteDoneHooks()
for action in complete_done_actions:
action()
def _GetCompleteDoneHooks( self ):
filetypes = vimsupport.CurrentFiletypes()
for key, value in iteritems( self._complete_done_hooks ):
if key in filetypes:
yield value
if 'cs' in vimsupport.CurrentFiletypes():
self._OnCompleteDone_Csharp()
else:
self._OnCompleteDone_FixIt()
def _GetCompletionsUserMayHaveCompleted( self ):
......@@ -106,11 +96,11 @@ class CompletionRequest( BaseRequest ):
# completed item and the list of completions. Sometimes this returns
# multiple possibilities, which is essentially unresolvable.
if 'user_data' not in completed_item:
completions = self.RawResponse()[ 'completions' ]
completions = self._RawResponse()[ 'completions' ]
return _FilterToMatchingCompletions( completed_item, completions )
if completed_item[ 'user_data' ]:
completions = self.RawResponse()[ 'completions' ]
completions = self._RawResponse()[ 'completions' ]
return [ completions[ int( completed_item[ 'user_data' ] ) ] ]
return []
......@@ -187,49 +177,43 @@ def _FilterToMatchingCompletions( completed_item, completions ):
return matched_completions
def _GetCompletionInfoField( completion_data ):
info = completion_data.get( 'detailed_info', '' )