From: Ryan Paul Date: 2004-05-13T09:58:53+09:00 Subject: Re: are there any ruby IDEs? On Thu, 13 May 2004 08:21:28 +0900, Gavin Sinclair wrote: > On Thursday, May 13, 2004, 7:08:54 AM, Ryan wrote: > >> I use vim most of the time, but i'm curious if there are any >> ruby specific IDEs, or any graphical debuggers. Additionally, if any of >> you folks have any good vim/ruby tricks to share, i'd love to hear them. >> I'm currently compiling vim with ruby and python embedded. (I plan on >> porting my vim extension scripts from python to ruby when I get a chance) > > See http://vim-ruby.rubyforge.org. > > The released files are quit out of date (/me smacks himself), so grab > a CVS tarball. It'll all be sorted out when Vim 6.3 arrives. > > And please share your Python vim extension scripts. I'm eager to see > what they do. > > Cheers, > Gavin Most of this is pretty grotesque, but it works relatively well. I wanted to come up with a way to make redirect stdout so that print would send content to a scratch buffer. I set it up so that I could assign an execution command to filetypes using autocmd. It executes that command on the content, and then puts the output in the scratch buffer. if the scratch buffer doesnt exist yet, it creates it. The way it finds the scratch buffer is really kludgy, but I couldnt think of a better way. The 'PyValOut' function is kind of neat. It takes the selected content in the current buffer and evaluates it through the embedded interpreter and dumps the content to the scratch buffer. I use this instead of interactive mode a lot of the time. I use this stuff regularly for several languages including ruby. My CamlComment function is kind of funky, it puts ocaml comments around the text of the current line, respecting starting whitespace. The CamlRunAct function is a quick and dirty shortcut I use to control whether I want the file to be run through the ocaml interpreter, or the compiler, or something else entirely. I'll probably port all this to ruby as soon as I get ruby/vim working, and figure out how to redirect stdout. """""" SegPhault's .vimrc """ Python Stuff python << EOF from vim import * import sys,commands def first(c,l): for x in l: if c(x): return x txtsplit = '-'*20 CB = lambda: current.buffer io = sys.stdout,sys.stderr getBuf = lambda x:first(x,buffers) pybuf = lambda x:x[0].startswith('Program Output') prepend = lambda l,t: l[:len(l)-len(l.lstrip())] + t + l.lstrip() def rep(t,l): for x in l.items(): t = t.replace(x[0],x[1]) return t def getSel(l1,l2): return '\n'.join(current.buffer.range(int(l1),int(l2))[:])+'\n' class vBuf: def __init__(s,b=None): s.buf = b and b or getBuf(pybuf) if not s.buf: command(':bel new') command(':set bt=nofile') s.buf = current.buffer s.clear() def write(s,t): if '\n' in t: map(s.buf.append,t.split('\n')) else: s.buf[-1]+=t def clear(s): s.buf[:] = None s.buf[-1] = 'Program Output Buffer' s.buf.append('-'*20) s.buf.append('') def redirbuf(b=None):sys.stdout = sys.stderr = vBuf(b) def resetbuf():sys.stdout,sys.stderr = io def PyValOut(r): redirbuf() exec(r) print txtsplit resetbuf() def PyExOut(r): redirbuf() print commands.getstatusoutput(r)[1] print txtsplit resetbuf() def FileDir(x): return '/'.join(x.split('/')[:-1]) def ToFileDir(): command('lcd '+FileDir(current.buffer.name)) EOF """" General Stuff let mapleader = "," map s :source % map b :MiniBufExplorer imap :wa imap =strftime("%x") imap imap $a imap ,c:w,,a command! ToFileDir py ToFileDir() """" C Stuff map mc :source /usr/share/vim/vim62/extraPlugins/c.vim:syntax on map ind :%!indent """" Python Stuff command! -range Pval py PyValOut(getSel(,)) map c :py vBuf().clear() autocmd BufEnter *.py map , :py PyExOut('python ' +current.buffer.name) """" XML Stuff autocmd BufEnter *.xsl map . :py curxsldoc = current.buffer.name autocmd BufEnter *.xml map , :py PyExOut('xsltproc %s %s'%(curxsldoc,current.buffer.name)) """" Ocaml Stuff python << EOF def camlComment(): l = current.line current.line = l.strip().startswith('(*')\ and rep(l,{'(* ':'',' *)':''})\ or prepend(l,'(* ') + ' *)' def camlRunAct(): return CB()[0].startswith('(* Build:')\ and CB()[0][CB()[0].find(':')+2:].replace('%',CB().name)\ or 'ocaml %s'%CB().name EOF autocmd BufEnter *.ml map , :py PyExOut(camlRunAct()) autocmd BufEnter *.ml imap (* *)hhi autocmd BufEnter *.ml map :py camlComment() """ Makefile Stuff autocmd BufEnter Makefile map , :py PyExOut('make exec') autocmd BufEnter Makefile map . :py PyExOut('make clean') """ Ruby Stuff autocmd BufEnter *.rb map , :py PyExOut('ruby '+current.buffer.name) """ colorscheme command! FoldDarkBG :highlight Folded guifg=purple guibg=black