Skip to content

Commit 76f06e5

Browse files
committed
Provide a setting to disable tern
1 parent 34a9380 commit 76f06e5

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

ycmd/completers/javascript/hook.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323

2424
def GetCompleter( user_options ):
25-
if ShouldEnableTernCompleter():
25+
if ShouldEnableTernCompleter( user_options ):
2626
return TernCompleter( user_options )
2727
if ShouldEnableTypeScriptCompleter( user_options ):
2828
return TypeScriptCompleter( user_options )

ycmd/completers/javascript/tern_completer.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,16 @@
5454
LOGFILE_FORMAT = 'tern_{port}_{std}_'
5555

5656

57-
def ShouldEnableTernCompleter():
57+
def ShouldEnableTernCompleter( user_options ):
5858
"""Returns whether or not the tern completer is 'installed'. That is whether
5959
or not the tern submodule has a 'node_modules' directory. This is pretty much
6060
the only way we can know if the user added '--js-completer' on
6161
install or manually ran 'npm install' in the tern submodule directory."""
6262

63+
if user_options.get( 'disable_tern' ):
64+
LOGGER.info( 'Not using Tern completer: disabled by user' )
65+
return False
66+
6367
if not PATH_TO_NODE:
6468
LOGGER.warning( 'Not using Tern completer: unable to find node' )
6569
return False

ycmd/tests/javascript/__init__.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ def setUpModule():
3939
subserver, should be done here."""
4040
global shared_app
4141

42-
with patch( 'ycmd.completers.javascript.hook.'
43-
'ShouldEnableTernCompleter', return_value = False ):
44-
shared_app = SetUpApp()
45-
WaitUntilCompleterServerReady( shared_app, 'javascript' )
42+
shared_app = SetUpApp( { 'disable_tern': True } )
43+
WaitUntilCompleterServerReady( shared_app, 'javascript' )
4644

4745

4846
def tearDownModule():

0 commit comments

Comments
 (0)