Skip to content

Commit f585580

Browse files
committed
Add settings
Adds settings files to the plugin. Adds a new setting: "disabled" which allows to disable the plugin.
1 parent e3f29ed commit f585580

3 files changed

Lines changed: 50 additions & 1 deletion

File tree

Main.sublime-menu

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[
2+
{
3+
"caption": "Preferences",
4+
"id": "preferences",
5+
"mnemonic": "n",
6+
"children":
7+
[
8+
{
9+
"caption": "Package Settings",
10+
"id": "package-settings",
11+
"mnemonic": "P",
12+
"children":
13+
[
14+
{
15+
"caption": "apiDoc Autocompletion",
16+
"children":
17+
[
18+
{
19+
"caption": "Settings – Default",
20+
"command": "open_file", "args":
21+
{
22+
"file": "${packages}/apiDoc Autocompletion/apiDocAutocompletion.sublime-settings"
23+
}
24+
},
25+
{
26+
"caption": "Settings – User",
27+
"command": "open_file", "args":
28+
{
29+
"file": "${packages}/User/apiDocAutocompletion.sublime-settings"
30+
}
31+
}
32+
]
33+
}
34+
]
35+
}
36+
]
37+
}
38+
]

apiDocAutocompletion.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import sublime
77
import sublime_plugin
88

9+
SETTINGS_FILENAME = 'apiDocAutocompletion.sublime-settings'
10+
911
class apiDocAutocompletion(sublime_plugin.EventListener):
1012
_suggestions = [
1113
("@api\tapiDoc", "@api {${1:method}} ${2:path} ${3:[title]}"),
@@ -44,6 +46,11 @@ class apiDocAutocompletion(sublime_plugin.EventListener):
4446
]
4547

4648
def on_query_completions(self, view, prefix, locations):
49+
settings = sublime.load_settings(SETTINGS_FILENAME)
50+
51+
plugin_disabled = settings.get('disabled', False)
52+
if plugin_disabled:
53+
return None
4754

4855
# Block comment scopes:
4956
# C#:
@@ -86,4 +93,4 @@ def on_query_completions(self, view, prefix, locations):
8693
if any(scope in current_scope for scope in target_scopes) == True:
8794
return apiDocAutocompletion._suggestions
8895
else:
89-
return []
96+
return None
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
// Disables the plugin
3+
"disabled": false,
4+
}

0 commit comments

Comments
 (0)