aboutsummaryrefslogtreecommitdiff
path: root/after/syntax
diff options
context:
space:
mode:
authorMax Christian Pohle2018-10-14 21:33:03 +0200
committerMax Christian Pohle2018-10-14 21:33:03 +0200
commit45c3e3581b74060dae453ac097e5a4d629603393 (patch)
tree48820d3971d86187c5754729b9f4ca598f87ee77 /after/syntax
parentc2808a2053fa4d382a1ad7edc9637951c9eefc55 (diff)
downloadvim-45c3e3581b74060dae453ac097e5a4d629603393.tar.bz2
vim-45c3e3581b74060dae453ac097e5a4d629603393.zip
Improved code folding and tidied up
The new foldexpr hides everything if its highlight group has 'comment' to it. The foldtext has also been improved and now shows textwidth characters. By now also 0 is allowed, but then it is as if foldtext would be empty. I will probably remove this.
Diffstat (limited to 'after/syntax')
-rw-r--r--after/syntax/c.vim11
1 files changed, 6 insertions, 5 deletions
diff --git a/after/syntax/c.vim b/after/syntax/c.vim
index 49e96f0..72136f6 100644
--- a/after/syntax/c.vim
+++ b/after/syntax/c.vim
@@ -1,11 +1,13 @@
1setlocal number
2setlocal foldenable 1setlocal foldenable
3setlocal foldmethod=expr 2setlocal foldmethod=expr
4setlocal foldcolumn=0 3" setlocal foldcolumn=0
5 4
6" setlocal foldexpr=get(synstack(v:lnum,1),0)==hlID('cComment') 5" setlocal foldexpr=get(synstack(v:lnum,1),0)==hlID('cComment')
7setlocal foldexpr=index([0,hlID('cComment'),hlID('Comment')],get(synstack(v:lnum,1),0)) 6" setlocal foldexpr=len(filter(synstack(v:lnum,indent(v:lnum)+1),'index([hlID(\"cComment\"),hlID(\"cCommentStart\")],v:val)!=-1'))>0
8 7" setlocal foldtext=printf('%*s%.'.eval(&textwidth-indent(v:foldstart)).'S',indent(v:foldstart),'',substitute(substitute(substitute(join(getline(v:foldstart,v:foldend)),'\\s\\s\\+\\\|\[\*\/\]','\ ','g'),'\^\\s\\+','','g'),\ '\\s\\s\\+',\ '\ ',\ 'g'))
8" setlocal foldexpr=index(get(synstack(v:lnum,1),0),hlID('cComment'))>0
9" setlocal foldexpr=index(synstack(v:lnum,indent(v:lnum)+1),hlID('cComment'))>0
10" setlocal signcolumn=no
9" syntax match cType "struct\s+[A-Za-z0-9_]+\>" 11" syntax match cType "struct\s+[A-Za-z0-9_]+\>"
10" syn clear cStructure 12" syn clear cStructure
11" highlight! link defines Special 13" highlight! link defines Special
@@ -23,7 +25,6 @@ syn region cBlock start=/{/ end=/}/ transparent
23" syn region myCComment start="/\*" end="\*/" fold keepend transparent 25" syn region myCComment start="/\*" end="\*/" fold keepend transparent
24 26
25 27
26
27" let b:current_syntax = "c" 28" let b:current_syntax = "c"
28" let g:polyglot_disabled = ['c/c++'] 29" let g:polyglot_disabled = ['c/c++']
29" unlet s:ft 30" unlet s:ft
..