-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
Use Elixir 1.6 task format
for code formatting
#997
Comments
Ideally, I don't want to use IDE's File Watcher for this, as I had many issues with it in the past (conflicts with auto save, safe save etc.). Formatting with |
As work-arounds until the feature is completed, you should be able to invoke
|
@KronicDeth For reference if anyone is interested in that as well:
|
@tschmidleithner Hmm, this doesn't seem to work well for me. I get compilation errors that I don't get when running the same command from the CLI. Maybe it's because I use |
@wizonesolutions I am not familiar with |
|
Workaround: I made a local script,
In Otherwise, I followed the instructions posted earlier: #997 (comment). Note that |
@wizonesolutions use format |
Thank you for sharing useful information. I just started using a plugin "File watcher" so that edited file will be formatted automatically, and it works great :) |
I've been looking in another language that has the same functionality, Go, specifically I would suggest it could be done in the same way for Elixir as well, since I am guessing they probably couldn't make the plugin or IDE fast enough on saves because of performing format every time. Maybe it can be documented this in the README.md how to do this in case someone is not aware how to do it and close this one. Source of the |
Hey everyone, I may have found a similar solution to what @tschmidleithner & @KronicDeth proposed. I write a lot of standalone elixir code as part of tutorials that don't require mix projects. This means that I don't get the What does it do?
script gist here
|
Made it work with asdf: |
Fixes KronicDeth#997 To format manually: With the keyboard * Mac: ⌥⇧⌘L * Linux/Windows: Ctrl+Alt+Shift+L From the menus 1. Code 2. Reformat File 3. Click Run in the "Reformat File" dialog To tun on format on save: 1. Preferences 2. Tools > Actions on Save. 3. Check "Reformat code". 4. Make sure "All file types" is set or at least "Files: Elixir" is set. Autosave JetBrains IDEs have autosave turned on by default, but you can adjust the settings: 1. Preferences 2. Appearance & Behavior > System Settings. 3. Check or uncheck the settings in the Autosave section.
Fixes KronicDeth#997 To format manually: With the keyboard * Mac: ⌥⇧⌘L * Linux/Windows: Ctrl+Alt+Shift+L From the menus 1. Code 2. Reformat File 3. Click Run in the "Reformat File" dialog To tun on format on save: 1. Preferences 2. Tools > Actions on Save. 3. Check "Reformat code". 4. Make sure "All file types" is set or at least "Files: Elixir" is set. Autosave JetBrains IDEs have autosave turned on by default, but you can adjust the settings: 1. Preferences 2. Appearance & Behavior > System Settings. 3. Check or uncheck the settings in the Autosave section.
Fixes KronicDeth#997 To format manually: With the keyboard * Mac: ⌥⇧⌘L * Linux/Windows: Ctrl+Alt+Shift+L From the menus 1. Code 2. Reformat File 3. Click Run in the "Reformat File" dialog To tun on format on save: 1. Preferences 2. Tools > Actions on Save. 3. Check "Reformat code". 4. Make sure "All file types" is set or at least "Files: Elixir" is set. Autosave JetBrains IDEs have autosave turned on by default, but you can adjust the settings: 1. Preferences 2. Appearance & Behavior > System Settings. 3. Check or uncheck the settings in the Autosave section.
Fixes KronicDeth#997 To format manually: With the keyboard * Mac: ⌥⇧⌘L * Linux/Windows: Ctrl+Alt+Shift+L From the menus 1. Code 2. Reformat File 3. Click Run in the "Reformat File" dialog To tun on format on save: 1. Preferences 2. Tools > Actions on Save. 3. Check "Reformat code". 4. Make sure "All file types" is set or at least "Files: Elixir" is set. Autosave JetBrains IDEs have autosave turned on by default, but you can adjust the settings: 1. Preferences 2. Appearance & Behavior > System Settings. 3. Check or uncheck the settings in the Autosave section.
Fixes KronicDeth#997 To format manually: With the keyboard * Mac: ⌥⇧⌘L * Linux/Windows: Ctrl+Alt+Shift+L From the menus 1. Code 2. Reformat File 3. Click Run in the "Reformat File" dialog To tun on format on save: 1. Preferences 2. Tools > Actions on Save. 3. Check "Reformat code". 4. Make sure "All file types" is set or at least "Files: Elixir" is set. Autosave JetBrains IDEs have autosave turned on by default, but you can adjust the settings: 1. Preferences 2. Appearance & Behavior > System Settings. 3. Check or uncheck the settings in the Autosave section.
Yesterday, José Valim announced the release of Elixir 1.6 with a new mix task called code formatter. Running
mix format
task automatically formats the code into a unique and consistent layout.Is it possible to make use of the
mix format
task via theReformat Code
command in IntelliJ?Thanks and best,
Tom
The text was updated successfully, but these errors were encountered: