mdsf
Format markdown code snippets using your favorite code formatters.
Installation
The latest version of mdsf
can be downloaded directly from github.com/hougesen/mdsf/releases.
Cargo
Install using the published crate:
or directly from source:
Usage
Shell completions
Shell completions can be generated using mdsf completions <SHELL>
.
Bash
Add the following to your .bashrc
.
Bash
Add the following to your .zshrc
.
Fish
Add the following to ~/.config/fish/config.fish
.
mdsf completions fish | source
PowerShell
Add the following to your PowerShell configuraiton (Can be found by running $PROFILE
).
Invoke-Expression (&mdsf completions powershell)
Elvish
Add the following to ~/.elvish/rc.elv
.
eval (mdsf completions elvish)
Configuration
The default configuration of mdsf
aims to as sane as possible. For that reason the default formatter for each language is the one most people have installed.
If you are interested in customizing which formatter is run, you can create a new mdsf
configuration file by running
mdsf
supports running multiple formatters on the save code snippet.
Supported languages & formatters
[!NOTE] mdsf is not a tool for installing formatters.
Only formatters that are already installed will be used.
Language | Formatters |
---|---|
Assembly | asmfmt |
Bazel | buildifier |
Bicep | bicep_format |
Blade | blade-formatter |
C | clang-format |
CSharp | clang-format , csharpier |
Cabal | cabal_format |
Clojure | cljstyle , joker , zprint |
Cpp | clang-format |
Crystal | crystal_format |
Css | prettier , stylelint |
D | dfmt |
Dart | dart_format |
Elixir | mix_format |
Elm | elm-format |
Erb | erb-formatter , htmlbeautifier |
Erlang | efmt , erlfmt |
FSharp | fantomas |
Fennel | fnlfmt |
Fish | fish_indent |
Fortran | findent , fprettify |
GDScript | gdformat |
Gleam | gleam_format |
Go | crlfmt , gci , gofmt , gofumpt , goimports , goimports-reviser , golines |
GraphQL | prettier |
Groovy | npm-groovy-lint |
Handlebars | djlint , prettier |
Haskell | fourmolu , hindent , ormolu , stylish-haskell |
Hcl | terraform_fmt , tofu_fmt |
Html | djlint , htmlbeautifier , prettier |
Java | clang-format , google-java-format |
JavaScript | biome , clang-format , deno_fmt , prettier , standardjs |
Json | biome , clang-format , deno_fmt , prettier |
Julia | juliaformatter.jl |
Just | just_fmt |
Kcl | kcl_fmt |
Kotlin | ktfmt , ktlint |
Lua | luaformatter , stylua |
Markdown | autocorrect , codespell , mdformat , misspell , prettier , typos |
Mustache | djlint |
Nim | nimpretty |
Nix | alejandra , nixfmt , nixpkgs-fmt |
Nunjucks | djlint |
OCaml | ocamlformat , ocp-indent |
ObjectiveC | clang-format |
Perl | perltidy |
Protobuf | buf , clang-format |
Puppet | puppet-lint |
PureScript | purs-tidy |
Python | auto-optional , autopep8 , black , blue , docstrfmt , isort , pyink , ruff , usort , yapf |
ReScript | rescript_format |
ReStructuredText | docstrfmt , rstfmt |
Roc | roc_format |
Ruby | rubocop , rubyfmt , rufo , standardrb |
Rust | leptosfmt , rustfmt , yew-fmt |
Scala | scalafmt |
Shell | beautysh , fish_indent , shfmt |
Solidity | forge_fmt |
Sql | sql-formatter , sqlfluff |
Swift | swift-format , swiftformat |
Toml | taplo |
TypeScript | biome , deno_fmt , prettier |
Vue | biome , prettier |
Xml | xmlformat , xmllint |
Yaml | prettier , yamlfix , yamlfmt |
Zig | zigfmt |
Acknowledgement
mdsf was inspired by the amazing neovim formatting plugin conform.nvim.
Alternatives to mdsf
- conform.nvim using
injected
mode. - mdformat.