Created
November 26, 2013 19:05
-
-
Save brianwisti/7664034 to your computer and use it in GitHub Desktop.
Terrible idea: vimrc in Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A terrible idea | |
# Spent a couple minutes experimenting with the idea of using Ruby to initialize | |
# my Vim session instead of something reliable, like a .vimrc. | |
# | |
# Why? Because I love terrible ideas. | |
# BTW - only works for the simplest of options right now. | |
class VimSession | |
include VIM | |
def initialize &options | |
instance_eval &options | |
end | |
def set setting, *values | |
if values.empty? | |
option_str = setting.to_s | |
else | |
value = values.join ',' | |
option_str = "#{setting}=#{value}" | |
end | |
set_option option_str | |
end | |
def filetype *flags | |
command "filetype #{flags.join(' ')} on" | |
end | |
end | |
$vim_session = VimSession.new do | |
set :nocompatible | |
set :shiftwidth, 2 | |
set :expandtab | |
set :number | |
filetype :plugin, :indent | |
end | |
# and off in the .vimrc | |
# | |
# ruby << END_INIT | |
# require "#{ENV['HOME']}/vimrc.rb" | |
# END_INIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment