vim-mix-format icon indicating copy to clipboard operation
vim-mix-format copied to clipboard

Allow :MixFormat command to run on eelixir filetype

Open sbennett33 opened this issue 3 years ago • 2 comments

Overview

With the heex formatter being added to LiveView it would be helpful to allow this plugin to run on those filetypes.

Connects #42

Notes

  • Until the new version of LiveView is released with this plugin built in you'll need to manually add it to your Elixir project: {:heex_formatter, github: "feliperenan/heex_formatter"}
  • If using the vim-elixir plugin, the filetype for *.heex files (should) be set to eelixir.
  • This PR targets eelixir files. I could also see adding support specifically for heex filetype since that is the filetype that gets detected when not using the vim-elixir plugin.

Testing Instructions

  • Update your .formatter.exs to support .heex files
  • Open a *.heex template in a new buffer
  • Ensure the :MixFormat command is available and works as expected

sbennett33 avatar Mar 24 '22 16:03 sbennett33

Nothing to do with this PR, but I thought it might be useful for people who stranded here trying to get their .heex files formatted on save.

Ale has a fixer for (e)elixir. So I followed these steps: https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.HTMLFormatter.html and then in my vim config I added:

Plug 'dense-analysis/ale'
let g:ale_fixers = {
\ 'elixir': ['mix_format'],
\ 'eelixir': ['mix_format'],
\ 'scss': ['stylelint'],
\ 'css': ['stylelint'],
\ 'javascript': ['eslint'],
\ 'ruby': ['rubocop']

\}
let g:ale_fix_on_save = 1

EasterPeanut avatar Jun 07 '22 12:06 EasterPeanut

Came here to make this exact PR. 👍

nathanl avatar Mar 08 '23 14:03 nathanl