diff options
author | Ryan Kavanagh <ryanakca@kubuntu.org> | 2011-08-14 17:16:55 -0400 |
---|---|---|
committer | Ryan Kavanagh <ryanakca@kubuntu.org> | 2011-08-25 07:42:57 -0400 |
commit | 1c019761dfaf6be82de9284fa5e2b9dbfbdec27d (patch) | |
tree | 7ed6bd2f437d3a334bd7a81f62e6dfa63689272b /.vim/indent/indent-r.vim |
Initial import
Diffstat (limited to '')
-rw-r--r-- | .vim/indent/indent-r.vim | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/.vim/indent/indent-r.vim b/.vim/indent/indent-r.vim new file mode 100644 index 0000000..30c03c5 --- /dev/null +++ b/.vim/indent/indent-r.vim @@ -0,0 +1,50 @@ +" Vim indent file +" Language: R +" Author: Jeremy Stephens <jeremy.f.stephens@vanderbilt.edu> +" URL: +" Last Change: +" Version: +" Notes: +" Changes: +" Options: + +" Only load this indent file when no other was loaded. +if exists("b:did_indent") + finish +endif +let b:did_indent = 1 + +setlocal indentexpr=GetRIndent() +"setlocal indentkeys+=0=,0),=EO +setlocal indentkeys+=0=,0),=EO,=> + +" Only define the function once. +if exists("*GetRIndent") + finish +endif + +function GetRIndent() + " Find a non-blank line above the current line. + let lnum = prevnonblank(v:lnum - 1) + " Hit the start of the file, use zero indent. + if lnum == 0 + return 0 + endif + + let line = getline(lnum) " last line + let cline = getline(v:lnum) " current line + let pline = getline(lnum - 1) " previous to last line + let ind = indent(lnum) + + " Indent blocks enclosed by {} or () + "if line =~ '[{(]\s*\(#[^)}]*\)\=$' + if line =~ '[{(]\s*[^)}]*$' + let ind = ind + &sw + endif + if cline =~ '^\s*[)}]' + let ind = ind - &sw + endif + + return ind +endfunction +" vim: set ts=4 sw=4: |