Merge branch 'master' into fork_master

This commit is contained in:
Andrey Pikas 2017-03-30 20:26:11 +03:00
commit ebc3856121
39 changed files with 356 additions and 264 deletions

View File

@ -376,8 +376,7 @@ _Windows x86-64_ for a 64-bit Vim. We recommend installing Python 3.
- [CMake][cmake-download]. Add CMake executable to the PATH environment - [CMake][cmake-download]. Add CMake executable to the PATH environment
variable. variable.
- [Visual Studio][visual-studio-download]. Download the community edition. - [Visual Studio][visual-studio-download]. Download the community edition.
During setup, choose _Custom_ as the installation type and select the _Visual During setup, select _Desktop development with C++_ in _Workloads_.
C++_ component.
- [7-zip][7z-download]. Required to build YCM with semantic support for - [7-zip][7z-download]. Required to build YCM with semantic support for
C-family languages. C-family languages.
@ -412,8 +411,8 @@ install with all language features, ensure `msbuild`, `go`, `tsserver`, `node`,
python install.py --all python install.py --all
You can specify the Microsoft Visual C++ (MSVC) version using the `--msvc` 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 option. YCM officially supports MSVC 12 (Visual Studio 2013), 14 (2015), and 15
(2015). (2017).
That's it. You're done. Refer to the _User Guide_ section on how to use YCM. 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, Don't forget that if you want the C-family semantic completion engine to work,
@ -573,7 +572,7 @@ process.
Python 3][python-win-download]. Pick the version corresponding to your Vim Python 3][python-win-download]. Pick the version corresponding to your Vim
architecture. You will also need Microsoft Visual C++ (MSVC) to build YCM. architecture. You will also need Microsoft Visual C++ (MSVC) to build YCM.
You can obtain it by installing [Visual Studio][visual-studio-download]. You can obtain it by installing [Visual Studio][visual-studio-download].
MSVC 11 (Visual Studio 2012), 12 (2013), and 14 (2015) are officially MSVC 12 (Visual Studio 2013), 14 (2015), and 15 (2017) are officially
supported. supported.
Here we'll assume you installed YCM with Vundle. That means that the Here we'll assume you installed YCM with Vundle. That means that the
@ -730,6 +729,7 @@ Quick Feature Summary
### TypeScript ### TypeScript
* Semantic auto-completion * Semantic auto-completion
* Real-time diagnostic display
* Renaming symbols (`RefactorRename <new name>`) * Renaming symbols (`RefactorRename <new name>`)
* Go to definition, find references (`GoToDefinition`, `GoToReferences`) * Go to definition, find references (`GoToDefinition`, `GoToReferences`)
* Semantic type information for identifiers (`GetType`) * Semantic type information for identifiers (`GetType`)
@ -1132,9 +1132,10 @@ Completer API.
### Diagnostic Display ### Diagnostic Display
YCM will display diagnostic notifications for C-family and C# languages if you YCM will display diagnostic notifications for C-family and C# languages if you
compiled YCM with Clang and Omnisharp support, respectively. Since YCM continuously compiled YCM with Clang and Omnisharp support, respectively. Diagnostics will
recompiles your file as you type, you'll get notified of errors and warnings also be displayed for TypeScript. Since YCM continuously recompiles your file as
in your file as fast as possible. you type, you'll get notified of errors and warnings in your file as fast as
possible.
Here are the various pieces of the diagnostic UI: Here are the various pieces of the diagnostic UI:
@ -2563,11 +2564,6 @@ But fear not, you should be able to tweak your extra conf files to continue
working by using the `g:ycm_extra_conf_vim_data` option. See the docs on that working by using the `g:ycm_extra_conf_vim_data` option. See the docs on that
option for details. option for details.
### On very rare occasions Vim crashes when I tab through the completion menu
That's a very rare Vim bug most users never encounter. It's fixed in Vim
7.4.72. Update to that version (or above) to resolve the issue.
### I get `ImportError` exceptions that mention `PyInit_ycm_core` or `initycm_core` ### I get `ImportError` exceptions that mention `PyInit_ycm_core` or `initycm_core`
These errors are caused by building the YCM native libraries for Python 2 and These errors are caused by building the YCM native libraries for Python 2 and
@ -3092,7 +3088,7 @@ This software is licensed under the [GPL v3 license][gpl].
[TSServer]: https://github.com/Microsoft/TypeScript/tree/master/src/server [TSServer]: https://github.com/Microsoft/TypeScript/tree/master/src/server
[vim-win-download]: https://bintray.com/micbou/generic/vim [vim-win-download]: https://bintray.com/micbou/generic/vim
[python-win-download]: https://www.python.org/downloads/windows/ [python-win-download]: https://www.python.org/downloads/windows/
[visual-studio-download]: https://www.visualstudio.com/products/free-developer-offers-vs.aspx [visual-studio-download]: https://www.visualstudio.com/downloads/
[7z-download]: http://www.7-zip.org/download.html [7z-download]: http://www.7-zip.org/download.html
[mono-install-osx]: http://www.mono-project.com/docs/getting-started/install/mac/ [mono-install-osx]: http://www.mono-project.com/docs/getting-started/install/mac/
[mono-install-ubuntu]: http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives [mono-install-ubuntu]: http://www.mono-project.com/docs/getting-started/install/linux/#debian-ubuntu-and-derivatives

View File

@ -1,4 +1,5 @@
version: '{build}' version: '{build}'
image: Visual Studio 2017
environment: environment:
COVERAGE: true COVERAGE: true
matrix: matrix:

View File

@ -90,8 +90,7 @@ function! youcompleteme#Enable()
" We also need to trigger buf init code on the FileType event because when " We also need to trigger buf init code on the FileType event because when
" the user does :enew and then :set ft=something, we need to run buf init " the user does :enew and then :set ft=something, we need to run buf init
" code again. " code again.
autocmd BufRead,FileType * call s:OnBufferRead() autocmd BufRead,BufEnter,FileType * call s:OnBufferVisit()
autocmd BufEnter * call s:OnBufferEnter()
autocmd BufUnload * call s:OnBufferUnload() autocmd BufUnload * call s:OnBufferUnload()
autocmd CursorHold,CursorHoldI * call s:OnCursorHold() autocmd CursorHold,CursorHoldI * call s:OnCursorHold()
autocmd InsertLeave * call s:OnInsertLeave() autocmd InsertLeave * call s:OnInsertLeave()
@ -101,11 +100,9 @@ function! youcompleteme#Enable()
augroup END augroup END
" BufRead/FileType events are not triggered for the first loaded file. " BufRead/FileType events are not triggered for the first loaded file.
" However, we don't directly call the s:OnBufferRead function because it would " However, we don't directly call the s:OnBufferVisit function because it
" send requests that can't succeed as the server is not ready yet and would " would send requests that can't succeed as the server is not ready yet and
" slow down startup. " would slow down startup.
call s:DisableOnLargeFile( expand( '%' ) )
if s:AllowedToCompleteInCurrentBuffer() if s:AllowedToCompleteInCurrentBuffer()
call s:SetCompleteFunc() call s:SetCompleteFunc()
endif endif
@ -313,6 +310,23 @@ function! s:TurnOffSyntasticForCFamily()
endfunction endfunction
function! s:DisableOnLargeFile( buffer )
if exists( 'b:ycm_largefile' )
return b:ycm_largefile
endif
let threshold = g:ycm_disable_for_files_larger_than_kb * 1024
let b:ycm_largefile =
\ threshold > 0 && getfsize( expand( a:buffer ) ) > threshold
if b:ycm_largefile
exec s:python_command "vimsupport.PostVimMessage(" .
\ "'YouCompleteMe is disabled in this buffer; " .
\ "the file exceeded the max size (see YCM options).' )"
endif
return b:ycm_largefile
endfunction
function! s:AllowedToCompleteInBuffer( buffer ) function! s:AllowedToCompleteInBuffer( buffer )
let buffer_filetype = getbufvar( a:buffer, '&filetype' ) let buffer_filetype = getbufvar( a:buffer, '&filetype' )
@ -322,7 +336,7 @@ function! s:AllowedToCompleteInBuffer( buffer )
return 0 return 0
endif endif
if exists( 'b:ycm_largefile' ) if s:DisableOnLargeFile( a:buffer )
return 0 return 0
endif endif
@ -401,22 +415,6 @@ function! s:SetUpYcmChangedTick()
endfunction endfunction
function! s:DisableOnLargeFile( filename )
if exists( 'b:ycm_largefile' )
return
endif
let threshold = g:ycm_disable_for_files_larger_than_kb * 1024
if threshold > 0 && getfsize( a:filename ) > threshold
exec s:python_command "vimsupport.PostVimMessage(" .
\ "'YouCompleteMe is disabled in this buffer; " .
\ "the file exceeded the max size (see YCM options).' )"
let b:ycm_largefile = 1
endif
endfunction
function! s:OnVimLeave() function! s:OnVimLeave()
exec s:python_command "ycm_state.OnVimLeave()" exec s:python_command "ycm_state.OnVimLeave()"
endfunction endfunction
@ -427,15 +425,13 @@ function! s:OnCompleteDone()
endfunction endfunction
function! s:OnBufferRead() function! s:OnBufferVisit()
" We need to do this even when we are not allowed to complete in the current " We need to do this even when we are not allowed to complete in the current
" buffer because we might be allowed to complete in the future! The canonical " buffer because we might be allowed to complete in the future! The canonical
" example is creating a new buffer with :enew and then setting a filetype. " example is creating a new buffer with :enew and then setting a filetype.
call s:SetUpYcmChangedTick() call s:SetUpYcmChangedTick()
call s:DisableOnLargeFile( expand( '<afile>:p' ) ) if !s:VisitedBufferRequiresReparse()
if !s:AllowedToCompleteInCurrentBuffer()
return return
endif endif
@ -448,16 +444,6 @@ function! s:OnBufferRead()
endfunction endfunction
function! s:OnBufferEnter()
if !s:VisitedBufferRequiresReparse()
return
endif
exec s:python_command "ycm_state.OnBufferVisit()"
call s:OnFileReadyToParse()
endfunction
function! s:OnBufferUnload() function! s:OnBufferUnload()
" Expanding <abuf> returns the unloaded buffer number as a string but we want " Expanding <abuf> returns the unloaded buffer number as a string but we want
" it as a true number for the getbufvar function. " it as a true number for the getbufvar function.

View File

@ -130,44 +130,43 @@ Contents ~
47. The |g:ycm_python_binary_path| option 47. The |g:ycm_python_binary_path| option
11. FAQ |youcompleteme-faq| 11. FAQ |youcompleteme-faq|
1. I used to be able to 'import vim' in '.ycm_extra_conf.py', but now can't |youcompleteme-i-used-to-be-able-to-import-vim-in-.ycm_extra_conf.py-but-now-cant| 1. I used to be able to 'import vim' in '.ycm_extra_conf.py', but now can't |youcompleteme-i-used-to-be-able-to-import-vim-in-.ycm_extra_conf.py-but-now-cant|
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| 2. I get 'ImportError' exceptions that mention 'PyInit_ycm_core' or 'initycm_core' |youcompleteme-i-get-importerror-exceptions-that-mention-pyinit_ycm_core-or-initycm_core|
3. I get 'ImportError' exceptions that mention 'PyInit_ycm_core' or 'initycm_core' |youcompleteme-i-get-importerror-exceptions-that-mention-pyinit_ycm_core-or-initycm_core| 3. I get a linker warning regarding 'libpython' on Mac when compiling YCM |youcompleteme-i-get-linker-warning-regarding-libpython-on-mac-when-compiling-ycm|
4. I get a linker warning regarding 'libpython' on Mac when compiling YCM |youcompleteme-i-get-linker-warning-regarding-libpython-on-mac-when-compiling-ycm| 4. I get a weird window at the top of my file when I use the semantic engine |youcompleteme-i-get-weird-window-at-top-of-my-file-when-i-use-semantic-engine|
5. I get a weird window at the top of my file when I use the semantic engine |youcompleteme-i-get-weird-window-at-top-of-my-file-when-i-use-semantic-engine| 5. It appears that YCM is not working |youcompleteme-it-appears-that-ycm-is-not-working|
6. It appears that YCM is not working |youcompleteme-it-appears-that-ycm-is-not-working| 6. Sometimes it takes much longer to get semantic completions than normal |youcompleteme-sometimes-it-takes-much-longer-to-get-semantic-completions-than-normal|
7. Sometimes it takes much longer to get semantic completions than normal |youcompleteme-sometimes-it-takes-much-longer-to-get-semantic-completions-than-normal| 7. YCM auto-inserts completion strings I don't want! |youcompleteme-ycm-auto-inserts-completion-strings-i-dont-want|
8. YCM auto-inserts completion strings I don't want! |youcompleteme-ycm-auto-inserts-completion-strings-i-dont-want| 8. I get a 'E227: mapping already exists for <blah>' error when I start Vim |youcompleteme-i-get-e227-mapping-already-exists-for-blah-error-when-i-start-vim|
9. I get a 'E227: mapping already exists for <blah>' error when I start Vim |youcompleteme-i-get-e227-mapping-already-exists-for-blah-error-when-i-start-vim| 9. I get "'GLIBC_2.XX' not found (required by libclang.so)" when starting Vim |youcompleteme-i-get-glibc_2.xx-not-found-when-starting-vim|
10. I get "'GLIBC_2.XX' not found (required by libclang.so)" when starting Vim |youcompleteme-i-get-glibc_2.xx-not-found-when-starting-vim| 10. I'm trying to use a Homebrew Vim with YCM and I'm getting segfaults |youcompleteme-im-trying-to-use-homebrew-vim-with-ycm-im-getting-segfaults|
11. I'm trying to use a Homebrew Vim with YCM and I'm getting segfaults |youcompleteme-im-trying-to-use-homebrew-vim-with-ycm-im-getting-segfaults| 11. I have a Homebrew Python and/or MacVim; can't compile/SIGABRT when starting |youcompleteme-i-have-homebrew-python-and-or-macvim-cant-compile-sigabrt-when-starting|
12. I have a Homebrew Python and/or MacVim; can't compile/SIGABRT when starting |youcompleteme-i-have-homebrew-python-and-or-macvim-cant-compile-sigabrt-when-starting| 12. I get 'LONG_BIT definition appears wrong for platform' when compiling |youcompleteme-i-get-long_bit-definition-appears-wrong-for-platform-when-compiling|
13. I get 'LONG_BIT definition appears wrong for platform' when compiling |youcompleteme-i-get-long_bit-definition-appears-wrong-for-platform-when-compiling| 13. I get 'libpython2.7.a [...] relocation R_X86_64_32' when compiling |youcompleteme-i-get-libpython2.7.a-...-relocation-r_x86_64_32-when-compiling|
14. I get 'libpython2.7.a [...] relocation R_X86_64_32' when compiling |youcompleteme-i-get-libpython2.7.a-...-relocation-r_x86_64_32-when-compiling| 14. I get 'Vim: Caught deadly signal SEGV' on Vim startup |youcompleteme-i-get-vim-caught-deadly-signal-segv-on-vim-startup|
15. I get 'Vim: Caught deadly signal SEGV' on Vim startup |youcompleteme-i-get-vim-caught-deadly-signal-segv-on-vim-startup| 15. I get 'Fatal Python error: PyThreadState_Get: no current thread' on startup |youcompleteme-i-get-fatal-python-error-pythreadstate_get-no-current-thread-on-startup|
16. I get 'Fatal Python error: PyThreadState_Get: no current thread' on startup |youcompleteme-i-get-fatal-python-error-pythreadstate_get-no-current-thread-on-startup| 16. 'install.py' says python must be compiled with '--enable-framework'. Wat? |youcompleteme-install.py-says-python-must-be-compiled-with-enable-framework-.-wat|
17. 'install.py' says python must be compiled with '--enable-framework'. Wat? |youcompleteme-install.py-says-python-must-be-compiled-with-enable-framework-.-wat| 17. YCM does not read identifiers from my tags files |youcompleteme-ycm-does-not-read-identifiers-from-my-tags-files|
18. YCM does not read identifiers from my tags files |youcompleteme-ycm-does-not-read-identifiers-from-my-tags-files| 18. 'CTRL-U' in insert mode does not work |youcompleteme-ctrl-u-in-insert-mode-does-not-work|
19. 'CTRL-U' in insert mode does not work |youcompleteme-ctrl-u-in-insert-mode-does-not-work| 19. YCM conflicts with UltiSnips TAB key usage |youcompleteme-ycm-conflicts-with-ultisnips-tab-key-usage|
20. YCM conflicts with UltiSnips TAB key usage |youcompleteme-ycm-conflicts-with-ultisnips-tab-key-usage| 20. Snippets added with ':UltiSnipsAddFiletypes' do not appear in the popup menu |youcompleteme-snippets-added-with-ultisnipsaddfiletypes-do-not-appear-in-popup-menu|
21. Snippets added with ':UltiSnipsAddFiletypes' do not appear in the popup menu |youcompleteme-snippets-added-with-ultisnipsaddfiletypes-do-not-appear-in-popup-menu| 21. Why isn't YCM just written in plain VimScript, FFS? |youcompleteme-why-isnt-ycm-just-written-in-plain-vimscript-ffs|
22. Why isn't YCM just written in plain VimScript, FFS? |youcompleteme-why-isnt-ycm-just-written-in-plain-vimscript-ffs| 22. Why does YCM demand such a recent version of Vim? |youcompleteme-why-does-ycm-demand-such-recent-version-of-vim|
23. Why does YCM demand such a recent version of Vim? |youcompleteme-why-does-ycm-demand-such-recent-version-of-vim| 23. I get annoying messages in Vim's status area when I type |youcompleteme-i-get-annoying-messages-in-vims-status-area-when-i-type|
24. I get annoying messages in Vim's status area when I type |youcompleteme-i-get-annoying-messages-in-vims-status-area-when-i-type| 24. Nasty bugs happen if I have the 'vim-autoclose' plugin installed |youcompleteme-nasty-bugs-happen-if-i-have-vim-autoclose-plugin-installed|
25. Nasty bugs happen if I have the 'vim-autoclose' plugin installed |youcompleteme-nasty-bugs-happen-if-i-have-vim-autoclose-plugin-installed| 25. Is there some sort of YCM mailing list? I have questions |youcompleteme-is-there-sort-of-ycm-mailing-list-i-have-questions|
26. Is there some sort of YCM mailing list? I have questions |youcompleteme-is-there-sort-of-ycm-mailing-list-i-have-questions| 26. I get an internal compiler error when installing |youcompleteme-i-get-an-internal-compiler-error-when-installing|
27. I get an internal compiler error when installing |youcompleteme-i-get-an-internal-compiler-error-when-installing| 27. I get weird errors when I press 'Ctrl-C' in Vim |youcompleteme-i-get-weird-errors-when-i-press-ctrl-c-in-vim|
28. I get weird errors when I press 'Ctrl-C' in Vim |youcompleteme-i-get-weird-errors-when-i-press-ctrl-c-in-vim| 28. Why did YCM stop using Syntastic for diagnostics display? |youcompleteme-why-did-ycm-stop-using-syntastic-for-diagnostics-display|
29. Why did YCM stop using Syntastic for diagnostics display? |youcompleteme-why-did-ycm-stop-using-syntastic-for-diagnostics-display| 29. Completion doesn't work with the C++ standard library headers |youcompleteme-completion-doesnt-work-with-c-standard-library-headers|
30. Completion doesn't work with the C++ standard library headers |youcompleteme-completion-doesnt-work-with-c-standard-library-headers| 30. When I open a JavaScript file, I get an annoying warning about '.tern-project'
31. When I open a JavaScript file, I get an annoying warning about '.tern-project'
file |youcompleteme-when-i-open-javascript-file-i-get-an-annoying-warning-about-.tern-project-file| file |youcompleteme-when-i-open-javascript-file-i-get-an-annoying-warning-about-.tern-project-file|
32. When I start vim I get a runtime error saying 'R6034 An application has made an 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.' |youcompleteme-when-i-start-vim-i-get-runtime-error-saying-r6034-an-application-has-made-an-attempt-to-load-c-runtime-library-incorrectly.| attempt to load the C runtime library incorrectly.' |youcompleteme-when-i-start-vim-i-get-runtime-error-saying-r6034-an-application-has-made-an-attempt-to-load-c-runtime-library-incorrectly.|
33. I hear that YCM only supports Python 2, is that true? |youcompleteme-i-hear-that-ycm-only-supports-python-2-is-that-true| 32. I hear that YCM only supports Python 2, is that true? |youcompleteme-i-hear-that-ycm-only-supports-python-2-is-that-true|
34. On Windows I get "E887: Sorry, this command is disabled, the Python's site 33. On Windows I get "E887: Sorry, this command is disabled, the Python's site
module could not be loaded" |youcompleteme-on-windows-i-get-e887-sorry-this-command-is-disabled-pythons-site-module-could-not-be-loaded| module could not be loaded" |youcompleteme-on-windows-i-get-e887-sorry-this-command-is-disabled-pythons-site-module-could-not-be-loaded|
35. I can't complete python packages in a virtual environment. |youcompleteme-i-cant-complete-python-packages-in-virtual-environment.| 34. I can't complete python packages in a virtual environment. |youcompleteme-i-cant-complete-python-packages-in-virtual-environment.|
36. I want to defer loading of YouCompleteMe until after Vim finishes booting |i-want-to-defer-loading-of-youcompleteme-until-after-vim-finishes-booting| 35. I want to defer loading of YouCompleteMe until after Vim finishes booting |i-want-to-defer-loading-of-youcompleteme-until-after-vim-finishes-booting|
12. Contributor Code of Conduct |youcompleteme-contributor-code-of-conduct| 12. Contributor Code of Conduct |youcompleteme-contributor-code-of-conduct|
13. Contact |youcompleteme-contact| 13. Contact |youcompleteme-contact|
14. License |youcompleteme-license| 14. License |youcompleteme-license|
@ -424,12 +423,14 @@ Install YouCompleteMe with Vundle [23].
using Vundle and the ycm_core library APIs have changed (happens rarely), YCM using Vundle and the ycm_core library APIs have changed (happens rarely), YCM
will notify you to recompile it. You should then rerun the install process. will notify you to recompile it. You should then rerun the install process.
Install development tools and CMake: 'sudo apt-get install build-essential Install development tools and CMake:
cmake' >
sudo apt-get install build-essential cmake
Make sure you have Python headers installed: 'sudo apt-get install python-dev <
python3-dev'. Make sure you have Python headers installed:
>
sudo apt-get install python-dev python3-dev
<
Compiling YCM **with** semantic support for C-family languages: Compiling YCM **with** semantic support for C-family languages:
> >
cd ~/.vim/bundle/YouCompleteMe cd ~/.vim/bundle/YouCompleteMe
@ -493,12 +494,14 @@ Install YouCompleteMe with Vundle [23].
using Vundle and the ycm_core library APIs have changed (happens rarely), YCM using Vundle and the ycm_core library APIs have changed (happens rarely), YCM
will notify you to recompile it. You should then rerun the install process. will notify you to recompile it. You should then rerun the install process.
Install development tools and CMake: 'sudo dnf install automake gcc gcc-c++ Install development tools and CMake:
kernel-devel cmake' >
sudo dnf install automake gcc gcc-c++ kernel-devel cmake
Make sure you have Python headers installed: 'sudo dnf install python-devel <
python3-devel'. Make sure you have Python headers installed:
>
sudo dnf install python-devel python3-devel
<
Compiling YCM **with** semantic support for C-family languages: Compiling YCM **with** semantic support for C-family languages:
> >
cd ~/.vim/bundle/YouCompleteMe cd ~/.vim/bundle/YouCompleteMe
@ -576,8 +579,8 @@ Download and install the following software:
- CMake [25]. Add CMake executable to the PATH environment variable. - CMake [25]. Add CMake executable to the PATH environment variable.
- Visual Studio [35]. Download the community edition. During setup, choose - Visual Studio [35]. Download the community edition. During setup, select
_Custom_ as the installation type and select the _Visual C++_ component. _Desktop development with C++_ in _Workloads_.
- 7-zip [36]. Required to build YCM with semantic support for C-family - 7-zip [36]. Required to build YCM with semantic support for C-family
languages. languages.
@ -617,8 +620,8 @@ install with all language features, ensure 'msbuild', 'go', 'tsserver', 'node',
python install.py --all python install.py --all
< <
You can specify the Microsoft Visual C++ (MSVC) version using the '--msvc' 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 option. YCM officially supports MSVC 12 (Visual Studio 2013), 14 (2015), and 15
(2015). (2017).
That's it. You're done. Refer to the _User Guide_ section on how to use YCM. 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, Don't forget that if you want the C-family semantic completion engine to work,
@ -782,8 +785,8 @@ will notify you to recompile it. You should then rerun the install process.
On Windows, you need to download and install Python 2 or Python 3 [34]. On Windows, you need to download and install Python 2 or Python 3 [34].
Pick the version corresponding to your Vim architecture. You will also Pick the version corresponding to your Vim architecture. You will also
need Microsoft Visual C++ (MSVC) to build YCM. You can obtain it by need Microsoft Visual C++ (MSVC) to build YCM. You can obtain it by
installing Visual Studio [35]. MSVC 11 (Visual Studio 2012), 12 (2013), installing Visual Studio [35]. MSVC 12 (Visual Studio 2013), 14 (2015),
and 14 (2015) are officially supported. and 15 (2017) are officially supported.
Here we'll assume you installed YCM with Vundle. That means that the top- Here we'll assume you installed YCM with Vundle. That means that the top-
level YCM directory is in '~/.vim/bundle/YouCompleteMe'. level YCM directory is in '~/.vim/bundle/YouCompleteMe'.
@ -954,6 +957,7 @@ Go ~
TypeScript ~ TypeScript ~
- Semantic auto-completion - Semantic auto-completion
- Real-time diagnostic display
- Renaming symbols ('RefactorRename <new name>') - Renaming symbols ('RefactorRename <new name>')
- Go to definition, find references (|GoToDefinition|, |GoToReferences|) - Go to definition, find references (|GoToDefinition|, |GoToReferences|)
- Semantic type information for identifiers (|GetType|) - Semantic type information for identifiers (|GetType|)
@ -1389,9 +1393,10 @@ Completer API.
Diagnostic Display ~ Diagnostic Display ~
YCM will display diagnostic notifications for C-family and C# languages if you YCM will display diagnostic notifications for C-family and C# languages if you
compiled YCM with Clang and Omnisharp support, respectively. Since YCM compiled YCM with Clang and Omnisharp support, respectively. Diagnostics will
continuously recompiles your file as you type, you'll get notified of errors also be displayed for TypeScript. Since YCM continuously recompiles your file
and warnings in your file as fast as possible. as you type, you'll get notified of errors and warnings in your file as fast as
possible.
Here are the various pieces of the diagnostic UI: Here are the various pieces of the diagnostic UI:
@ -2797,13 +2802,6 @@ But fear not, you should be able to tweak your extra conf files to continue
working by using the |g:ycm_extra_conf_vim_data| option. See the docs on that working by using the |g:ycm_extra_conf_vim_data| option. See the docs on that
option for details. option for details.
-------------------------------------------------------------------------------
*youcompleteme-on-very-rare-occasions-vim-crashes-when-i-tab-through-completion-menu*
On very rare occasions Vim crashes when I tab through the completion menu ~
That's a very rare Vim bug most users never encounter. It's fixed in Vim
7.4.72. Update to that version (or above) to resolve the issue.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
*youcompleteme-i-get-importerror-exceptions-that-mention-pyinit_ycm_core-or-initycm_core* *youcompleteme-i-get-importerror-exceptions-that-mention-pyinit_ycm_core-or-initycm_core*
I get 'ImportError' exceptions that mention 'PyInit_ycm_core' or ~ I get 'ImportError' exceptions that mention 'PyInit_ycm_core' or ~
@ -3367,7 +3365,7 @@ References ~
[32] http://www.mono-project.com/docs/getting-started/install/linux/#centos-7-fedora-19-and-later-and-derivatives [32] http://www.mono-project.com/docs/getting-started/install/linux/#centos-7-fedora-19-and-later-and-derivatives
[33] https://bintray.com/micbou/generic/vim [33] https://bintray.com/micbou/generic/vim
[34] https://www.python.org/downloads/windows/ [34] https://www.python.org/downloads/windows/
[35] https://www.visualstudio.com/products/free-developer-offers-vs.aspx [35] https://www.visualstudio.com/downloads/
[36] http://www.7-zip.org/download.html [36] http://www.7-zip.org/download.html
[37] http://stackoverflow.com/questions/6319274/how-do-i-run-msbuild-from-the-command-line-using-windows-sdk-7-1 [37] http://stackoverflow.com/questions/6319274/how-do-i-run-msbuild-from-the-command-line-using-windows-sdk-7-1
[38] https://github.com/tpope/vim-pathogen#pathogenvim [38] https://github.com/tpope/vim-pathogen#pathogenvim

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from future.utils import iteritems from future.utils import iteritems

View File

@ -19,18 +19,16 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
import contextlib import contextlib
import logging import logging
import urllib.parse
import json import json
from future.utils import native from future.utils import native
from base64 import b64decode, b64encode from base64 import b64decode, b64encode
from ycm import vimsupport from ycm import vimsupport
from ycmd.utils import ToBytes from ycmd.utils import ToBytes, urljoin, urlparse
from ycmd.hmac_utils import CreateRequestHmac, CreateHmac, SecureBytesEqual from ycmd.hmac_utils import CreateRequestHmac, CreateHmac, SecureBytesEqual
from ycmd.responses import ServerError, UnknownExtraConf from ycmd.responses import ServerError, UnknownExtraConf
@ -120,7 +118,7 @@ class BaseRequest( object ):
headers = dict( _HEADERS ) headers = dict( _HEADERS )
headers[ _HMAC_HEADER ] = b64encode( headers[ _HMAC_HEADER ] = b64encode(
CreateRequestHmac( ToBytes( method ), CreateRequestHmac( ToBytes( method ),
ToBytes( urllib.parse.urlparse( request_uri ).path ), ToBytes( urlparse( request_uri ).path ),
request_body, request_body,
BaseRequest.hmac_secret ) ) BaseRequest.hmac_secret ) )
return headers return headers
@ -263,8 +261,7 @@ def _ValidateResponseObject( response ):
def _BuildUri( handler ): def _BuildUri( handler ):
return native( ToBytes( urllib.parse.urljoin( BaseRequest.server_location, return native( ToBytes( urljoin( BaseRequest.server_location, handler ) ) )
handler ) ) )
def MakeServerException( data ): def MakeServerException( data ):

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.client.base_request import ( BaseRequest, BuildRequestData, from ycm.client.base_request import ( BaseRequest, BuildRequestData,

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.client.base_request import ( BaseRequest, BuildRequestData, from ycm.client.base_request import ( BaseRequest, BuildRequestData,

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycmd.utils import ToUnicode from ycmd.utils import ToUnicode

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.client.base_request import ( BaseRequest, BuildRequestData, from ycm.client.base_request import ( BaseRequest, BuildRequestData,

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.client.base_request import ( BaseRequest, BuildRequestData, from ycm.client.base_request import ( BaseRequest, BuildRequestData,

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.client.completion_request import CompletionRequest from ycm.client.completion_request import CompletionRequest

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.client.base_request import BaseRequest, HandleServerException from ycm.client.base_request import BaseRequest, HandleServerException

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
import time import time

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from future.utils import iterkeys, iteritems from future.utils import iterkeys, iteritems

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from future.utils import itervalues, iteritems from future.utils import itervalues, iteritems
@ -109,8 +108,9 @@ class DiagnosticInterface( object ):
self._diag_message_needs_clearing = False self._diag_message_needs_clearing = False
return return
text = diags[ 0 ][ 'text' ] first_diag = diags[ 0 ]
if diags[ 0 ].get( 'fixit_available', False ): text = first_diag[ 'text' ]
if first_diag.get( 'fixit_available', False ):
text += ' (FixIt)' text += ' (FixIt)'
vimsupport.PostVimMessage( text, warning = False, truncate = True ) vimsupport.PostVimMessage( text, warning = False, truncate = True )
@ -133,7 +133,8 @@ def _UpdateSquiggles( buffer_number_to_line_to_diags ):
line_to_diags = buffer_number_to_line_to_diags[ vim.current.buffer.number ] line_to_diags = buffer_number_to_line_to_diags[ vim.current.buffer.number ]
for diags in itervalues( line_to_diags ): for diags in itervalues( line_to_diags ):
for diag in diags: # Insert squiggles in reverse order so that errors overlap warnings.
for diag in reversed( diags ):
location_extent = diag[ 'location_extent' ] location_extent = diag[ 'location_extent' ]
is_error = _DiagnosticIsError( diag ) is_error = _DiagnosticIsError( diag )
@ -202,23 +203,23 @@ def _GetKeptAndNewSigns( placed_signs, buffer_number_to_line_to_diags,
continue continue
for line, diags in iteritems( line_to_diags ): for line, diags in iteritems( line_to_diags ):
for diag in diags: # Only one sign is visible by line.
sign = _DiagSignPlacement( next_sign_id, first_diag = diags[ 0 ]
line, sign = _DiagSignPlacement( next_sign_id,
buffer_number, line,
_DiagnosticIsError( diag ) ) buffer_number,
if sign not in placed_signs: _DiagnosticIsError( first_diag ) )
new_signs += [ sign ] if sign not in placed_signs:
next_sign_id += 1 new_signs.append( sign )
else: next_sign_id += 1
# We use .index here because `sign` contains a new id, but else:
# we need the sign with the old id to unplace it later on. # We use .index here because `sign` contains a new id, but
# We won't be placing the new sign. # we need the sign with the old id to unplace it later on.
kept_signs += [ placed_signs[ placed_signs.index( sign ) ] ] # We won't be placing the new sign.
kept_signs.append( placed_signs[ placed_signs.index( sign ) ] )
return new_signs, kept_signs, next_sign_id return new_signs, kept_signs, next_sign_id
def _PlaceNewSigns( kept_signs, new_signs ): def _PlaceNewSigns( kept_signs, new_signs ):
placed_signs = kept_signs[:] placed_signs = kept_signs[:]
for sign in new_signs: for sign in new_signs:
@ -227,7 +228,7 @@ def _PlaceNewSigns( kept_signs, new_signs ):
if sign in placed_signs: if sign in placed_signs:
continue continue
vimsupport.PlaceSign( sign.id, sign.line, sign.buffer, sign.is_error ) vimsupport.PlaceSign( sign.id, sign.line, sign.buffer, sign.is_error )
placed_signs.append(sign) placed_signs.append( sign )
return placed_signs return placed_signs
@ -248,10 +249,10 @@ def _ConvertDiagListToDict( diag_list ):
for line_to_diags in itervalues( buffer_to_line_to_diags ): for line_to_diags in itervalues( buffer_to_line_to_diags ):
for diags in itervalues( line_to_diags ): for diags in itervalues( line_to_diags ):
# We also want errors to be listed before warnings so that errors aren't # We want errors to be listed before warnings so that errors aren't hidden
# hidden by the warnings; Vim won't place a sign oven an existing one. # by the warnings.
diags.sort( key = lambda diag: ( diag[ 'location' ][ 'column_num' ], diags.sort( key = lambda diag: ( diag[ 'kind' ],
diag[ 'kind' ] ) ) diag[ 'location' ][ 'column_num' ] ) )
return buffer_to_line_to_diags return buffer_to_line_to_diags

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
import vim import vim

View File

@ -1,4 +1,4 @@
# Copyright (C) 2015 YouCompleteMe contributors. # Copyright (C) 2015-2017 YouCompleteMe contributors.
# #
# This file is part of YouCompleteMe. # This file is part of YouCompleteMe.
# #
@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
import os import os
@ -35,7 +34,7 @@ DIR_OF_YCMD = os.path.join( DIR_OF_CURRENT_SCRIPT, '..', '..', 'third_party',
'ycmd' ) 'ycmd' )
WIN_PYTHON_PATH = os.path.join( sys.exec_prefix, 'python.exe' ) WIN_PYTHON_PATH = os.path.join( sys.exec_prefix, 'python.exe' )
PYTHON_BINARY_REGEX = re.compile( PYTHON_BINARY_REGEX = re.compile(
r'python((2(\.[67])?)|(3(\.[3-9])?))?(.exe)?$' ) r'python((2(\.[67])?)|(3(\.[3-9])?))?(.exe)?$', re.IGNORECASE )
def Memoize( obj ): def Memoize( obj ):
@ -52,19 +51,20 @@ def Memoize( obj ):
@Memoize @Memoize
def PathToPythonInterpreter(): def PathToPythonInterpreter():
# Not calling the Python interpreter to check its version as it significantly
# impacts startup time.
from ycmd import utils from ycmd import utils
python_interpreter = vim.eval( 'g:ycm_server_python_interpreter' ) python_interpreter = vim.eval( 'g:ycm_server_python_interpreter' )
if python_interpreter: if python_interpreter:
if IsPythonVersionCorrect( python_interpreter ): if _EndsWithPython( python_interpreter ):
return python_interpreter return python_interpreter
raise RuntimeError( "Path in 'g:ycm_server_python_interpreter' option " raise RuntimeError( "Path in 'g:ycm_server_python_interpreter' option "
"does not point to a valid Python 2.6+ or 3.3+." ) "does not point to a valid Python 2.6+ or 3.3+." )
python_interpreter = _PathToPythonUsedDuringBuild() python_interpreter = _PathToPythonUsedDuringBuild()
if IsPythonVersionCorrect( python_interpreter ): if _EndsWithPython( python_interpreter ):
return python_interpreter return python_interpreter
# On UNIX platforms, we use sys.executable as the Python interpreter path. # On UNIX platforms, we use sys.executable as the Python interpreter path.
@ -73,8 +73,7 @@ def PathToPythonInterpreter():
# interpreter path. # interpreter path.
python_interpreter = ( WIN_PYTHON_PATH if utils.OnWindows() else python_interpreter = ( WIN_PYTHON_PATH if utils.OnWindows() else
sys.executable ) sys.executable )
if _EndsWithPython( python_interpreter ):
if IsPythonVersionCorrect( python_interpreter ):
return python_interpreter return python_interpreter
# As a last resort, we search python in the PATH. We prefer Python 2 over 3 # As a last resort, we search python in the PATH. We prefer Python 2 over 3
@ -85,8 +84,7 @@ def PathToPythonInterpreter():
python_interpreter = utils.PathToFirstExistingExecutable( [ 'python2', python_interpreter = utils.PathToFirstExistingExecutable( [ 'python2',
'python', 'python',
'python3' ] ) 'python3' ] )
if python_interpreter:
if IsPythonVersionCorrect( python_interpreter ):
return python_interpreter return python_interpreter
raise RuntimeError( "Cannot find Python 2.6+ or 3.3+. You can set its path " raise RuntimeError( "Cannot find Python 2.6+ or 3.3+. You can set its path "
@ -105,34 +103,10 @@ def _PathToPythonUsedDuringBuild():
return None return None
def EndsWithPython( path ): def _EndsWithPython( path ):
"""Check if given path ends with a python 2.6+ or 3.3+ name.""" """Check if given path ends with a python 2.6+ or 3.3+ name."""
return path and PYTHON_BINARY_REGEX.search( path ) is not None return path and PYTHON_BINARY_REGEX.search( path ) is not None
def IsPythonVersionCorrect( path ):
"""Check if given path is the Python interpreter version 2.6+ or 3.3+."""
from ycmd import utils
if not EndsWithPython( path ):
return False
command = [ path,
# Disable site customize. Faster, and less likely to encounter
# issues with disconnected mounts (nfs, fuse, etc.)
'-S',
'-c',
"import sys;"
"major, minor = sys.version_info[ :2 ];"
"good_python = ( major == 2 and minor >= 6 ) "
"or ( major == 3 and minor >= 3 ) or major > 3;"
# If this looks weird, remember that:
# int( True ) == 1
# int( False ) == 0
"sys.exit( not good_python )" ]
return utils.SafePopen( command ).wait() == 0
def PathToServerScript(): def PathToServerScript():
return os.path.join( DIR_OF_YCMD, 'ycmd' ) return os.path.join( DIR_OF_YCMD, 'ycmd' )

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from future.utils import itervalues from future.utils import itervalues

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.tests.test_utils import MockVimModule from ycm.tests.test_utils import MockVimModule

View File

@ -22,8 +22,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
import contextlib import contextlib

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.tests.test_utils import ExtendedMock, MockVimModule from ycm.tests.test_utils import ExtendedMock, MockVimModule

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from nose.tools import eq_ from nose.tools import eq_

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from copy import deepcopy from copy import deepcopy

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from mock import MagicMock from mock import MagicMock

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.tests.test_utils import ( MockVimModule, MockVimBuffers, VimBuffer ) from ycm.tests.test_utils import ( MockVimModule, MockVimBuffers, VimBuffer )

View File

@ -21,8 +21,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.tests.test_utils import ( CurrentWorkingDirectory, ExtendedMock, from ycm.tests.test_utils import ( CurrentWorkingDirectory, ExtendedMock,

View File

@ -19,8 +19,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.tests.test_utils import MockVimModule from ycm.tests.test_utils import MockVimModule

View File

@ -21,8 +21,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.tests.test_utils import ( CurrentWorkingDirectory, ExtendedMock, from ycm.tests.test_utils import ( CurrentWorkingDirectory, ExtendedMock,
@ -49,8 +48,8 @@ def PresentDialog_Confirm_Call( message ):
def PlaceSign_Call( sign_id, line_num, buffer_num, is_error ): def PlaceSign_Call( sign_id, line_num, buffer_num, is_error ):
sign_name = 'YcmError' if is_error else 'YcmWarning' sign_name = 'YcmError' if is_error else 'YcmWarning'
return call( 'sign place {0} line={1} name={2} buffer={3}' return call( 'sign place {0} name={1} line={2} buffer={3}'
.format( sign_id, line_num, sign_name, buffer_num ) ) .format( sign_id, sign_name, line_num, buffer_num ) )
def UnplaceSign_Call( sign_id, buffer_num ): def UnplaceSign_Call( sign_id, buffer_num ):

View File

@ -21,11 +21,10 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from future.utils import PY2
from future.utils import PY2
from mock import patch, call from mock import patch, call
from nose.tools import eq_ from nose.tools import eq_
from hamcrest import contains_string from hamcrest import contains_string

View File

@ -1,4 +1,4 @@
# Copyright (C) 2016 YouCompleteMe contributors # Copyright (C) 2016-2017 YouCompleteMe contributors
# #
# This file is part of YouCompleteMe. # This file is part of YouCompleteMe.
# #
@ -19,23 +19,24 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.tests.test_utils import MockVimModule from ycm.tests.test_utils import MockVimModule
MockVimModule() MockVimModule()
from nose.tools import ok_ from nose.tools import ok_
from ycm.paths import EndsWithPython from ycm.paths import _EndsWithPython
def EndsWithPython_Good( path ): def EndsWithPython_Good( path ):
ok_( EndsWithPython( path ) ) ok_( _EndsWithPython( path ),
'Path {0} does not end with a Python name.'.format( path ) )
def EndsWithPython_Bad( path ): def EndsWithPython_Bad( path ):
ok_( not EndsWithPython( path ) ) ok_( not _EndsWithPython( path ),
'Path {0} does end with a Python name.'.format( path ) )
def EndsWithPython_Python2Paths_test(): def EndsWithPython_Python2Paths_test():
@ -44,14 +45,14 @@ def EndsWithPython_Python2Paths_test():
'python2', 'python2',
'/usr/bin/python2.6', '/usr/bin/python2.6',
'/home/user/.pyenv/shims/python2.7', '/home/user/.pyenv/shims/python2.7',
r'C:\Python26\python.exe' r'C:\Python26\python.exe',
'/Contents/MacOS/Python'
] ]
for path in python_paths: for path in python_paths:
yield EndsWithPython_Good, path yield EndsWithPython_Good, path
def EndsWithPython_Python3Paths_test(): def EndsWithPython_Python3Paths_test():
python_paths = [ python_paths = [
'python3', 'python3',

View File

@ -21,8 +21,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.tests.test_utils import MockVimModule from ycm.tests.test_utils import MockVimModule

View File

@ -20,8 +20,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.tests.test_utils import MockVimModule from ycm.tests.test_utils import MockVimModule

View File

@ -20,8 +20,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from mock import MagicMock, patch from mock import MagicMock, patch
@ -42,6 +41,9 @@ BWIPEOUT_REGEX = re.compile(
'^(?:silent! )bwipeout!? (?P<buffer_number>[0-9]+)$' ) '^(?:silent! )bwipeout!? (?P<buffer_number>[0-9]+)$' )
GETBUFVAR_REGEX = re.compile( GETBUFVAR_REGEX = re.compile(
'^getbufvar\((?P<buffer_number>[0-9]+), "&(?P<option>.+)"\)$' ) '^getbufvar\((?P<buffer_number>[0-9]+), "&(?P<option>.+)"\)$' )
MATCHADD_REGEX = re.compile(
'^matchadd\(\'(?P<group>.+)\', \'(?P<pattern>.+)\'\)$' )
MATCHDELETE_REGEX = re.compile( '^matchdelete\((?P<id>)\)$' )
# One-and only instance of mocked Vim object. The first 'import vim' that is # One-and only instance of mocked Vim object. The first 'import vim' that is
# executed binds the vim module to the instance of MagicMock that is created, # executed binds the vim module to the instance of MagicMock that is created,
@ -53,6 +55,8 @@ GETBUFVAR_REGEX = re.compile(
# https://github.com/Valloric/YouCompleteMe/pull/1694 # https://github.com/Valloric/YouCompleteMe/pull/1694
VIM_MOCK = MagicMock() VIM_MOCK = MagicMock()
VIM_MATCHES = []
@contextlib.contextmanager @contextlib.contextmanager
def CurrentWorkingDirectory( path ): def CurrentWorkingDirectory( path ):
@ -131,6 +135,30 @@ def _MockVimOptionsEval( value ):
return None return None
def _MockVimMatchEval( value ):
if value == 'getmatches()':
return VIM_MATCHES
match = MATCHADD_REGEX.search( value )
if match:
group = match.group( 'group' )
option = match.group( 'pattern' )
vim_match = VimMatch( group, option )
VIM_MATCHES.append( vim_match )
return vim_match.id
match = MATCHDELETE_REGEX.search( value )
if match:
identity = match.group( 'id' )
for index, vim_match in enumerate( VIM_MATCHES ):
if vim_match.id == identity:
VIM_MATCHES.pop( index )
return -1
return 0
return None
def _MockVimEval( value ): def _MockVimEval( value ):
if value == 'g:ycm_min_num_of_chars_for_completion': if value == 'g:ycm_min_num_of_chars_for_completion':
return 0 return 0
@ -155,6 +183,10 @@ def _MockVimEval( value ):
if result is not None: if result is not None:
return result return result
result = _MockVimMatchEval( value )
if result is not None:
return result
raise ValueError( 'Unexpected evaluation: {0}'.format( value ) ) raise ValueError( 'Unexpected evaluation: {0}'.format( value ) )
@ -218,6 +250,23 @@ class VimBuffer( object ):
return [ ToUnicode( x ) for x in self.contents ] return [ ToUnicode( x ) for x in self.contents ]
class VimMatch( object ):
def __init__( self, group, pattern ):
self.id = len( VIM_MATCHES )
self.group = group
self.pattern = pattern
def __eq__( self, other ):
return self.group == other.group and self.pattern == other.pattern
def __repr__( self ):
return "VimMatch( group = '{0}', pattern = '{1}' )".format( self.group,
self.pattern )
@contextlib.contextmanager @contextlib.contextmanager
def MockVimBuffers( buffers, current_buffer, cursor_position = ( 1, 1 ) ): def MockVimBuffers( buffers, current_buffer, cursor_position = ( 1, 1 ) ):
"""Simulates the Vim buffers list |buffers| where |current_buffer| is the """Simulates the Vim buffers list |buffers| where |current_buffer| is the

View File

@ -21,8 +21,7 @@
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.tests import PathToTestFile from ycm.tests import PathToTestFile

View File

@ -19,12 +19,11 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from ycm.tests.test_utils import ( ExtendedMock, MockVimBuffers, MockVimModule, from ycm.tests.test_utils import ( ExtendedMock, MockVimBuffers, MockVimModule,
VimBuffer ) VimBuffer, VimMatch )
MockVimModule() MockVimModule()
import os import os
@ -33,7 +32,7 @@ from hamcrest import ( assert_that, contains, empty, is_in, is_not, has_length,
matches_regexp ) matches_regexp )
from mock import call, MagicMock, patch from mock import call, MagicMock, patch
from ycm.tests import StopServer, YouCompleteMeInstance from ycm.tests import StopServer, test_utils, YouCompleteMeInstance
from ycm.client.base_request import _LoadExtraConfFile from ycm.client.base_request import _LoadExtraConfFile
from ycmd.responses import ServerError from ycmd.responses import ServerError
@ -360,8 +359,8 @@ def YouCompleteMe_ShowDiagnostics_DiagnosticsFound_DoNotOpenLocationList_test(
'text': 'error text', 'text': 'error text',
'location': { 'location': {
'filepath': 'buffer', 'filepath': 'buffer',
'column_num': 2, 'line_num': 19,
'line_num': 19 'column_num': 2
} }
} }
@ -400,8 +399,8 @@ def YouCompleteMe_ShowDiagnostics_DiagnosticsFound_OpenLocationList_test(
'text': 'error text', 'text': 'error text',
'location': { 'location': {
'filepath': 'buffer', 'filepath': 'buffer',
'column_num': 2, 'line_num': 19,
'line_num': 19 'column_num': 2
} }
} }
@ -425,3 +424,120 @@ def YouCompleteMe_ShowDiagnostics_DiagnosticsFound_OpenLocationList_test(
'valid': 1 'valid': 1
} ] ) } ] )
open_location_list.assert_called_once_with( focus = True ) open_location_list.assert_called_once_with( focus = True )
@YouCompleteMeInstance( { 'echo_current_diagnostic': 1,
'enable_diagnostic_signs': 1,
'enable_diagnostic_highlighting': 1 } )
@patch( 'ycm.youcompleteme.YouCompleteMe.FiletypeCompleterExistsForFiletype',
return_value = True )
@patch( 'ycm.vimsupport.PostVimMessage', new_callable = ExtendedMock )
@patch( 'vim.command', new_callable = ExtendedMock )
def YouCompleteMe_UpdateDiagnosticInterface_PrioritizeErrorsOverWarnings_test(
ycm, vim_command, post_vim_message, *args ):
contents = """int main() {
int x, y;
x == y
}"""
# List of diagnostics returned by ycmd for the above code.
diagnostics = [ {
'kind': 'ERROR',
'text': "expected ';' after expression",
'location': {
'filepath': 'buffer',
'line_num': 3,
'column_num': 9
},
# Looks strange but this is really what ycmd is returning.
'location_extent': {
'start': {
'filepath': '',
'line_num': 0,
'column_num': 0,
},
'end': {
'filepath': '',
'line_num': 0,
'column_num': 0,
}
},
'ranges': [],
'fixit_available': True
}, {
'kind': 'WARNING',
'text': 'equality comparison result unused',
'location': {
'filepath': 'buffer',
'line_num': 3,
'column_num': 7,
},
'location_extent': {
'start': {
'filepath': 'buffer',
'line_num': 3,
'column_num': 5,
},
'end': {
'filepath': 'buffer',
'line_num': 3,
'column_num': 7,
}
},
'ranges': [ {
'start': {
'filepath': 'buffer',
'line_num': 3,
'column_num': 3,
},
'end': {
'filepath': 'buffer',
'line_num': 3,
'column_num': 9,
}
} ],
'fixit_available': True
} ]
current_buffer = VimBuffer( 'buffer',
filetype = 'c',
contents = contents.splitlines(),
number = 5,
window = 2 )
test_utils.VIM_MATCHES = []
with MockVimBuffers( [ current_buffer ], current_buffer, ( 3, 1 ) ):
with patch( 'ycm.client.event_notification.EventNotification.Response',
return_value = diagnostics ):
ycm.OnFileReadyToParse()
ycm.HandleFileParseRequest( block = True )
# Error match is added after warning matches.
assert_that(
test_utils.VIM_MATCHES,
contains(
VimMatch( 'YcmWarningSection', '\%3l\%5c\_.\{-}\%3l\%7c' ),
VimMatch( 'YcmWarningSection', '\%3l\%3c\_.\{-}\%3l\%9c' ),
# FIXME: match should be inserted at the end of line 3 (missing ";").
VimMatch( 'YcmErrorSection', '\%0l\%0c' )
)
)
# Only the error sign is placed.
vim_command.assert_has_exact_calls( [
call( 'sign define ycm_dummy_sign' ),
call( 'sign place 3 name=ycm_dummy_sign line=3 buffer=5' ),
call( 'sign place 1 name=YcmError line=3 buffer=5' ),
call( 'sign undefine ycm_dummy_sign' ),
call( 'sign unplace 3 buffer=5' )
] )
# When moving the cursor on the diagnostics, the error is displayed to the
# user, not the warning.
ycm.OnCursorMoved()
post_vim_message.assert_has_exact_calls( [
call( "expected ';' after expression (FixIt)",
truncate = True, warning = False )
] )

View File

@ -20,8 +20,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from future.utils import iterkeys from future.utils import iterkeys
@ -176,8 +175,8 @@ def PlaceSign( sign_id, line_num, buffer_num, is_error = True ):
line_num = 1 line_num = 1
sign_name = 'YcmError' if is_error else 'YcmWarning' sign_name = 'YcmError' if is_error else 'YcmWarning'
vim.command( 'sign place {0} line={1} name={2} buffer={3}'.format( vim.command( 'sign place {0} name={1} line={2} buffer={3}'.format(
sign_id, line_num, sign_name, buffer_num ) ) sign_id, sign_name, line_num, buffer_num ) )
def PlaceDummySign( sign_id, buffer_num, line_num ): def PlaceDummySign( sign_id, buffer_num, line_num ):

View File

@ -20,8 +20,7 @@ from __future__ import unicode_literals
from __future__ import print_function from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from future import standard_library # Not installing aliases from python-future; it's unreliable and slow.
standard_library.install_aliases()
from builtins import * # noqa from builtins import * # noqa
from future.utils import iteritems from future.utils import iteritems
@ -101,7 +100,8 @@ CORE_OUTDATED_MESSAGE = (
'YCM core library too old; PLEASE RECOMPILE by running the install.py ' 'YCM core library too old; PLEASE RECOMPILE by running the install.py '
'script. See the documentation for more details.' ) 'script. See the documentation for more details.' )
SERVER_IDLE_SUICIDE_SECONDS = 10800 # 3 hours SERVER_IDLE_SUICIDE_SECONDS = 10800 # 3 hours
DIAGNOSTIC_UI_FILETYPES = set( [ 'cpp', 'cs', 'c', 'objc', 'objcpp' ] ) DIAGNOSTIC_UI_FILETYPES = set( [ 'cpp', 'cs', 'c', 'objc', 'objcpp',
'typescript' ] )
CLIENT_LOGFILE_FORMAT = 'ycm_' CLIENT_LOGFILE_FORMAT = 'ycm_'
SERVER_LOGFILE_FORMAT = 'ycmd_{port}_{std}_' SERVER_LOGFILE_FORMAT = 'ycmd_{port}_{std}_'

2
third_party/ycmd vendored

@ -1 +1 @@
Subproject commit ec7a154f8fe50c071ecd0ac6841de8a50ce92f5d Subproject commit 13da3d47255d559308b946242e508d3531dabda5