Skip to content

Commit

Permalink
add multi-language formatter: topiary (#469)
Browse files Browse the repository at this point in the history
Site: https://topiary.tweag.io

fixes #468

Working for me locally against OCaml, TOML, and Nickel files.

---

User/contributor toastal wishes this repository was mirrored away from the US proprietary control of Microsoft™ GitHub so users can contribute with privacy & freedom.
  • Loading branch information
toastal committed Jun 29, 2023
1 parent 1412d20 commit 1dd282c
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 18 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@ that caused Neoformat to be invoked.
- HCL
- [`hclfmt`](https://github.com/hashicorp/hcl)
- Toml
- [`taplo`](https://taplo.tamasfe.dev/cli/usage/formatting.html)
- [`taplo`](https://taplo.tamasfe.dev/cli/usage/formatting.html),
[`topiary`](https://topiary.tweag.io)
- Puppet
- [`puppet-lint`](https://github.com/rodjek/puppet-lint)
- PureScript
Expand Down Expand Up @@ -375,8 +376,9 @@ that caused Neoformat to be invoked.
[`prettierd`](https://github.com/fsouza/prettierd),
[`prettier`](https://github.com/prettier/prettier),
[`jq`](https://stedolan.github.io/jq/),
[`fixjson`](https://github.com/rhysd/fixjson)
[`deno fmt`](https://deno.land/manual/tools/formatter)
[`fixjson`](https://github.com/rhysd/fixjson),
[`deno fmt`](https://deno.land/manual/tools/formatter),
[`topiary`](https://topiary.tweag.io)
- JSONC (JSON with comments)
- [`prettierd`](https://github.com/fsouza/prettierd),
[`prettier`](https://github.com/prettier/prettier),
Expand Down Expand Up @@ -410,6 +412,8 @@ that caused Neoformat to be invoked.
- [`matlab-formatter-vscode`](https://github.com/affenwiesel/matlab-formatter-vscode)
- Nginx
- [nginxbeautifier](https://github.com/vasilevich/nginxbeautifier)
- Nickel
- [`topiary`](https://topiary.tweag.io)
- Nim
- `nimpretty` (ships with [`nim`](https://nim-lang.org/))
- Nix
Expand All @@ -422,7 +426,8 @@ that caused Neoformat to be invoked.
[`astyle`](http://astyle.sourceforge.net)
- OCaml
- [`ocp-indent`](http://www.typerex.org/ocp-indent.html),
[`ocamlformat`](https://github.com/ocaml-ppx/ocamlformat)
[`ocamlformat`](https://github.com/ocaml-ppx/ocamlformat),
[`topiary`](https://topiary.tweag.io)
- Pandoc Markdown
- [`pandoc`](https://pandoc.org/MANUAL.html)
- Pawn
Expand Down Expand Up @@ -468,7 +473,8 @@ that caused Neoformat to be invoked.
[`standard`](https://github.com/testdouble/standard)
[`prettier`](https://github.com/prettier/plugin-ruby)
- Rust
- [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt)
- [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt),
[`topiary`](https://topiary.tweag.io)
- Sass
- [`sass-convert`](http://sass-lang.com/documentation/#executables),
[`stylelint`](https://stylelint.io/),
Expand All @@ -490,7 +496,8 @@ that caused Neoformat to be invoked.
- [`shfmt`](https://github.com/mvdan/sh)
```vim
let g:shfmt_opt="-ci"
```
```,
[`topiary`](https://topiary.tweag.io)
- Solidity
- [`prettierd`](https://github.com/fsouza/prettierd),
[`prettier`](https://github.com/prettier-solidity/prettier-plugin-solidity),
Expand Down
11 changes: 10 additions & 1 deletion autoload/neoformat/formatters/json.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function! neoformat#formatters#json#enabled() abort
return ['jsbeautify', 'prettydiff', 'prettierd', 'prettier', 'jq', 'fixjson', 'denofmt']
return ['jsbeautify', 'prettydiff', 'prettierd', 'prettier', 'jq', 'fixjson', 'denofmt', 'topiary']
endfunction

function! neoformat#formatters#json#jsbeautify() abort
Expand Down Expand Up @@ -51,3 +51,12 @@ function! neoformat#formatters#json#denofmt() abort
\ 'stdin': 1,
\ }
endfunction

function! neoformat#formatters#json#topiary() abort
return {
\ 'exe': 'topiary',
\ 'no_append': 1,
\ 'stdin': 1,
\ 'args': ['--language', '"json"' ]
\ }
endfunction
11 changes: 11 additions & 0 deletions autoload/neoformat/formatters/nickel.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function! neoformat#formatters#nickel#enabled() abort
return ['topiary']
endfunction

function! neoformat#formatters#nickel#topiary() abort
return {
\ 'exe': 'topiary',
\ 'stdin': 1,
\ 'args': ['--language', '"nickel"' ]
\ }
endfunction
10 changes: 9 additions & 1 deletion autoload/neoformat/formatters/ocaml.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function! neoformat#formatters#ocaml#enabled() abort
return ['ocamlformat', 'ocpindent']
return ['ocamlformat', 'ocpindent', 'topiary']
endfunction

function! neoformat#formatters#ocaml#ocpindent() abort
Expand All @@ -16,3 +16,11 @@ function! neoformat#formatters#ocaml#ocamlformat() abort
\ 'args': ['--name', '"%:p"', '-']
\ }
endfunction

function! neoformat#formatters#ocaml#topiary() abort
return {
\ 'exe': 'topiary',
\ 'stdin': 1,
\ 'args': ['--language', '"ocaml"' ]
\ }
endfunction
10 changes: 9 additions & 1 deletion autoload/neoformat/formatters/rust.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function! neoformat#formatters#rust#enabled() abort
return ['rustfmt']
return ['rustfmt', 'topiary']
endfunction

function! neoformat#formatters#rust#rustfmt() abort
Expand All @@ -8,3 +8,11 @@ function! neoformat#formatters#rust#rustfmt() abort
\ 'stdin': 1,
\ }
endfunction

function! neoformat#formatters#rust#topiary() abort
return {
\ 'exe': 'topiary',
\ 'stdin': 1,
\ 'args': ['--language', '"rust"' ]
\ }
endfunction
10 changes: 9 additions & 1 deletion autoload/neoformat/formatters/sh.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function! neoformat#formatters#sh#enabled() abort
return ['shfmt']
return ['shfmt', 'topiary']
endfunction

function! neoformat#formatters#sh#shfmt() abort
Expand All @@ -10,3 +10,11 @@ function! neoformat#formatters#sh#shfmt() abort
\ 'stdin': 1,
\ }
endfunction

function! neoformat#formatters#sh#topiary() abort
return {
\ 'exe': 'topiary',
\ 'stdin': 1,
\ 'args': ['--language', '"bash"' ]
\ }
endfunction
10 changes: 9 additions & 1 deletion autoload/neoformat/formatters/toml.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function! neoformat#formatters#toml#enabled() abort
return ['taplo']
return ['taplo', 'topiary']
endfunction

function! neoformat#formatters#toml#taplo() abort
Expand All @@ -10,3 +10,11 @@ function! neoformat#formatters#toml#taplo() abort
\ 'try_node_exe': 1,
\ }
endfunction

function! neoformat#formatters#toml#topiary() abort
return {
\ 'exe': 'topiary',
\ 'stdin': 1,
\ 'args': ['--language', '"toml"' ]
\ }
endfunction
21 changes: 14 additions & 7 deletions doc/neoformat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,9 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
[`prettierd`](https://github.com/fsouza/prettierd),
[`prettier`](https://github.com/prettier/prettier),
[`jq`](https://stedolan.github.io/jq/),
[`fixjson`](https://github.com/rhysd/fixjson)
[`deno fmt`](https://deno.land/manual/tools/formatter)
[`fixjson`](https://github.com/rhysd/fixjson),
[`deno fmt`](https://deno.land/manual/tools/formatter),
[`topiary`](https://topiary.tweag.io)
- Kotlin
- [`ktlint`](https://github.com/shyiko/ktlint)
[`prettierd`](https://github.com/fsouza/prettierd),
Expand All @@ -379,6 +380,8 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
- [`matlab-formatter-vscode`](https://github.com/affenwiesel/matlab-formatter-vscode)
- Nginx
- [nginxbeautifier](https://github.com/vasilevich/nginxbeautifier)
- Nickel
- [`topiary`](https://topiary.tweag.io)
- Nim
- nimpretty (ships with [nim](https://nim-lang.org/)),
- Nix
Expand All @@ -390,8 +393,9 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
[`clang-format`](http://clang.llvm.org/docs/ClangFormat.html),
[`astyle`](http://astyle.sourceforge.net)
- OCaml
- [`ocp-indent`](http://www.typerex.org/ocp-indent.html)
- [`ocamlformat`](https://github.com/ocaml-ppx/ocamlformat)
- [`ocp-indent`](http://www.typerex.org/ocp-indent.html),
[`ocamlformat`](https://github.com/ocaml-ppx/ocamlformat),
[`topiary`](https://topiary.tweag.io)
- Pandoc Markdown
- [`pandoc`](https://pandoc.org/MANUAL.html)
- Pawn
Expand Down Expand Up @@ -437,7 +441,8 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
- [`standard`](https://github.com/testdouble/standard)
- [`prettier`](https://github.com/prettier/plugin-ruby)
- Rust
- [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt)
- [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt),
[`topiary`](https://topiary.tweag.io)
- Sass
- [`sass-convert`](http://sass-lang.com/documentation/#executables),
[`stylelint`](https://stylelint.io/),
Expand All @@ -456,7 +461,8 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
[`prettydiff`](https://github.com/prettydiff/prettydiff),
[`csscomb`](http://csscomb.com)
- Shell
- [`shfmt`](https://github.com/mvdan/sh)
- [`shfmt`](https://github.com/mvdan/sh),
[`topiary`](https://topiary.tweag.io)
- Solidity
- [`prettierd`](https://github.com/fsouza/prettierd),
[`prettier`](https://github.com/prettier-solidity/prettier-plugin-solidity)
Expand Down Expand Up @@ -486,7 +492,8 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
[`clang-format`](http://clang.llvm.org/docs/ClangFormat.html),
[`deno fmt`](https://deno.land/manual/tools/formatter)
- Toml
- [`taplo`](https://taplo.tamasfe.dev/cli/usage/formatting.html)
- [`taplo`](https://taplo.tamasfe.dev/cli/usage/formatting.html),
[`topiary`](https://topiary.tweag.io)
- V
- `v fmt` (ships with [`v`](https://vlang.io))
- VALA
Expand Down

0 comments on commit 1dd282c

Please sign in to comment.