espec icon indicating copy to clipboard operation
espec copied to clipboard

Syntax doesn't play nicely with vimerl

Open lucaspiller opened this issue 13 years ago • 6 comments

Possible related to the first answer mentioned on https://github.com/jimenezrick/vimerl/issues/7

Auto indenting ends up with:

spec() ->
  describe("beforespec", fun() ->
        it("should do stuff", fun() ->
              io:format("output from: it should do stuff~n", [])
          end),
    end).

It should be:

spec() ->
    describe("beforespec", fun() ->
        it("should do stuff", fun() ->
            io:format("output from: it should do stuff~n", [])
        end),
    end).

lucaspiller avatar Dec 25 '11 18:12 lucaspiller

there are a couple of alternative syntaxes we could use.

for example the following plays nice with vimerl and is valid erlang:

spec() ->
  describe("blah", 
    it("should do stuff",
      X = 2,
      Y = 3
    )
  ).

i've tried a bunch of different erlang expressions and they all seem to play nice. i assume since everything in erlang is an expression then it doesn't really matter if you are in a function body or in the actual params to a function call but i might be wrong here.

though, i can see how people might be wtffffff

there is also the more rubyish syntax but that doesn't play nice with vimerl :(

describe("foo", begin
  it("should do stuff", begin
    X = 2,
    Y = 3
  end)
end).

benmmurphy avatar Dec 26 '11 23:12 benmmurphy

i also like this syntax:

describe("foo"), begin
    it("should do stuff"), begin
      X = 2,
      Y = 3
    end
end.

doesn't play nice with vimerl and is kind of evil

benmmurphy avatar Dec 27 '11 13:12 benmmurphy

Hmm. I don't think any of those are really nicer than what we have at the moment. Maybe it can be easily fixed in Vimerl?

lucaspiller avatar Dec 27 '11 15:12 lucaspiller

maybe the fix is use a proper editor like emacs or textmate :)

benmmurphy avatar Dec 27 '11 20:12 benmmurphy

:P

Do Textmate and Emacs handle it fine?

lucaspiller avatar Dec 28 '11 09:12 lucaspiller

textmate works for me but emacs has an even worse behaviour. the first indent of the body of a fun starts at the character after the fun() ->.

benmmurphy avatar Dec 28 '11 09:12 benmmurphy