Skip to content

Commit

Permalink
feat: add deno fmt (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
ribru17 authored Sep 14, 2023
1 parent ee679d1 commit db7461a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
2 changes: 2 additions & 0 deletions doc/conform.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
25 changes: 25 additions & 0 deletions lua/conform/formatters/deno_fmt.lua
Original file line number Diff line number Diff line change
@@ -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,
}

0 comments on commit db7461a

Please sign in to comment.