aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin/foldlevelstart_stdin.vim
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-08-03 09:25:53 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-08-03 09:25:53 +1200
commit71ced1ccfa28a4dffe126b1408849676e4b36505 (patch)
tree73f184a6c4b81dbf6551fddc84810eb86dc4b86c /vim/plugin/foldlevelstart_stdin.vim
parentMerge branch 'hotfix/v1.41.1' (diff)
parentRebuild dotfiles(7) man page (diff)
downloaddotfiles-71ced1ccfa28a4dffe126b1408849676e4b36505.tar.gz
dotfiles-71ced1ccfa28a4dffe126b1408849676e4b36505.zip
Merge branch 'release/v1.42.0'v1.42.0
* release/v1.42.0: Rebuild dotfiles(7) man page Bump VERSION Remove unsupported pandoc(1) option Remove j/gj,k/gk maps again Revert "Remove & remaps" Add some experimental :vimgrep and :helpgrep maps Use g_ instead of $ for yanking command lines Correct \: mapping Round out execution mappings Use \! instead of \@ for line-execute Add 'confirm' Add \@ mapping to execute lines with 'shell' Revert "Remove j/gj remappings" Add leader mappings for < and > Check for existence of +completeopt Add longest and menuone to 'completeopt' Add equalalways_resized.vim plugin Remove trailing space from Vim plugin Add missing abort attribute to plugin Add scroll_next.vim plugin Don't set up 'wildignore' in &compatible mode Add foldlevelstart_stdin.vim plugin Correct syntax of new map Try an expanded mapping for <Space> Remove backspace mapping Update insert_cancel.vim plugin
Diffstat (limited to 'vim/plugin/foldlevelstart_stdin.vim')
-rw-r--r--vim/plugin/foldlevelstart_stdin.vim28
1 files changed, 28 insertions, 0 deletions
diff --git a/vim/plugin/foldlevelstart_stdin.vim b/vim/plugin/foldlevelstart_stdin.vim
new file mode 100644
index 00000000..f8e4d50e
--- /dev/null
+++ b/vim/plugin/foldlevelstart_stdin.vim
@@ -0,0 +1,28 @@
+"
+" foldlevelstart_stdin.vim: Set 'foldlevel' to 'foldlevelstart' after reading
+" from standard input, which Vim doesn't do by default.
+"
+" Author: Tom Ryder <tom@sanctum.geek.nz>
+" License: Same as Vim itself
+"
+if exists('g:loaded_foldlevelstart_stdin') || &compatible
+ finish
+endif
+if !has('autocmd') || !has('folding') || !exists('##StdinReadPre')
+ finish
+endif
+let g: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()
+augroup END