aboutsummaryrefslogtreecommitdiff
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
parentc2808a2053fa4d382a1ad7edc9637951c9eefc55 (diff)
downloadvim-karlmarks-45c3e3581b74060dae453ac097e5a4d629603393.tar.bz2
vim-karlmarks-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.
-rw-r--r--after/syntax/c.vim11
-rw-r--r--vimrc-full52
2 files changed, 48 insertions, 15 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
diff --git a/vimrc-full b/vimrc-full
index cc7cce0..468c505 100644
--- a/vimrc-full
+++ b/vimrc-full
@@ -64,7 +64,7 @@ if has("multi_byte")
64 set listchars+=tab:▏\ | " 64 set listchars+=tab:▏\ | "
65 set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars) 65 set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars)
66 " set listchars+=eol:↲ | " symbols used when using :set list (which displays non-printable chars) 66 " set listchars+=eol:↲ | " symbols used when using :set list (which displays non-printable chars)
67 " set listchars+=space:· | " symbols used when using :set list (which displays non-printable chars) 67 set listchars+=space:· | " symbols used when using :set list (which displays non-printable chars)
68 set showbreak+=› | " symbol used in the beginning of a wrapped line 68 set showbreak+=› | " symbol used in the beginning of a wrapped line
69 69
70 " automatically enter list mode when going in insert mode (makes above syntax command temporarily ineffective) 70 " automatically enter list mode when going in insert mode (makes above syntax command temporarily ineffective)
@@ -215,7 +215,7 @@ set writedelay=0
215" display and performance 215" display and performance
216set lazyredraw | " disables redraw during macro execution (improves performance) 216set lazyredraw | " disables redraw during macro execution (improves performance)
217set cmdheight=2 | " sets the command line's height 217set cmdheight=2 | " sets the command line's height
218set signcolumn=auto | " auto=auto hide, yes=always, no=never show the column with error indicators 218set signcolumn=yes | " auto=auto hide, yes=always, no=never show the column with error indicators
219set nocursorcolumn | " turn visual cursor column off (improves performance) 219set nocursorcolumn | " turn visual cursor column off (improves performance)
220set updatetime=80 | " updates the screen more often 220set updatetime=80 | " updates the screen more often
221set redrawtime=1500 | " Timeout in milliseconds for redrawing the screen (switches syntax off when ssh too slow) / CTRL+L to retry 221set redrawtime=1500 | " Timeout in milliseconds for redrawing the screen (switches syntax off when ssh too slow) / CTRL+L to retry
@@ -242,17 +242,25 @@ set tags+=../tags
242set nofoldenable | " disable folding, because we have zi to toggle foldenable :) 242set nofoldenable | " disable folding, because we have zi to toggle foldenable :)
243set foldclose=all | " automatically fold, when the cursor leaves the folded area 243set foldclose=all | " automatically fold, when the cursor leaves the folded area
244set foldcolumn=1 | " I think I don't need this second indicator 244set foldcolumn=1 | " I think I don't need this second indicator
245set numberwidth=5 245" set numberwidth=5
246" set foldmethod=syntax | " foldlevel: syntax, indent, manual / foldmethod=syntax makes Vim incredible slow 246" set foldmethod=syntax | " foldlevel: syntax, indent, manual / foldmethod=syntax makes Vim incredible slow
247set foldnestmax=1 | " top level folding only 247set foldnestmax=1 | " top level folding only
248set foldopen=block,hor,search | " when do we unfold? 248set foldopen=block,hor,search | " when do we unfold?
249" set foldtext=Foldtext() | " 249" set foldtext=Foldtext() | "
250" set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\v^/[/*]\','','g') 250" set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\v^/[/*]\','','g')
251" set foldtext='⊞\ '.substitute(getline(v:foldstart),'^[\ '.printf(&cms,'').']*','','').'↵'.getline(v:foldstart+1).'↵'.getline(v:foldstart+2) 251" set foldtext='⊞\ '.substitute(getline(v:foldstart),'^[\ '.printf(&cms,'').']*','','').'↵'.getline(v:foldstart+1).'↵'.getline(v:foldstart+2)
252set foldtext='⊞\ '.substitute(substitute(substitute(join(getline(v:foldstart,v:foldend)),'\\s\\s\\+\\\|\[\*\/\]','\ ','g'),'\^\\s\\+','','g'),\ '\\s\\s\\+',\ '\ ',\ 'g') 252" set foldtext=repeat('',indent(v:foldstart)).substitute(substitute(substitute(join(getline(v:foldstart,v:foldend)),'\\s\\s\\+\\\|\[\*\/\]','\ ','g'),'\^\\s\\+','','g'),\ '\\s\\s\\+',\ '\ ',\ 'g')
253set foldtext=printf('%*s%.*S',indent(v:foldstart),'',&textwidth-indent(v:foldstart),substitute(substitute(join(getline(v:foldstart,v:foldend),'\ '),'[[:space:]]\\+','\ ','g'),'^[[:space:]]','','g'))
254
255" works ...
256" set foldexpr=match(synIDattr(synID(v:lnum,indent(v:lnum)+1,0),'name'),'Comment')>-1
257set foldexpr=!empty(filter(synstack(v:lnum,indent(v:lnum)+1),{_,val->match(synIDattr(val,'name'),'Comment')>-1}))
258
259" set 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'))
253 260
254" vim window behaviour 261" vim window behaviour
255set splitbelow | " open new windows below the current one (i find that more intuitive) 262set splitbelow | " open new windows below the current one (i find that more intuitive)
263set splitright | " this also works for me and makes better use of the scren space I think
256set winminwidth=0 | " (and all other windows, so TODO: watch out) 264set winminwidth=0 | " (and all other windows, so TODO: watch out)
257set winwidth=30 | " keep NERDTreeWindow at least this size 265set winwidth=30 | " keep NERDTreeWindow at least this size
258 266
@@ -692,11 +700,18 @@ Plug 'tpope/vim-fugitive' | " the most complete GIT integration plug
692Plug 'godlygeek/tabular' | " align code on a sign, like :Tab/= 700Plug 'godlygeek/tabular' | " align code on a sign, like :Tab/=
693Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with ' 701Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with '
694let g:signify_vcs_list = [ 'git' ] | " use signify only with git (improves speed when loading buffers, see :h signify) 702let g:signify_vcs_list = [ 'git' ] | " use signify only with git (improves speed when loading buffers, see :h signify)
695let g:signify_cursorhold_insert = 0 703let g:signify_cursorhold_insert = 0
696let g:signify_cursorhold_normal = 0 704let g:signify_cursorhold_normal = 0
697let g:signify_update_on_bufenter = 0 705let g:signify_update_on_bufenter = 0
698let g:signify_update_on_focusgained = 0 706let g:signify_update_on_focusgained = 0
699let g:signify_sign_show_count = 1 707let g:signify_sign_show_count = 1
708
709let g:signify_sign_add = '≫'
710let g:signify_sign_delete = '≪'
711let g:signify_sign_delete_first_line = '≪'
712let g:signify_sign_change = '≶'
713let g:signify_sign_changedelete = g:signify_sign_change
714
700 715
701" NERDTree: replaces NetRW, as long as it has so many bugs 716" NERDTree: replaces NetRW, as long as it has so many bugs
702Plug 'scrooloose/nerdtree' | " 717Plug 'scrooloose/nerdtree' | "
@@ -995,7 +1010,12 @@ function! ExtendColorTheme()
995 highlight! link PmenuSbar Pmenu 1010 highlight! link PmenuSbar Pmenu
996 highlight! PmenuThumb cterm=inverse 1011 highlight! PmenuThumb cterm=inverse
997 highlight! MoreMsg cterm=inverse 1012 highlight! MoreMsg cterm=inverse
998 highlight! link Folded LineNr 1013
1014 highlight! link LineNr Comment
1015 highlight! link Folded Comment
1016 highlight! link SignColumn Comment
1017 highlight! link FoldColumn Comment
1018 " highlight! Folded ctermbg=NONE
999 " highlight! Cursor guibg=#729fcf ctermbg=yellow 1019 " highlight! Cursor guibg=#729fcf ctermbg=yellow
1000 highlight! link VertSplit NonText 1020 highlight! link VertSplit NonText
1001 " highlight! SpellBad ctermbg=none 1021 " highlight! SpellBad ctermbg=none
@@ -1009,6 +1029,7 @@ function! ExtendColorTheme()
1009 highlight! link WildMenu Search 1029 highlight! link WildMenu Search
1010 1030
1011 " generic, which should exist but don't 1031 " generic, which should exist but don't
1032 highlight! SignifySignAdd ctermbg=NONE
1012 highlight! Bold cterm=bold gui=bold 1033 highlight! Bold cterm=bold gui=bold
1013 highlight! Italic cterm=italic gui=italic 1034 highlight! Italic cterm=italic gui=italic
1014 highlight! Underline cterm=underline gui=underline 1035 highlight! Underline cterm=underline gui=underline
@@ -1027,6 +1048,17 @@ function! ExtendColorTheme()
1027 1048
1028 highlight! link Convention Error 1049 highlight! link Convention Error
1029 1050
1051
1052 highlight! link SignifySignAdd LineNr
1053 highlight! link SignifySignChange LineNr
1054 highlight! link SignifySignDelete LineNr
1055 highlight! link SignifySignChangeDelete LineNr
1056 highlight! link SignifySignDeleteFirstLine LineNr
1057
1058 highlight! SpellBad ctermbg=NONE ctermfg=red cterm=NONE
1059 highlight! link YcmErrorSign SpellBad
1060 highlight! link YcmWarningSign Spellbad
1061
1030 " autocmd InsertLeave * call matchadd('Conceal', ' \+$', -1, 101, { 'conceal': '⟶' }) 1062 " autocmd InsertLeave * call matchadd('Conceal', ' \+$', -1, 101, { 'conceal': '⟶' })
1031 autocmd InsertEnter * silent! call matchdelete(101) 1063 autocmd InsertEnter * silent! call matchdelete(101)
1032 autocmd InsertLeave * silent! call matchadd('Convention', ' \+$', -1, 101, { 'conceal': '⟶' }) 1064 autocmd InsertLeave * silent! call matchadd('Convention', ' \+$', -1, 101, { 'conceal': '⟶' })
..