Skip to content

Instantly share code, notes, and snippets.

@wadewest
Created September 14, 2011 17:35
Show Gist options
  • Save wadewest/1217190 to your computer and use it in GitHub Desktop.
Save wadewest/1217190 to your computer and use it in GitHub Desktop.
Searches up the directory structure for files named vimrc and loads them.
" 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