Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elvis integration? #14

Open
deadtrickster opened this issue Mar 3, 2018 · 5 comments
Open

Elvis integration? #14

deadtrickster opened this issue Mar 3, 2018 · 5 comments

Comments

@deadtrickster
Copy link
Contributor

deadtrickster commented Mar 3, 2018

Elvis is the Erlang style reviewer (https://github.com/inaka/elvis).

Many use elvis to enforce code style (me included). There are rules related to text formatting, such as:

I would like to have sourcer_indent integrated with elvis, i.e. understand formatting specific rules and apply them (e.g. add space after ,).

@vladdu
Copy link
Collaborator

vladdu commented Mar 3, 2018

That's a good idea - I assume you mean that we could autocorrect some style issues that elvis reports, using elvis.config as guide/config? It's definitely a useful feature.

This will be something for later (for what I am concerned, I want to get the server going first). The code formatter right now is actually an indenter only, as we don't break any lines. Breaking lines at the right place is not very easy to do right.

As long as we don't have a full formatter, I would probably do these fixes as a separate command. If elvis is integrated in the editor/IDE, then the user can choose a "quick fix" operation for each one (or each type) and see and review the results right away.

@deadtrickster
Copy link
Contributor Author

ok, I'll do this as a separate command, maybe reusing some of (or depending on) the elvis core (https://github.com/inaka/elvis_core). What you think? something like erlang_ls -i --elvis.

@vladdu
Copy link
Collaborator

vladdu commented Mar 3, 2018

There should be some configuration to specify which fixes to apply (to which elvis rules). Maybe "--elvis" to use info in config file and "--elvis ruleX,ruleY" will correct only ruleX and ruleY.

This functionality is in a bit of gray zone: elvis could just as well have a "--fix" parameter that would make the corrections. I don't think that the implementation will make use of any sourcer-specific code.

@deadtrickster
Copy link
Contributor Author

I agree, at least right now adding this directly to elvis might be a better idea.

I was trying to study indenter code a bit more, but there lots of things are going on. Any documentation/blog post? In theory if it's building AST, then said AST could be dumped as text following configured formatting rules. I feel like indenter and elvis probably overlap here to some extent.

@vladdu
Copy link
Collaborator

vladdu commented Mar 3, 2018

Sorry, there is no documentation but the code. I didn't wrote any of it, so I confess I don't know much about how it works. I don't think it parses into an AST, because then we could have had a full formatter (like erl_tidy) and also it would only have worked on compileable code (which when editing is not always the case). I think it uses empiric rules and looks at the previous row to decide how to indent the current one (a bit simplified, of course).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants