Skip to content
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

are fold status get saved? #115

Open
luxus opened this issue Feb 19, 2023 · 4 comments
Open

are fold status get saved? #115

luxus opened this issue Feb 19, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@luxus
Copy link

luxus commented Feb 19, 2023

Neovim version (nvim -v | head -n1)

0.9

Operating system/version

macOS

How to reproduce the issue

      vim.o.foldcolumn = "1" -- '0' is not bad
      vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
      vim.o.foldlevelstart = -1
      vim.o.foldenable = true
      vim.o.fillchars = [[eob: ,fold: ,foldopen:,foldsep: ,foldclose:]]

when i open a file, fold some lines, closing the file and reopen it (or a :e) i thought the folds stays closed.

Expected behavior

after saving a file and reloading still have the same fold and unfold state

Actual behavior

everything is unfolded again

@luxus luxus added the bug Something isn't working label Feb 19, 2023
@luxus
Copy link
Author

luxus commented Feb 19, 2023

okay i learned that mkview and loadview needs to be used.
https://github.com/neovim/neovim/blob/bfe6b49447744cea1cd941660b2a3a501a0701cb/runtime/doc/fold.txt#L42-L43
is this the best way?

-- remember folds
vim.cmd [[
augroup remember_folds
  autocmd!
  autocmd BufWinLeave *.* mkview
  autocmd BufWinEnter *.* silent! loadview
augroup END
]]

@kevinhwang91
Copy link
Owner

No bad, some save session plugins also solve this issue.

@kevinhwang91 kevinhwang91 added question Further information is requested and removed bug Something isn't working labels Feb 20, 2023
@yizhenAllen
Copy link

In some cases, the snippet above would change the cwd when you enter a buffer, and the following command can solve this problem:

vim.cmd [[set viewoptions-=curdir]]

@kevinhwang91 kevinhwang91 reopened this Nov 11, 2024
@kevinhwang91
Copy link
Owner

mkview and loadview are fired by events frequently, which read and write the file IO.
Should add this feature in ufo.

@kevinhwang91 kevinhwang91 added enhancement New feature or request and removed question Further information is requested labels Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants