-
Notifications
You must be signed in to change notification settings - Fork 13
Support for native win32 gvim from cygwin ruby #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,11 +46,16 @@ def vim | |
config.include(Vimrunner::Testing) | ||
|
||
# Each example is executed in a separate directory | ||
# No trace shall be left in the tmp directory otherwise cygwin won't permit | ||
# rmdir => vim is outside the directory at the end | ||
# TODO: ensure a cd(pwd) à la RAII | ||
pwd = Dir.pwd | ||
config.around(:each) do |example| | ||
Dir.mktmpdir do |dir| | ||
Dir.chdir(dir) do | ||
vim.command("cd #{dir}") | ||
vim.cd(dir) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems a good idea in general but we might want to tweak the order a little and guard against test failures: config.around(:each) do |example|
original_dir = Dir.pwd
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
begin
vim.cd(dir)
example.run
ensure
vim.cd(original_dir)
end
end
end
end |
||
example.run | ||
vim.cd(pwd) | ||
end | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,13 +19,15 @@ class Server | |
VIMRC = File.expand_path("../../../vim/vimrc", __FILE__) | ||
VIMRUNNER_RC = File.expand_path("../../../vim/vimrunner_rc", __FILE__) | ||
|
||
attr_reader :name, :executable, :vimrc, :gvimrc | ||
attr_reader :name, :executable, :spawn_executable, :vimrc, :gvimrc | ||
|
||
# Public: Initialize a Server | ||
# | ||
# options - The Hash options used to define a server (default: {}): | ||
# :executable - The String Vim executable to use (optional) | ||
# (default: Platform.vim). | ||
# :spawn_executable - The String Vim spawn executable to use (optional) | ||
# (default: Platform.spawn_executable). | ||
# :name - The String name of the Vim server (optional) | ||
# (default: "VIMRUNNER#{rand}"). | ||
# :vimrc - The String vimrc file to source in the client (optional) | ||
|
@@ -35,6 +37,7 @@ class Server | |
# | ||
def initialize(options = {}) | ||
@executable = options.fetch(:executable) { Platform.vim } | ||
@spawn_executable = options.fetch(:spawn_executable) { Platform.spawn_executable } | ||
@name = options.fetch(:name) { "VIMRUNNER#{rand}" }.upcase | ||
@vimrc = options.fetch(:vimrc) { VIMRC } | ||
@gvimrc = options.fetch(:gvimrc) { "NONE" } | ||
|
@@ -138,7 +141,7 @@ def new_client | |
# | ||
# Returns an Array of String server names currently running. | ||
def serverlist | ||
execute([executable, "--serverlist"]).split("\n") | ||
execute([executable, "--serverlist"]).split(/\r?\n/) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might be able to use |
||
end | ||
|
||
# Public: Evaluates an expression in the Vim server and returns the result. | ||
|
@@ -172,8 +175,10 @@ def execute(command) | |
end | ||
|
||
def spawn | ||
PTY.spawn(executable, *%W[ | ||
#{foreground_option} --servername #{name} -u #{vimrc} -U #{gvimrc} | ||
the_exec = spawn_executable | ||
# pp (%W[ #{the_exec} #{foreground_option} --servername #{name} -u #{vimrc} -U #{gvimrc} ]) | ||
PTY.spawn(the_exec, *%W[ | ||
#{foreground_option} --servername #{name} -u #{Platform.fix_path vimrc} -U #{gvimrc} | ||
]) | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we not add this to
gvims
, e.g.