This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
/
go.js
80 lines (72 loc) · 2.7 KB
/
go.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* Cloud9 Go support
*
* @copyright 2015, Ajax.org B.V.
*/
define(function(require, exports, module) {
main.consumes = [
"Plugin", "language", "jsonalyzer", "settings",
"preferences", "preferences.experimental"
];
main.provides = ["language.go"];
return main;
function main(options, imports, register) {
var Plugin = imports.Plugin;
var language = imports.language;
var jsonalyzer = imports["jsonalyzer"];
var preferences = imports.preferences;
var settings = imports.settings;
var plugin = new Plugin("Ajax.org", main.consumes);
plugin.on("load", function() {
preferences.add({
"Project": {
"Go Support": {
position: 1400,
"Enable Go code completion": {
position: 510,
type: "checkbox",
path: "project/golang/@completion",
},
"Format Code on Save": {
position: 520,
type: "checkbox",
path: "project/golang/@formatOnSave",
},
"Custom Code Formatter": {
position: 530,
type: "textbox",
path: "project/golang/@formatter",
}
}
}
}, plugin);
settings.on("read", function(e) {
settings.setDefaults("project/golang", [
["completion", true],
["formatOnSave", true],
["formatter", 'gofmt -w "$file"'],
]);
}, plugin);
language.registerLanguageHandler("plugins/c9.ide.language.go/worker/go_completer", function(err, handler) {
if (err) return console.error(err);
setupHandler(handler);
});
});
function setupHandler(handler) {
settings.on("project/golang", sendSettings.bind(null, handler), plugin);
sendSettings(handler);
}
function sendSettings(handler) {
handler.emit("set_go_config", {
enabled: settings.get("project/golang/@completion"),
});
}
plugin.on("unload", function() {
jsonalyzer.unregisterWorkerHandler("plugins/c9.ide.language.go/worker/go_completer");
});
/** @ignore */
register(null, {
"language.go": plugin
});
}
});