Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

make a tmux pipe that can connect vim to rdb

- require vim compiling with +clientserver option, for macport, enable
variant 'x11'
  • Loading branch information...
commit fb36f828db184cc3560271a520d284f46f726388 1 parent f1db043
@linsong authored
Showing with 72 additions and 1 deletion.
  1. +1 −1  .rdebugrc
  2. +2 −0  .tmux.conf
  3. +69 −0 .tmux/pipes/rdb
View
2  .rdebugrc
@@ -1,3 +1,3 @@
set autoeval on # if the input is not rdb command, then eval it as ruby code
set forcestep on # skip duplicate lines during step
-set autolist 1
+#set autolist 1
View
2  .tmux.conf
@@ -61,6 +61,8 @@ bind C-s command-prompt "swap-pane -s %%"
bind -t vi-choice C-b page-up
bind -t vi-copy C-b page-up
+bind C-f pipe-pane -o '~/.tmux/pipes/rdb'
+
#}}}1
# {{{1 window options
View
69 .tmux/pipes/rdb
@@ -0,0 +1,69 @@
+#! /usr/bin/env ruby
+
+class VimProxy
+ @@server_name = :DEBUGGER_VIEWER
+ @@sign_name = :db_indicator
+
+ def init
+ @last_sign_id = 1
+ unless isVimServerRunning
+ # start vim
+ #%x{tmux -L main split-window -dv -p 70 'vim -R --servername #{@@server_name}'}
+ %x{tmux -L main split-window -dh 'vim -R --servername #{@@server_name}'}
+
+ wait_counter = 20
+ until isVimServerRunning || wait_counter <= 0 do
+ sleep 0.3
+ wait_counter -= 1
+ end
+
+ if wait_counter <= 0
+ return false
+ end
+
+ # define sign
+ sendCmd(%Q{:sign define #{@@sign_name} text=>> texthl=Search})
+ end
+ return true
+ end
+
+ def show(fname, lnum)
+ locate(fname, lnum)
+ setSign(fname, lnum)
+ end
+
+ protected
+
+ def locate(fname, lnum)
+ #%x{vim --servername #{@@server_name} --remote-silent +"call PutSignCurLine('#{fname}', #{lnum})" +#{lnum} #{fname}}
+ sendCmd(%Q{:silent edit +#{lnum} #{fname}})
+ end
+
+ def setSign(fname, lnum)
+ new_sign_id = @last_sign_id == 1 ? 2 : 1
+ [
+ %Q{:norm zz<CR>},
+ %Q{:exec 'sign place #{new_sign_id} line=#{lnum} name=#{@@sign_name} buffer=' . bufnr('%')<CR>},
+ %Q{:sign unplace #{@last_sign_id}<CR>},
+ ].each {|vcmd| sendCmd(vcmd) }
+ @last_sign_id = new_sign_id
+ end
+
+ def sendCmd(vcmd)
+ cmd = %Q{vim --servername #{@@server_name} --remote-send}
+ %x{#{cmd} "#{vcmd}<CR>"}
+ end
+
+ def isVimServerRunning
+ %x{vim --serverlist}.split.include?(@@server_name.to_s)
+ end
+end
+
+proxy = VimProxy.new
+proxy.init
+
+ARGF.each do |line|
+ proxy.show($1, $2) if line =~ /^(\/[^:]+):(\d+)/
+end
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.