@@ -394,26 +394,27 @@ def getSublimeScope(view):
394394 return view .scope_name (pos )
395395
396396
397+ source_scopes = {
398+ "json" : "JSON" ,
399+ "js" : "JavaScript" ,
400+ "python.3" : "Python3" ,
401+ "python" : "Python" ,
402+ "php" : "PHP" ,
403+ "perl" : "Perl" ,
404+ "ruby" : "Ruby"
405+ }
406+
407+ # order is important - longest keys first
408+ ordered_checks = OrderedDict (sorted (source_scopes .items (), key = lambda t : len (t [0 ]), reverse = True ))
409+
410+
397411def guess_lang (view = None , path = None , sublime_scope = None ):
398- if not view or not codeintel_enabled ( view ) :
412+ if not view :
399413 return None
400414
401415 #######################################
402416 # try to guess lang using sublime scope
403417
404- source_scopes = {
405- "json" : "JSON" ,
406- "js" : "JavaScript" ,
407- "python.3" : "Python3" ,
408- "python" : "Python" ,
409- "php" : "PHP" ,
410- "perl" : "Perl" ,
411- "ruby" : "Ruby"
412- }
413-
414- # order is important - longest keys first
415- ordered_checks = OrderedDict (sorted (source_scopes .items (), key = lambda t : len (t [0 ]), reverse = True ))
416-
417418 scopes = sublime_scope if sublime_scope else getSublimeScope (view )
418419 if scopes :
419420 for scope in scopes .split (" " ):
@@ -422,6 +423,12 @@ def guess_lang(view=None, path=None, sublime_scope=None):
422423 if scope [7 :].startswith (check ):
423424 return source_scopes [check ]
424425
426+ if 'text.plain' in scopes :
427+ return None
428+
429+ if not codeintel_enabled (view ):
430+ return None
431+
425432 # check for html
426433 if "text.html" in scopes :
427434 return "HTML"
@@ -1442,15 +1449,19 @@ def on_close(self, view):
14421449
14431450 def on_modified (self , view ):
14441451 view_sel = view .sel ()
1445- settings_manager .update ()
1446-
1447- if not view_sel or settings_manager .sublime_auto_complete is None :
1452+ if not view_sel :
14481453 return
14491454
14501455 sublime_scope = getSublimeScope (view )
1451-
14521456 path = view .file_name ()
14531457 lang = guess_lang (view , path , sublime_scope )
1458+ if not lang :
1459+ return
1460+
1461+ settings_manager .update ()
1462+
1463+ if settings_manager .sublime_auto_complete is None :
1464+ return
14541465
14551466 exclude_scopes = settings_manager .get ("codeintel_exclude_scopes_from_complete_triggers" , language = lang , default = [])
14561467
@@ -1465,8 +1476,7 @@ def on_modified(self, view):
14651476 # if live completion is disabled, we're wrong here!
14661477 return
14671478
1468- if not settings_manager .get ('codeintel_live' , default = True , language = lang ):
1469- # if live completion is disabled, we're wrong here!
1479+ if lang .lower () not in [l .lower () for l in settings_manager .get ('codeintel_enabled_languages' , [])]:
14701480 return
14711481
14721482 # disable sublime's auto_complete for now / this is for files with
0 commit comments