mirror of
https://github.com/sstent/sublime-text-3.git
synced 2026-01-26 15:11:55 +00:00
backing up sublime settings
This commit is contained in:
10
Packages/SublimeREPL/config/NodeJS/Default.sublime-commands
Normal file
10
Packages/SublimeREPL/config/NodeJS/Default.sublime-commands
Normal file
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"caption": "SublimeREPL: Node",
|
||||
"command": "run_existing_window_command", "args":
|
||||
{
|
||||
"id": "repl_node",
|
||||
"file": "config/NodeJS/Main.sublime-menu"
|
||||
}
|
||||
}
|
||||
]
|
||||
31
Packages/SublimeREPL/config/NodeJS/Main.sublime-menu
Normal file
31
Packages/SublimeREPL/config/NodeJS/Main.sublime-menu
Normal file
@@ -0,0 +1,31 @@
|
||||
[
|
||||
{
|
||||
"id": "tools",
|
||||
"children":
|
||||
[{
|
||||
"caption": "SublimeREPL",
|
||||
"mnemonic": "r",
|
||||
"id": "SublimeREPL",
|
||||
"children":
|
||||
[
|
||||
{"command": "repl_open",
|
||||
"caption": "Node",
|
||||
"id": "repl_node",
|
||||
"mnemonic": "n",
|
||||
"args": {
|
||||
"type": "subprocess",
|
||||
"encoding": "utf8",
|
||||
"cmd": {"linux": ["node", "${packages}/SublimeREPL/config/NodeJS/repl.js"],
|
||||
"osx": ["node", "${packages}/SublimeREPL/config/NodeJS/repl.js"],
|
||||
"windows": ["node.exe", "${packages}/SublimeREPL/config/NodeJS/repl.js"]},
|
||||
"cwd": "$file_path",
|
||||
"syntax": "Packages/JavaScript/JavaScript.tmLanguage",
|
||||
"external_id": "js",
|
||||
"autocomplete_server": true,
|
||||
"extend_env": {"NODE_NO_READLINE": 1}
|
||||
}
|
||||
}
|
||||
]
|
||||
}]
|
||||
}
|
||||
]
|
||||
38
Packages/SublimeREPL/config/NodeJS/repl.js
Normal file
38
Packages/SublimeREPL/config/NodeJS/repl.js
Normal file
@@ -0,0 +1,38 @@
|
||||
(function () {
|
||||
|
||||
var repl = require('repl');
|
||||
|
||||
var rep = repl.start({
|
||||
prompt: null, //'> ',
|
||||
source: null, //process.stdin,
|
||||
eval: null, //require('vm').runInThisContext,
|
||||
useGlobal: true, //false
|
||||
useColors: false
|
||||
});
|
||||
|
||||
|
||||
var net = require('net');
|
||||
var ac_port = process.env.SUBLIMEREPL_AC_PORT;
|
||||
var client = new net.Socket();
|
||||
client.connect(ac_port, "localhost", function() {});
|
||||
|
||||
client.on('data', function(data) {
|
||||
var strData = data.toString();
|
||||
var index = strData.indexOf(":");
|
||||
var json = strData.slice(index+1, strData.length - 1)
|
||||
var inData = JSON.parse(json);
|
||||
var wordIndex = inData.line.slice(inData.cursor_pos).search(/\b/);
|
||||
if(wordIndex !== 0){
|
||||
inData.line = inData.line.slice(0, inData.cursor_pos);
|
||||
}
|
||||
|
||||
var send = function (_, completions) {
|
||||
var comps = completions[0];
|
||||
var msg = JSON.stringify([inData.line, comps]);
|
||||
var payload = msg.length + ":" + msg + ",";
|
||||
client.write(payload)
|
||||
}
|
||||
rep.rli.completer(inData.line, send);
|
||||
});
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user