Compare commits
No commits in common. "0d443f89d4a023ddc6425c2fc8ea455e0b968a44" and "eb9ba299aa210514c1d2aade9a5d7a087f32099a" have entirely different histories.
0d443f89d4
...
eb9ba299aa
@ -287,7 +287,7 @@ alias rsync-vfat='rsync -rtv --stats --modify-window=2'
|
|||||||
###########################################################################
|
###########################################################################
|
||||||
|
|
||||||
export LESS='Ri'
|
export LESS='Ri'
|
||||||
export EDITOR=nvim
|
export EDITOR=vim
|
||||||
export LC_COLLATE=C
|
export LC_COLLATE=C
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
|
|||||||
62
e
62
e
@ -1,67 +1,39 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require "open3"
|
# Use HighContrast GTK2 theme for gvim.
|
||||||
|
ENV["GTK2_RC_FILES"] = "/usr/share/themes/HighContrast/gtk-2.0/gtkrc"
|
||||||
|
|
||||||
SEARCH = %w[.git project.vim]
|
def get_server_name(path)
|
||||||
EDITOR = "nvim-qt"
|
if path
|
||||||
|
|
||||||
def find_proj_root(path)
|
|
||||||
path = File.expand_path(path)
|
path = File.expand_path(path)
|
||||||
loop do
|
while path != "/"
|
||||||
dirname = File.dirname(path)
|
dirname = File.dirname(path)
|
||||||
if SEARCH.any? {|s| File.exist?(File.join(dirname, s))}
|
if File.exist?(File.join(dirname, "project.vim"))
|
||||||
if dirname =~ %r{([^/]+)/([^/]+)/*$}
|
if dirname =~ %r{([^/]+)/([^/]+)/*$}
|
||||||
pretty_name = "#{$2}(#{$1})"
|
sn = "#{$2}(#{$1})"
|
||||||
else
|
else
|
||||||
pretty_name = File.basename(dirname)
|
sn = File.basename(dirname)
|
||||||
end
|
end
|
||||||
stdout, stderr, status = Open3.capture3("xxh32sum", stdin_data: dirname)
|
return sn
|
||||||
socket_name = stdout.sub(/\s.*/m, "")
|
|
||||||
return [socket_name, pretty_name]
|
|
||||||
end
|
end
|
||||||
path = dirname
|
path = dirname
|
||||||
if path == "/"
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
nil
|
return "GVIM"
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_dir
|
def server_running?(server_name)
|
||||||
ENV["XDG_RUNTIME_DIR"] || "/tmp"
|
`gvim --serverlist`.lines.map(&:chomp).include?(server_name.upcase)
|
||||||
end
|
|
||||||
|
|
||||||
def launch(socket_path, pretty_name, path)
|
|
||||||
if File.exist?(socket_path)
|
|
||||||
# Server running, send it remote command
|
|
||||||
system("nvim", "--headless", "--server", socket_path, "--remote-tab-silent", path)
|
|
||||||
else
|
|
||||||
# Start the server
|
|
||||||
$started_server = true
|
|
||||||
system(EDITOR, path, "--", "--listen", socket_path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if ARGV.empty?
|
if ARGV.empty?
|
||||||
exec(EDITOR)
|
server_name = get_server_name('local_file')
|
||||||
|
exec("/usr/bin/gvim", "--servername", server_name, err: "/dev/null")
|
||||||
else
|
else
|
||||||
ARGV.each_with_index do |path, i|
|
ARGV.each_with_index do |path, i|
|
||||||
socket_name, pretty_name = find_proj_root(path)
|
server_name = get_server_name(path)
|
||||||
socket_path = "#{run_dir}/e-#{socket_name}.sock"
|
sleep(0.2) if i > 0
|
||||||
if i == 1
|
system("/usr/bin/gvim", "--servername", server_name, "--remote-tab-silent", path, err: "/dev/null")
|
||||||
20.times do
|
|
||||||
sleep(0.01)
|
|
||||||
break if File.exist?(socket_path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
launch(socket_path, pretty_name, path)
|
|
||||||
if i == ARGV.length - 1
|
|
||||||
# This is the last argument. If the server was not started for any paths,
|
|
||||||
# then request that the window take focus.
|
|
||||||
unless $server_started
|
|
||||||
system("nvim", "--headless", "--server", socket_path, "--remote-send", "<Esc>:call GuiForeground()<CR><C-l>")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user