YAML that folds right?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

YAML that folds right?

Steve Litt
Hi all,

Is there something I can use to make Vim fold correctly on YAML files?

Thanks,

SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


BPJ
Reply | Threaded
Open this post in threaded view
|

Re: YAML that folds right?

BPJ
2013-07-22 04:01, Steve Litt skrev:
> Hi all,
>
> Is there something I can use to make Vim fold correctly on YAML files?

You might look at how Python folding is done.

Fold markers in YAML comments would *work*, I suppose, however
inelegant.  I find myself wanting to insert navigational
comments into large YAML files anyway.

/pbj

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: YAML that folds right?

Benji Fisher-2
On Mon, Jul 22, 2013 at 1:44 PM, BPJ <[hidden email]> wrote:
2013-07-22 04:01, Steve Litt skrev:

Hi all,

Is there something I can use to make Vim fold correctly on YAML files?

You might look at how Python folding is done.

Fold markers in YAML comments would *work*, I suppose, however
inelegant.  I find myself wanting to insert navigational
comments into large YAML files anyway.

     How close does

:set fdm=indent

get you? (Make sure that the 'shiftwidth' setting is right.)

:help 'foldmethod'
:help 'shiftwidth'

-- 
HTH
Benji Fisher

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
 
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: YAML that folds right?

Steve Litt
On Mon, 22 Jul 2013 14:23:50 -0400
Benji Fisher <[hidden email]> wrote:

>      How close does
>
> :set fdm=indent
>
> get you? (Make sure that the 'shiftwidth' setting is right.)
>
> :help 'foldmethod'
> :help 'shiftwidth'

Close enough, Benji. Thank you *very* much.

The problem, which I believe I can solve with one simple Python
program, is that nothing in the YAML specification states that subnodes
of different nodes or subnodes need be indented the same number of
spaces. Therefore, different YAML files will require different
shiftwidth settings, and even within a single YAML file, indent
widths may be different.

The practical effect of this is that you must set Vim's shiftwidth to a
number less than or equal to the smallest indent in the file. In doing
so, larger indents under some nodes might require multiple invocations
of zc to unfold. This is not a showstopper if left untreated, and can
be made even better if I write a Python program that parses a YAML file
into an in-memory object, then writes back that in-memory object to a
YAML file with consistent indentation.

For extra credit, I'll eventually need to adapt VimOutliner's code to
YAML so that folds don't show up *under* their parent, and so doing
zo on a parent, as opposed to its fold, opens it. But for the time
being, your answer scratched my itch, and I thank you for that.

After considering a switch from Xfce to OpenBox, my UMENU menu program
suddenly became much more important. Until now, UMENU was a deployment
nightmare. Menu system changes required a change to an EMDL file, EMDL
being a home-grown, fragile data file based on a tab indented outline.
Once that change was done, a special (and complicated and hard to
deploy) converter program converted the EMDL to .mnu files for each
individual menu. In practice, the deployment was so bad that probably
less than 100 people worldwide use UMENU, and it was so bad that it was
actually hard for me, the author, to copy UMENU to a new machine. And
even on my daily driver desktop, UMENU is always breaking because of
these deployment issues. That's just unacceptable.

The obvious choice, enabled by your Vim advice, is to author menu
systems in YAML, have a UMENU server that reads the YAML into a (huge)
in memory object tree, and handles queries from UMENU clients. This
should be easily deployable anywhere someone can type in an unused port
number. The YAML will also be much more readable than my kludgy EMDL.
And thanks to Vim's folding, modifications to huge (my main EMDL file
is over 2000 lines and at least 7 levels deep) YAML files will be easy
drilldowns.

Thanks again.

SteveT

Steve Litt                *  http://www.troubleshooters.com/
Troubleshooting Training  *  Human Performance

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.