@@ -84,22 +84,31 @@ def init(self):
8484
8585 if int (sublime .version ()) >= 3000 :
8686
87- installer .install (node_variables .NODE_JS_VERSION )
87+ sublime . set_timeout_async ( lambda : installer .install (node_variables .NODE_JS_VERSION ) )
8888
8989mainPlugin = startPlugin ()
9090
91+ import json
92+
9193JC_SETTINGS_FOLDER_NAME = "javascript_completions"
9294JC_SETTINGS_FOLDER = os .path .join (PACKAGE_PATH , JC_SETTINGS_FOLDER_NAME )
9395
9496class JavaScriptCompletions ():
9597 def init (self ):
9698 self .api = {}
9799 self .API_Setup = sublime .load_settings ('JavaScript-Completions.sublime-settings' ).get ('completion_active_list' )
100+ sublime .set_timeout_async (self .load_api )
98101
102+ def load_api (self ):
99103 # Caching completions
100104 if self .API_Setup :
101105 for API_Keyword in self .API_Setup :
102- self .api [API_Keyword ] = sublime .load_settings ( API_Keyword + '.sublime-settings' )
106+ self .api [API_Keyword ] = sublime .load_settings ( API_Keyword + '.sublime-settings' )
107+ if self .api [API_Keyword ].get ("scope" ) == None :
108+ path_to_json = os .path .join (PACKAGE_PATH , "sublime-completions" , API_Keyword + '.sublime-settings' )
109+ if os .path .isfile (path_to_json ):
110+ with open (path_to_json ) as json_file :
111+ self .api [API_Keyword ] = json .load (json_file )
103112
104113 def get (self , key ):
105114 return sublime .load_settings ('JavaScript-Completions.sublime-settings' ).get (key )
@@ -1109,6 +1118,8 @@ def is_visible(self, **args) :
11091118 return False
11101119 return True
11111120
1121+ import re
1122+
11121123 class create_class_from_object_literalCommand (sublime_plugin .TextCommand ):
11131124 def run (self , edit , ** args ):
11141125 view = self .view
@@ -1126,6 +1137,7 @@ def run(self, edit, **args):
11261137 object_literal = item_object_literal .get ("region_string_stripped" )
11271138 from node .main import NodeJS
11281139 node = NodeJS ()
1140+ object_literal = re .sub (r'[\n\r\t]' , ' ' , object_literal )
11291141 object_literal = json .loads (node .eval ("JSON.stringify(" + object_literal + ")" , "print" ))
11301142 object_literal = [(key , json .dumps (value )) for key , value in object_literal .items ()]
11311143
0 commit comments