Skip to content

Commit 8872535

Browse files
fixed #13 issue (initial sublime text freezing), fixed #34 issue ((Not working) 'Create class from object literal'), fixed #30 issue (Global autocompletions aren't loaded)
1 parent 381ccd4 commit 8872535

4 files changed

+28
-4
lines changed

_generated_2017_03_05_at_21_51_28.py _generated_2017_03_30_at_17_44_57.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -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

8989
mainPlugin = startPlugin()
9090

91+
import json
92+
9193
JC_SETTINGS_FOLDER_NAME = "javascript_completions"
9294
JC_SETTINGS_FOLDER = os.path.join(PACKAGE_PATH, JC_SETTINGS_FOLDER_NAME)
9395

9496
class 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

helper/create_class_from_object_literal_command.py

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import re
2+
13
class create_class_from_object_literalCommand(sublime_plugin.TextCommand):
24
def run(self, edit, **args):
35
view = self.view
@@ -15,6 +17,7 @@ def run(self, edit, **args):
1517
object_literal = item_object_literal.get("region_string_stripped")
1618
from node.main import NodeJS
1719
node = NodeJS()
20+
object_literal = re.sub(r'[\n\r\t]', ' ', object_literal)
1821
object_literal = json.loads(node.eval("JSON.stringify("+object_literal+")", "print"))
1922
object_literal = [(key, json.dumps(value)) for key, value in object_literal.items()]
2023

Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1+
import json
2+
13
JC_SETTINGS_FOLDER_NAME = "javascript_completions"
24
JC_SETTINGS_FOLDER = os.path.join(PACKAGE_PATH, JC_SETTINGS_FOLDER_NAME)
35

46
class JavaScriptCompletions():
57
def init(self):
68
self.api = {}
79
self.API_Setup = sublime.load_settings('JavaScript-Completions.sublime-settings').get('completion_active_list')
10+
sublime.set_timeout_async(self.load_api)
811

12+
def load_api(self):
913
# Caching completions
1014
if self.API_Setup:
1115
for API_Keyword in self.API_Setup:
12-
self.api[API_Keyword] = sublime.load_settings( API_Keyword + '.sublime-settings')
16+
self.api[API_Keyword] = sublime.load_settings( API_Keyword + '.sublime-settings' )
17+
if self.api[API_Keyword].get("scope") == None :
18+
path_to_json = os.path.join(PACKAGE_PATH, "sublime-completions", API_Keyword + '.sublime-settings' )
19+
if os.path.isfile(path_to_json):
20+
with open(path_to_json) as json_file:
21+
self.api[API_Keyword] = json.load(json_file)
1322

1423
def get(self, key):
1524
return sublime.load_settings('JavaScript-Completions.sublime-settings').get(key)

make/_init.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ 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

8989
mainPlugin = startPlugin()
9090

0 commit comments

Comments
 (0)