diff --git a/README.md b/README.md index e01f0d7efb8..d334d7050bc 100644 --- a/README.md +++ b/README.md @@ -165,6 +165,7 @@ To view configured and available formatters, as well as to see the path to the l - [cljstyle](https://github.com/greglook/cljstyle) - Formatter for Clojure code. - [cmake_format](https://github.com/cheshirekow/cmake_format) - Parse cmake listfiles and format them nicely. - [dart_format](https://dart.dev/tools/dart-format) - Replace the whitespace in your program with formatting that follows Dart guidelines. +- [deno_fmt](https://deno.land/manual/tools/formatter) - Use [Deno](https://deno.land/) to format TypeScript, JavaScript/JSON and markdown. - [dfmt](https://github.com/dlang-community/dfmt) - Formatter for D source code. - [djlint](https://github.com/Riverside-Healthcare/djLint) - ✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks - Handlebars - GoLang. - [elm_format](https://github.com/avh4/elm-format) - elm-format formats Elm source code according to a standard set of rules based on the official [Elm Style Guide](https://elm-lang.org/docs/style-guide). diff --git a/doc/conform.txt b/doc/conform.txt index 33c1ef7b3ee..2ed701f5b66 100644 --- a/doc/conform.txt +++ b/doc/conform.txt @@ -160,6 +160,8 @@ FORMATTERS *conform-formatter `cmake_format` - Parse cmake listfiles and format them nicely. `dart_format` - Replace the whitespace in your program with formatting that follows Dart guidelines. +`deno_fmt` - Use [Deno](https://deno.land/) to format TypeScript, + JavaScript/JSON and markdown. `dfmt` - Formatter for D source code. `djlint` - ✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks - Handlebars - GoLang. diff --git a/lua/conform/formatters/deno_fmt.lua b/lua/conform/formatters/deno_fmt.lua new file mode 100644 index 00000000000..7b48320585f --- /dev/null +++ b/lua/conform/formatters/deno_fmt.lua @@ -0,0 +1,25 @@ +local extensions = { + javascript = "js", + javascriptreact = "jsx", + json = "json", + jsonc = "jsonc", + markdown = "md", + typescript = "ts", + typescriptreact = "tsx", +} +---@type conform.FileFormatterConfig +return { + meta = { + url = "https://deno.land/manual/tools/formatter", + description = "Use [Deno](https://deno.land/) to format TypeScript, JavaScript/JSON and markdown.", + }, + command = "deno", + args = function(ctx) + return { + "fmt", + "-", + "--ext", + extensions[vim.bo[ctx.buf].filetype], + } + end, +}