Skip to content

Commit 8928136

Browse files
"On Hover Description" Feature, "Can I use?" Feature, "Split string lines to variable" feature, "Find JavaScript Description" feature: Search improved
1 parent 5d7b8b1 commit 8928136

17 files changed

Lines changed: 992 additions & 57 deletions

Main.sublime-menu

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[
2+
{
3+
"caption": "JavaScript Completions Tools",
4+
"mnemonic": "J",
5+
"id": "javascript_completions_tools",
6+
"children":[
7+
{
8+
"caption": "Search on \"Can I use\" list",
9+
"command": "can_i_use",
10+
"args": {"from": "main-menu"}
11+
},
12+
{ "caption": "-" },
13+
{
14+
"caption": "GitHub Project",
15+
"command": "open_url",
16+
"args": {"url": "https://github.com/pichillilorenzo/JavaScript-Completions"}
17+
}
18+
]
19+
}
20+
]

README.md

Lines changed: 74 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ It helps you to write your scripts more quickly with hints and completions.
1111
<strong>jQuery</strong> and <strong>NativeScript</strong> completions disabled by default!
1212
You can enable them on Preferences -> Package Settings -> JavaScript Completions.
1313

14+
Features list:
15+
- <a href="#find-javascript-description">"Find JavaScript Description" Feature</a>
16+
- <a href="#on-hover-description">"On Hover Description" Feature</a>
17+
- <a href="#evaluate-javascript">"Evaluate JavaScript" Feature</a>
18+
- <a href="#can-i-use">"Can I use?" Feature</a>
19+
- <a href="#context-menu-options">Context menu options</a>
20+
1421
<h2>Usage</h2>
1522

