swift.vim icon indicating copy to clipboard operation
swift.vim copied to clipboard

Add Code Folding Support

Open xanderdunn opened this issue 4 years ago • 3 comments

I just installed swift.vim in neovim 0.4.3. My swift files compile and run fine in Swift version 5.3-dev (LLVM 55d27a5828, Swift 6a5d84ec08).

But vim doesn't find any folds in my swift files. When I press one of the commands to open or close folds, such as zO or zc, I see the error E490: No fold found. This is unusual. Most languages have code folding support in vim.

xanderdunn avatar Jul 26 '20 01:07 xanderdunn

What is required to make this work?

keith avatar Jul 26 '20 01:07 keith

This swift plugin for vim, which hasn't been updated since 2015, indicates that it supports code folding. I haven't created a language plugin for vim before, I'm looking through it to see where the folding support comes in. I can't imagine it would be much different from C++ code folding, but I'm also new to Swift.

  • It looks like this is the declaration that the plugin supports code folding
  • My best guess is that the fold keywords peppered throughout this file indicate to Swift what to start and end folds on.
  • Here is the documentation on the option to disable code folding.

xanderdunn avatar Jul 26 '20 01:07 xanderdunn

Happy to accept PRs for this but I likely won't get to it

keith avatar Jul 28 '20 16:07 keith