-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Markdown folding disturbs diff mode #427
Comments
I'm seeing this as well. For me, diffs are completely broken for markdown files when this plugin is active. i.e. |
I'm suffering from this, too. Setting below in Plugin 'plasticboy/vim-markdown'
let g:vim_markdown_folding_disabled = 1
autocmd BufNewFile,BufRead *.md setlocal foldmethod=expr foldexpr=Foldexpr_markdown(v:lnum) |
This patch may work: diff --git a/after/ftplugin/markdown.vim b/after/ftplugin/markdown.vim
index 8be6ff9..9840217 100644
--- a/after/ftplugin/markdown.vim
+++ b/after/ftplugin/markdown.vim
@@ -177,8 +177,12 @@ function! s:MarkdownSetupFolding()
setlocal foldtext=Foldtext_markdown()
endif
endif
- setlocal foldexpr=Foldexpr_markdown(v:lnum)
- setlocal foldmethod=expr
+ if &foldexpr == ""
+ setlocal foldexpr=Foldexpr_markdown(v:lnum)
+ endif
+ if &foldmethod != "diff"
+ setlocal foldmethod=expr
+ endif
endif
endfunction
Besides But I'm not sure whether this is a better solution. |
Perhaps just checking diff --git a/after/ftplugin/markdown.vim b/after/ftplugin/markdown.vim
index 8be6ff9..991a470 100644
--- a/after/ftplugin/markdown.vim
+++ b/after/ftplugin/markdown.vim
@@ -177,8 +177,10 @@ function! s:MarkdownSetupFolding()
setlocal foldtext=Foldtext_markdown()
endif
endif
- setlocal foldexpr=Foldexpr_markdown(v:lnum)
- setlocal foldmethod=expr
+ if &foldexpr == ""
+ setlocal foldexpr=Foldexpr_markdown(v:lnum)
+ setlocal foldmethod=expr
+ endif
endif
endfunction
|
This issue being left for a long time, |
The default value of 'foldexpr' 'fde'
'foldexpr' 'fde' string (default: "0")
local to window
{not available when compiled without the +folding
or +eval features} |
Oh, this was because I set |
Fixed. |
For example, add a random line to this project's README.md and save it as README2.md:
Run
vimdiff README.md README2.md
, then one of the buffer will have weird folding:According to after/ftplugin/markdown.vim, the
s:MarkdownSetupFolding()
is called onBufWinEnter
,BufWritePost
,InsertEnter
,InsertLeave
,CursorHold
,CursorHoldI
. When Vim shows diff,'foldmethod'
is set to'diff'
, ands:MarkdownSetupFolding()
resets it. So I think checking if the buffer is diff or not (using&diff
) would be appropriate.The text was updated successfully, but these errors were encountered: