Closed yhuangatimvucom closed 6 years ago
@pseewald , hi, I am huangyingw, yhuangatimvucom is my office github account, this issue is much more difficult, I don't think I could fix it myself this time :(
did some debug tonight: it will recognize the line, with # in the first col as comment:
while for line like this, the # is not in the first col, would not be recognized as comment.
I am trying to fix
function! s:CommentLine(lnum, force) abort if indent(a:lnum) >= &sw && !a:force return 0 else return getline(a:lnum) =~? '^.#.' \ || synIDattr(synID(a:lnum,indent(a:lnum)+1,1),"name") =~? 'comment|string' endif endfunction
Hi,
vim-anyfold does not fold indented comments on purpose. The problem is that synID
(that is called to recognize comments) is very slow. Therefore it is called on unindented lines only. However it is really easy to provide an option to fold all comment lines (in the function s:CommentLine above, just set force always to 1). You don't need to spend time on this, I can easily provide this as an option.
I just committed the fix for this issue. In order to enable this option, put let anyfold_identify_comments = 2
in your vimrc. Can you let me know if it works for you? Thanks!
it works well, now it is very very perfect, thanks for the quick commit.
@huangyingw the defaults for comments have changed in commit e73a3921b5c140b5d0a27e9fd5d3f7cb903ee5f2 because I wanted vim-anyfold to be faster by default. This completely changes the meaning of anyfold_identify_comments
. You may set it to 1 if you want to fold Python comments starting with #
(fast). You need to set it to 2 if you want to fold Python multiline comments using """
(slow). No matter what value you use, indented comments are always identified.
Thanks for letting me know, I have synced with your repo, till now, haven't seen any issue.
I am setting anyfold_identify_comments to 2. It could fold python multi-line comments using ", I haven't tried """ yet.
I just did an experiment:
I set anyfold_identify_comments to 1, and python multi-line comments using " also work.
So, for now, I would like to set anyfold_identify_comments to 1, to have better performance.
Thanks again for great work, if any issue, I will let you know, or try to fix and then let you know :)
On 3/14/18 5:36 AM, Patrick Seewald wrote:
@huangyingw https://github.com/huangyingw the defaults for comments have changed in commit e73a392 https://github.com/pseewald/vim-anyfold/commit/e73a3921b5c140b5d0a27e9fd5d3f7cb903ee5f2 because I wanted vim-anyfold to be faster by default. This completely changes the meaning of |anyfold_identify_comments|. You may set it to 1 if you want to fold Python comments starting with |#| (fast). You need to set it to 2 if you want to fold Python multiline comments using |"""| (slow). No matter what value you use, indented comments are always identified.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/pseewald/vim-anyfold/issues/17#issuecomment-373005417, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFmbVxRq_mWZerpTgQc7hyMURSKOWpyks5teQ7egaJpZM4SDIlU.
These are my configuration for vim-anyfold in .vimrc " configuration for vim-anyfold syntax on let anyfold_activate = 1 let anyfold_fold_comments = 1 set foldlevel=0 " configuration for vim-anyfold
This is the py file, which I want to fold, since there are lots of continuous comments, I want to fold them, but vim-anyfold not working. https://www.dropbox.com/s/dmivhrx6j8h3na8/lesson1.py?dl=0