preservim / vim-markdown

Markdown Vim Mode
4.69k stars 523 forks source link

How to unfold by default #622

Open glow12121 opened 1 year ago

glow12121 commented 1 year ago
let g:vim_markdown_folding_level = 6
let g:vim_markdown_override_foldtext = 0

With the settings above, I cannot figure out how to keep everything in markdown texts unfolded by default.

Specifically, I don't see how to control lines and empty lines being folded. Probably let g:vim_markdown_override_foldtext = 0 has nothing to do with it.

## Title
+--  3 lines: ········································································································
### Title
+--  3 lines: Line of text···················································································
ilya-vv commented 1 year ago

@glow12121 You may add something like this to your ~/.vimrc file:

autocmd FileType markdown normal zR

This commands run zR and unfold whole file on opening. Result might depends on position the line in ~/.vimrc file...

glow12121 commented 1 year ago

Isn't it a workaround?

I cannot figure out why the plugin keeps on folding the text one way or another, whichever folding level I select. Even if it's, say, 6, still all the stuff is folded.

These are literally all my settings related to the plugin:

Plug 'godlygeek/tabular'
Plug 'preservim/vim-markdown'
" Syntax highlighting, matching rules and mappings for the original Markdown and extensions.
" The tabular plugin must come before vim-markdown.
" g:vim_markdown_folding_level setting (default 1) is set to foldlevel. Thus level 1 heading which is served as a document title is expanded by default.
" Folding level is a number between 1 and 6. By default, if not specified, it is set to 1.
let g:vim_markdown_folding_level = 0
" To prevent foldtext from being set add the following to your .vimrc:
" let g:vim_markdown_override_foldtext = 0
ilya-vv commented 1 year ago

Well, yes. My suggestion is a workaround.

Can't say about vim-markdown - use it for several days - but, as I remember, when Vim receives command set foldmethod=..., it applies folding for the whole buffer and folds everything, it's default behavior.

mcookly commented 1 year ago

@glow12121,

I think the problem might be that foldlevel is a hacky way of opening folds. Maybe set foldlevelstart=6. This page might help!

Nan-Do commented 1 year ago

@mcookly Thanks for the tip setting that variable fixed the problem for me

polirritmico commented 1 year ago

Thanks. This is working for me:

vim.cmd [[
    autocmd BufRead,BufNewFile *.markdown,*.md set conceallevel=2 foldlevelstart=6
]]

Don't know if there is a better way.

vyrwu commented 11 months ago

I'm on lazy v10.15.1, based on this thread, I got it working with the following config:

{
  "preservim/vim-markdown",
  ft = "markdown",
  init = function()
    vim.cmd [[set foldlevelstart=6]]
  end,
  dependencies = {
    "godlygeek/tabular",
  },
}