diff --git a/autoload/SpaceVim/layers/edit.vim b/autoload/SpaceVim/layers/edit.vim index 3a25a413a..b07429a21 100644 --- a/autoload/SpaceVim/layers/edit.vim +++ b/autoload/SpaceVim/layers/edit.vim @@ -8,7 +8,7 @@ function! SpaceVim#layers#edit#plugins() abort \ ['kana/vim-textobj-indent'], \ ['kana/vim-textobj-line'], \ ['kana/vim-textobj-entire'], - \ ['scrooloose/nerdcommenter'], + \ ['scrooloose/nerdcommenter', { 'loadconf' : 1}], \ ['mattn/emmet-vim', { 'on_cmd' : 'EmmetInstall'}], \ ['gcmt/wildfire.vim',{'on_map' : '(wildfire-'}], \ ['easymotion/vim-easymotion'], diff --git a/autoload/SpaceVim/mapping/space.vim b/autoload/SpaceVim/mapping/space.vim index 9351fe91e..5fabbabac 100644 --- a/autoload/SpaceVim/mapping/space.vim +++ b/autoload/SpaceVim/mapping/space.vim @@ -13,6 +13,7 @@ function! SpaceVim#mapping#space#init() abort let g:_spacevim_mappings_space.T = {'name' : '+UI toggles/themes'} let g:_spacevim_mappings_space.a = {'name' : '+Applications'} let g:_spacevim_mappings_space.b = {'name' : '+Buffers'} + let g:_spacevim_mappings_space.c = {'name' : '+Comments'} let g:_spacevim_mappings_space.f = {'name' : '+Files'} let g:_spacevim_mappings_space.j = {'name' : '+Jump/Join/Split'} let g:_spacevim_mappings_space.w = {'name' : '+Windows'} @@ -65,6 +66,16 @@ function! SpaceVim#mapping#space#init() abort nnoremap [SPC]bp :bp let g:_spacevim_mappings_space.b.p = ['bp', 'previous buffer'] call SpaceVim#mapping#menu('Open previous buffer', '[SPC]bp', 'bp') + + " + " Comments sections + " + " Toggles the comment state of the selected line(s). If the topmost selected + " line is commented, all selected lines are uncommented and vice versa. + let g:_spacevim_mappings_space.c.c = ['cl', 'Toggle commment line(s)'] + call SpaceVim#mapping#menu('Toggle comment line(s)', '[SPC]cl', '') + nnoremap [SPC]cl :call NERDComment("n", "Toggle") + let g:_spacevim_mappings_space.e = {'name' : '+Errors/Encoding'} let g:_spacevim_mappings_space.B = {'name' : '+Global-buffers'} nnoremap [SPC]tn :setlocal nonumber! norelativenumber! diff --git a/config/plugins/nerdcommenter.vim b/config/plugins/nerdcommenter.vim new file mode 100644 index 000000000..2f4b3c0cb --- /dev/null +++ b/config/plugins/nerdcommenter.vim @@ -0,0 +1,31 @@ +scriptencoding utf-8 + +" +" nerd-commenter plugin settings +" + +" Add extra space around delimiters when commenting, remove them when +" uncommenting +let g:NERDSpaceDelims = 1 + +" Always remove the extra spaces when uncommenting regardless of whether +" NERDSpaceDelims is set +let g:NERDRemoveExtraSpaces = 1 + +" Use compact syntax for prettified multi-line comments +let g:NERDCompactSexyComs = 1 + +" Align line-wise comment delimiters flush left instead of following code +" indentation +let g:NERDDefaultAlign = 'left' + +" Allow commenting and inverting empty lines (useful when commenting a +" region) +let g:NERDCommentEmptyLines = 1 + +" Enable trimming of trailing whitespace when uncommenting +let g:NERDTrimTrailingWhitespace = 1 + +" Always use alternative delimiter +let g:NERD_c_alt_style = 1 +let g:NERDCustomDelimiters = {'c': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }}