aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRiley Bruins <ribru17@hotmail.com>2023-09-14 11:07:55 -0700
committerGitHub <noreply@github.com>2023-09-14 11:07:55 -0700
commitdb7461afcf751023adeb346d833f2e5d40a420c4 (patch)
treead4a03b0356bc795961e5d38c41a81003bc88d28
parentee679d1f71a64b706d53d2acff36dd2c62fc9c6e (diff)
feat: add deno fmt (#46)
-rw-r--r--README.md1
-rw-r--r--doc/conform.txt2
-rw-r--r--lua/conform/formatters/deno_fmt.lua25
3 files changed, 28 insertions, 0 deletions
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,
+}