diepm / vim-rest-console

A REST console for Vim.
658 stars 54 forks source link

Request body folding #103

Open giftig opened 2 months ago

giftig commented 2 months ago

Having folding in the syntax for *.rest would be useful as it'll make it much easier to organise requests in a worksheet. Initially I tried to manually create folds and save them via techniques like this: https://stackoverflow.com/questions/37552913/vim-how-to-keep-folds-on-save but inevitably as I modify requests and add new requests my folds end up broken because they're just created as line ranges.

If my vimscript-fu is up to the task I'll see if I can add some basic folding and contribute it, though I wonder the simplest approach is embedding other syntax formats, i.e. making it understand that the body is JSON, which would both add better syntax highlighting and solve the fold problem, as the JSON syntax knows how to fold JSON already. I've seen effective embedded syntaxes in https://github.com/xolox/vim-notes for example. Obviously one complication with that approach is that your body might not be JSON and you'd have to indicate content type in a way the syntax logic could understand, so just being able to fold the whole body would be a start.

giftig commented 2 months ago

Side note: I've found this plugin super useful for juggling many different elasticsearch queries and have also started using it for regular RESTful API calls in a lot of cases rather than piping stuff to curl as is my normal approach, so thanks, great plugin :+1: