Closed KronicDeth closed 7 years ago
@smeevil you wanted this too, right?
Oh yes ! 9configurable) reformat document would be very welkome :)
I agree, this is the last missing piece of this great language and plugin .. Currently there are no online tools, notepad++ plugins etc. for this purpose.
+1
Following https://github.com/levionessa/elixir_style_guide would be a good idea - 1400 stars, active community.
👍
👍
👍
👍
👍
Looks like formatting is not working. I used 4.7.0 and still no code style preset in editor and no code formatting. Sad. Are there some hack to activate it for at least so basic elements like modules, functions and cond operators. Erlang plugin struggle for a long time with good one, but basic things they did fast.
@mkuznetsov, the issue is still open, if the issue were closed it would indicate the feature was complete and a PR implementing it had been merged to master. What led you to believe 4.7.0 would included the feature?
I found an ExtensionPoint called PredefinedCodeStyle
, which looks like it may allow the plugin to define multiple styles, so both "The Elixir Style Guide" and "Credo's Elixir Style Guide" could be shipped and selectable.
That's really nice :)
Hey,
just asked myself it it is possible to format the code like with supported IDE languages. Great to see some activity here recently. So this will come in the near future?
@PhillippOhlandt this is my active issue. I forgot to mark it as assigned to me.
@KronicDeth Awesome! No more manual switching from 2 space indent to 4 space indent when copying from the docs soon :P
FYI: At elixirconfeu, Jose presented the idea of elixirfmt. https://github.com/beamcommunity/beamcommunity.github.com/wiki/Project:-Elixir
Implement a formatter for Elixir code that can take a piece of Elixir code and format it according to a standard style guide. Very similar to tools such as rustfmt and gofmt. Expected results: a command-line tool that takes Elixir code as input and returns formatted Elixir code as output
@mudasobwa told me about elixirfmt
already. To summarize the thread, just like using alchemist-server
, which many people suggested before I implemented all the references for Go To Declaration, the problem is the tools written in Elixir usually depend on the elixir lexer (tokenizer) and/or parser to get them an AST, so the code has to be valid Elixir code before it works.
I'm of the opinion that IDEs need to be more forgiving than compiler parsers of user mistakes and work while you're still typing code (which also looks like mistakes), so I prefer to use the JetBrains OpenAPI system available to plugins because I can format (and highlight and annotate) code that has syntax errors while I doubt elixirfmt
will be able to do that.
Found a new bug in the native grammar while splitting not
from !
(since not
needs a spaces and !
does not, but they're both unary operators in the native and current IntelliJ elixir grammar): https://groups.google.com/d/msg/elixir-lang-core/aZ7KkHrAVzc/g2oA1-6rAQAJ
Use guide to write formatter to reformat code to some style. Find out if there is a style-guide for Elixir yet or just copy @pragdave's style from his books.