comparison .chezmoitemplates/config.vim @ 463:1d2e33dfe0c6

Clean up folding and foldtexts
author zegervdv <zegervdv@me.com>
date Fri, 24 Sep 2021 10:03:31 +0200
parents ae7e377bced8
children d2b877b4ef8b
comparison
equal deleted inserted replaced
462:676d7ef5fecb 463:1d2e33dfe0c6
237 augroup diff_files 237 augroup diff_files
238 au! 238 au!
239 au BufWritePost * if &diff == 1 | diffupdate | endif 239 au BufWritePost * if &diff == 1 | diffupdate | endif
240 augroup END 240 augroup END
241 " 241 "
242
243 " Custom folding by Steve Losh
244 function! MyFoldText() "
245 let line = getline(v:foldstart)
246
247 let nucolwidth = &fdc + &number * &numberwidth
248 let windowwidth = winwidth(0) - nucolwidth - 3
249 let foldedlinecount = v:foldend - v:foldstart
250
251 " expand tabs into spaces
252 let onetab = strpart(' ', 0, &tabstop)
253 let line = substitute(line, '\t', onetab, 'g')
254
255 let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
256 let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
257 return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
258 endfunction "
259 set foldtext=MyFoldText()
260 set foldopen+=jump
261 242
262 " Detect Filetype from content if file has no extension 243 " Detect Filetype from content if file has no extension
263 augroup newFileDetection 244 augroup newFileDetection
264 au! 245 au!
265 autocmd CursorMovedI * call CheckFileType() 246 autocmd CursorMovedI * call CheckFileType()
647 " System Verilog 628 " System Verilog
648 augroup ft_systemverilog 629 augroup ft_systemverilog
649 au! 630 au!
650 au FileType systemverilog setlocal suffixesadd+=.sv,.v 631 au FileType systemverilog setlocal suffixesadd+=.sv,.v
651 au FileType systemverilog setlocal foldmethod=expr 632 au FileType systemverilog setlocal foldmethod=expr
652 au FileType systemverilog setlocal foldexpr=nvim_treesitter#foldexpr()
653 au FileType systemverilog,verilog call SVAlign() 633 au FileType systemverilog,verilog call SVAlign()
654 au FileType systemverilog,verilog let b:delimitMate_quotes = "\"" 634 au FileType systemverilog,verilog let b:delimitMate_quotes = "\""
655 au FileType systemverilog,verilog set iskeyword+=' 635 au FileType systemverilog,verilog set iskeyword+='
656 augroup END 636 augroup END
657 637