Created
September 14, 2011 17:35
-
-
Save wadewest/1217190 to your computer and use it in GitHub Desktop.
Searches up the directory structure for files named vimrc and loads them.
This file contains 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
" loadSources Recursively | |
if has('ruby') | |
ruby << EOF | |
# loadOtherSource - climbs the directory structure looking for | |
# files named "vimrc" and calls source on each | |
# one starting with the one furthest from the | |
# current file. | |
def loadOtherSources | |
fileName = VIM::Buffer.current.name | |
unless fileName.nil? | |
rcFileName = "vimrc" | |
fullPath = File.expand_path( File.dirname( fileName ) ) | |
path = fullPath | |
sourceFiles = [] | |
loop do | |
oldPath = path | |
rcFile = File.join( path, rcFileName ) | |
if File.exist?( rcFile ) | |
sourceFiles.unshift rcFile | |
end | |
path = File.dirname(path) | |
break if path == oldPath | |
end | |
sourceFiles.each do |file| | |
VIM.command( "source #{file}" ) | |
end | |
end | |
end | |
loadOtherSources | |
EOF | |
endif " has('ruby') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment