aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-28 23:06:54 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-28 23:06:54 +1200
commit80449e388f2b1fb7a181dda17a789b17b16b2fbd (patch)
tree4a333aa96675e01bb1deb63aac6abb83429acac8 /plugin
parentMerge branch 'release/v0.2.0' into develop (diff)
downloadvim-foldlevelstart-stdin-80449e388f2b1fb7a181dda17a789b17b16b2fbd.tar.gz
vim-foldlevelstart-stdin-80449e388f2b1fb7a181dda17a789b17b16b2fbd.zip
Pare down to single command
Diffstat (limited to 'plugin')
-rw-r--r--plugin/foldlevelstart_stdin.vim16
1 files changed, 3 insertions, 13 deletions
diff --git a/plugin/foldlevelstart_stdin.vim b/plugin/foldlevelstart_stdin.vim
index 37caddc..7e3531c 100644
--- a/plugin/foldlevelstart_stdin.vim
+++ b/plugin/foldlevelstart_stdin.vim
@@ -5,24 +5,14 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('loaded_foldlevelstart_stdin') || &compatible
- finish
-endif
-if !has('autocmd') || !has('folding') || !exists('##StdinReadPre')
+if exists('loaded_foldlevelstart_stdin') || &compatible || v:version < 700
finish
endif
let loaded_foldlevelstart_stdin = 1
-" Check if 'foldlevelstart' is non-negative, and set 'foldlevel' to its value
-" if it is
-function! s:SetFoldlevel() abort
- if &foldlevelstart >= 0
- let &l:foldlevel = &foldlevelstart
- endif
-endfunction
-
" Watch for stdin reads and set fold level accordingly
augroup foldlevelstart_stdin
autocmd!
- autocmd StdinReadPre * call s:SetFoldlevel()
+ autocmd StdinReadPre *
+ \ let &l:foldlevel = max([&foldlevelstart, &g:foldlevel, 0])
augroup END