@@ -84,22 +84,31 @@ def init(self):
84
84
85
85
if int (sublime .version ()) >= 3000 :
86
86
87
- installer .install (node_variables .NODE_JS_VERSION )
87
+ sublime . set_timeout_async ( lambda : installer .install (node_variables .NODE_JS_VERSION ) )
88
88
89
89
mainPlugin = startPlugin ()
90
90
91
+ import json
92
+
91
93
JC_SETTINGS_FOLDER_NAME = "javascript_completions"
92
94
JC_SETTINGS_FOLDER = os .path .join (PACKAGE_PATH , JC_SETTINGS_FOLDER_NAME )
93
95
94
96
class JavaScriptCompletions ():
95
97
def init (self ):
96
98
self .api = {}
97
99
self .API_Setup = sublime .load_settings ('JavaScript-Completions.sublime-settings' ).get ('completion_active_list' )
100
+ sublime .set_timeout_async (self .load_api )
98
101
102
+ def load_api (self ):
99
103
# Caching completions
100
104
if self .API_Setup :
101
105
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 )
103
112
104
113
def get (self , key ):
105
114
return sublime .load_settings ('JavaScript-Completions.sublime-settings' ).get (key )
@@ -1109,6 +1118,8 @@ def is_visible(self, **args) :
1109
1118
return False
1110
1119
return True
1111
1120
1121
+ import re
1122
+
1112
1123
class create_class_from_object_literalCommand (sublime_plugin .TextCommand ):
1113
1124
def run (self , edit , ** args ):
1114
1125
view = self .view
@@ -1126,6 +1137,7 @@ def run(self, edit, **args):
1126
1137
object_literal = item_object_literal .get ("region_string_stripped" )
1127
1138
from node .main import NodeJS
1128
1139
node = NodeJS ()
1140
+ object_literal = re .sub (r'[\n\r\t]' , ' ' , object_literal )
1129
1141
object_literal = json .loads (node .eval ("JSON.stringify(" + object_literal + ")" , "print" ))
1130
1142
object_literal = [(key , json .dumps (value )) for key , value in object_literal .items ()]
1131
1143
0 commit comments