From db7461afcf751023adeb346d833f2e5d40a420c4 Mon Sep 17 00:00:00 2001 From: Riley Bruins Date: Thu, 14 Sep 2023 11:07:55 -0700 Subject: feat: add deno fmt (#46) --- README.md | 1 + doc/conform.txt | 2 ++ lua/conform/formatters/deno_fmt.lua | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 lua/conform/formatters/deno_fmt.lua diff --git a/README.md b/README.md index e01f0d7..d334d70 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 33c1ef7..2ed701f 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 0000000..7b48320 --- /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, +} -- cgit v1.2.3-70-g09d2