|
Textmate Footnotes with vim supportWritten By: Ben Wyrosdick June 11th, 2008 |
I just switched to doing rails development in vim rather than textmate but I sure did miss my textmate footnotes. I found a post about a plugin called redit that converted stacktraces over to links that would open in vim (textmate footnotes style) so I decided to take that and patch Textmate Footnotes. I had to make sure not to messup any of the developers who were going to still use Textmate so it patches it to do both based on an env variable we will talk about later.
First I took the controller from the afore mentioned plugin and tweaked it to make sure we were running in development mode before executing code on the server and changed it to use MacVim as the vim app. Simply create a new controller called ReditController and paste the code below changing the system call if you use something other than MacVim.
require 'base64'
class ReditController < ApplicationController
def open
if ENV['RAILS_ENV'] == 'development'
file = Base64.decode64(params[:id])
line = params[:line].to_s
# Run editor here
Thread.new do
### MacVim
# Open file in new tab of vim server
system("mvim","--remote-tab","+#{line}",file)
end
end
redirect_to :back
end
end
Next you need to replace the lib/textmate_footnotes.rb with this one. I am working with an older version of textmate footnotes so be forewarned that my file may not work 100% with your version … I will update to the latest soon and update my file. Here is an example of how the patch changes the urls generated:
def controller_url
if ENV['FOOTNOTE_APP'] == 'vim'
escape(
"/redit/open/" +
CGI.escape(Base64.encode64(controller_filename)) +
(index_of_method ? "&line=#{controller_line_number + 1}&column=3" : "")
)
else
escape(
textmate_prefix +
controller_filename +
(index_of_method ? "&line=#{controller_line_number + 1}&column=3" : "")
)
end
end
And lastly to make the plugin give you vim links rather than textmate links you need to set the FOOTNOTE_APP env variable. To make this happen every time you login place the following snippet in your ~/.bash_profile
export FOOTNOTE_APP=vim
October 28th, 2008 at 11:45 AM You no longer need this with the latest MacVim. The latest MacVim supports a URL handler: mvim://open?. Just add this to your environment.rb: Footnotes::Filter.prefix ||= 'mvim://open?url=file://' if RUBY_PLATFORM.include?('darwin')
May 5th, 2009 at 12:22 AM That is good to know ... I will update the post accordingly
January 23rd, 2010 at 05:29 AM [url=http://urbancruiser.ru/][img]http://imagepix.org/preview/dba3f3e42bf39c649836f766fe029834.jpg[/img][/url] ??? ???? ???? ????? ???????? ??? ??????? ????? ??????? - [b][url=http://urbancruiser.ru/]?????? vbybl bgbr [/url][/b], ?? ???????? ?? ??????????? ?? ???????… ? ???, ?? ???? ???????? ????? ?????????: ?????? ?????????? ????????? ????????? ? ????? ?? ????????? [b][url=http://urbancruiser.ru/]?????? ????? ?????? ???? [/url][/b], ?? ???????? ?????????? ???? ?????? Scion.