Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 13765dd2fee8ee47bc32306457180d587e9f8e82 0 parents
@AD7six authored
Showing with 108 additions and 0 deletions.
  1. +46 −0 README.md
  2. +62 −0 plugin/independence.vim
46 README.md
@@ -0,0 +1,46 @@
+Vim Independence
+================
+
+This vim plugin allows you to load (git) project specific .vimrc files
+
+# Installation
+
+I recommend using [Vim Pathogen](https://github.com/tpope/vim-pathogen)
+
+Therefore:
+
+ cd .vim/bundles
+ git clone git://github.com/AD7six/vim-independence.git
+
+Alternatively - simply put the file independence.vim in your plugin folder directly
+
+# Usage
+
+The plugin is automatic, if the file `.vimrc` exists in your git project root - it will load it
+
+For example, let's consider that you use the [Syntastic](https://github.com/scrooloose/syntastic)
+plugin, and most of your projects are php. The default standard for syntastic to check code against
+is the Zend standard - a reasonable default. If all of your projects follow the Zend standard, that's
+fine. If all of your projects follow a different standard - that's also fine, you can simply define
+`g:syntastic_phpcs_conf` in your `~/.vimrc` file and the syntastic plugin will take that config.
+
+If you need to follow more than one standard using vim independence that becomes easy:
+
+in `~/somepearproject` create `~/somepearproject/.vimrc` with the following contents:
+
+ let g:syntastic_phpcs_conf = '--standard=Pear`
+
+in `~/somesymfony2project` create `~/somesymfony2project/.vimrc` with the following contents:
+
+ let g:syntastic_phpcs_conf = '--standard=Symfony2`
+
+Etc.
+
+# Gotchas
+
+As you may deduce from the above example, if you modify a global variable in a project-specific
+`.vimrc` file - those settings will persist for all subsequent buffers you open.
+
+# Changelog
+
+* 0.1.0 Intial release
62 plugin/independence.vim
@@ -0,0 +1,62 @@
+""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+" independence.vim
+" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
+"
+" Authors: Andy Dawson <andydawson76 AT gmail DOT com>
+" Version: 0.1.0
+" Licence: http://www.opensource.org/licenses/mit-license.php
+" The MIT License
+" URL: http://github.com/AD7six/vim-independence
+"
+"-----------------------------------------------------------------------------
+"
+" Section: Documentation
+"
+" The vim independence plugin loads a .vimrc file from your git project root
+" if it exists
+"
+" This allows you to override your vim settings on a project by project basis
+
+" Section: Plugin header
+"
+" loaded_independence is set to 1 when initialization begins, and 2 when it
+" completes.
+
+if exists('g:loaded_independence')
+ finish
+endif
+let g:loaded_independence=1
+
+" Section: Event group setup
+" Log creating, opening and writing files
+augroup ActivityLog
+ au BufNewFile * call s:LoadConfig()
+ au BufReadPre * call s:LoadConfig()
+augroup END
+
+" Section: Script variables
+
+" Currently none
+
+" Section: Utility functions
+" These functions are not/should not be directly accessible
+
+" Function: LoadConfig()
+"
+" If the file .vimrc exists in the root of a git project - load it
+function s:LoadConfig()
+ let l:file = fnameescape(expand("%:p"))
+ if empty(l:file)
+ return
+ endif
+
+ let l:root = system('cd ' . fnameescape(expand("%:h")) . "; echo -n `git rev-parse --show-toplevel`")
+ let l:configFile = l:root . '/.vimrc'
+ if filereadable(l:configFile)
+ echom "Loading " . l:configFile
+ exec ":source " . l:configFile
+ endif
+endfunction
+
+" Section: Plugin completion
+let g:loaded_independence=2
Please sign in to comment.
Something went wrong with that request. Please try again.