luke-gru / riml

Riml is a subset of VimL with some nice added features. It compiles to plain VimL.
MIT License
224 stars 6 forks source link

A way to specify the output file #2

Closed dsawardekar closed 11 years ago

dsawardekar commented 11 years ago

Riml is awesome!!! I don't understand why this isn't more well known? I stumbled upon it by pure accident, looking at some completely unrelated stuff. Maybe you should have a github website?

I think this is going to bring about a renaissance in vim plugin development!

Enough gushing, to my question. :)

How do I specify an output path to the compiled vim file. Something like,

riml -c foo.riml -o foo.vim

Currently it seems to output everything into the current working directory. I am working on an RSpec clone for Riml. I have a bunch of *.riml files that are tests organized in sub directories that I want to compile into a different directory, or into the same directory. ie:- I want preserve their folder structure.

Thanks again, for this awesome project!

tek commented 11 years ago

That would be very convenient. Until then, we'll have to use riml -s < riml/foo.riml > autoload/foo.vim

luke-gru commented 11 years ago

Hey, thanks for the encouragement @dsawardekar! As for specifying an output file, I'll work on it this weekend for sure. It's a small change, but I need to think about making it work with other features as well.

For example, right now if you riml_source or riml_include a file, the default location to check for those files is the current working directory the command was issued in, but in the case of outputting a file into a different directory, I guess you could make the case that it should look in the directory that the file is outputted to and not the directory it was compiled in. Not too sure, let me know if you have any thoughts on this. :smile:

and @tek, yes that is definitely one way to do it! I agree it's not ideal.

dsawardekar commented 11 years ago

@luke-gru Maybe a good approach would be to specify the output directory, Similar to what Coffeescript does. With riml -c foo.riml -o build, the built foo.vim files would go into the build directory. Any riml_source files would go inside that directory. The output directory could mirror the source directory layout, if possible.

With Speckle(), my RSpec clone I am doing these 2 things with mv inside a Rakefile.

  1. Compiling a main speckle.riml into speckle.vim in current directory then moving it to build.
  2. Compiling individual *_spec.riml files into *_spec.vim, then moving them into build/**, to match the original structure.
dsawardekar commented 11 years ago

@tek Yeah. Currently I just move the file. I have a build file, so it's not much of an issue for me. But it's a good feature to have for people new to Riml. Since it's the general way most compilers work.

luke-gru commented 11 years ago

Yeah, that's a good idea to have an output directory like CoffeeScript. I didn't even know it did this, as I can't say I even remember the last time I used the cmdline to compile .coffee files. Usually I just have some asset framework do the job for me :laughing:

BTW @dsawardekar, speckle looks like a cool project. I'm going to try it out as soon as I can. Are you familiar with https://github.com/kana/vim-vspec? It may or may not be similar, I'm only vaguely familiar with Vimscript testing libraries.

dsawardekar commented 11 years ago

@tek Me too, especially with the source maps stuff...

I've used vspec, it's a pretty cool project. It was what I was using before Riml.

But Riml changes things completely. With Riml you can write code that looks just like actual products that you otherwise work on. Speckle is designed to fit into this ecosystem.

Vspec has nice syntax and works quite well if your plugin is in viml. But if your plugin is in Riml it makes sense to have your test code in Riml too. :)

It's still a work in progress, and I have to write some proper docs for it!

tek commented 11 years ago

Very interesting. I've been using vspec for a few months now, but speckle sure looks promising. Right now I've set up a guard-shell mechanism like this for compilation:

guard :shell, all_on_start: true do
  watch(/riml\/(.*).riml$/) do |file, base|
    `riml -s < #{file} > autoload/#{base}.vim`
  end
end
dsawardekar commented 11 years ago

I am doing something similar in a Guardfile. I started out thinking maybe a --watch option would be a good idea. But seems Guard is a lot better with all the numerous ways it can show notifications.

If you are interested, you can checkout the spec's folder. When you run rake, Speckle uses itself to compile and drive it's own tests. :)

That will compile all the riml specs then launch vim and run the built vim files with a test runner.

A spec is a class whose name ends with Spec, Eg:- class FooSpec. And a test is a defm method starting with it_foo The syntax for making assertions is something like,

expect('foo').to_equal('bar')

with a bunch of different matchers like to_be_true, to_be_close_to, to_be_between, etc. You can also provide custom matchers like a to_have_name shown here.

tek commented 11 years ago

I tried speckle already – it started vim interactively, what's your plan regarding that? It even prompted me, making it impossible to run headless.

dsawardekar commented 11 years ago

Do you mean vim's silent mode switches, -e -s? You can do this currently in speckle with the -m or --vim option like. This option allows you set the vim program used to run the test suite.

speckle --vim "vim -e -s"

I had this by default earlier. But thought it may be better to provide feedback during the test suite run inside a buffer. And to avoid side effects if plugins rely on not being in silent mode.

Should I make this the default behaviour?

luke-gru commented 11 years ago

Hey guys,

Just wrote a patch for this. Works like @dsawardekar suggested, --output-dir (-o) flag names a directory that will house the .vim files. It's in the new version (0.2.9). Please let me know if there are any issues with it or if something isn't working as you expect.

Thanks!

dsawardekar commented 11 years ago

@luke-gru Nice work! -o works fine for me. I updated Speckle to use 0.2.9.

tek commented 11 years ago

saweet.