, 05 Jun 2006
- " ZDR: This needs to be an AND (we are 'after the start of the pair' AND
- " we are 'before the end of the pair'). Otherwise, indentation
- " before the start of the script block will be affected; the end of
- " the pair will still match if we are before the beginning of the
- " pair.
- "
- if 0 < searchpair(js, '', '', 'nWb')
- \ && 0 < searchpair(js, '', '', 'nW')
- " we're inside javascript
-
- if getline(lnum) !~ js && getline(a:lnum) !~ ''
- if restore_ic == 0
- setlocal noic
- endif
- return GetJsIndent(a:lnum)
- endif
- endif
-
- if getline(lnum) =~ '\c'
- " line before the current line a:lnum contains
- " a closing . --> search for line before
- " starting to restore the indent.
- let preline = prevnonblank(search('\c', 'bW') - 1)
- if preline > 0
- if restore_ic == 0
- setlocal noic
- endif
- return indent(preline)
- endif
- endif
-
- let ind = HtmlIndentSum(lnum, -1)
- let ind = ind + HtmlIndentSum(a:lnum, 0)
-
- if restore_ic == 0
- setlocal noic
- endif
-
- return indent(lnum) + (&sw * ind)
-endfun
-
-let &cpo = s:cpo_save
-unlet s:cpo_save
-
-" [-- EOF /indent/html.vim --]
diff --git a/vim/dot_vim/indent/javascript.vim b/vim/dot_vim/indent/javascript.vim
deleted file mode 100644
index b0e190c..0000000
--- a/vim/dot_vim/indent/javascript.vim
+++ /dev/null
@@ -1,407 +0,0 @@
-" Vim indent file Language: JavaScript
-" Author: Preston Koprivica (pkopriv2@gmail.com)
-" URL:
-" Last Change: April 30, 2010
-
-" 0. Standard Stuff
-" =================
-
-" Only load one indent script per buffer
-if exists('b:did_indent')
- finish
-endif
-
-let b:did_indent = 1
-
-" Set the global log variable 1 = logging enabled, 0 = logging disabled
-if !exists("g:js_indent_log")
- let g:js_indent_log = 0
-endif
-
-setlocal indentexpr=GetJsIndent(v:lnum)
-setlocal indentkeys=
-
-
-setlocal cindent
-setlocal autoindent
-
-
-" 1. Variables
-" ============
-
-" Inline comments (for anchoring other statements)
-let s:js_mid_line_comment = '\s*\(\/\*.*\*\/\)*\s*'
-let s:js_end_line_comment = s:js_mid_line_comment . '\s*\(//.*\)*'
-let s:js_line_comment = s:js_end_line_comment
-
-" Comment/String Syntax Key
-let s:syn_comment = '\(Comment\|String\|Regexp\)'
-
-
-" 2. Aux. Functions
-" =================
-
-" = Method: IsInComment
-"
-" Determines whether the specified position is contained in a comment. "Note:
-" This depends on a
-function! s:IsInComment(lnum, cnum)
- return synIDattr(synID(a:lnum, a:cnum, 1), 'name') =~? s:syn_comment
-endfunction
-
-
-" = Method: IsComment
-"
-" Determines whether a line is a comment or not.
-function! s:IsComment(lnum)
- let line = getline(a:lnum)
-
- return s:IsInComment(a:lnum, 1) && s:IsInComment(a:lnum, strlen(line)) "Doesn't absolutely work. Only Probably!
-endfunction
-
-
-" = Method: GetNonCommentLine
-"
-" Grabs the nearest non-commented line
-function! s:GetNonCommentLine(lnum)
- let lnum = prevnonblank(a:lnum)
-
- while lnum > 0
- if s:IsComment(lnum)
- let lnum = prevnonblank(lnum - 1)
- else
- return lnum
- endif
- endwhile
-
- return lnum
-endfunction
-
-" = Method: SearchForPair
-"
-" Returns the beginning tag of a given pair starting from the given line.
-function! s:SearchForPair(lnum, beg, end)
- " Save the cursor position.
- let curpos = getpos(".")
-
- " Set the cursor position to the beginning of the line (default
- " behavior when using ==)
- call cursor(a:lnum, 0)
-
- " Search for the opening tag
- let mnum = searchpair(a:beg, '', a:end, 'bW',
- \ 'synIDattr(synID(line("."), col("."), 0), "name") =~? s:syn_comment' )
-
- "Restore the cursor position
- call cursor(curpos)
-
- " Finally, return the matched line number
- return mnum
-endfunction
-
-
-" Object Helpers
-" ==============
-let s:object_beg = '{[^}]*' . s:js_end_line_comment . '$'
-let s:object_end = '^' . s:js_mid_line_comment . '}[;,]\='
-
-
-function! s:IsObjectBeg(line)
- return a:line =~ s:object_beg
-endfunction
-
-function! s:IsObjectEnd(line)
- return a:line =~ s:object_end
-endfunction
-
-function! s:GetObjectBeg(lnum)
- return s:SearchForPair(a:lnum, '{', '}')
-endfunction
-
-
-" Array Helpers
-" ==============
-let s:array_beg = '\[[^\]]*' . s:js_end_line_comment . '$'
-let s:array_end = '^' . s:js_mid_line_comment . '[^\[]*\][;,]*' . s:js_end_line_comment . '$'
-
-
-function! s:IsArrayBeg(line)
- return a:line =~ s:array_beg
-endfunction
-
-function! s:IsArrayEnd(line)
- return a:line =~ s:array_end
-endfunction
-
-function! s:GetArrayBeg(lnum)
- return s:SearchForPair(a:lnum, '\[', '\]')
-endfunction
-
-
-" MultiLine Declaration/Invocation Helpers
-" ========================================
-let s:paren_beg = '([^)]*' . s:js_end_line_comment . '$'
-let s:paren_end = '^' . s:js_mid_line_comment . '[^(]*)[;,]*'
-
-function! s:IsParenBeg(line)
- return a:line =~ s:paren_beg
-endfunction
-
-function! s:IsParenEnd(line)
- return a:line =~ s:paren_end
-endfunction
-
-function! s:GetParenBeg(lnum)
- return s:SearchForPair(a:lnum, '(', ')')
-endfunction
-
-
-
-" Continuation Helpers
-" ====================
-let s:continuation = '\(+\|\\\)\{1}' . s:js_line_comment . '$'
-
-function! s:IsContinuationLine(line)
- return a:line =~ s:continuation
-endfunction
-
-function! s:GetContinuationBegin(lnum)
- let cur = a:lnum
-
- while s:IsContinuationLine(getline(cur))
- let cur -= 1
- endwhile
-
- return cur + 1
-endfunction
-
-
-" Switch Helpers
-" ==============
-let s:switch_beg_next_line = 'switch\s*(.*)\s*' . s:js_mid_line_comment . s:js_end_line_comment . '$'
-let s:switch_beg_same_line = 'switch\s*(.*)\s*' . s:js_mid_line_comment . '{\s*' . s:js_line_comment . '$'
-let s:switch_mid = '^.*\(case.*\|default\)\s*:\s*'
-
-function! s:IsSwitchBeginNextLine(line)
- return a:line =~ s:switch_beg_next_line
-endfunction
-
-function! s:IsSwitchBeginSameLine(line)
- return a:line =~ s:switch_beg_same_line
-endfunction
-
-function! s:IsSwitchMid(line)
- return a:line =~ s:switch_mid
-endfunction
-
-
-" Control Helpers
-" ===============
-let s:cntrl_beg_keys = '\(\(\(if\|for\|with\|while\)\s*(.*)\)\|\(try\|do\)\)\s*'
-let s:cntrl_mid_keys = '\(\(\(else\s*if\|catch\)\s*(.*)\)\|\(finally\|else\)\)\s*'
-
-let s:cntrl_beg = s:cntrl_beg_keys . s:js_end_line_comment . '$'
-let s:cntrl_mid = s:cntrl_mid_keys . s:js_end_line_comment . '$'
-
-let s:cntrl_end = '\(while\s*(.*)\)\s*;\=\s*' . s:js_end_line_comment . '$'
-
-function! s:IsControlBeg(line)
- return a:line =~ s:cntrl_beg
-endfunction
-
-function! s:IsControlMid(line)
- return a:line =~ s:cntrl_mid
-endfunction
-
-function! s:IsControlMidStrict(line)
- return a:line =~ s:cntrl_mid
-endfunction
-
-function! s:IsControlEnd(line)
- return a:line =~ s:cntrl_end
-endfunction
-
-" = Method: Log
-"
-" Logs a message to the stdout.
-function! s:Log(msg)
- if g:js_indent_log
- echo "LOG: " . a:msg
- endif
-endfunction
-
-
-" 3. Indenter
-" ===========
-function! GetJsIndent(lnum)
- " Grab the first non-comment line prior to this line
- let pnum = s:GetNonCommentLine(a:lnum-1)
-
- " First line, start at indent = 0
- if pnum == 0
- call s:Log("No, noncomment lines prior to the current line.")
- return 0
- endif
-
- " Grab the second non-comment line prior to this line
- let ppnum = s:GetNonCommentLine(pnum-1)
-
- call s:Log("Line: " . a:lnum)
- call s:Log("PLine: " . pnum)
- call s:Log("PPLine: " . ppnum)
-
- " Grab the lines themselves.
- let line = getline(a:lnum)
- let pline = getline(pnum)
- let ppline = getline(ppnum)
-
- " Determine the current level of indentation
- let ind = indent(pnum)
-
-
- " Handle: Object Closers (ie })
- " =============================
- if s:IsObjectEnd(line) && !s:IsComment(a:lnum)
- call s:Log("Line matched object end")
-
- let obeg = s:GetObjectBeg(a:lnum)
- let oind = indent(obeg)
- let oline = getline(obeg)
-
- call s:Log("The object beg was found at: " . obeg)
- return oind
- endif
-
- if s:IsObjectBeg(pline)
- call s:Log("Pline matched object beg")
- return ind + &sw
- endif
-
-
- " Handle: Array Closer (ie ])
- " ============================
- if s:IsArrayEnd(line) && !s:IsComment(a:lnum)
- call s:Log("Line matched array end")
-
- let abeg = s:GetArrayBeg(a:lnum)
- let aind = indent(abeg)
-
- call s:Log("The array beg was found at: " . abeg)
- return aind
- endif
-
- if s:IsArrayBeg(pline)
- call s:Log("Pline matched array beg")
- return ind + &sw
- endif
-
- " Handle: Parens
- " ==============
- if s:IsParenEnd(line) && !s:IsComment(a:lnum)
- call s:Log("Line matched paren end")
-
- let abeg = s:GetParenBeg(a:lnum)
- let aind = indent(abeg)
-
- call s:Log("The paren beg was found at: " . abeg)
- return aind
- endif
-
- if s:IsParenBeg(pline)
- call s:Log("Pline matched paren beg")
- return ind + &sw
- endif
-
-
- " Handle: Continuation Lines.
- " ========================================================
- if s:IsContinuationLine(pline)
- call s:Log('Pline is a continuation line.')
-
- let cbeg = s:GetContinuationBegin(pnum)
- let cind = indent(cbeg)
-
- call s:Log('The continuation block begin found at: ' . cbeg)
- return cind + &sw
- endif
-
- if s:IsContinuationLine(ppline)
- call s:Log('PPline was a continuation line but pline wasnt.')
- return ind - &sw
- endif
-
- " Handle: Switch Control Blocks
- " =============================
- if s:IsSwitchMid(pline)
- call s:Log("PLine matched switch cntrl mid")
- if s:IsSwitchMid(line) || s:IsObjectEnd(line)
- call s:Log("Line matched a cntrl mid")
- return ind
- else
- call s:Log("Line didnt match a cntrl mid")
- return ind + &sw
- endif
- endif
-
- if s:IsSwitchMid(line)
- call s:Log("Line matched switch cntrl mid")
- return ind - &sw
- endif
-
-
- " Handle: Single Line Control Blocks
- " ==================================
- if s:IsControlBeg(pline)
- call s:Log("Pline matched control beginning")
-
- if s:IsControlMid(line)
- call s:Log("Line matched a control mid")
- return ind
- elseif line =~ '^\s*{\s*$'
- call s:Log("Line matched an object beg")
- return ind
- else
- return ind + &sw
- endif
-
- endif
-
- if s:IsControlMid(pline)
- call s:Log("Pline matched a control mid")
-
- if s:IsControlMid(line)
- call s:Log("Line matched a control mid")
- return ind
- elseif s:IsObjectBeg(line)
- call s:Log("Line matched an object beg")
- return ind
- else
- call s:Log("Line didn't match a control mid or object beg."
- return ind + &sw
- endif
- endif
-
- if s:IsControlMid(line)
- call s:Log("Line matched a control mid.")
-
- if s:IsControlEnd(pline) || s:IsObjectEnd(pline)
- call s:Log("PLine matched control end")
- return ind
- else
- call s:Log("Pline didn't match object end")
- return ind - &sw
- endif
- endif
-
-
- if ( s:IsControlBeg(ppline) || s:IsControlMid(ppline) ) &&
- \ !s:IsObjectBeg(pline) && !s:IsObjectEnd(pline)
- call s:Log("PPLine matched single line control beg or mid")
- return ind - &sw
- endif
-
- " Handle: No matches
- " ==================
- "call s:Log("Line didn't match anything. Retaining indent")
- return ind
-endfunction
diff --git a/vim/dot_vimrc b/vim/dot_vimrc
index 5ae6a6d..15abfba 100644
--- a/vim/dot_vimrc
+++ b/vim/dot_vimrc
@@ -23,7 +23,7 @@ Bundle 'file-line'
Bundle 'tpope/vim-fugitive'
" Needs Vim compiled with Ruby
" Quick find files in project
-Bundle 'wincent/Command-T'
+Bundle 'wincent/Command-T'
" -- Buffer Nav --
" Tree view for managing tabs
@@ -54,20 +54,31 @@ Bundle 'tpope/vim-surround'
Bundle 'terryma/vim-multiple-cursors'
" -- GUI --
-Bundle 'vividchalk.vim'
-" Can probably drop this for wombat256
-Bundle 'vim-scripts/Wombat'
-Bundle 'wombat256.vim'
Bundle 'gregsexton/MatchTag'
" Custom Status Line
Bundle 'bling/vim-airline'
"Powerline Config
-"If using a patched font: https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts
+"If using a patched font: https://github.com/Lokaltog/vim-powerline/wiki/Patched-fonts
"let g:airline_powerline_fonts = 1
+" -- Themes --
+Bundle 'vividchalk.vim'
+Bundle 'wombat256.vim'
+"Bundle 'BusyBee.vim'
+Bundle 'nanotech/jellybeans.vim'
+"Bundle 'github.vim'
+Bundle 'candy.vim'
+Bundle 'therubymug/vim-pyte'
+Bundle 'eclipse.vim'
+Bundle 'summerfruit256.vim'
+Bundle 'nuvola.vim'
+Bundle 'altercation/vim-colors-solarized'
+
" -- Filetypes --
Bundle 'ViViDboarder/vim-forcedotcom'
Bundle 'pdurbin/vim-tsv'
+"Bundle 'chrisbra/csv.vim'
+Bundle 'pangloss/vim-javascript'
" ***************************
" Built in settings
@@ -140,19 +151,24 @@ try
colorscheme $VIM_COLOR
else
if has("gui_running")
- colorscheme wombat
+ colorscheme wombat256mod
else
colorscheme vividchalk
endif
endif
catch /^Vim\%((\a\+)\)\=:E185/
- " Colorschemes not installed yet
- " This happens when first installing bundles
+ " Colorschemes not installed yet
+ " This happens when first installing bundles
endtry
+" Set Airline theme
+if g:colors_name == 'github'
+ let g:airline_theme = 'solarized'
+endif
+
" Set gui fonts
if has("gui_running")
- if has("gui_win32")
+ if has("gui_win32")
set guifont=Consolas:h10:b
elseif has("gui_macvim")
try
@@ -209,7 +225,7 @@ nmap lw :set wrap!
nmap ws :set list!
" Map Shift+U to redo
-nnoremap
+nnoremap
" Stupid shift key fixes
cmap WQ wq
@@ -217,11 +233,16 @@ cmap Wq wq
cmap W w
cmap Q q
cmap Q! q!
+" Stupid semicolon files
+cnoremap w; w
+cnoremap W; w
+cnoremap q; q
+cnoremap Q; q
" Clearing highlighted search
nmap / :set hlsearch! hlsearch?
noremap :set hlsearch! hlsearch?
-" Clear search
+" Clear search
nmap cs :nohlsearch
" Code fold
@@ -231,6 +252,29 @@ nmap cf ?{zf%:nohlsearch
" PLUGIN SETTINGS
" ********************************
+" Airline config
+" Use short-form mode text
+let g:airline_mode_map = {
+ \ '__' : '-',
+ \ 'n' : 'N',
+ \ 'i' : 'I',
+ \ 'R' : 'R',
+ \ 'c' : 'C',
+ \ 'v' : 'V',
+ \ 'V' : 'V',
+ \ '' : 'V',
+ \ 's' : 'S',
+ \ 'S' : 'S',
+ \ '' : 'S',
+ \ }
+let g:airline#extensions#whitespace#trailing_format = 'tw[%s]'
+let g:airline#extensions#whitespace#mixed_indent_format = 'i[%s]'
+let g:airline_left_sep=''
+let g:airline_left_alt_sep=''
+let g:airline_right_sep=''
+let g:airline_right_alt_sep=''
+let g:airline#extensions#tabline#enabled = 1
+
" Buffet shortcut
nnoremap :Bufferlist
nnoremap bl :Bufferlist
@@ -289,7 +333,7 @@ endif
nnoremap u :CtrlPCurFile
nnoremap m :CtrlPMRUFiles
-" fugitive
+" fugitive
" Add some shortcuts for git commands
nnoremap gs :Gstatus
nnoremap gc :Gcommit