vim-erlang / vim-erlang-runtime

Erlang indentation and syntax for Vim
https://vim-erlang.github.io
101 stars 29 forks source link

erlang-mode style indent #31

Closed ghost closed 8 years ago

ghost commented 8 years ago

It would be very useful to be able to switch the indenter into an erlang.el style, in order to not produce different indenting based on which editor was used. This way, one can instruct contributors to use either vim or emacs, while having the right settings in file headers (vim modeline, emacs local vars), and thereby avoid any manual steps.

aerosol commented 8 years ago

@tuncer Not sure if I understand correctly, but have you tried https://github.com/ciaranm/detectindent or https://github.com/tpope/vim-sleuth? FWIW there's also editorconfig.

ghost commented 8 years ago

Sorry, I was talking about the style of indentation, or rather formatting, which is not the same in vim-erlang and erlang-mode.

aerosol commented 8 years ago

I'm sorry but I don't think anyone has capacity to implement this. PRs welcome of course.

hcs42 commented 8 years ago

The goal of vim-erlang indentation has been to be as close to the Emacs indentation as possible. Currently the two main differences are that type specs are not supported by vim-erlang, and expressions like this:

% Emacs
X =
    1 +
    2

% vim-erlang
X =
1 +
2

This latter is especially difficult to implement (I gave a lot of thought to this when I implemented vim-erlang indentation in 2013).

So it's not a "switch" that needs to be added to vim-erlang indentation to make it work more similarly to Emacs, but these two features need to be implemented. (OK, I admit, there is one thing where one could add a switch: Emacs's crazy way of intending lines that start with a single '%' towards the right.)

Anyway, as @aerosol mentioned, PRs are welcome. (But brace yourself, it's not easy code...)

ghost commented 8 years ago

Ah, good to hear that the intention is to produce the same output as erlang.el. We don't need a switch then.

Regarding single '%': that's an end-of-line comment, which by convention uses a single '%'. For that you use a common key binding which moves the cursor to the end of the line and inserts a single '%'. There's also '%%' and '%%%', and the three variants all serve a different purpose.