aboutsummaryrefslogtreecommitdiff
path: root/vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim')
-rw-r--r--vim/after/indent/awk.vim8
-rw-r--r--vim/after/indent/css.vim8
-rw-r--r--vim/after/indent/html.vim12
-rw-r--r--vim/after/indent/javascript.vim8
-rw-r--r--vim/after/indent/mail.vim8
-rw-r--r--vim/after/indent/perl.vim8
-rw-r--r--vim/after/indent/php.vim8
-rw-r--r--vim/after/indent/sh.vim8
-rw-r--r--vim/after/indent/vim.vim12
-rw-r--r--vim/autoload/indent.vim32
10 files changed, 45 insertions, 67 deletions
diff --git a/vim/after/indent/awk.vim b/vim/after/indent/awk.vim
index ba6dfdeb..61f09a1e 100644
--- a/vim/after/indent/awk.vim
+++ b/vim/after/indent/awk.vim
@@ -1,8 +1,2 @@
" Use four spaces for indentation
-setlocal expandtab
-setlocal shiftwidth=4
-let b:undo_ftplugin .= '|setlocal expandtab< shiftwidth<'
-if &l:softtabstop != -1
- let &l:softtabstop = &l:shiftwidth
- let b:undo_ftplugin .= '|setlocal softtabstop<'
-endif
+call indent#spaces(4)
diff --git a/vim/after/indent/css.vim b/vim/after/indent/css.vim
index ba6dfdeb..61f09a1e 100644
--- a/vim/after/indent/css.vim
+++ b/vim/after/indent/css.vim
@@ -1,8 +1,2 @@
" Use four spaces for indentation
-setlocal expandtab
-setlocal shiftwidth=4
-let b:undo_ftplugin .= '|setlocal expandtab< shiftwidth<'
-if &l:softtabstop != -1
- let &l:softtabstop = &l:shiftwidth
- let b:undo_ftplugin .= '|setlocal softtabstop<'
-endif
+call indent#spaces(4)
diff --git a/vim/after/indent/html.vim b/vim/after/indent/html.vim
index 72c92d21..c043f620 100644
--- a/vim/after/indent/html.vim
+++ b/vim/after/indent/html.vim
@@ -1,15 +1,9 @@
+" Use four spaces for indentation
+call indent#spaces(4)
+
" Clear away the flag we set to indent after paragraphs
unlet html_indent_inctags
" Don't re-indent lines on right-angle-bracket or enter
setlocal indentkeys-=<>>,<Return>
let b:undo_ftplugin .= '|setlocal indentkeys<'
-
-" Use four spaces for indentation
-setlocal expandtab
-setlocal shiftwidth=4
-let b:undo_ftplugin .= '|setlocal expandtab< shiftwidth<'
-if &l:softtabstop != -1
- let &l:softtabstop = &l:shiftwidth
- let b:undo_ftplugin .= '|setlocal softtabstop<'
-endif
diff --git a/vim/after/indent/javascript.vim b/vim/after/indent/javascript.vim
index ba6dfdeb..61f09a1e 100644
--- a/vim/after/indent/javascript.vim
+++ b/vim/after/indent/javascript.vim
@@ -1,8 +1,2 @@
" Use four spaces for indentation
-setlocal expandtab
-setlocal shiftwidth=4
-let b:undo_ftplugin .= '|setlocal expandtab< shiftwidth<'
-if &l:softtabstop != -1
- let &l:softtabstop = &l:shiftwidth
- let b:undo_ftplugin .= '|setlocal softtabstop<'
-endif
+call indent#spaces(4)
diff --git a/vim/after/indent/mail.vim b/vim/after/indent/mail.vim
index ba6dfdeb..61f09a1e 100644
--- a/vim/after/indent/mail.vim
+++ b/vim/after/indent/mail.vim
@@ -1,8 +1,2 @@
" Use four spaces for indentation
-setlocal expandtab
-setlocal shiftwidth=4
-let b:undo_ftplugin .= '|setlocal expandtab< shiftwidth<'
-if &l:softtabstop != -1
- let &l:softtabstop = &l:shiftwidth
- let b:undo_ftplugin .= '|setlocal softtabstop<'
-endif
+call indent#spaces(4)
diff --git a/vim/after/indent/perl.vim b/vim/after/indent/perl.vim
index ba6dfdeb..61f09a1e 100644
--- a/vim/after/indent/perl.vim
+++ b/vim/after/indent/perl.vim
@@ -1,8 +1,2 @@
" Use four spaces for indentation
-setlocal expandtab
-setlocal shiftwidth=4
-let b:undo_ftplugin .= '|setlocal expandtab< shiftwidth<'
-if &l:softtabstop != -1
- let &l:softtabstop = &l:shiftwidth
- let b:undo_ftplugin .= '|setlocal softtabstop<'
-endif
+call indent#spaces(4)
diff --git a/vim/after/indent/php.vim b/vim/after/indent/php.vim
index ba6dfdeb..61f09a1e 100644
--- a/vim/after/indent/php.vim
+++ b/vim/after/indent/php.vim
@@ -1,8 +1,2 @@
" Use four spaces for indentation
-setlocal expandtab
-setlocal shiftwidth=4
-let b:undo_ftplugin .= '|setlocal expandtab< shiftwidth<'
-if &l:softtabstop != -1
- let &l:softtabstop = &l:shiftwidth
- let b:undo_ftplugin .= '|setlocal softtabstop<'
-endif
+call indent#spaces(4)
diff --git a/vim/after/indent/sh.vim b/vim/after/indent/sh.vim
index ba6dfdeb..61f09a1e 100644
--- a/vim/after/indent/sh.vim
+++ b/vim/after/indent/sh.vim
@@ -1,8 +1,2 @@
" Use four spaces for indentation
-setlocal expandtab
-setlocal shiftwidth=4
-let b:undo_ftplugin .= '|setlocal expandtab< shiftwidth<'
-if &l:softtabstop != -1
- let &l:softtabstop = &l:shiftwidth
- let b:undo_ftplugin .= '|setlocal softtabstop<'
-endif
+call indent#spaces(4)
diff --git a/vim/after/indent/vim.vim b/vim/after/indent/vim.vim
index 320e5d7d..ce99f713 100644
--- a/vim/after/indent/vim.vim
+++ b/vim/after/indent/vim.vim
@@ -1,15 +1,9 @@
+" Use two (not four!) spaces for indentation, per convention
+call indent#spaces(2)
+
" Remove inapplicable defaults from 'indentkeys'; we should only need to undo
" this if the stock plugin didn't already arrange that (before v7.3.539)
setlocal indentkeys-=0#,0{,0},0),:
if !exists('b:undo_indent')
let b:undo_indent = 'setlocal indentkeys<'
endif
-
-" Observe VimL conventions for two-space indents
-setlocal expandtab
-setlocal shiftwidth=2
-let b:undo_indent .= '|setlocal expandtab< shiftwidth<'
-if &softtabstop != -1
- let &l:softtabstop = &l:shiftwidth
- let b:undo_indent .= '|setlocal softtabstop<'
-endif
diff --git a/vim/autoload/indent.vim b/vim/autoload/indent.vim
new file mode 100644
index 00000000..3e850c63
--- /dev/null
+++ b/vim/autoload/indent.vim
@@ -0,0 +1,32 @@
+function! indent#spaces(...) abort
+ setlocal expandtab
+ let &l:shiftwidth = a:0
+ \ ? a:1
+ \ : 0
+ let &l:softtabstop = has#('patch-7.3.693')
+ \ ? -1
+ \ : &l:shiftwidth
+ call indent#undo()
+endfunction
+
+function! indent#tabs() abort
+ setlocal noexpandtab shiftwidth< softtabstop<
+ call indent#undo()
+endfunction
+
+function! indent#undo() abort
+ if exists('b:undo_indent_set')
+ return
+ endif
+ let l:undo = 'call indent#reset()'
+ if exists('b:undo_indent')
+ let b:undo_indent .= '|'.l:undo
+ else
+ let b:undo_indent = l:undo
+ endif
+ let b:undo_indent_set = 1
+endfunction
+
+function! indent#reset() abort
+ setlocal expandtab< shiftwidth< softtabstop< tabstop<
+endfunction