aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim/init/config.vim
diff options
context:
space:
mode:
authorHsieh Chin Fan <pham@topo.tw>2024-08-01 00:32:50 +0800
committerHsieh Chin Fan <pham@topo.tw>2024-08-01 00:32:50 +0800
commitcc96870ff94afba7b0f2dc18f0209611ff7201f7 (patch)
tree82f71922f8a4b93da295229e024cbdd7809bdbba /vim/init/config.vim
parente94b17515037564d993209f7917329e8f9a42727 (diff)
Update
Diffstat (limited to 'vim/init/config.vim')
-rw-r--r--vim/init/config.vim30
1 files changed, 25 insertions, 5 deletions
diff --git a/vim/init/config.vim b/vim/init/config.vim
index e4403fb..318bc58 100644
--- a/vim/init/config.vim
+++ b/vim/init/config.vim
@@ -18,9 +18,9 @@ augroup TerminalSize
18 au! 18 au!
19 function! LayoutForSmallTerminal(bound) 19 function! LayoutForSmallTerminal(bound)
20 if &lines < a:bound || g:alacritty_extra_padding 20 if &lines < a:bound || g:alacritty_extra_padding
21 silent! set cmdheight=0 laststatus=0 showtabline=0 nowrap scrolloff=1 21 silent! set laststatus=0 showtabline=0 signcolumn=0 nowrap scrolloff=1
22 else 22 else
23 silent! set cmdheight& laststatus& showtabline=2 scrolloff=3 23 silent! set laststatus& showtabline& signcolumn& scrolloff&
24 endif 24 endif
25 endfunc 25 endfunc
26 autocmd VimEnter,VimResized * silent call LayoutForSmallTerminal(20) 26 autocmd VimEnter,VimResized * silent call LayoutForSmallTerminal(20)
@@ -148,6 +148,7 @@ augroup InitFileTypes
148 augroup Config_Markdown 148 augroup Config_Markdown
149 au! 149 au!
150 au FileType markdown call InitMarkdown() 150 au FileType markdown call InitMarkdown()
151 au FileType markdown let b:in_frontmatter = 0
151 152
152 function! InitMarkdown() 153 function! InitMarkdown()
153 setlocal wrap sw=2 ts=2 154 setlocal wrap sw=2 ts=2
@@ -159,12 +160,25 @@ augroup InitFileTypes
159 syn match DetailsEnd '^</details>' conceal cchar=E 160 syn match DetailsEnd '^</details>' conceal cchar=E
160 endfunc 161 endfunc
161 162
162 " Fold by heading level
163 function! MarkdownLevel() 163 function! MarkdownLevel()
164 " For frontmatter
165 if v:lnum == 1 && getline(1) =~ '^---'
166 let b:in_frontmatter = 1
167 return '>1'
168 endif
169 if b:in_frontmatter
170 if getline(v:lnum) =~ '^---'
171 let b:in_frontmatter = 0
172 return '<1'
173 else
174 return '='
175 endif
176 endif
177
178 " Fold for heading and the following contents
164 let hash_num = matchstr(getline(v:lnum), '^#\+') 179 let hash_num = matchstr(getline(v:lnum), '^#\+')
165 if !empty(hash_num) 180 if !empty(hash_num)
166 " HEADING 181 " HEADING
167 " return ">"..(len(hash_num) - 1)
168 return len(hash_num) == 1 ? 0 : '>1' 182 return len(hash_num) == 1 ? 0 : '>1'
169 else 183 else
170 " Contents 184 " Contents
@@ -173,8 +187,14 @@ augroup InitFileTypes
173 endfunc 187 endfunc
174 188
175 function! MarkdownFoldTextHeading() 189 function! MarkdownFoldTextHeading()
190 " For frontmatter
191 if v:foldstart == 1 && getline(v:foldstart) =~ '^---'
192 return '===FrontMatter==='
193 endif
194
195 " For heading, foltext()
176 let origin = split(MarkdownFoldText()[2:], ' ') 196 let origin = split(MarkdownFoldText()[2:], ' ')
177 let heading = substitute(join(origin[:-3], ' '), '\#', ' ', 'g') 197 let heading = substitute(join(origin[:-3], ' '), '\#', ' ', 'g')
178 let lines = join(origin[-2:], ' ')[1:-2] 198 let lines = join(origin[-2:], ' ')[1:-2]
179 let fills = repeat('.', 48 - len(heading) - len(lines)) 199 let fills = repeat('.', 48 - len(heading) - len(lines))
180 return heading.." "..fills.." "..lines 200 return heading.." "..fills.." "..lines