aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Christian Pohle2018-01-31 00:39:09 +0100
committerMax Christian Pohle2018-01-31 00:39:09 +0100
commit449c7d316d7176c0fe44bf570d18d013fe3f3272 (patch)
tree2ec21421dbc510af0a3cee533711821f887483b8
parent7eea1b6c9c6f807fe53ff896a88a14171334c690 (diff)
downloadvim-449c7d316d7176c0fe44bf570d18d013fe3f3272.tar.bz2
vim-449c7d316d7176c0fe44bf570d18d013fe3f3272.zip
Added comment folding to C filetype
this works by overruling some of the default settings, see :help mysyntaxfile-add*
-rw-r--r--after/syntax/c.vim25
-rw-r--r--ftplugin/c.vim9
-rw-r--r--vimrc-full15
3 files changed, 38 insertions, 11 deletions
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 @@
1set number
2set foldenable
3set foldmethod=syntax
4
5" syntax match cType "struct\s+[A-Za-z0-9_]+\>"
6" syn clear cStructure
7" highlight! link defines Special
8syntax match Define "\<[A-Z][A-Z0-9_]*\>"
9syntax match Todo "\/\/ @[A-Z]*\:.*$"
10
11" clear default group for a cBlock so we can redefine it without the fold option
12syn clear cBlock
13syn region cBlock start=/{/ end=/}/ transparent
14
15" multiple single line comments in a row
16syn match cComment /\v\/\/.*(\_.\/\/.*)+/ fold
17
18
19
20
21" let b:current_syntax = "c"
22" let g:polyglot_disabled = ['c/c++']
23" unlet s:ft
24" let &cpo = s:cpo_save
25" 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 @@
1set number
2
3syntax match Define "\<[A-Z][A-Z0-9_]*\>"
4syntax match Todo "\/\/ @[A-Z]*\:.*$"
5
6" syntax match cType "struct\s+[A-Za-z0-9_]+\>"
7" syn clear cStructure
8" highlight! link defines Special
9
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")
41 set encoding=utf-8 | " we need default UTF-8 encoding to use cool chars as line break and so on (see below) 41 set encoding=utf-8 | " we need default UTF-8 encoding to use cool chars as line break and so on (see below)
42 let &termencoding=&encoding | " once we use special chars we assume everybody uses a terminal supporting those 42 let &termencoding=&encoding | " once we use special chars we assume everybody uses a terminal supporting those
43 43
44 set fillchars+=fold:\ | " 44 set fillchars+=fold:\ | "
45 set fillchars+=vert:\║ | " cool vertical split char 45 set fillchars+=vert:\║ | " cool vertical split char
46 set fillchars+=diff:\ | " a white space gets used here 46 set fillchars+=diff:\ | " a white space gets used here
47 47
@@ -223,7 +223,9 @@ set foldcolumn=0 | " I think I don't need this second indicator
223" set foldmethod=syntax | " foldlevel: syntax, indent, manual / foldmethod=syntax makes Vim incredible slow 223" set foldmethod=syntax | " foldlevel: syntax, indent, manual / foldmethod=syntax makes Vim incredible slow
224set foldnestmax=1 | " top level folding only 224set foldnestmax=1 | " top level folding only
225set foldopen=block,hor,search | " when do we unfold? 225set foldopen=block,hor,search | " when do we unfold?
226set foldtext=Foldtext() | " 226let v:foldstart = "FOO"
227" set foldtext=Foldtext() | "
228set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\v^/[/*]\','','g')
227 229
228" vim window behaviour 230" vim window behaviour
229set splitbelow | " open new windows below the current one (i find that more intuitive) 231set splitbelow | " open new windows below the current one (i find that more intuitive)
@@ -365,6 +367,12 @@ if has("autocmd")
365 autocmd FileType vim setlocal keywordprg=:help |. 367 autocmd FileType vim setlocal keywordprg=:help |.
366 autocmd FileType c,cpp setlocal equalprg=clang-format 368 autocmd FileType c,cpp setlocal equalprg=clang-format
367 autocmd FileType c,cpp setlocal breakat-=- 369 autocmd FileType c,cpp setlocal breakat-=-
370
371 if filereadable("/usr/bin/vendor_perl/ack")
372 autocmd FileType c,cpp set grepprg=/usr/bin/vendor_perl/ack\ --type=cc\ --nogroup\ --column\ $*
373 autocmd FileType c,cpp set grepformat=%f:%l:%c:%m
374 endif
375
368 autocmd BufWinEnter * if &previewwindow | setlocal nonumber signcolumn=no filetype=c nobuflisted | endif 376 autocmd BufWinEnter * if &previewwindow | setlocal nonumber signcolumn=no filetype=c nobuflisted | endif
369 377
370 378
@@ -373,6 +381,9 @@ if has("autocmd")
373 " the following helps to make file=/etc/something work with gf, but disallows filenames with an equal sign in them 381 " the following helps to make file=/etc/something work with gf, but disallows filenames with an equal sign in them
374 autocmd FileType conf setlocal isfname-== 382 autocmd FileType conf setlocal isfname-==
375 383
384
385 autocmd Filetype css command! CSSsort :g/{/+1;/}/-1 sort
386
376 " keyboard mapping for xml alike languages 387 " keyboard mapping for xml alike languages
377 " Alt-Up : Move cursor up one tag 388 " Alt-Up : Move cursor up one tag
378 " Alt-Down: Move cursor down one tag 389 " Alt-Down: Move cursor down one tag
..