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
|
module Support
class << self
attr_accessor :nvim_version
end
def self.workspace
File.expand_path("../workspace", __FILE__)
end
def self.socket_path
file_path("nvim.sock")
end
def self.tcp_port
server = TCPServer.new("127.0.0.1", 0)
begin
server.addr[1]
ensure
server.close
end
end
def self.file_path(name)
File.join(workspace, name)
end
def self.setup_workspace
FileUtils.mkdir_p(workspace)
end
def self.teardown_workspace
FileUtils.rm_rf(workspace)
end
def self.child_argv
[Neovim.executable.path, "--headless", "-i", "NONE", "-u", "NONE", "-n"]
end
def self.windows?
Gem.win_platform?
end
def self.kill(pid)
windows? ? Process.kill(:KILL, pid) : Process.kill(:TERM, pid)
end
begin
self.nvim_version = Neovim.executable.version
rescue => e
abort("Failed to load nvim: #{e}")
end
end
|