Browse code

Add implementation

Robert Cranston authored on 03/06/2022 01:42:07
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,78 @@
1
+""
2
+" @section About
3
+" - Version: 1.0.0
4
+" - Author:  Robert Cranston
5
+" - License: ISC
6
+" - URL:     https://git.rcrnstn.net/rcrnstn/vim-unobtrusive-fold
7
+" @order intro config commands functions example about
8
+
9
+""
10
+" @section Introduction, intro
11
+" unobtrusive-fold provides commands that define folds from text that blends in
12
+" with the rest of the content, such as comments or markup headings.
13
+" Optionally, this can be combined with folds for indented paragraphs. Folds
14
+" are automatically ended when the indentation drops below that of the line
15
+" where the fold was introduced. It also provides 'foldtext' function and a
16
+" command for debugging 'foldexpr's.
17
+
18
+""
19
+" @section Example
20
+" Example |vimrc|:
21
+" >
22
+"   set commentstring=
23
+"   set shiftwidth=2
24
+"   set textwidth=79
25
+"   set fillchars+=fold:─
26
+"   set foldtext=unobtrusive_fold#text()
27
+"
28
+"   syntax enable
29
+"   filetype plugin indent on
30
+"
31
+"   autocmd FileType *        UnobtrusiveFoldComment
32
+"   autocmd FileType markdown UnobtrusiveFoldChar #
33
+
34
+"" Guard
35
+if exists('g:loaded_unobtrusive_fold') || &compatible
36
+  finish
37
+endif
38
+let g:loaded_unobtrusive_fold = 1
39
+
40
+"" Commands
41
+
42
+"" :UnobtrusiveFoldComment
43
+
44
+""
45
+" Sets the current window's 'foldmethod', 'foldexpr', and plugin-internal
46
+" variables based on the current buffer's 'commentstring'. Does nothing when it
47
+" is empty. Give ! to enable indented paragraph folding.
48
+"
49
+" Defines folds with a fold level equal to the number of times the last
50
+" character (ignoring whitespace) of the first part of 'commentstring' is
51
+" repeated (not including the first occurrence) at the start of line. For
52
+" example, if 'commentstring' is `/* %s */`, `/**` starts a level 1 fold,
53
+" `/***` starts a level 2 fold, etc.
54
+command -bar -bang -nargs=0 UnobtrusiveFoldComment
55
+\ call unobtrusive_fold#comment(<q-bang>)
56
+
57
+"" :UnobtrusiveFoldChar
58
+
59
+""
60
+" Sets the current window's 'foldmethod', 'foldexpr' and plugin-internal
61
+" variables based on {char}. Lines in syntax groups whose names contain
62
+" "Comment", "Code", or "Snippet" are ignored. Give ! to enable indented
63
+" paragraph folding.
64
+"
65
+" Defines folds with a fold level equal to the number of times {char} is
66
+" repeated at the start of line (including the first occurrence) at the start
67
+" of line. For example, if {char} is `#`, `#` starts a level 1 fold, `##`
68
+" starts a level 2 fold, etc.
69
+command -bar -bang -nargs=1 UnobtrusiveFoldChar
70
+\ call unobtrusive_fold#char(<q-bang>, <f-args>)
71
+
72
+"" :UnobtrusiveFoldDebug
73
+
74
+""
75
+" Inserts the return value of 'foldexpr' and the effective |foldlevel()| into
76
+" the leftmost columns of the current buffer.
77
+command -bar -nargs=0 UnobtrusiveFoldDebug
78
+\ call unobtrusive_fold#debug()