1623
To try it, just write.
@@ -32,7 +39,12 @@ Information about the description of function/property/method has been taken on
3239
- [http://api.jquery.com/](http://api.jquery.com/)
3340
- [https://docs.nativescript.org/api-reference/globals.html](https://docs.nativescript.org/api-reference/globals.html)
3441

35-
<h3>"Find JavaScript Description" Feature</h3>
42+
<h3>ENABLE or DISABLE completions</h3>
43+
44+
You can ENABLE or DISABLE completions! Just go to Preferences -> Package Settings -> JavaScript Completions
45+
46+
47+
<h3 id="find-javascript-description">"Find JavaScript Description" Feature</h3>
3648

3749
<strong>Supported only by Sublime Text 3</strong>
3850

@@ -48,7 +60,23 @@ In case, you can also use "key-map"! Just go to Preferences -> Package Settings
4860

4961
<img src="https://s17.postimg.io/pyfvf1sn3/Schermata_2016_09_18_alle_17_40_28.png" alt="example #2 Find JavaScript Description Feature">
5062

51-
<h3>"Evaluate JavaScript" Feature</h3>
63+
64+
<h3 id="on-hover-description">"On Hover Description" Feature</h3>
65+
66+
<strong>Supported only by Sublime Text 3, Build >= 3124</strong>
67+
68+
Just put the cursor over a name of a function, property or constructor and it will appear a little popup with all matching found from the <code>/sublime-completions</code> list enabled.
69+
70+
- F = function
71+
- P = property
72+
- C = constructor
73+
74+
Example:
75+
76+
<img src="https://media.giphy.com/media/l2Sq7JFMFtMJY3Eo8/giphy.gif" alt="example #1 On Hover Description Feature">
77+
78+
79+
<h3 id="evaluate-javascript">"Evaluate JavaScript" Feature</h3>
5280

5381
<strong>Supported only by Sublime Text 3</strong>
5482

@@ -84,17 +112,41 @@ In case, you can also use "key-map"! Just go to Preferences -> Package Settings
84112

85113
<img src="https://s17.postimg.io/fs79w288v/Schermata_2016_09_18_alle_18_08_55.png" alt="example #2 Evaluate JavaScript Feature">
86114

87-
<h3>ENABLE or DISABLE completions</h3>
88115

89-
You can ENABLE or DISABLE completions! Just go to Preferences -> Package Settings -> JavaScript Completions
116+
<h3 id="can-i-use">"Can I use?" Feature</h3>
117+
118+
<strong>Supported only by Sublime Text 3, Build >= 3124</strong>
90119

91-
<h3>Other Context menu options</h3>
120+
This feature uses "can i use" json data from this [repository](https://github.com/Fyrd/caniuse), that contains raw data from the [http://caniuse.com](http://caniuse.com) support tables.
121+
122+
Thanks to @Fyrd.
123+
124+
You can use this feature in HTML, CSS and JavaScript context!
125+
126+
Just put the cursor on the word you want to check, "right-click" -> <code>"Can I use?"</code> and it will appear an input panel with all items that have a name matching with the word.
127+
128+
You can use key-map: <code>ctrl+alt+w</code>. You can also change it. Just go to Preferences -> Package Settings -> JavaScript Completions Tools -> Key Bindings - User.
129+
130+
After selecting an item from the list, it will appear a popup with all information from the [http://caniuse.com](http://caniuse.com) support tables.
131+
132+
You can also use the menu <code>JavaScript Completions Tools</code> on the top and select <code>Search on "Can I use" list</code> to search what you want.
133+
134+
Example :
135+
136+
<img src="https://media.giphy.com/media/26ufnXCKlXwFghwDS/giphy.gif" alt="example #1 Can I use? Feature">
137+
138+
<img src="http://s17.postimg.org/8hqxb0fvj/Schermata_2016_09_24_alle_21_07_44.png" alt="example #2 Can I use? Feature">
139+
140+
<img src="http://s17.postimg.org/wa4u0a7a7/Schermata_2016_09_24_alle_21_07_55.png" alt="example #3 Can I use? Feature">
141+
142+
<h3 id="context-menu-options">Context menu options</h3>
92143

93144
Context menu options:
94145
- <a href="#surround-with">Surround With</a>
95146
- <a href="#delete-surround">Delete Surrounded</a>
96147
- <a href="#create-class-from-object-literal">Create Class from object literal</a>
97148
- <a href="#sort-array">Sort array</a>
149+
- <a href="#split-string-lines-to-variable">Split string lines to variable</a>
98150

99151
<h4 id="surround-with">Surround With</h4>
100152

@@ -111,7 +163,7 @@ You can surround code with:
111163
- Multi-line comment
112164
- Single-line comment
113165

114-
This options works also on multiple selections at once.
166+
This option works also on multiple selections at once.
115167

116168
<h4 id="delete-surround">Delete Surrounded</h4>
117169

@@ -120,7 +172,7 @@ Options are:
120172
- Delete single-line comment
121173
- Strip quoted string
122174

123-
This options works also on multiple selections at once.
175+
This option works also on multiple selections at once.
124176

125177
<h4 id="create-class-from-object-literal">Create Class from object literal</h4>
126178

@@ -139,22 +191,34 @@ var Person = {
139191
}
140192
```
141193

142-
This options works also on multiple selections at once.
194+
This option works also on multiple selections at once.
143195

144196
<h4 id="sort-array">Sort array</h4>
145197

146-
Just put the cursor between brackets and will appear a menu with this options:
198+
Just put the cursor between brackets and will appear a menu with these options:
147199
- Sort array ASC ( compare function: <code>function(x,y){return x-y;}</code> )
148200
- Sort array DESC ( compare function: <code>function(x,y){return y-x;}</code> )
149201
- Sort array alphabetically ASC
150202
- Sort array alphabetically DESC
151203

152-
This options works also on multiple selections at once.
204+
This option works also on multiple selections at once.
153205

154206
Examples of usage:
155207

156208
<img src="https://media.giphy.com/media/3o7TKOwWEYUGPX4G6Q/giphy.gif" alt="example #1 Other Context menu option">
157209

158210
<img id="context-menu-option-example-2" src="https://media.giphy.com/media/l3vR1DjPDWRFfl3LG/giphy.gif" alt="example #2 Other Context menu option">
159211

212+
<h4 id="split-string-lines-to-variable">Split string lines to variable</h4>
213+
214+
Just put the cursor between a string with multiple lines and this option will appear in the context menu.
215+
216+
It will split the string and for each line will be concatenated to a variable named "str".
217+
218+
This option works also on multiple selections at once.
219+
220+
Example:
221+
222+
<img src="https://media.giphy.com/media/l2Sq0iS3ga6p9iXjq/giphy.gif" alt="example #1 Split string lines to variable">
223+
160224
<i>MIT License</i>

_init.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sublime, sublime_plugin
2-
import os, sys, imp, platform, json, traceback, threading
2+
import os, sys, imp, platform, json, traceback, threading, urllib, shutil
33
from shutil import copyfile
44
from threading import Timer
55

@@ -22,7 +22,6 @@
2222

2323
_plugins = ["javascript_completions", "evaluate_javascript", "helper"]
2424

25-
2625
class handle_settingCommand(sublime_plugin.WindowCommand) :
2726
def run(self, folder_from_package, file_name, extension) :
2827
open_setting(folder_from_package, file_name, extension)
@@ -33,6 +32,7 @@ def is_visible(self, folder_from_package, file_name, extension) :
3332
elif file_name.find(" (") >= 0 and file_name.find(" ("+PLATFORM+")") < 0 :
3433
return False
3534
return True
35+
3636
def setTimeout(time, func):
3737
timer = Timer(time, func)
3838
timer.start()
@@ -43,7 +43,6 @@ def enable_setting(folder_from_package, file_name, extension) :
4343
file_name_disabled = file_name + "_disabled" + "." + extension
4444
path_file_enabled = os.path.join(path, file_name_enabled)
4545
path_file_disabled = os.path.join(path, file_name_disabled)
46-
path_load_resource = os.path.join(PACKAGE_NAME, path, file_name_enabled)
4746
try :
4847
if os.path.isfile(path_file_disabled) :
4948
os.rename(path_file_disabled, path_file_enabled)
@@ -56,20 +55,24 @@ def disable_setting(folder_from_package, file_name, extension) :
5655
file_name_disabled = file_name + "_disabled" + "." + extension
5756
path_file_enabled = os.path.join(path, file_name_enabled)
5857
path_file_disabled = os.path.join(path, file_name_disabled)
59-
path_load_resource = os.path.join(PACKAGE_NAME, path, file_name_enabled)
6058
try :
6159
if os.path.isfile(path_file_enabled) :
6260
os.rename(path_file_enabled, path_file_disabled)
6361
except Exception as e :
6462
print("Error: "+traceback.format_exc())
6563

64+
def is_setting_enabled(folder_from_package, file_name, extension) :
65+
path = os.path.join(PACKAGE_PATH, folder_from_package)
66+
file_name_enabled = file_name + "." + extension
67+
path_file_enabled = os.path.join(path, file_name_enabled)
68+
return os.path.isfile(path_file_enabled)
69+
6670
def open_setting(folder_from_package, file_name, extension) :
6771
path = os.path.join(PACKAGE_PATH, folder_from_package)
6872
file_name_enabled = file_name + "." + extension
6973
file_name_disabled = file_name + "_disabled" + "." + extension
7074
path_file_enabled = os.path.join(path, file_name_enabled)
7175
path_file_disabled = os.path.join(path, file_name_disabled)
72-
path_load_resource = os.path.join(PACKAGE_NAME, path, file_name_enabled)
7376

7477
if os.path.isfile(path_file_enabled) :
7578
sublime.active_window().open_file(path_file_enabled)
@@ -90,7 +93,7 @@ def init(self):
9093
node_js_version = sublime.load_settings('Evaluate-JavaScript.sublime-settings').get("node_js_version") or eval_js_json.get("node_js_version") or node_variables.NODE_JS_VERSION
9194

9295
installer.install(node_js_version)
93-
96+
9497
self.handle_plugins()
9598

9699
def load_plugins(self):

changelog/2.6.5.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
v2.6.5
2+
3+
4+
## Features
5+
6+
- "On Hover Description" Feature :
7+
8+
Supported only by Sublime Text 3, Build >= 3124
9+
10+
Just put the cursor over a name of a function, property or constructor and it will appear a little popup with all matching found from the "/sublime-completions" list enabled.
11+
- F = function
12+
- P = property
13+
- C = constructor
14+
15+
16+
- "Can I use?" Feature :
17+
18+
Supported only by Sublime Text 3, Build >= 3124
19+
20+
This feature uses "can i use" json data from this repository: https://github.com/Fyrd/caniuse, that contains raw data from the http://caniuse.com support tables.
21+
Thanks to @Fyrd.
22+
You can use this feature in HTML, CSS and JavaScript context!
23+
Just put the cursor on the word you want to check, "right-click" -> "Can I use?" and it will appear an input panel with all items that have a name matching with the word.
24+
You can use key-map: ctrl+alt+w. You can also change it. Just go to Preferences -> Package Settings -> JavaScript Completions Tools -> Key Bindings - User.
25+
After selecting an item from the list, it will appear a popup with all information from the http://caniuse.com support tables.
26+
27+
28+
- Context menu options:
29+
30+
- "Split string lines to variable" feature :
31+
32+
Just put the cursor between a string with multiple lines and this option will appear in the context menu.
33+
It will split the string and for each line will be concatenated to a variable named "str".
34+
This option works also on multiple selections at once.
35+
36+
37+
## Improvements
38+
39+
- "Find JavaScript Description" feature:
40+
41+
Search improved

0 commit comments

Comments
 (0)