From 449c7d316d7176c0fe44bf570d18d013fe3f3272 Mon Sep 17 00:00:00 2001
From: Max Christian Pohle
Date: Wed, 31 Jan 2018 00:39:09 +0100
Subject: Added comment folding to C filetype

this works by overruling some of the default settings, see :help mysyntaxfile-add*
---
 after/syntax/c.vim | 25 +++++++++++++++++++++++++
 ftplugin/c.vim     |  9 ---------
 vimrc-full         | 15 +++++++++++++--
 3 files changed, 38 insertions(+), 11 deletions(-)
 create mode 100644 after/syntax/c.vim
 delete mode 100644 ftplugin/c.vim

diff --git a/after/syntax/c.vim b/after/syntax/c.vim
new file mode 100644
index 0000000..ca694a2
--- /dev/null
+++ b/after/syntax/c.vim
@@ -0,0 +1,25 @@
+set number
+set foldenable
+set foldmethod=syntax
+
+" syntax match cType "struct\s+[A-Za-z0-9_]+\>"
+" syn clear cStructure
+" highlight! link defines Special
+syntax match Define "\<[A-Z][A-Z0-9_]*\>"
+syntax match Todo "\/\/ @[A-Z]*\:.*$"
+
+" clear default group for a cBlock so we can redefine it without the fold option
+syn clear cBlock
+syn region cBlock start=/{/ end=/}/ transparent
+
+" multiple single line comments in a row
+syn match cComment /\v\/\/.*(\_.\/\/.*)+/ fold
+
+
+
+
+" let b:current_syntax    = "c"
+" let g:polyglot_disabled = ['c/c++']
+" unlet s:ft
+" let &cpo = s:cpo_save
+" unlet s:cpo_save
diff --git a/ftplugin/c.vim b/ftplugin/c.vim
deleted file mode 100644
index 12ba001..0000000
--- a/ftplugin/c.vim
+++ /dev/null
@@ -1,9 +0,0 @@
-set number
-
-syntax match Define "\<[A-Z][A-Z0-9_]*\>"
-syntax match Todo "\/\/ @[A-Z]*\:.*$"
-
-" syntax match cType "struct\s+[A-Za-z0-9_]+\>"
-" syn clear cStructure
-" highlight! link defines Special
-
diff --git a/vimrc-full b/vimrc-full
index 02c7246..494495d 100644
--- a/vimrc-full
+++ b/vimrc-full
@@ -41,7 +41,7 @@ if has("multi_byte")
   set encoding=utf-8         | " we need default UTF-8 encoding to use cool chars as line break and so on (see below)
   let &termencoding=&encoding | " once we use special chars we assume everybody uses a terminal supporting those
 
-  set fillchars+=fold:\—     | "
+  set fillchars+=fold:\      | "
   set fillchars+=vert:\║     | " cool vertical split char
   set fillchars+=diff:\      | " a white space gets used here
 
@@ -223,7 +223,9 @@ set foldcolumn=0              | " I think I don't need this second indicator
 " set foldmethod=syntax         | " foldlevel: syntax, indent, manual / foldmethod=syntax makes Vim incredible slow
 set foldnestmax=1             | " top level folding only
 set foldopen=block,hor,search | " when do we unfold?
-set foldtext=Foldtext()       | "
+let v:foldstart = "FOO"
+" set foldtext=Foldtext()       | "
+set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\v^/[/*]\','','g')
 
 " vim window behaviour
 set splitbelow                | " open new windows below the current one (i find that more intuitive)
@@ -365,6 +367,12 @@ if has("autocmd")
     autocmd FileType vim    setlocal keywordprg=:help |.
     autocmd FileType c,cpp  setlocal equalprg=clang-format
     autocmd FileType c,cpp  setlocal breakat-=-
+
+    if filereadable("/usr/bin/vendor_perl/ack")
+      autocmd FileType c,cpp  set grepprg=/usr/bin/vendor_perl/ack\ --type=cc\ --nogroup\ --column\ $*
+      autocmd FileType c,cpp  set grepformat=%f:%l:%c:%m
+    endif
+
     autocmd BufWinEnter * if &previewwindow | setlocal nonumber signcolumn=no filetype=c nobuflisted | endif
 
 
@@ -373,6 +381,9 @@ if has("autocmd")
     " the following helps to make file=/etc/something work with gf, but disallows filenames with an equal sign in them
     autocmd FileType conf   setlocal isfname-==
 
+
+    autocmd Filetype css command! CSSsort :g/{/+1;/}/-1 sort
+
     " keyboard mapping for xml alike languages
     " Alt-Up : Move cursor up one tag
     " Alt-Down: Move cursor down one tag
-- 
cgit v1.2.3