aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-08-16 22:21:34 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-08-16 22:21:34 +1200
commit77d9d2c3ee865f6334ffda5d665ecb6cdf0541cd (patch)
tree25eb88c2ff5b4c4c497c127d3eb6a00c838a9807
downloadvim-foldlevelstart-stdin-77d9d2c3ee865f6334ffda5d665ecb6cdf0541cd.tar.gz
vim-foldlevelstart-stdin-77d9d2c3ee865f6334ffda5d665ecb6cdf0541cd.zip
First versionv0.1.0
-rw-r--r--README.md13
-rw-r--r--VERSION1
-rw-r--r--doc/foldlevelstart_stdin.txt21
-rw-r--r--plugin/foldlevelstart_stdin.vim28
4 files changed, 63 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..3087e91
--- /dev/null
+++ b/README.md
@@ -0,0 +1,13 @@
+foldlevelstart\_stdin.vim
+=========================
+
+This tiny plugin sets `'foldlevel'` to `'foldlevelstart'` after reading from
+standard input, which Vim doesn't do by default.
+
+License
+-------
+
+Copyright (c) [Tom Ryder][1]. Distributed under the same terms as Vim itself.
+See `:help license`.
+
+[1]: https://sanctum.geek.nz/
diff --git a/VERSION b/VERSION
new file mode 100644
index 0000000..6e8bf73
--- /dev/null
+++ b/VERSION
@@ -0,0 +1 @@
+0.1.0
diff --git a/doc/foldlevelstart_stdin.txt b/doc/foldlevelstart_stdin.txt
new file mode 100644
index 0000000..97945c3
--- /dev/null
+++ b/doc/foldlevelstart_stdin.txt
@@ -0,0 +1,21 @@
+*foldlevelstart_stdin.txt* For Vim version 7.0 Last change: 2018 Aug 16
+
+DESCRIPTION *foldlevelstart_stdin*
+
+This tiny plugin sets 'foldlevel' to 'foldlevelstart' after reading from
+standard input, which Vim doesn't do by default.
+
+REQUIREMENTS *foldlevelstart_stdin-requirements*
+
+This plugin only loads if 'compatible' is not set. It requires the |+autocmd|,
+and |+folding| features, with the |StdinReadPre| event introduced in Vim.
+
+AUTHOR *foldlevelstart_stdin-author*
+
+Written and maintained by Tom Ryder <tom@sanctum.geek.nz>.
+
+LICENSE *foldlevelstart_stdin-license*
+
+Licensed for distribution under the same terms as Vim itself (see |license|).
+
+ vim:tw=78:ts=8:ft=help:norl:
diff --git a/plugin/foldlevelstart_stdin.vim b/plugin/foldlevelstart_stdin.vim
new file mode 100644
index 0000000..f8e4d50
--- /dev/null
+++ b/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