mirror of
https://github.com/sstent/sublime-text-3.git
synced 2026-02-13 19:07:14 +00:00
backing up sublime settings
This commit is contained in:
18
Packages/SublimeREPL/config/Ruby/Default.sublime-commands
Normal file
18
Packages/SublimeREPL/config/Ruby/Default.sublime-commands
Normal file
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"caption": "SublimeREPL: Ruby",
|
||||
"command": "run_existing_window_command", "args":
|
||||
{
|
||||
"id": "repl_ruby",
|
||||
"file": "config/Ruby/Main.sublime-menu"
|
||||
}
|
||||
},
|
||||
{
|
||||
"caption": "SublimeREPL: Ruby IRB (deprecated)",
|
||||
"command": "run_existing_window_command", "args":
|
||||
{
|
||||
"id": "repl_ruby_irb",
|
||||
"file": "config/Ruby/Main.sublime-menu"
|
||||
}
|
||||
}
|
||||
]
|
||||
85
Packages/SublimeREPL/config/Ruby/Main.sublime-menu
Normal file
85
Packages/SublimeREPL/config/Ruby/Main.sublime-menu
Normal file
@@ -0,0 +1,85 @@
|
||||
[
|
||||
{
|
||||
"id":"tools",
|
||||
"children":[
|
||||
{
|
||||
"caption":"SublimeREPL",
|
||||
"mnemonic":"r",
|
||||
"id":"SublimeREPL",
|
||||
"children":[
|
||||
{
|
||||
"caption":"Ruby",
|
||||
"children":[
|
||||
{
|
||||
"command":"repl_open",
|
||||
"caption":"Ruby",
|
||||
"id":"repl_ruby",
|
||||
"mnemonic":"r",
|
||||
"args":{
|
||||
"type":"subprocess",
|
||||
"external_id":"ruby",
|
||||
"encoding":"utf8",
|
||||
"cmd":{
|
||||
"windows":[
|
||||
"ruby.exe",
|
||||
"${packages}/SublimeREPL/config/Ruby/pry_repl.rb",
|
||||
"$editor"
|
||||
],
|
||||
"linux":[
|
||||
"ruby",
|
||||
"${packages}/SublimeREPL/config/Ruby/pry_repl.rb",
|
||||
"$editor"
|
||||
],
|
||||
"osx":[
|
||||
"ruby",
|
||||
"${packages}/SublimeREPL/config/Ruby/pry_repl.rb",
|
||||
"$editor"
|
||||
]
|
||||
},
|
||||
"soft_quit":"\nexit\n",
|
||||
"cwd":"$file_path",
|
||||
"cmd_postfix":"\n",
|
||||
"autocomplete_server": true,
|
||||
"syntax":"Packages/Ruby/Ruby.tmLanguage"
|
||||
}
|
||||
},
|
||||
{
|
||||
"command":"repl_open",
|
||||
"caption":"Ruby - IRB (deprecated)",
|
||||
"id":"repl_ruby_irb",
|
||||
"mnemonic":"r",
|
||||
"args":{
|
||||
"type":"subprocess",
|
||||
"external_id":"ruby",
|
||||
"encoding":"utf8",
|
||||
"cmd":{
|
||||
"windows":[
|
||||
"irb.bat",
|
||||
"--noreadline",
|
||||
"--inf-ruby-mode"
|
||||
],
|
||||
"linux":[
|
||||
"irb",
|
||||
"--noreadline",
|
||||
"--inf-ruby-mode"
|
||||
],
|
||||
"osx":[
|
||||
"irb",
|
||||
"--noreadline",
|
||||
"--inf-ruby-mode"
|
||||
]
|
||||
},
|
||||
"soft_quit":"\nexit\n",
|
||||
"cwd":"$file_path",
|
||||
"cmd_postfix":"\n",
|
||||
"suppress_echo":true,
|
||||
"syntax":"Packages/Ruby/Ruby.tmLanguage"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
72
Packages/SublimeREPL/config/Ruby/pry_repl.rb
Normal file
72
Packages/SublimeREPL/config/Ruby/pry_repl.rb
Normal file
@@ -0,0 +1,72 @@
|
||||
require 'rubygems'
|
||||
gem 'pry'
|
||||
require 'pry'
|
||||
require 'socket'
|
||||
require 'thread'
|
||||
require 'json'
|
||||
|
||||
include Socket::Constants
|
||||
|
||||
class PryInput
|
||||
def readline(prompt)
|
||||
$stdout.print prompt
|
||||
$stdout.flush
|
||||
$stdin.readline
|
||||
end
|
||||
end
|
||||
|
||||
class PryOutput
|
||||
def puts(data="")
|
||||
$stdout.puts(data.gsub('`', "'"))
|
||||
$stdout.flush
|
||||
end
|
||||
end
|
||||
|
||||
Pry.config.input = PryInput.new()
|
||||
Pry.config.output = PryOutput.new()
|
||||
Pry.config.color = false
|
||||
Pry.config.editor = ARGV[0]
|
||||
Pry.config.auto_indent = false
|
||||
Pry.config.correct_indent = false
|
||||
|
||||
port = ENV["SUBLIMEREPL_AC_PORT"].to_i
|
||||
|
||||
socket = Socket.new(AF_INET, SOCK_STREAM, 0)
|
||||
sockaddr = Socket.pack_sockaddr_in(port, '127.0.0.1')
|
||||
socket.connect(sockaddr)
|
||||
completer = Pry::InputCompleter.build_completion_proc(binding)
|
||||
|
||||
def read_netstring(s)
|
||||
size = 0
|
||||
while true
|
||||
ch = s.recvfrom(1)[0]
|
||||
if ch == ':'
|
||||
break
|
||||
end
|
||||
size = size * 10 + ch.to_i
|
||||
end
|
||||
msg = ""
|
||||
while size != 0
|
||||
msg += s.recvfrom(size)[0]
|
||||
size -= msg.length
|
||||
end
|
||||
ch = s.recvfrom(1)[0]
|
||||
return msg
|
||||
end
|
||||
|
||||
# Thread.abort_on_exception = true
|
||||
t1 = Thread.new do
|
||||
while true
|
||||
data = read_netstring(socket)
|
||||
req = JSON.parse(data)
|
||||
line = req["line"]
|
||||
completions = completer.call(req["line"])
|
||||
response = [line, completions]
|
||||
response_msg = JSON.dump(response)
|
||||
payload = response_msg.length.to_s + ":" + response_msg + ","
|
||||
socket.write(payload)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Pry.start self
|
||||
Reference in New Issue
Block a user