How can I change formatter used for specific file type in doom-emacs format
module?
So far I've been happy with using mostly doom defaults and haven't gotten into writing custom configurations and seriously using Elisp, so I'm a bit lost.
I'm trying to use doom-emacs as an IDE for Laravel development and I'm running into problems with Blade files. The main one being wrong code auto formatting. Prettier run from the command line has no problem formating the files, but doom defaults do. Eg.:
Input:
@section('content')
@foreach ($posts as $post)
<article class="article">
</article>
@endforeach
@endsection
Result:
@section('content')
@foreach ($posts as $post)
<article class="article">
</article>
@endforeach
@endsection
Expected:
@section('content')
@foreach ($posts as $post)
<article class="article">
</article>
@endforeach
@endsection
I'm using +onsave
option. The files are opened in web-mode
and the extension is *.blade.php
. And I think it's using lsp formatting by default.
I've tried using (set-formatter! 'prettier "prettier" :modes '(web-mode))
and setting format-with-lsp
to nil
just to see if I can force the web-mode itself to use prettier. But no luck.
- How can I change the formatter used?
- How can I specify on which file extension it should be used?
I've been searching format-all, Doom, Googleing and trying find something in the source code, but no luck so far.