diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2019-12-18 17:32:18 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2019-12-18 17:32:18 +1300 |
commit | c978da17884ef456cb41d28133790550f98b6ae8 (patch) | |
tree | cc8580f3d91f32367b08b5f6d194d705961de71a /vim/autoload/indent.vim | |
parent | Merge branch 'release/v8.5.0' (diff) | |
parent | Bump VERSION (diff) | |
download | dotfiles-c978da17884ef456cb41d28133790550f98b6ae8.tar.gz dotfiles-c978da17884ef456cb41d28133790550f98b6ae8.zip |
Merge branch 'release/v8.6.0'v8.6.0
* release/v8.6.0:
Refactor indent macros into autoload function
Fix indentation of a Makefile line
Put common indent setting patterns in macros
Diffstat (limited to 'vim/autoload/indent.vim')
-rw-r--r-- | vim/autoload/indent.vim | 32 |
1 files changed, 32 insertions, 0 deletions
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 |