kevinhughes27 / dotfiles

4 stars 1 forks source link

usable fold implementation #16

Closed kevinhughes27 closed 1 year ago

kevinhughes27 commented 1 year ago

I've been wanting to explore folds mostly to see if they would be useful in my note taking and how I use my notes to think and plan other things. It does use the new status column (neovim 0.9 and up) and the plugin https://github.com/luukvbaal/statuscol.nvim but it seems the clickable folds are actually builtin so more of what makes this work is the new settings which enable this and the plugin is mostly for cosmetic tweaks. The column doesn't show outside of notes where it is quite wide. The setting of 1 seems to turn it on and then the statuscol plugin sets the width from there. 0 shows nothing but making it bigger adds extra padding on top of the plugin.

The main thing here was using how to create, delete and toggle or open and close folds. I could add a command to help quickly make or toggle folds in Markdown as a next step.

Another thing I thought I would like it persistent and possibly synced fold state. This could be done with mkview and passing it a path like: :mkview! %.v which saves a new relative file with .v appended. This file can be sourced to reload the view. If you use mkview without an argument it saves it to a local vim folder and you can load it with :loadview. Using this manually is enough for now to see if I find folds useful.

references: https://stackoverflow.com/questions/46497623/vim-loadview-from-a-specific-file https://www.reddit.com/r/neovim/comments/opznf4/custom_foldtext_in_lua/ https://vim.fandom.com/wiki/Make_views_automatic https://vim.fandom.com/wiki/Folding