vimconfig / .vimrc

" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below.  If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed.  It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the
" following enables syntax highlighting by default.
if has("syntax")
  syntax on

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
"  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
"  filetype plugin indent on

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd		"Show (partial) command in status line.
"set showmatch		"Show matching brackets.
"set ignorecase		"Do case insensitive matching
"set smartcase		"Do smart case matching
"set incsearch		"Incremental search
"set autowrite		"Automatically save before commands like :next and :make
"set hidden         "Hide buffers when they are abandoned
"set mouse=a		"Enable mouse usage (all modes)

" Source a global configuration file if available
"if filereadable("/etc/vim/vimrc.local")
"  source /etc/vim/vimrc.local

" my additions
call pathogen#infect()
filetype on         "enables filetype detection
filetype plugin on  "enables filetype specific plugins
set guioptions-=T   "remove toolbar
set expandtab
set tabstop=4       "set tabstop at 4
set softtabstop=4
set hlsearch        "highlight searches
set shiftwidth=4    "numbers of spaces to (auto)indent
set ruler           "show the cursor position all the time
set number          "show line numbers
set backspace=2     "make backspace work more as expected - mainly for windows
"set autoindent     "always set autoindenting on
"set indentexpr=GetIndent()
"set smartindent    "smart indent
"set cindent        "cindent
set noautoindent
set nosmartindent
set nocindent
set encoding=utf-8
set t_Co=256
set laststatus=2    " show status bar. CLI vim doesn't show it
set wildignore=*.exe,CVS,*.class,*.dll,*.pyc,*.bak,*.jpg,*.gif,*.png,*.bmp,*.zip,*.rar,*.tar.gz
"Syntax highlight option above unlike on my win machine
set list

function GetIndent()
	let lnum = prevnonblank(v:lnum - 1)
	let ind = indent(lnum)
	return ind

"Highlight white space
""Change char based on whether it's unix or win
if has("win32")
    set listchars=tab:>-,eol:^
    set listchars=tab:▸\ ,eolendif

"Keyboard mappings
"map F1 to open previous buffer
map <F1> :bprev<CR>
"map F2 to open next buffer
map <F2> :bnext<CR>
"map F3 to open NerdTree
map <F3> :NERDTree $HOME<CR>

"Common command line typos
cmap W w
cmap Q q

map ,p :CommandT<CR>

" Move around windows with Alt + arrow keys
" Note: nmap so it only works in normal mode
nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Left> :wincmd h<CR>
nmap <silent> <A-Right> :wincmd l<CR>

"----- write out html file
map ,h :source $VIM/vim73/syntax/2html.vim<cr>:w<cr>:clo<cr>

au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery

"NOTE for windows use double quotes around % to account for directories with spaces

"--php compile
au BufNewFile,BufRead *.php map <buffer><F6> :w!<cr>
\ :!php -l "%"<CR>
"--php run
au BufNewFile,BufRead *.php map <buffer><F7> :w!<cr>
\ :!php "%"<CR>

"--python pylint (-r n = reports no)
au BufNewFile,BufRead *.py map <buffer><F6> :w!<CR>
\ :!pylint -r n "%"<CR>
"--python run (-r n = reports no)
au BufNewFile,BufRead *.py map <buffer><F7> :w!<CR>
\ :!python "%"<CR>

"--perl syntax check / some useful warning checks / taint checks
au BufNewFile,BufRead *.pl map <buffer><F6> :w!<cr>
\ :!perl -cwT "%"<CR>
au BufNewFile,BufRead *.pl map <buffer><F7> :w!<cr>
\ :!perl "%"<CR>
"--xmllint xml file formatting
au FileType xml exe ":silent 1,$!xmllint --format --recover - 2>/dev/null"

"Temp files
au BufWritePre * let &bex = '-' . strftime("%Y%m%d-%H%M%S") . '.vimbackup'

"On Windows I'll just dump the stuff in <vim folder>/temp
""otherwise <HOME>/temp
if has("win32")
    set backupdir=$VIM/temp//
    set directory=$VIM/temp//
    set backupdir=$HOME/temp//
    set directory=$HOME/temp//

"set nobackup
"set nowritebackup

let g:NERDTreeQuitOnOpen = 1
let g:NERDTreeChDirMode = 0

"mini buffer plugin options
"let g:miniBufExplMapWindowNavVim = 1
"let g:miniBufExplMapWindowNavArrows = 1
"let g:miniBufExplMapCTabSwitchBufs = 1
"let g:miniBufExplModSelTarget = 1

"buftab settings
let g:buftabs_only_basename = 1                 "show only the file basename
let g:buftabs_in_statusline = 1                 "show in the status line rather than commandline
let g:buftabs_other_components_length = 20      "give legnt of 20 to other status line compoents
let g:buftabs_active_highlight_group="Visual"   "highlight active
let g:buftabs_show_number = 1                   "show buffer number
let g:buftabs_marker_start = "["                "signifies start of buffer name
let g:buftabs_marker_end = "]"                  "signifies end of buffer name
let g:buftabs_separator = "-"                   "buffer seperator
let g:buftabs_marker_modified = "!"             "marker for modified buffer
"don't show NERD_tree buffers
let g:buftabs_blacklist = ["^NERD_tree_[0-9]*$"]
"set up status bar for buftab
set statusline=\ #{buftabs}%=\ \ Ln\ %-5.5l\ Col\ %-4.4v

"task list options
"map T :TaskList<CR>
let g:tlWindowPosition = 1		"open at the bottom - 0 for top
let g:tlRememberPosition = 1

" toggle if can't get 256 color terminal
"colorscheme delek
colorscheme aldmeris

if has("gui_running")
    highlight SpellBad term=underline gui=undercurl guisp=Red
    set lines=55
    set columns=120
    winpos 10 10
    " using 256 color term for most machines now
    "colorscheme aldmeris
    "colorscheme morrowind

"Set Windows font - will likely change but this will
""do for now
if has ("win32")
    set guifont=Courier_New:h9:cANSI

"ant menu
let g:buildFile='build.xml' 
let g:antOption='-debug' 
if has("win32")
    let g:logFile='$VIM/log/ant.log'
    let g:logFile='$HOME/log/ant.log'

" end of my additions

" Cref commands
" \cr (normal/visual mode) -  get reference for word
" \cw - prompt for word to search for
" \cc - go to toc for ref manual
" To add ref to help - :helptags <path to cref doc folder>
" LuaRef commands
" \lr (normal/visual mode) - get reference for word
" \lc - go to toc for ref manual
" To add ref to help - :helptags <path to luaref doc folder>