From d8d021537b9ceadd8f8ec17d2f30c0b1f2b2f37c Mon Sep 17 00:00:00 2001 From: micbou Date: Sat, 17 Nov 2018 13:01:15 +0100 Subject: [PATCH 1/3] Update ycmd Include the following changes: - replace Boost canonical function with our own implementation; - improve filename completer; - support completion FixIts for C-family languages; - update jdt.ls to 0.26.0; - install fixed version of TypeScript in third-party folder; - only add the necessary directories to Python path. --- third_party/ycmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/ycmd b/third_party/ycmd index ae8a33f8..0e999dbe 160000 --- a/third_party/ycmd +++ b/third_party/ycmd @@ -1 +1 @@ -Subproject commit ae8a33f87a116092639ba164a712960886890a1c +Subproject commit 0e999dbee209ea79a522259816ce3a68b7d6cddc From 4b4f678bef2e91bc26ab004a94701136af6711ba Mon Sep 17 00:00:00 2001 From: micbou Date: Fri, 17 Aug 2018 04:36:27 +0200 Subject: [PATCH 2/3] Support completion FixIts for C-family languages --- README.md | 2 +- doc/youcompleteme.txt | 4 +- python/ycm/client/completion_request.py | 21 ++------- python/ycm/tests/postcomplete_test.py | 60 +++++++------------------ 4 files changed, 24 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 1aaabc6d..6a26d576 100644 --- a/README.md +++ b/README.md @@ -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`) diff --git a/doc/youcompleteme.txt b/doc/youcompleteme.txt index 30632ee3..18d800e5 100644 --- a/doc/youcompleteme.txt +++ b/doc/youcompleteme.txt @@ -920,7 +920,7 @@ General (all languages) ~ *youcompleteme-c-family-languages* 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|) @@ -3630,7 +3630,7 @@ http://valloric.github.io/YouCompleteMe/. The author's homepage is http://val.markovic.io. Please do **NOT** go to #vim on freenode for support. Please contact the -YouCompleteMe maintainers directly using the contact details below. +YouCompleteMe maintainers directly using the contact details. =============================================================================== *youcompleteme-license* diff --git a/python/ycm/client/completion_request.py b/python/ycm/client/completion_request.py index 4729571d..7f5af13d 100644 --- a/python/ycm/client/completion_request.py +++ b/python/ycm/client/completion_request.py @@ -23,7 +23,6 @@ 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 ) @@ -38,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 ): @@ -88,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 ): diff --git a/python/ycm/tests/postcomplete_test.py b/python/ycm/tests/postcomplete_test.py index 515bea2e..27801e2d 100644 --- a/python/ycm/tests/postcomplete_test.py +++ b/python/ycm/tests/postcomplete_test.py @@ -129,63 +129,37 @@ def _SetUpCompleteDone( completions ): yield request -@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'cs' ] ) -def GetCompleteDoneHooks_ResultOnCsharp_test( *args ): - request = CompletionRequest( None ) - result = list( request._GetCompleteDoneHooks() ) - eq_( result, [ request._OnCompleteDone_Csharp ] ) - - -@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'java' ] ) -def GetCompleteDoneHooks_ResultOnJava_test( *args ): - request = CompletionRequest( None ) - result = list( request._GetCompleteDoneHooks() ) - eq_( result, [ request._OnCompleteDone_FixIt ] ) - - -@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'typescript' ] ) -def GetCompleteDoneHooks_ResultOnTypeScript_test( *args ): - request = CompletionRequest( None ) - result = list( request._GetCompleteDoneHooks() ) - eq_( result, [ request._OnCompleteDone_FixIt ] ) - - @patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'ycmtest' ] ) -def GetCompleteDoneHooks_EmptyOnOtherFiletype_test( *args ): - request = CompletionRequest( None ) - result = request._GetCompleteDoneHooks() - eq_( len( list( result ) ), 0 ) - - -@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'ycmtest' ] ) -def OnCompleteDone_WithActionCallsIt_test( *args ): - request = CompletionRequest( None ) - request.Done = MagicMock( return_value = True ) - action = MagicMock() - request._complete_done_hooks[ 'ycmtest' ] = action - request.OnCompleteDone() - ok_( action.called ) - - -@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'ycmtest' ] ) -def OnCompleteDone_NoActionNoError_test( *args ): +def OnCompleteDone_DefaultFixIt_test( *args ): request = CompletionRequest( None ) request.Done = MagicMock( return_value = True ) request._OnCompleteDone_Csharp = MagicMock() request._OnCompleteDone_FixIt = MagicMock() request.OnCompleteDone() request._OnCompleteDone_Csharp.assert_not_called() + request._OnCompleteDone_FixIt.assert_called_once_with() + + +@patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'cs' ] ) +def OnCompleteDone_CsharpFixIt_test( *args ): + request = CompletionRequest( None ) + request.Done = MagicMock( return_value = True ) + request._OnCompleteDone_Csharp = MagicMock() + request._OnCompleteDone_FixIt = MagicMock() + request.OnCompleteDone() + request._OnCompleteDone_Csharp.assert_called_once_with() request._OnCompleteDone_FixIt.assert_not_called() @patch( 'ycm.vimsupport.CurrentFiletypes', return_value = [ 'ycmtest' ] ) -def OnCompleteDone_NoActionIfNotDone_test( *args ): +def OnCompleteDone_NoFixItIfNotDone_test( *args ): request = CompletionRequest( None ) request.Done = MagicMock( return_value = False ) - action = MagicMock() - request._complete_done_hooks[ 'ycmtest' ] = action + request._OnCompleteDone_Csharp = MagicMock() + request._OnCompleteDone_FixIt = MagicMock() request.OnCompleteDone() - action.assert_not_called() + request._OnCompleteDone_Csharp.assert_not_called() + request._OnCompleteDone_FixIt.assert_not_called() def FilterToCompletedCompletions_MatchIsReturned_test(): From 76aa22886ff2a637fd0a73087dfae3a603ed56b0 Mon Sep 17 00:00:00 2001 From: micbou Date: Sun, 14 Oct 2018 15:19:15 +0200 Subject: [PATCH 3/3] Update TypeScript instructions in docs --- README.md | 36 +++++++++++++++--------------------- doc/youcompleteme.txt | 36 +++++++++++++++--------------------- 2 files changed, 30 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index 6a26d576..b94b7f77 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/doc/youcompleteme.txt b/doc/youcompleteme.txt index 18d800e5..bfe61b4c 100644 --- a/doc/youcompleteme.txt +++ b/doc/youcompleteme.txt @@ -410,8 +410,8 @@ The following additional language support options are available: - Go support: install Go [28] and add '--go-completer' when calling 'install.py'. -- JavaScript and TypeScript support: install Node.js and npm [29] then - install the TypeScript SDK with 'npm install -g typescript'. +- JavaScript and TypeScript support: install Node.js and npm [29] and add + '--ts-completer' when calling 'install.py'. - Rust support: install Rust [30] and add '--rust-completer' when calling 'install.py'. @@ -488,8 +488,8 @@ The following additional language support options are available: - Go support: install Go [28] and add '--go-completer' when calling 'install.py'. -- JavaScript and TypeScript support: install Node.js and npm [29] then - install the TypeScript SDK with 'npm install -g typescript'. +- JavaScript and TypeScript support: install Node.js and npm [29] and add + '--ts-completer' when calling 'install.py'. - Rust support: install Rust [30] and add '--rust-completer' when calling 'install.py'. @@ -585,8 +585,8 @@ The following additional language support options are available: - Go support: install Go [28] and add '--go-completer' when calling 'install.py'. -- JavaScript and TypeScript support: install Node.js and npm [29] then - install the TypeScript SDK with 'npm install -g typescript'. +- JavaScript and TypeScript support: install Node.js and npm [29] and add + '--ts-completer' when calling 'install.py'. - Rust support: install Rust [30] and add '--rust-completer' when calling 'install.py'. @@ -661,8 +661,8 @@ The following additional language support options are available: - Go support: install Go [28] and add '--go-completer' when calling './install.py'. -- JavaScript and TypeScript support: install Node.js and npm [29] then - install the TypeScript SDK with 'npm install -g typescript'. +- JavaScript and TypeScript support: install Node.js and npm [29] and add + '--ts-completer' when calling 'install.py'. - Rust support: install Rust [30] and add '--rust-completer' when calling './install.py'. @@ -878,9 +878,9 @@ will notify you to recompile it. You should then rerun the install process. '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 [29]. + - JavaScript and TypeScript support: install Node.js and npm [29], + navigate to 'YouCompleteMe/third_party/ycmd' and run 'npm install -g + --prefix third_party/tsserver typescript'. - Rust support: install Rust [30]. Navigate to 'YouCompleteMe/third_party/ycmd/third_party/racerd' and run 'cargo @@ -1514,11 +1514,10 @@ installation. Further instructions on how to setup YCM with Tern [63] are available on the wiki [64]. All JavaScript and TypeScript features are provided by the TSServer [16] -engine, which is included in the TypeScript SDK. To get the SDK, install -Node.js and npm [29] and run the command: -> - npm install -g typescript -< +engine, which is included in the TypeScript SDK. To enable these features, +install Node.js and npm [29] and call the 'install.py' script with the '--ts- +completer' flag. + TSServer [16] relies on the 'jsconfig.json' file [65] for JavaScript and the 'tsconfig.json' file [66] for TypeScript to analyze your project. Ensure the file exists at the root of your project. @@ -1532,11 +1531,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|. If the version is 'None', your TypeScript is -too old and should be updated. - ------------------------------------------------------------------------------- *youcompleteme-semantic-completion-for-other-languages* Semantic Completion for Other Languages ~