aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim/init/config.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/init/config.vim')
-rw-r--r--vim/init/config.vim118
1 files changed, 58 insertions, 60 deletions
diff --git a/vim/init/config.vim b/vim/init/config.vim
index 8c75de9..8d84ff1 100644
--- a/vim/init/config.vim
+++ b/vim/init/config.vim
@@ -145,71 +145,66 @@ augroup InitFileTypes
145 " }}} 145 " }}}
146 " Markdown {{{ 146 " Markdown {{{
147 147
148 augroup Config_Markdown 148 au FileType markdown call InitMarkdownFile()
149 au! 149 function! InitMarkdownFile()
150 150 setlocal wrap sw=2 ts=2
151 au FileType markdown call InitMarkdownFile() 151 let g:markdown_apply_heading_level = 0
152 function! InitMarkdownFile() 152 nnoremap \fl :let markdown_apply_heading_level = !markdown_apply_heading_level<CR>zX
153 setlocal wrap sw=2 ts=2 153
154 let g:markdown_apply_heading_level = 0 154 let b:in_frontmatter = 0
155 nnoremap \fl :let markdown_apply_heading_level = !markdown_apply_heading_level<CR>zX 155 setlocal foldexpr=MarkdownLevel() foldmethod=expr
156 156 setlocal foldtext=MarkdownFoldTextHeading()
157 let b:in_frontmatter = 0 157
158 setlocal foldexpr=MarkdownLevel() foldmethod=expr 158 call MarkdownHighlights()
159 setlocal foldtext=MarkdownFoldTextHeading() 159 endfunc
160 160
161 call MarkdownHighlights() 161 function! MarkdownHighlights()
162 endfunc 162 syn match MarkdownHtmlDetails '^<details>' conceal cchar=▶
163 163 syn match MarkdownHtmlSummary '<summary>' conceal cchar=
164 function! MarkdownHighlights() 164 syn match MarkdownHtmlSummaryEnd '</summary>' conceal
165 syn match MarkdownHtmlDetails '^<details>' conceal cchar=▶ 165 syn match MarkdownHtmlDetailsEnd '^</details>' conceal cchar=E
166 syn match MarkdownHtmlSummary '<summary>' conceal cchar= 166 endfunc
167 syn match MarkdownHtmlSummaryEnd '</summary>' conceal
168 syn match MarkdownHtmlDetailsEnd '^</details>' conceal cchar=E
169 endfunc
170
171 function! MarkdownLevel()
172 " For frontmatter
173 if v:lnum == 1 && getline(1) =~ '^---'
174 let b:in_frontmatter = 1
175 return '>1'
176 endif
177 if b:in_frontmatter
178 if getline(v:lnum) =~ '^---'
179 let b:in_frontmatter = 0
180 return '<1'
181 else
182 return '='
183 endif
184 endif
185 167
186 " Fold for heading and the following contents 168 function! MarkdownLevel()
187 let hash_num = matchstr(getline(v:lnum), '^#\+') 169 " For frontmatter
188 if !empty(hash_num) 170 if v:lnum == 1 && getline(1) =~ '^---'
189 let foldlevel = g:markdown_apply_heading_level ? len(hash_num) - 1 : 1 171 let b:in_frontmatter = 1
190 " HEADING 172 return '>1'
191 return len(hash_num) == 1 ? 0 : '>'.foldlevel 173 endif
174 if b:in_frontmatter
175 if getline(v:lnum) =~ '^---'
176 let b:in_frontmatter = 0
177 return '<1'
192 else 178 else
193 " Contents 179 return '='
194 return "="
195 endif 180 endif
196 endfunc 181 endif
197 182
198 function! MarkdownFoldTextHeading() 183 " Fold for heading and the following contents
199 " For frontmatter 184 let hash_num = matchstr(getline(v:lnum), '^#\+')
200 if v:foldstart == 1 && getline(v:foldstart) =~ '^---' 185 if !empty(hash_num)
201 return '===FrontMatter===' 186 let foldlevel = g:markdown_apply_heading_level ? len(hash_num) - 1 : 1
202 endif 187 " HEADING
188 return len(hash_num) == 1 ? 0 : '>'.foldlevel
189 else
190 " Contents
191 return "="
192 endif
193 endfunc
203 194
204 " For heading, foltext() 195 function! MarkdownFoldTextHeading()
205 let origin = split(MarkdownFoldText()[2:], ' ') 196 " For frontmatter
206 let heading = substitute(join(origin[:-3], ' '), '\#', ' ', 'g') 197 if v:foldstart == 1 && getline(v:foldstart) =~ '^---'
207 let lines = origin[-2][1:] 198 return '===FrontMatter==='
208 let fills = repeat('.', 48 - strwidth(heading) - len(lines)) 199 endif
209 return heading.." "..fills.." "..lines
210 endfunc
211 200
212 augroup END 201 " For heading, foltext()
202 let origin = split(MarkdownFoldText()[2:], ' ')
203 let heading = substitute(join(origin[:-3], ' '), '\#', ' ', 'g')
204 let lines = origin[-2][1:]
205 let fills = repeat('.', 48 - strwidth(heading) - len(lines))
206 return heading.." "..fills.." "..lines
207 endfunc
213 208
214 " }}} 209 " }}}
215 " HTML {{{ 210 " HTML {{{
@@ -255,9 +250,12 @@ augroup InitFileTypes
255 function! SetPasswordFile() 250 function! SetPasswordFile()
256 setlocal foldminlines=0 251 setlocal foldminlines=0
257 setlocal foldmethod=manual 252 setlocal foldmethod=manual
258 setlocal foldtext="Password" 253 setlocal foldtext=PasswordFoldtext()
259 norm! ggzfl 254 norm! ggzfl
260 endfunc 255 endfunc
256 function! PasswordFoldtext()
257 return "---Password---"
258 endfunc
261 " }}} 259 " }}}
262 " Beancount {{{ 260 " Beancount {{{
263 261