Mix format plugins and lowercase sigils not working

I am trying to use mix format to format some graphql code but when I define the plugin it will work with a capital sigil IE ~G but not a lowercase one ~g. The problem is that some of the test code requires string interpolation which will not work with the uppercase sigil.

Is there a way to get a formatter plugin to work with a lowercase sigil? It has not worked when I have tried it?

You might open a feature request over on Absinthe to add sigil support to their formatter plugin, maybe?

I wrote a wrapper plugin, but it won’t format if you use the sigil ~g it wants an uppercase letter.

I’d share the source code for your plugin if you want help!

sure, the module looks like this. What I want is to use the sigil ~g vs ~G so it does string escaping but that does not seem to work with mix format.

defmodule GraphqlFormatter do
  @moduledoc """
  Format graphql code when marked with the sigil ~G 
  """

  @behaviour Mix.Tasks.Format

  def features(_opts) do
    [sigils: [:G], extensions: []]
  end

  def format(contents, opts \\ []) do
    Absinthe.Formatter.format(contents, opts)
  end
end

I don’t think the expecation for external formatters is to be able to support elixir interpolation. With uppercase sigils and no interpolation you can be sure the to-be-formatted code is complete, uninterruped and only of syntax of the external format.

Have you tried adding :g to the sigils list?

yes, it gives an error