From a0fc3ad29004e5da49cdfff9c20fbebcfd54e8fb Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 30 Dec 2024 22:20:05 +0800 Subject: [PATCH] fix(commenter): fix nerdcommenter for markdown --- .../plugin/{NERD_commenter.vim => nerdcommenter.vim} | 4 ++++ config/plugins/nerdcommenter.vim | 12 ++++++------ docs/bundle-plugins.md | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) rename bundle/nerdcommenter/plugin/{NERD_commenter.vim => nerdcommenter.vim} (99%) diff --git a/bundle/nerdcommenter/plugin/NERD_commenter.vim b/bundle/nerdcommenter/plugin/nerdcommenter.vim similarity index 99% rename from bundle/nerdcommenter/plugin/NERD_commenter.vim rename to bundle/nerdcommenter/plugin/nerdcommenter.vim index 5d32d38f6..1095a6db5 100644 --- a/bundle/nerdcommenter/plugin/NERD_commenter.vim +++ b/bundle/nerdcommenter/plugin/nerdcommenter.vim @@ -1205,6 +1205,10 @@ function! NERDCommentIsLineCommented(lineNo) return s:IsInSexyComment(a:lineNo) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine) endfunction +function! NERDCommentSetUpForNewFiletype(ft) abort + call s:SetUpForNewFiletype(a:ft, 1) +endfunction + " Function: NERDComment(mode, type) function " This function is a Wrapper for the main commenting functions " diff --git a/config/plugins/nerdcommenter.vim b/config/plugins/nerdcommenter.vim index f75c1ba1d..d13479541 100644 --- a/config/plugins/nerdcommenter.vim +++ b/config/plugins/nerdcommenter.vim @@ -30,19 +30,19 @@ let g:NERDTrimTrailingWhitespace = 1 " Always use alternative delimiter let g:NERD_c_alt_style = 1 let g:NERDCustomDelimiters = {'c': { 'left': '//', 'leftAlt': '/*', 'rightAlt': '*/' }} -let g:ft = '' +let s:ft = '' fu! NERDCommenter_before() if &ft ==# 'markdown' - let g:ft = 'markdown' let cf = context_filetype#get() if cf.filetype !=# 'markdown' - exe 'setf ' . cf.filetype + let s:ft = 'markdown' + call NERDCommentSetUpForNewFiletype(cf.filetype) endif endif endfu fu! NERDCommenter_after() - if g:ft ==# 'markdown' - setf markdown - let g:ft = '' + if s:ft ==# 'markdown' + call NERDCommentSetUpForNewFiletype(s:ft) + let s:ft = '' endif endfu diff --git a/docs/bundle-plugins.md b/docs/bundle-plugins.md index 7a749d23c..4524ee513 100644 --- a/docs/bundle-plugins.md +++ b/docs/bundle-plugins.md @@ -54,6 +54,7 @@ These plugins are changed based on a specific version of origin plugin. - `jedi-vim`: based on [jedi-vim@e82d07](https://github.com/davidhalter/jedi-vim/tree/e82d07faa17c3b3fe04b4fa6ab074e8e8601a596) - `vim-unstack`: based on [vim-unstack@9b191419](https://github.com/mattboehm/vim-unstack/tree/9b191419b4d3f26225a5ae3df5e409c62b426941) - `tagbar`: based on [tagbar@af3ce7c](https://github.com/preservim/tagbar/tree/af3ce7c3cec81f2852bdb0a0651d2485fcd01214) +- `nerdcommenter`: based on [nerdcommenter@fade3d4b2](https://github.com/preservim/nerdcommenter/tree/fade3d4b26f5a0d58f256a06ba7b0a04d9fb4f3b) #### `core` layer