Open dbarnett opened 10 years ago
As far as portability, it's probably just as simple to use plain python and provide a common python vim interface instead of creating a DSL. You can even do something like this already with the :python
command and the built-in vim module (although I noticed AssertionErrors aren't being handled properly: #39).
As far as portability, it's probably just as simple to use plain python and provide a common python vim interface instead of creating a DSL. You can even do something like this already with the :python command and the built-in vim module (although I noticed AssertionErrors aren't being handled properly: #39).
If you don't mind, I'd like to give a shot at implementing this DSL for vroom. Even though embedding python is a simpler solution, it would be great to have a DSL that understands statements like line2.foreground should be 'red' from 8 to 12
. This also has the advantage of keeping vroom specs language-agnostic
Sure, let's get a prototype going and see how it feels.
My biggest concern is just the complexity of having too many different ways to do things in vroom. That would depend on the scope of the DSL, how much documentation it would want, and how much overlap it has with other approaches.
Strong selling points might be if:
For instance, we've discussed different approaches to making assertions (#18). If this just replaced existing approaches as the de facto way to write assertions (maybe with a single-line syntax instead of block syntax), that might work nicely. You might have more high-level information about what's being asserted and be able to give better failure messages.
A few random suggestions:
Do macros solve this, now that you've added support for those in #46? You should be able to do something like @do (assert_foreground_color, start=8, end=12, color='red')
to get such a check, which is about as expressive and readable as a DSL would be.
@tarruda proposed in #29 that vroom syntax should support some kind of embedded python blocks (or python-based DSL) to enable more complex interactions and assertions. This could have a magic vim object defined to interact with vim state.
For example, here's how we could write python code that tests a plugin that highlights in red all capitalized words:
The syntax could look something like: