diff options
author | Max Christian Pohle | 2018-10-14 21:33:03 +0200 |
---|---|---|
committer | Max Christian Pohle | 2018-10-14 21:33:03 +0200 |
commit | 45c3e3581b74060dae453ac097e5a4d629603393 (patch) | |
tree | 48820d3971d86187c5754729b9f4ca598f87ee77 /after | |
parent | c2808a2053fa4d382a1ad7edc9637951c9eefc55 (diff) | |
download | vim-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')
-rw-r--r-- | after/syntax/c.vim | 11 |
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 @@ | |||
1 | setlocal number | ||
2 | setlocal foldenable | 1 | setlocal foldenable |
3 | setlocal foldmethod=expr | 2 | setlocal foldmethod=expr |
4 | setlocal 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') |
7 | setlocal 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 |