├── .editorconfig ├── .gitignore ├── .kodiak.toml ├── .nvmrc ├── .travis.yml ├── .vintrc.yaml ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── autoload ├── neoformat.vim └── neoformat │ ├── formatters │ ├── arduino.vim │ ├── asm.vim │ ├── astro.vim │ ├── beancount.vim │ ├── bib.vim │ ├── blade.vim │ ├── bzl.vim │ ├── c.vim │ ├── cabal.vim │ ├── caddyfile.vim │ ├── cmake.vim │ ├── cpp.vim │ ├── crystal.vim │ ├── cs.vim │ ├── css.vim │ ├── csv.vim │ ├── cue.vim │ ├── d.vim │ ├── d2.vim │ ├── dart.vim │ ├── dhall.vim │ ├── dune.vim │ ├── ebuild.vim │ ├── eelixir.vim │ ├── elixir.vim │ ├── elm.vim │ ├── erlang.vim │ ├── eruby.vim │ ├── fennel.vim │ ├── fish.vim │ ├── fortran.vim │ ├── fsharp.vim │ ├── gdscript.vim │ ├── gleam.vim │ ├── glsl.vim │ ├── gn.vim │ ├── go.vim │ ├── graphql.vim │ ├── haskell.vim │ ├── hcl.vim │ ├── html.vim │ ├── htmldjango.vim │ ├── jade.vim │ ├── java.vim │ ├── javascript.vim │ ├── javascriptreact.vim │ ├── jinja.vim │ ├── json.vim │ ├── jsonc.vim │ ├── jsonnet.vim │ ├── just.vim │ ├── kotlin.vim │ ├── less.vim │ ├── lua.vim │ ├── markdown.vim │ ├── matlab.vim │ ├── nginx.vim │ ├── nickel.vim │ ├── nim.vim │ ├── nix.vim │ ├── objc.vim │ ├── objcpp.vim │ ├── ocaml.vim │ ├── opencl.vim │ ├── openscad.vim │ ├── pandoc.vim │ ├── pawn.vim │ ├── perl.vim │ ├── php.vim │ ├── prisma.vim │ ├── proto.vim │ ├── ps1.vim │ ├── pug.vim │ ├── puppet.vim │ ├── purescript.vim │ ├── python.vim │ ├── r.vim │ ├── reason.vim │ ├── rego.vim │ ├── ruby.vim │ ├── rust.vim │ ├── sass.vim │ ├── sbt.vim │ ├── scala.vim │ ├── scss.vim │ ├── sh.vim │ ├── solidity.vim │ ├── sql.vim │ ├── starlark.vim │ ├── svelte.vim │ ├── swift.vim │ ├── systemverilog.vim │ ├── terraform.vim │ ├── tex.vim │ ├── tf.vim │ ├── toml.vim │ ├── typescript.vim │ ├── typescriptreact.vim │ ├── typst.vim │ ├── v.vim │ ├── vala.vim │ ├── verilog.vim │ ├── vue.vim │ ├── xhtml.vim │ ├── xml.vim │ ├── yaml.vim │ ├── zig.vim │ └── zsh.vim │ ├── sugarss.vim │ └── utils.vim ├── doc └── neoformat.txt ├── plugin └── neoformat.vim └── test ├── .gitignore ├── README.md ├── after ├── cp.cp ├── cssbeautify-indent-6.css ├── cssbeautify.css ├── csscomb.css ├── prettydiff.css ├── tsfmt.ts └── yapf.py ├── autocomplete_test.vim ├── before ├── cp.cp ├── cssbeautify.css ├── csscomb.css ├── prettydiff.css ├── tsfmt.ts └── yapf.py ├── bin └── exit64 ├── install.sh ├── neoformat.vader ├── requirements.txt ├── test.py ├── utils.vader ├── vimrc ├── visual_after ├── css_cssbeautify_3_4 └── javascript_jsbeautify_3_4 ├── visual_before ├── css_cssbeautify_3_4 └── javascript_jsbeautify_3_4 ├── visual_selection_after.txt └── visual_selection_before.txt /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_style = space 3 | end_of_line = lf 4 | charset = utf-8 5 | trim_trailing_whitespace = true 6 | insert_final_newline = true 7 | 8 | [*.vim] 9 | indent_size = 4 10 | tab_width = 4 11 | 12 | [*.vader] 13 | indent_size = 2 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | test/$VADER_OUTPUT_FILE 2 | node_modules/ 3 | .cache 4 | doc/tags 5 | -------------------------------------------------------------------------------- /.kodiak.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | [merge.message] 4 | title = "pull_request_title" 5 | body = "pull_request_body" 6 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 5.11.1 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | sudo: required 4 | 5 | cache: 6 | - pip 7 | - npm 8 | 9 | env: 10 | - PATH="$PATH:/home/travis/build/sbdchd/neoformat/test/bin" 11 | 12 | python: 13 | - "3.6" 14 | 15 | before_install: 16 | - nvm install $NODE_VERSION 17 | 18 | install: 19 | - ./test/install.sh 20 | - pip install -r test/requirements.txt 21 | 22 | script: 23 | - cd test && pytest -v test.py 24 | -------------------------------------------------------------------------------- /.vintrc.yaml: -------------------------------------------------------------------------------- 1 | cmdargs: 2 | severity: error 3 | 4 | env: 5 | neovim: true 6 | 7 | policies: 8 | ProhibitSetNoCompatible: 9 | enabled: false 10 | ProhibitImplicitScopeVariable: 11 | enabled: false 12 | ProhibitEqualTildeOperator: 13 | enabled: false 14 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # contributing 2 | 3 | If you are looking to add or update a formatter, please be sure to update both 4 | [`doc/neoformat.txt`](./doc/neoformat.txt) as well as [`README.md`](./README.md). Thanks! 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016, Steve Dignam 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 18 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 20 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 21 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 22 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: 2 | 3 | .PHONY: test 4 | test: 5 | ./test/test.sh 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Neoformat [![Build Status](https://travis-ci.org/sbdchd/neoformat.svg?branch=master)](https://travis-ci.org/sbdchd/neoformat) 2 | 3 | A (Neo)vim plugin for formatting code. 4 | 5 | Neoformat uses a variety of formatters for many filetypes. Currently, Neoformat 6 | will run a formatter using the current buffer data, and on success it will 7 | update the current buffer with the formatted text. On a formatter failure, 8 | Neoformat will try the next formatter defined for the filetype. 9 | 10 | By using `getbufline()` to read from the current buffer instead of file, 11 | Neoformat is able to format your buffer without you having to `:w` your file first. 12 | Also, by using `setline()`, marks, jumps, etc. are all maintained after formatting. 13 | 14 | Neoformat supports both sending buffer data to formatters via stdin, and also 15 | writing buffer data to `/tmp/` for formatters to read that do not support input 16 | via stdin. 17 | 18 | ## Basic Usage 19 | 20 | Format the entire buffer, or visual selection of the buffer 21 | 22 | ```viml 23 | :Neoformat 24 | ``` 25 | 26 | Or specify a certain formatter (must be defined for the current filetype) 27 | 28 | ```viml 29 | :Neoformat jsbeautify 30 | ``` 31 | 32 | Or format a visual selection of code in a different filetype 33 | 34 | **Note:** you must use a ! and pass the filetype of the selection 35 | 36 | ```viml 37 | :Neoformat! python 38 | ``` 39 | 40 | You can also pass a formatter to use 41 | 42 | ```viml 43 | :Neoformat! python yapf 44 | ``` 45 | 46 | Or perhaps run a formatter on save 47 | 48 | ```viml 49 | augroup fmt 50 | autocmd! 51 | autocmd BufWritePre * undojoin | Neoformat 52 | augroup END 53 | ``` 54 | 55 | The `undojoin` command will put changes made by Neoformat into the same 56 | `undo-block` with the latest preceding change. See 57 | [Managing Undo History](#managing-undo-history). 58 | 59 | ## Install 60 | 61 | The best way to install Neoformat is with your favorite plugin manager for Vim, such as [vim-plug](https://github.com/junegunn/vim-plug): 62 | 63 | ```viml 64 | Plug 'sbdchd/neoformat' 65 | ``` 66 | 67 | ## Current Limitation(s) 68 | 69 | If a formatter is either not configured to use `stdin`, or is not able to read 70 | from `stdin`, then buffer data will be written to a file in `/tmp/neoformat/`, 71 | where the formatter will then read from 72 | 73 | ## Config [Optional] 74 | 75 | Define custom formatters. 76 | 77 | Options: 78 | 79 | | name | description | default | optional / required | 80 | | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------------------- | 81 | | `exe` | the name the formatter executable in the path | n/a | **required** | 82 | | `args` | list of arguments | \[] | optional | 83 | | `replace` | overwrite the file, instead of updating the buffer | 0 | optional | 84 | | `stdin` | send data to the stdin of the formatter | 0 | optional | 85 | | `stderr` | capture stderr output from formatter | 0 | optional | 86 | | `no_append` | do not append the `path` of the file to the formatter command, used when the `path` is in the middle of a command | 0 | optional | 87 | | `env` | list of environment variable definitions to be prepended to the formatter command | \[] | optional | 88 | | `valid_exit_codes` | list of valid exit codes for formatters who do not respect common unix practices | \[0] | optional | 89 | | `try_node_exe` | attempt to find `exe` in a `node_modules/.bin` directory in the current working directory or one of its parents (requires setting `g:neoformat_try_node_exe`) | 0 | optional | 90 | 91 | Example: 92 | 93 | ```viml 94 | let g:neoformat_python_autopep8 = { 95 | \ 'exe': 'autopep8', 96 | \ 'args': ['-s 4', '-E'], 97 | \ 'replace': 1, " replace the file, instead of updating buffer (default: 0) 98 | \ 'stdin': 1, " send data to stdin of formatter (default: 0) 99 | \ 'env': ["DEBUG=1"], " prepend environment variables to formatter command 100 | \ 'valid_exit_codes': [0, 23], 101 | \ 'no_append': 1, 102 | \ } 103 | 104 | let g:neoformat_enabled_python = ['autopep8'] 105 | ``` 106 | 107 | Configure enabled formatters. 108 | 109 | ```viml 110 | let g:neoformat_enabled_python = ['autopep8', 'yapf', 'docformatter'] 111 | ``` 112 | 113 | Have Neoformat use &formatprg as a formatter 114 | 115 | ```viml 116 | let g:neoformat_try_formatprg = 1 117 | ``` 118 | 119 | Enable basic formatting when a filetype is not found. Disabled by default. 120 | 121 | ```viml 122 | " Enable alignment 123 | let g:neoformat_basic_format_align = 1 124 | 125 | " Enable tab to spaces conversion 126 | let g:neoformat_basic_format_retab = 1 127 | 128 | " Enable trimmming of trailing whitespace 129 | let g:neoformat_basic_format_trim = 1 130 | ``` 131 | 132 | Run all enabled formatters (by default Neoformat stops after the first formatter 133 | succeeds) 134 | 135 | ```viml 136 | let g:neoformat_run_all_formatters = 1 137 | ``` 138 | 139 | Above options can be activated or deactivated per buffer. For example: 140 | 141 | ```viml 142 | " runs all formatters for current buffer without tab to spaces conversion 143 | let b:neoformat_run_all_formatters = 1 144 | let b:neoformat_basic_format_retab = 0 145 | ``` 146 | 147 | Have Neoformat only msg when there is an error 148 | 149 | ```viml 150 | let g:neoformat_only_msg_on_error = 1 151 | ``` 152 | 153 | When debugging, you can enable either of following variables for extra logging. 154 | 155 | ```viml 156 | let g:neoformat_verbose = 1 " only affects the verbosity of Neoformat 157 | " Or 158 | let &verbose = 1 " also increases verbosity of the editor as a whole 159 | ``` 160 | 161 | Have Neoformat look for a formatter executable in the `node_modules/.bin` 162 | directory in the current working directory or one of its parents (only applies 163 | to formatters with `try_node_exe` set to `1`): 164 | 165 | ```viml 166 | let g:neoformat_try_node_exe = 1 167 | ``` 168 | 169 | ## Adding a New Formatter 170 | 171 | Note: you should replace everything `{{ }}` accordingly 172 | 173 | 1. Create a file in `autoload/neoformat/formatters/{{ filetype }}.vim` if it does not 174 | already exist for your filetype. 175 | 176 | 2. Follow the following format 177 | 178 | See Config above for options 179 | 180 | ```viml 181 | function! neoformat#formatters#{{ filetype }}#enabled() abort 182 | return ['{{ formatter name }}', '{{ other formatter name for filetype }}'] 183 | endfunction 184 | 185 | function! neoformat#formatters#{{ filetype }}#{{ formatter name }}() abort 186 | return { 187 | \ 'exe': '{{ formatter name }}', 188 | \ 'args': ['-s 4', '-q'], 189 | \ 'stdin': 1 190 | \ } 191 | endfunction 192 | 193 | function! neoformat#formatters#{{ filetype }}#{{ other formatter name }}() abort 194 | return {'exe': {{ other formatter name }} 195 | endfunction 196 | ``` 197 | 198 | ## Managing Undo History 199 | 200 | If you use an `autocmd` to run Neoformat on save, and you have your editor 201 | configured to save automatically on `CursorHold` then you might run into 202 | problems reverting changes. Pressing `u` will undo the last change made by 203 | Neoformat instead of the change that you made yourself - and then Neoformat 204 | will run again redoing the change that you just reverted. To avoid this 205 | problem you can run Neoformat with the Vim `undojoin` command to put changes 206 | made by Neoformat into the same `undo-block` with the preceding change. For 207 | example: 208 | 209 | ```viml 210 | augroup fmt 211 | autocmd! 212 | autocmd BufWritePre * undojoin | Neoformat 213 | augroup END 214 | ``` 215 | 216 | When `undojoin` is used this way pressing `u` will "skip over" the Neoformat 217 | changes - it will revert both the changes made by Neoformat and the change 218 | that caused Neoformat to be invoked. 219 | 220 | ## Supported Filetypes 221 | 222 | - Arduino 223 | - [`uncrustify`](http://uncrustify.sourceforge.net), 224 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 225 | [`astyle`](http://astyle.sourceforge.net) 226 | - Assembly 227 | - [`asmfmt`](https://github.com/klauspost/asmfmt) 228 | - Astro 229 | - [`prettier`](https://github.com/withastro/prettier-plugin-astro/) 230 | - Bazel 231 | - [`buildifier`](https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md) 232 | - Beancount 233 | - [`bean-format`](https://beancount.github.io/docs/running_beancount_and_generating_reports.html#bean-format) 234 | - Blade 235 | - [`blade-formatter`](https://github.com/shufo/blade-formatter) 236 | - Bib 237 | - [bibtex-tidy](https://github.com/FlamingTempura/bibtex-tidy) 238 | - [bibclean](https://github.com/tobywf/bibclean) 239 | - C 240 | - [`uncrustify`](http://uncrustify.sourceforge.net), 241 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 242 | [`astyle`](http://astyle.sourceforge.net) 243 | - C# 244 | - [`uncrustify`](http://uncrustify.sourceforge.net), 245 | [`astyle`](http://astyle.sourceforge.net), 246 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html) 247 | [`csharpier`](https://csharpier.com/) 248 | - C++ 249 | - [`uncrustify`](http://uncrustify.sourceforge.net), 250 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 251 | [`astyle`](http://astyle.sourceforge.net) 252 | - Cabal 253 | - [`cabal-fmt`](https://github.com/phadej/cabal-fmt) 254 | - Caddyfile 255 | - [`caddy fmt`](https://caddyserver.com/docs/command-line#caddy-fmt) 256 | - CMake 257 | - [`cmake_format`](https://github.com/cheshirekow/cmake_format) 258 | - Crystal 259 | - `crystal tool format` (ships with [`crystal`](http://crystal-lang.org)) 260 | - CSS 261 | - `css-beautify` (ships with [`js-beautify`](https://github.com/beautify-web/js-beautify)), 262 | [`prettydiff`](https://github.com/prettydiff/prettydiff), 263 | [`stylefmt`](https://github.com/morishitter/stylefmt), 264 | [`stylelint`](https://stylelint.io/), 265 | [`csscomb`](http://csscomb.com), 266 | [`prettierd`](https://github.com/fsouza/prettierd), 267 | [`prettier`](https://github.com/prettier/prettier), 268 | [`topiary`](https://topiary.tweag.io) 269 | - CSV 270 | - [`prettydiff`](https://github.com/prettydiff/prettydiff) 271 | - Cue 272 | - [`cue fmt`](https://cuelang.org/) 273 | - D 274 | - [`uncrustify`](http://uncrustify.sourceforge.net), 275 | [`dfmt`](https://github.com/Hackerpilot/dfmt) 276 | - D2 277 | - [`d2 fmt`](https://d2lang.com/tour/auto-formatter) 278 | - Dart 279 | - [`dartfmt`](https://www.dartlang.org/tools/) 280 | - [`dart format`](https://dart.dev/tools/dart-format) 281 | - Dhall 282 | - [`dhall format`](https://dhall-lang.org) 283 | - dune 284 | - [`dune format`](https://github.com/ocaml/dune) 285 | - Ebuild 286 | - [`shfmt`](https://github.com/mvdan/sh) 287 | ```vim 288 | let g:shfmt_opt="-ci" 289 | ``` 290 | - Elixir 291 | - [`mix format`](https://hexdocs.pm/mix/master/Mix.Tasks.Format.html) 292 | - Elm 293 | - [`elm-format`](https://github.com/avh4/elm-format) 294 | - Eruby 295 | - [`htmlbeautifier`](https://github.com/threedaymonk/htmlbeautifier) 296 | - Erlang 297 | - [`erlfmt`](https://github.com/WhatsApp/erlfmt) 298 | - Fennel 299 | - [`fnlfmt`](https://git.sr.ht/~technomancy/fnlfmt) 300 | - Fish 301 | - [`fish_indent`](http://fishshell.com) 302 | - Fortran 303 | - [`fprettify`](https://github.com/pseewald/fprettify) 304 | - F# 305 | - [`fantomas`](https://github.com/fsprojects/fantomas) 306 | - GDScript 307 | - [`gdformat`](https://github.com/Scony/godot-gdscript-toolkit) 308 | - Gleam 309 | - [`gleam format`](https://github.com/gleam-lang/gleam/) 310 | - Go 311 | - [`gofmt`](https://golang.org/cmd/gofmt/), 312 | [`goimports`](https://godoc.org/golang.org/x/tools/cmd/goimports), 313 | [`gofumpt`](https://github.com/mvdan/gofumpt), 314 | [`gofumports`](https://github.com/mvdan/gofumpt) 315 | - GLSL 316 | - [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html) 317 | - GN 318 | - [`gn`](https://gn.googlesource.com/gn) 319 | - GraphQL 320 | - [`prettierd`](https://github.com/fsouza/prettierd), 321 | [`prettier`](https://github.com/prettier/prettier) 322 | - Haskell 323 | - [`stylishhaskell`](https://github.com/jaspervdj/stylish-haskell), 324 | [`hindent`](https://github.com/chrisdone/hindent), 325 | [`hfmt`](https://github.com/danstiner/hfmt), 326 | [`brittany`](https://github.com/lspitzner/brittany), 327 | [`sortimports`](https://github.com/evanrelf/sort-imports), 328 | [`floskell`](https://github.com/ennocramer/floskell) 329 | [`ormolu`](https://github.com/tweag/ormolu) 330 | ```vim 331 | let g:ormolu_ghc_opt=["TypeApplications", "RankNTypes"] 332 | ``` 333 | - You must use formatter's name without "`-`" 334 | ```vim 335 | " right 336 | let g:neoformat_enabled_haskell = ['sortimports', 'stylishhaskell'] 337 | " wrong 338 | let g:neoformat_enabled_haskell = ['sort-imports', 'stylish-haskell'] 339 | ``` 340 | - HCL 341 | - [`hclfmt`](https://github.com/hashicorp/hcl) 342 | - Toml 343 | - [`taplo`](https://taplo.tamasfe.dev/cli/usage/formatting.html), 344 | [`topiary`](https://topiary.tweag.io) 345 | - Puppet 346 | - [`puppet-lint`](https://github.com/rodjek/puppet-lint) 347 | - PureScript 348 | - [`purs-tidy`](https://github.com/natefaubion/purescript-tidy) 349 | - [`purty`](https://gitlab.com/joneshf/purty) 350 | - HTML 351 | - `html-beautify` (ships with [`js-beautify`](https://github.com/beautify-web/js-beautify)), 352 | [`prettierd`](https://github.com/fsouza/prettierd), 353 | [`prettier`](https://github.com/prettier/prettier), 354 | [`prettydiff`](https://github.com/prettydiff/prettydiff) 355 | - HTMLDjango 356 | - [djlint](https://djlint.com/) 357 | - Jade 358 | - [`pug-beautifier`](https://github.com/vingorius/pug-beautifier) 359 | - Java 360 | - [`uncrustify`](http://uncrustify.sourceforge.net), 361 | [`astyle`](http://astyle.sourceforge.net), 362 | [`prettierd`](https://github.com/fsouza/prettierd), 363 | [`prettier`](https://github.com/prettier/prettier) 364 | - JavaScript 365 | - [`js-beautify`](https://github.com/beautify-web/js-beautify), 366 | [`prettierd`](https://github.com/fsouza/prettierd), 367 | [`prettier`](https://github.com/prettier/prettier), 368 | [`prettydiff`](https://github.com/prettydiff/prettydiff), 369 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 370 | [`esformatter`](https://github.com/millermedeiros/esformatter/), 371 | [`prettier-eslint`](https://github.com/kentcdodds/prettier-eslint-cli), 372 | [`eslint_d`](https://github.com/mantoni/eslint_d.js), 373 | [`standard`](https://standardjs.com/), 374 | [`semistandard`](https://github.com/standard/semistandard), 375 | [`deno fmt`](https://deno.land/manual/tools/formatter), 376 | [`biome format`](https://biomejs.dev) 377 | - JSON 378 | - [`js-beautify`](https://github.com/beautify-web/js-beautify), 379 | [`prettydiff`](https://github.com/prettydiff/prettydiff), 380 | [`prettierd`](https://github.com/fsouza/prettierd), 381 | [`prettier`](https://github.com/prettier/prettier), 382 | [`jq`](https://stedolan.github.io/jq/), 383 | [`fixjson`](https://github.com/rhysd/fixjson), 384 | [`deno fmt`](https://deno.land/manual/tools/formatter), 385 | [`topiary`](https://topiary.tweag.io), 386 | [`biome format`](https://biomejs.dev) 387 | - JSONC (JSON with comments) 388 | - [`prettierd`](https://github.com/fsouza/prettierd), 389 | [`prettier`](https://github.com/prettier/prettier), 390 | [`deno fmt`](https://deno.land/manual/tools/formatter), 391 | [`biome format`](https://biomejs.dev) 392 | - jsonnet 393 | - [`jsonnetfmt`](https://github.com/google/jsonnet) 394 | - just 395 | - [`just`](https://github.com/casey/just) 396 | - Kotlin 397 | - [`ktlint`](https://github.com/shyiko/ktlint), 398 | [`prettierd`](https://github.com/fsouza/prettierd), 399 | [`prettier`](https://github.com/prettier/prettier) 400 | - LaTeX 401 | - [`latexindent`](https://github.com/cmhughes/latexindent.pl) 402 | ```vim 403 | let g:latexindent_opt="-m" 404 | ``` 405 | - Less 406 | - [`csscomb`](http://csscomb.com), 407 | [`prettydiff`](https://github.com/prettydiff/prettydiff), 408 | [`prettierd`](https://github.com/fsouza/prettierd), 409 | [`prettier`](https://github.com/prettier/prettier), 410 | [`stylelint`](https://stylelint.io/) 411 | - Lua 412 | - [`luaformatter`](https://github.com/LuaDevelopmentTools/luaformatter) 413 | - [`lua-fmt`](https://github.com/trixnz/lua-fmt) 414 | - [`lua-format`](https://github.com/Koihik/LuaFormatter) 415 | - [`stylua`](https://github.com/JohnnyMorganz/StyLua) 416 | - Markdown 417 | - [`remark`](https://github.com/wooorm/remark), 418 | [`prettierd`](https://github.com/fsouza/prettierd), 419 | [`prettier`](https://github.com/prettier/prettier), 420 | [`deno fmt`](https://deno.land/manual/tools/formatter), 421 | [`mdformat`](https://github.com/executablebooks/mdformat) 422 | - Matlab 423 | - [`matlab-formatter-vscode`](https://github.com/affenwiesel/matlab-formatter-vscode) 424 | - Nginx 425 | - [nginxbeautifier](https://github.com/vasilevich/nginxbeautifier) 426 | - Nickel 427 | - [`topiary`](https://topiary.tweag.io) 428 | - Nim 429 | - `nimpretty` (ships with [`nim`](https://nim-lang.org/)) 430 | - [`nph`](https://github.com/arnetheduck/nph) 431 | - Nix 432 | - [`nixfmt`](https://github.com/serokell/nixfmt) 433 | - [`nixpkgs-fmt`](https://github.com/nix-community/nixpkgs-fmt) 434 | - [`alejandra`](https://github.com/kamadorueda/alejandra) 435 | - Objective-C 436 | - [`uncrustify`](http://uncrustify.sourceforge.net), 437 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 438 | [`astyle`](http://astyle.sourceforge.net) 439 | - Objective-C++ 440 | - [`uncrustify`](http://uncrustify.sourceforge.net), 441 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 442 | [`astyle`](http://astyle.sourceforge.net) 443 | - OCaml 444 | - [`ocp-indent`](http://www.typerex.org/ocp-indent.html), 445 | [`ocamlformat`](https://github.com/ocaml-ppx/ocamlformat), 446 | [`topiary`](https://topiary.tweag.io) 447 | - OpenSCAD 448 | - [`openscad-format`](https://github.com/Maxattax97/openscad-format) 449 | - Pandoc Markdown 450 | - [`pandoc`](https://pandoc.org/MANUAL.html) 451 | - Pawn 452 | - [`uncrustify`](http://uncrustify.sourceforge.net) 453 | - Perl 454 | - [`perltidy`](http://perltidy.sourceforge.net) 455 | - [`perlimports`](https://github.com/perl-ide/App-perlimports) 456 | - PHP 457 | - [`php_beautifier`](http://pear.php.net/package/PHP_Beautifier), 458 | [`php-cs-fixer`](http://cs.sensiolabs.org/), 459 | [`phpcbf`](https://github.com/squizlabs/PHP_CodeSniffer), 460 | [`prettierd`](https://github.com/fsouza/prettierd), 461 | [`prettier`](https://github.com/prettier/plugin-php) 462 | [`laravel-pint`](https://github.com/laravel/pint), 463 | - PowerShell 464 | - [`PSScriptAnalyzer`](https://github.com/PowerShell/PSScriptAnalyzer), 465 | [`PowerShell-Beautifier`](https://github.com/DTW-DanWard/PowerShell-Beautifier) 466 | - Prisma 467 | - [`prettier`](https://github.com/umidbekk/prettier-plugin-prisma) 468 | - Proto 469 | - [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html) 470 | - Pug (formally Jade) 471 | - [`pug-beautifier`](https://github.com/vingorius/pug-beautifier) 472 | - Python 473 | - [`yapf`](https://github.com/google/yapf), 474 | [`autopep8`](https://github.com/hhatto/autopep8), 475 | [`black`](https://github.com/psf/black), 476 | [`pydevf`](https://github.com/fabioz/PyDev.Formatter), 477 | [`isort`](https://github.com/timothycrosley/isort), 478 | [`docformatter`](https://github.com/myint/docformatter), 479 | [`pyment`](https://github.com/dadadel/pyment), 480 | [`ruff`](https://github.com/astral-sh/ruff) 481 | - R 482 | - [`styler`](https://github.com/r-lib/styler), 483 | [`formatR`](https://github.com/yihui/formatR) 484 | - Reason 485 | - [`refmt`](https://github.com/facebook/reason) 486 | - [`bsrefmt`](https://github.com/bucklescript/bucklescript) 487 | - Rego 488 | - [`opa fmt`](https://www.openpolicyagent.org/docs/latest/cli/#opa-fmt) 489 | - Ruby 490 | - [`rufo`](https://github.com/ruby-formatter/rufo), 491 | [`ruby-beautify`](https://github.com/erniebrodeur/ruby-beautify), 492 | [`rubocop`](https://github.com/rubocop/rubocop), 493 | [`standard`](https://github.com/testdouble/standard) 494 | [`prettier`](https://github.com/prettier/plugin-ruby) 495 | - Rust 496 | - [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt), 497 | [`topiary`](https://topiary.tweag.io) 498 | - Sass 499 | - [`sass-convert`](http://sass-lang.com/documentation/#executables), 500 | [`stylelint`](https://stylelint.io/), 501 | [`csscomb`](http://csscomb.com) 502 | - Sbt 503 | - [`scalafmt`](http://scalameta.org/scalafmt/) 504 | - Scala 505 | - [`scalariform`](https://github.com/scala-ide/scalariform), 506 | [`scalafmt`](http://scalameta.org/scalafmt/) 507 | - SCSS 508 | - [`sass-convert`](http://sass-lang.com/documentation/#executables), 509 | [`stylelint`](https://stylelint.io/), 510 | [`stylefmt`](https://github.com/morishitter/stylefmt), 511 | [`prettydiff`](https://github.com/prettydiff/prettydiff), 512 | [`csscomb`](http://csscomb.com), 513 | [`prettierd`](https://github.com/fsouza/prettierd), 514 | [`prettier`](https://github.com/prettier/prettier) 515 | - Shell 516 | - [`shfmt`](https://github.com/mvdan/sh) 517 | ```vim 518 | let g:shfmt_opt="-ci" 519 | ``` 520 | - [`topiary`](https://topiary.tweag.io) 521 | - Solidity 522 | - [`prettierd`](https://github.com/fsouza/prettierd), 523 | [`prettier`](https://github.com/prettier-solidity/prettier-plugin-solidity), 524 | [`forge fmt`](https://book.getfoundry.sh/) 525 | - SQL 526 | - [`sqlfmt`](https://github.com/jackc/sqlfmt), 527 | `sqlformat` (ships with [sqlparse](https://github.com/andialbrecht/sqlparse)), 528 | `pg_format` (ships with [pgFormatter](https://github.com/darold/pgFormatter)), 529 | [`sleek`](https://github.com/nrempel/sleek) 530 | [`sql-formatter`](https://github.com/sql-formatter-org/sql-formatter) 531 | - Starlark 532 | - [`buildifier`](https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md) 533 | - SugarSS 534 | [`stylelint`](https://stylelint.io/) 535 | - Svelte 536 | - [`prettierd`](https://github.com/fsouza/prettierd), 537 | [`prettier-plugin-svelte`](https://github.com/UnwrittenFun/prettier-plugin-svelte) 538 | - Swift 539 | - [`Swiftformat`](https://github.com/nicklockwood/SwiftFormat) 540 | - Terraform 541 | - [`terraform`](https://www.terraform.io/docs/commands/fmt.html), 542 | - TypeScript 543 | - [`tsfmt`](https://github.com/vvakame/typescript-formatter), 544 | [`prettierd`](https://github.com/fsouza/prettierd), 545 | [`prettier`](https://github.com/prettier/prettier), 546 | [`prettier-eslint`](https://github.com/kentcdodds/prettier-eslint-cli), 547 | [`tslint`](https://palantir.github.io/tslint), 548 | [`eslint_d`](https://github.com/mantoni/eslint_d.js), 549 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 550 | [`deno fmt`](https://deno.land/manual/tools/formatter), 551 | [`biome format`](https://biomejs.dev) 552 | - Typst 553 | - [`typstfmt`](https://github.com/astrale-sharp/typstfmt) 554 | [`typstyle`](https://github.com/Enter-tainer/typstyle) 555 | - V 556 | - `v fmt` (ships with [`v`](https://vlang.io)) 557 | - VALA 558 | - [`uncrustify`](http://uncrustify.sourceforge.net) 559 | - Vue 560 | - [`prettierd`](https://github.com/fsouza/prettierd), 561 | [`prettier`](https://github.com/prettier/prettier) 562 | - XHTML 563 | - [`tidy`](http://www.html-tidy.org), 564 | [`prettydiff`](https://github.com/prettydiff/prettydiff) 565 | - XML 566 | - [`tidy`](http://www.html-tidy.org), 567 | [`prettydiff`](https://github.com/prettydiff/prettydiff), 568 | [`prettierd`](https://github.com/fsouza/prettierd), 569 | [`prettier`](https://github.com/prettier/prettier), 570 | [`xmllint`](https://gitlab.gnome.org/GNOME/libxml2) 571 | - YAML 572 | - [`pyaml`](https://pypi.python.org/pypi/pyaml), 573 | [`prettierd`](https://github.com/fsouza/prettierd), 574 | [`prettier`](https://github.com/prettier/prettier), 575 | [`yamlfmt`](https://github.com/mmlb/yamlfmt) (by @mmlb), 576 | [`yamlfmt`](https://github.com/google/yamlfmt) (by @google), 577 | [`yamlfix`](https://github.com/lyz-code/yamlfix) 578 | - zig 579 | - [`zigformat`](https://github.com/Himujjal/zigformat) 580 | [`zig fmt`](https://github.com/ziglang/zig) 581 | - zsh 582 | - [`shfmt`](https://github.com/mvdan/sh) 583 | ```vim 584 | let g:shfmt_opt="-ci" 585 | ``` 586 | -------------------------------------------------------------------------------- /autoload/neoformat.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#Neoformat(bang, user_input, start_line, end_line) abort 2 | let view = winsaveview() 3 | let search = @/ 4 | let original_filetype = &filetype 5 | 6 | call s:neoformat(a:bang, a:user_input, a:start_line, a:end_line) 7 | 8 | " Setting &filetype might destroy existing folds, so only do that 9 | " if the filetype got changed (which can only be possible when 10 | " invoking with a bang) 11 | if a:bang && &filetype != original_filetype 12 | let &filetype = original_filetype 13 | endif 14 | let @/ = search 15 | call winrestview(view) 16 | endfunction 17 | 18 | function! s:neoformat(bang, user_input, start_line, end_line) abort 19 | 20 | if !&modifiable 21 | return neoformat#utils#warn('buffer not modifiable') 22 | endif 23 | 24 | let using_visual_selection = a:start_line != 1 || a:end_line != line('$') 25 | 26 | let inputs = split(a:user_input) 27 | if a:bang 28 | let &filetype = len(inputs) > 1 ? inputs[0] : a:user_input 29 | endif 30 | 31 | let filetype = s:split_filetypes(&filetype) 32 | 33 | let using_user_passed_formatter = (!empty(a:user_input) && !a:bang) 34 | \ || (len(inputs) > 1 && a:bang) 35 | 36 | if using_user_passed_formatter 37 | let formatters = len(inputs) > 1 ? [inputs[1]] : [a:user_input] 38 | else 39 | let formatters = s:get_enabled_formatters(filetype) 40 | if formatters == [] 41 | call neoformat#utils#msg('formatter not defined for ' . filetype . ' filetype') 42 | return s:basic_format() 43 | endif 44 | endif 45 | 46 | let formatters_failed = [] 47 | let formatters_changed = [] 48 | for formatter in formatters 49 | 50 | if &formatprg != '' && split(&formatprg)[0] ==# formatter 51 | \ && neoformat#utils#var('neoformat_try_formatprg') 52 | call neoformat#utils#log('using formatprg') 53 | let fmt_prg_def = split(&formatprg) 54 | let definition = { 55 | \ 'exe': fmt_prg_def[0], 56 | \ 'args': fmt_prg_def[1:], 57 | \ 'stdin': 1, 58 | \ } 59 | elseif exists('b:neoformat_' . filetype . '_' . formatter) 60 | let definition = b:neoformat_{filetype}_{formatter} 61 | elseif exists('g:neoformat_' . filetype . '_' . formatter) 62 | let definition = g:neoformat_{filetype}_{formatter} 63 | elseif s:autoload_func_exists('neoformat#formatters#' . filetype . '#' . formatter) 64 | let definition = neoformat#formatters#{filetype}#{formatter}() 65 | else 66 | call neoformat#utils#log('definition not found for formatter: ' . formatter) 67 | if using_user_passed_formatter 68 | call neoformat#utils#msg('formatter definition for ' . a:user_input . ' not found') 69 | 70 | return s:basic_format() 71 | endif 72 | continue 73 | endif 74 | 75 | let cmd = s:generate_cmd(definition, filetype) 76 | if cmd == {} 77 | if using_user_passed_formatter 78 | return neoformat#utils#warn('formatter ' . a:user_input . ' failed') 79 | endif 80 | continue 81 | endif 82 | 83 | let stdin = getbufline(bufnr('%'), a:start_line, a:end_line) 84 | let original_buffer = getbufline(bufnr('%'), 1, '$') 85 | 86 | call neoformat#utils#log(stdin) 87 | 88 | call neoformat#utils#log(cmd.exe) 89 | if cmd.stdin 90 | call neoformat#utils#log('using stdin') 91 | let stdin_str = join(stdin, "\n") 92 | let stdout = split(system(cmd.exe, stdin_str), '\n') 93 | else 94 | call neoformat#utils#log('using tmp file') 95 | call writefile(stdin, cmd.tmp_file_path) 96 | let stdout = split(system(cmd.exe), '\n') 97 | endif 98 | 99 | " read from /tmp file if formatter replaces file on format 100 | if cmd.replace 101 | let stdout = readfile(cmd.tmp_file_path) 102 | endif 103 | 104 | call neoformat#utils#log(stdout) 105 | 106 | call neoformat#utils#log(cmd.valid_exit_codes) 107 | call neoformat#utils#log(v:shell_error) 108 | 109 | let process_ran_succesfully = index(cmd.valid_exit_codes, v:shell_error) != -1 110 | 111 | if cmd.stderr_log != '' 112 | call neoformat#utils#log('stderr output redirected to file' . cmd.stderr_log) 113 | call neoformat#utils#log_file_content(cmd.stderr_log) 114 | endif 115 | if process_ran_succesfully 116 | " 1. append the lines that are before and after the formatterd content 117 | let lines_after = getbufline(bufnr('%'), a:end_line + 1, '$') 118 | let lines_before = getbufline(bufnr('%'), 1, a:start_line - 1) 119 | 120 | let new_buffer = lines_before + stdout + lines_after 121 | if new_buffer !=# original_buffer 122 | 123 | call s:deletelines(len(new_buffer), line('$')) 124 | 125 | call setline(1, new_buffer) 126 | 127 | call add(formatters_changed, cmd.name) 128 | let endmsg = cmd.name . ' formatted buffer' 129 | else 130 | 131 | let endmsg = 'no change necessary with ' . cmd.name 132 | endif 133 | if !neoformat#utils#var('neoformat_run_all_formatters') 134 | return neoformat#utils#msg(endmsg) 135 | endif 136 | call neoformat#utils#log('running next formatter') 137 | else 138 | call add(formatters_failed, cmd.name) 139 | call neoformat#utils#log(v:shell_error) 140 | call neoformat#utils#log('trying next formatter') 141 | endif 142 | endfor 143 | if len(formatters_failed) > 0 144 | call neoformat#utils#msg('formatters ' . join(formatters_failed, ", ") . ' failed to run') 145 | endif 146 | if len(formatters_changed) > 0 147 | call neoformat#utils#msg(join(formatters_changed, ", ") . ' formatted buffer') 148 | elseif len(formatters_failed) == 0 149 | call neoformat#utils#msg('no change necessary') 150 | endif 151 | endfunction 152 | 153 | function! s:get_enabled_formatters(filetype) abort 154 | if &formatprg != '' && neoformat#utils#var('neoformat_try_formatprg') 155 | call neoformat#utils#log('adding formatprg to enabled formatters') 156 | let format_prg_exe = [split(&formatprg)[0]] 157 | else 158 | let format_prg_exe = [] 159 | endif 160 | 161 | " Note: we append format_prg_exe to ever return as it will either be 162 | " [], or it will be a formatter that we want to try first 163 | 164 | if exists('b:neoformat_enabled_' . a:filetype) 165 | return format_prg_exe + b:neoformat_enabled_{a:filetype} 166 | elseif exists('g:neoformat_enabled_' . a:filetype) 167 | return format_prg_exe + g:neoformat_enabled_{a:filetype} 168 | elseif s:autoload_func_exists('neoformat#formatters#' . a:filetype . '#enabled') 169 | return format_prg_exe + neoformat#formatters#{a:filetype}#enabled() 170 | endif 171 | return format_prg_exe 172 | endfunction 173 | 174 | function! s:deletelines(start, end) abort 175 | silent! execute a:start . ',' . a:end . 'delete _' 176 | endfunction 177 | 178 | function! neoformat#CompleteFormatters(ArgLead, CmdLine, CursorPos) abort 179 | if a:CmdLine =~ '!' 180 | " 1. user inputting formatter :Neoformat! css 181 | if a:CmdLine =~# 'Neoformat! \S*\s' 182 | let filetype = split(a:CmdLine)[1] 183 | return filter(s:get_enabled_formatters(filetype), 184 | \ "v:val =~? '^" . a:ArgLead ."'") 185 | endif 186 | 187 | " 2. user inputting filetype :Neoformat! 188 | " https://github.com/junegunn/fzf.vim/pull/110 189 | " 1. globpath (find) all filetype files in neoformat 190 | " 2. split at new lines 191 | " 3. map ~/.config/nvim/plugged/neoformat/autoload/neoformat/formatters/xml.vim --> xml 192 | " 4. sort & uniq to eliminate dupes 193 | " 5. filter for input 194 | return filter(uniq(sort(map(split(globpath(&runtimepath, 195 | \ 'plugged/neoformat/autoload/neoformat/formatters/*.vim'), '\n'), 196 | \ "fnamemodify(v:val, ':t:r')"))), 197 | \ "v:val =~? '^" . a:ArgLead . "'") 198 | endif 199 | if a:ArgLead =~ '[^A-Za-z0-9]' 200 | return [] 201 | endif 202 | let filetype = s:split_filetypes(&filetype) 203 | return filter(s:get_enabled_formatters(filetype), 204 | \ "v:val =~? '^" . a:ArgLead ."'") 205 | endfunction 206 | 207 | function! s:autoload_func_exists(func_name) abort 208 | try 209 | call eval(a:func_name . '()') 210 | catch /^Vim\%((\a\+)\)\=:E/ 211 | return 0 212 | endtry 213 | return 1 214 | endfunction 215 | 216 | function! s:split_filetypes(filetype) abort 217 | if a:filetype == '' 218 | return '' 219 | endif 220 | return split(a:filetype, '\.')[0] 221 | endfunction 222 | 223 | function! s:get_node_exe(exe) abort 224 | let node_exe = findfile('node_modules/.bin/' . a:exe, getcwd() . ';') 225 | if !empty(node_exe) && executable(node_exe) 226 | return node_exe 227 | endif 228 | 229 | return a:exe 230 | endfunction 231 | 232 | function! s:generate_cmd(definition, filetype) abort 233 | let executable = get(a:definition, 'exe', '') 234 | if executable == '' 235 | call neoformat#utils#log('no exe field in definition') 236 | return {} 237 | endif 238 | 239 | if exists('g:neoformat_try_node_exe') 240 | \ && g:neoformat_try_node_exe 241 | \ && get(a:definition, 'try_node_exe', 0) 242 | let executable = s:get_node_exe(executable) 243 | endif 244 | 245 | if &shell =~ '\v%(powershell|pwsh)' 246 | if system('[bool](Get-Command ' . executable . ' -ErrorAction SilentlyContinue)') !~ 'True' 247 | call neoformat#utils#log('executable: ' . executable . ' is not a cmdlet, function, script file, or an executable program') 248 | return {} 249 | endif 250 | elseif !executable(executable) 251 | call neoformat#utils#log('executable: ' . executable . ' is not an executable') 252 | return {} 253 | endif 254 | 255 | let args = get(a:definition, 'args', []) 256 | let args_expanded = [] 257 | for a in args 258 | let args_expanded = add(args_expanded, s:expand_fully(a)) 259 | endfor 260 | 261 | let no_append = get(a:definition, 'no_append', 0) 262 | let using_stdin = get(a:definition, 'stdin', 0) 263 | let using_stderr = get(a:definition, 'stderr', 0) 264 | let stderr_log = '' 265 | 266 | let filename = expand('%:t') 267 | 268 | let tmp_dir = has('win32') ? expand('$TEMP/neoformat') : 269 | \ exists('$TMPDIR') ? expand('$TMPDIR/neoformat') : 270 | \ '/tmp/neoformat' 271 | 272 | if !isdirectory(tmp_dir) 273 | call mkdir(tmp_dir, 'p') 274 | endif 275 | 276 | if get(a:definition, 'replace', 0) 277 | let path = !using_stdin ? expand(tmp_dir . '/' . fnameescape(filename), 1) : '' 278 | else 279 | let path = !using_stdin ? tempname() : '' 280 | endif 281 | 282 | let inline_environment = get(a:definition, 'env', []) 283 | let _fullcmd = join(inline_environment, ' ') . ' ' . executable . ' ' . join(args_expanded) . ' ' . (no_append ? '' : path) 284 | " make sure there aren't any double spaces in the cmd 285 | let fullcmd = join(split(_fullcmd)) 286 | if !using_stderr 287 | if neoformat#utils#should_be_verbose() 288 | let stderr_log = expand(tmp_dir . '/stderr.log', 1) 289 | let fullcmd = fullcmd . ' 2> ' . stderr_log 290 | else 291 | if (has('win32') || has('win64')) 292 | let stderr_log = '' 293 | let fullcmd = fullcmd . ' 2> ' . 'NUL' 294 | else 295 | let stderr_log = '' 296 | let fullcmd = fullcmd . ' 2> ' . '/dev/null' 297 | endif 298 | endif 299 | endif 300 | 301 | return { 302 | \ 'exe': fullcmd, 303 | \ 'stdin': using_stdin, 304 | \ 'stderr_log': stderr_log, 305 | \ 'name': a:definition.exe, 306 | \ 'replace': get(a:definition, 'replace', 0), 307 | \ 'tmp_file_path': path, 308 | \ 'valid_exit_codes': get(a:definition, 'valid_exit_codes', [0]), 309 | \ } 310 | endfunction 311 | 312 | function! s:expand_fully(string) abort 313 | return substitute(a:string, '%\(:[a-z]\)*', '\=expand(submatch(0))', 'g') 314 | endfunction 315 | 316 | function! s:basic_format() abort 317 | call neoformat#utils#log('running basic format') 318 | if !exists('g:neoformat_basic_format_align') 319 | let g:neoformat_basic_format_align = 0 320 | endif 321 | 322 | if !exists('g:neoformat_basic_format_retab') 323 | let g:neoformat_basic_format_retab = 0 324 | endif 325 | 326 | if !exists('g:neoformat_basic_format_trim') 327 | let g:neoformat_basic_format_trim = 0 328 | endif 329 | 330 | if neoformat#utils#var('neoformat_basic_format_align') 331 | call neoformat#utils#log('aligning with basic formatter') 332 | let v = winsaveview() 333 | silent! execute 'normal gg=G' 334 | call winrestview(v) 335 | endif 336 | if neoformat#utils#var('neoformat_basic_format_retab') 337 | call neoformat#utils#log('converting tabs with basic formatter') 338 | retab 339 | endif 340 | if neoformat#utils#var('neoformat_basic_format_trim') 341 | call neoformat#utils#log('trimming whitespace with basic formatter') 342 | " http://stackoverflow.com/q/356126 343 | let search = @/ 344 | let view = winsaveview() 345 | " vint: -ProhibitCommandRelyOnUser -ProhibitCommandWithUnintendedSideEffect 346 | silent! %s/\s\+$//e 347 | " vint: +ProhibitCommandRelyOnUser +ProhibitCommandWithUnintendedSideEffect 348 | let @/=search 349 | call winrestview(view) 350 | endif 351 | endfunction 352 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/arduino.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#arduino#enabled() abort 2 | return ['uncrustify', 'clangformat', 'astyle'] 3 | endfunction 4 | 5 | function! neoformat#formatters#arduino#uncrustify() abort 6 | return neoformat#formatters#cpp#uncrustify() 7 | endfunction 8 | 9 | function! neoformat#formatters#arduino#clangformat() abort 10 | return neoformat#formatters#c#clangformat() 11 | endfunction 12 | 13 | function! neoformat#formatters#arduino#astyle() abort 14 | return neoformat#formatters#c#astyle() 15 | endfunction 16 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/asm.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#asm#enabled() abort 2 | return ['asmfmt', ] 3 | endfunction 4 | 5 | function! neoformat#formatters#asm#asmfmt() abort 6 | return { 7 | \ 'exe': 'asmfmt', 8 | \ 'stdin': 1 9 | \ } 10 | endfunction 11 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/astro.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#astro#enabled() abort 2 | return ['prettier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#astro#prettier() abort 6 | return { 7 | \ 'exe': 'prettier', 8 | \ 'args': ['--stdin-filepath', '"%:p"'], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/beancount.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#beancount#enabled() abort 2 | return ['beanformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#beancount#beanformat() abort 6 | return { 7 | \ 'exe': 'bean-format', 8 | \ 'stdin': 1, 9 | \ } 10 | endfunction 11 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/bib.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#bib#enabled() abort 2 | return ['bibclean', 'bibtextidy'] 3 | endfunction 4 | 5 | function! neoformat#formatters#bib#bibclean() abort 6 | return { 7 | \ 'exe': 'bibclean', 8 | \ 'stdin': 1, 9 | \ } 10 | endfunction 11 | 12 | function! neoformat#formatters#bib#bibtextidy() abort 13 | return { 14 | \ 'exe': 'bibtex-tidy', 15 | \ 'stdin': 1, 16 | \ } 17 | endfunction 18 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/blade.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#blade#enabled() abort 2 | return ['blade_formatter'] 3 | endfunction 4 | 5 | function! neoformat#formatters#blade#blade_formatter() abort 6 | return { 7 | \ 'exe': 'blade-formatter', 8 | \ 'args': ['--stdin'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/bzl.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#bzl#enabled() abort 2 | return ['buildifier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#bzl#buildifier() abort 6 | return { 7 | \ 'exe': 'buildifier', 8 | \ 'args': ['-path', expand('%:p')], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/c.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#c#enabled() abort 2 | return ['uncrustify', 'clangformat', 'astyle'] 3 | endfunction 4 | 5 | function! neoformat#formatters#c#uncrustify() abort 6 | return { 7 | \ 'exe': 'uncrustify', 8 | \ 'args': ['-q', '-l C'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#c#clangformat() abort 14 | return { 15 | \ 'exe': 'clang-format', 16 | \ 'args': ['-assume-filename=' . expand('"%"')], 17 | \ 'stdin': 1, 18 | \ } 19 | endfunction 20 | 21 | function! neoformat#formatters#c#astyle() abort 22 | return { 23 | \ 'exe': 'astyle', 24 | \ 'args': ['--mode=c'], 25 | \ 'stdin': 1, 26 | \ } 27 | endfunction 28 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/cabal.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#cabal#enabled() abort 2 | return ['cabalfmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#cabal#cabalfmt() abort 6 | return { 7 | \ 'args' : [expand('%:p')], 8 | \ 'exe' : 'cabal-fmt', 9 | \ 'no_append' : 1, 10 | \ 'stdin' : 0 11 | \ } 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/caddyfile.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#caddyfile#enabled() abort 2 | return ['caddyformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#caddyfile#caddyformat() abort 6 | return { 7 | \ 'exe': 'caddy', 8 | \ 'args': ['fmt', '-'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/cmake.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#cmake#enabled() abort 2 | return ['cmakeformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#cmake#cmakeformat() abort 6 | return { 7 | \ 'exe': 'cmake-format', 8 | \ 'args': ['-'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/cpp.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#cpp#enabled() abort 2 | return ['uncrustify', 'clangformat', 'astyle'] 3 | endfunction 4 | 5 | function! neoformat#formatters#cpp#uncrustify() abort 6 | return { 7 | \ 'exe': 'uncrustify', 8 | \ 'args': ['-q', '-l CPP'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#cpp#clangformat() abort 14 | return neoformat#formatters#c#clangformat() 15 | endfunction 16 | 17 | function! neoformat#formatters#cpp#astyle() abort 18 | return neoformat#formatters#c#astyle() 19 | endfunction 20 | 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/crystal.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#crystal#enabled() abort 2 | return ['crystalformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#crystal#crystalformat() abort 6 | return { 7 | \ 'exe': 'crystal', 8 | \ 'args': ['tool', 'format'], 9 | \ 'replace': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/cs.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#cs#enabled() abort 2 | return ['uncrustify', 'astyle', 'clangformat', 'csharpier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#cs#uncrustify() abort 6 | return { 7 | \ 'exe': 'uncrustify', 8 | \ 'args': ['-q', '-l CS'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#cs#astyle() abort 14 | return { 15 | \ 'exe': 'astyle', 16 | \ 'args': ['--mode=cs'], 17 | \ 'stdin': 1, 18 | \ } 19 | endfunction 20 | 21 | function! neoformat#formatters#cs#clangformat() abort 22 | return { 23 | \ 'exe': 'clang-format', 24 | \ 'args': ['-assume-filename=' . expand('%:t')], 25 | \ 'stdin': 1, 26 | \ } 27 | endfunction 28 | 29 | function! neoformat#formatters#cs#csharpier() abort 30 | return { 31 | \ 'exe': 'dotnet', 32 | \ 'args': ['csharpier', 'format'], 33 | \ 'stdin': 1, 34 | \ } 35 | endfunction 36 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/css.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#css#enabled() abort 2 | return ['stylelint', 'stylefmt', 'prettierd', 'prettier', 'cssbeautify', 'prettydiff', 'csscomb', 'topiary'] 3 | endfunction 4 | 5 | function! neoformat#formatters#css#cssbeautify() abort 6 | return { 7 | \ 'exe': 'css-beautify', 8 | \ 'args': ['--indent-size ' .shiftwidth()], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#css#csscomb() abort 14 | return { 15 | \ 'exe': 'csscomb', 16 | \ 'replace': 1, 17 | \ 'try_node_exe': 1, 18 | \ } 19 | endfunction 20 | 21 | function! neoformat#formatters#css#prettydiff() abort 22 | return { 23 | \ 'exe': 'prettydiff', 24 | \ 'args': ['mode:"beautify"', 25 | \ 'lang:"css"', 26 | \ 'insize:' .shiftwidth(), 27 | \ 'readmethod:"filescreen"', 28 | \ 'endquietly:"quiet"', 29 | \ 'source:"%:p"'], 30 | \ 'no_append': 1 31 | \ } 32 | endfunction 33 | 34 | function! neoformat#formatters#css#stylefmt() abort 35 | return { 36 | \ 'exe': 'stylefmt', 37 | \ 'stdin': 1, 38 | \ 'try_node_exe': 1, 39 | \ } 40 | endfunction 41 | 42 | function! neoformat#formatters#css#prettier() abort 43 | return { 44 | \ 'exe': 'prettier', 45 | \ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'css'], 46 | \ 'stdin': 1, 47 | \ 'try_node_exe': 1, 48 | \ } 49 | endfunction 50 | 51 | function! neoformat#formatters#css#prettierd() abort 52 | return { 53 | \ 'exe': 'prettierd', 54 | \ 'args': ['"%:p"'], 55 | \ 'stdin': 1, 56 | \ } 57 | endfunction 58 | 59 | function! neoformat#formatters#css#stylelint() abort 60 | return { 61 | \ 'exe': 'stylelint', 62 | \ 'args': ['--fix', '--stdin-filename', '"%:t"'], 63 | \ 'stdin': 1, 64 | \ 'try_node_exe': 1, 65 | \ } 66 | endfunction 67 | 68 | function! neoformat#formatters#json#topiary() abort 69 | return { 70 | \ 'exe': 'topiary', 71 | \ 'no_append': 1, 72 | \ 'stdin': 1, 73 | \ 'args': ['format', '--merge-configuration', '--language', '"css"' ] 74 | \ } 75 | endfunction 76 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/csv.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#csv#enabled() abort 2 | return ['prettydiff'] 3 | endfunction 4 | 5 | function! neoformat#formatters#csv#prettydiff() abort 6 | return { 7 | \ 'exe': 'prettydiff', 8 | \ 'args': ['mode:"beautify"', 9 | \ 'lang:"csv"', 10 | \ 'readmethod:"filescreen"', 11 | \ 'endquietly:"quiet"', 12 | \ 'source:"%:p"'], 13 | \ 'no_append': 1 14 | \ } 15 | endfunction 16 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/cue.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#cue#enabled() abort 2 | return ['cue'] 3 | endfunction 4 | 5 | function! neoformat#formatters#cue#cue() abort 6 | return { 7 | \ 'exe': 'cue', 8 | \ 'args': ['fmt', '-'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/d.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#d#enabled() abort 2 | return ['uncrustify', 'dfmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#d#dfmt() abort 6 | return { 7 | \ 'exe': 'dfmt', 8 | \ 'stdin': 1, 9 | \ } 10 | endfunction 11 | 12 | function! neoformat#formatters#d#uncrustify() abort 13 | return { 14 | \ 'exe': 'uncrustify', 15 | \ 'args': ['-q', '-l D'], 16 | \ 'stdin': 1, 17 | \ } 18 | endfunction 19 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/d2.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#d2#enabled() abort 2 | return ['d2fmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#d2#d2fmt() abort 6 | return { 7 | \ 'exe': 'd2', 8 | \ 'args': ['fmt','-'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/dart.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#dart#enabled() abort 2 | return ['dartfmt', 'format'] 3 | endfunction 4 | 5 | function! neoformat#formatters#dart#dartfmt() abort 6 | return { 7 | \ 'exe': 'dartfmt', 8 | \ 'stdin': 1, 9 | \ } 10 | endfunction 11 | 12 | function! neoformat#formatters#dart#format() abort 13 | return { 14 | \ 'exe': 'dart', 15 | \ 'args': ['format'], 16 | \ 'replace': 1, 17 | \ } 18 | endfunction 19 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/dhall.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#dhall#enabled() abort 2 | return ['dhall'] 3 | endfunction 4 | 5 | function! neoformat#formatters#dhall#dhall() abort 6 | return { 7 | \ 'exe': 'dhall', 8 | \ 'args': ['format'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/dune.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#dune#enabled() abort 2 | return ['dune'] 3 | endfunction 4 | 5 | function! neoformat#formatters#dune#dune() abort 6 | return { 7 | \ 'exe': 'dune', 8 | \ 'args': ['format'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/ebuild.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#ebuild#enabled() abort 2 | return ['shfmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#ebuild#shfmt() abort 6 | let opts = neoformat#utils#var_default('shfmt_opt', '') 7 | return { 8 | \ 'exe': 'shfmt', 9 | \ 'args': ['-i ' . (&expandtab ? shiftwidth() : 0), opts], 10 | \ 'stdin': 1, 11 | \ } 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/eelixir.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#eelixir#enabled() abort 2 | return ['mixformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#eelixir#mixformat() abort 6 | return { 7 | \ 'exe': 'mix', 8 | \ 'args': ['format', '--stdin-filename="%:t"', '-'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/elixir.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#elixir#enabled() abort 2 | return ['mixformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#elixir#mixformat() abort 6 | return { 7 | \ 'exe': 'mix', 8 | \ 'args': ['format', "-"], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/elm.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#elm#enabled() abort 2 | return ['elmformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#elm#elmformat() abort 6 | return { 7 | \ 'exe': 'elm-format', 8 | \ 'args': ['--stdin', '--elm-version=0.19'], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/erlang.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#erlang#enabled() abort 2 | return ['erlfmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#erlang#erlfmt() abort 6 | return { 7 | \ 'exe': 'erlfmt', 8 | \ 'args': ["-"], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/eruby.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#eruby#enabled() abort 2 | return ['htmlbeautifier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#eruby#htmlbeautifier() abort 6 | return { 7 | \ 'exe': 'htmlbeautifier', 8 | \ 'args': ['--keep-blank-lines', '1'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/fennel.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#fennel#enabled() abort 2 | return ['fnlfmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#fennel#fnlfmt() abort 6 | return { 7 | \ 'exe': 'fnlfmt', 8 | \ 'args': ['--fix'], 9 | \ 'replace': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/fish.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#fish#enabled() abort 2 | return ['fish_indent'] 3 | endfunction 4 | 5 | function! neoformat#formatters#fish#fish_indent() abort 6 | return { 7 | \ 'exe': 'fish_indent', 8 | \ 'stdin': 1, 9 | \ } 10 | endfunction 11 | 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/fortran.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#fortran#enabled() abort 2 | return ['fprettify'] 3 | endfunction 4 | 5 | function! neoformat#formatters#fortran#fprettify() abort 6 | return { 7 | \ 'exe': 'fprettify', 8 | \ 'args': ['--silent'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/fsharp.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#fsharp#enabled() abort 2 | return ['fantomas'] 3 | endfunction 4 | 5 | function! neoformat#formatters#fsharp#fantomas() abort 6 | return { 7 | \ 'exe': 'fantomas', 8 | \ 'args': ['--stdin'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/gdscript.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#gdscript#enabled() abort 2 | return ['gdformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#gdscript#gdformat() abort 6 | return { 7 | \ 'exe': 'gdformat', 8 | \ 'args': ['-'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/gleam.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#gleam#enabled() abort 2 | return ['gleamformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#gleam#gleamformat() abort 6 | return { 7 | \ 'exe': 'gleam', 8 | \ 'args': ['format', '--stdin'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/glsl.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#glsl#enabled() abort 2 | return ['clangformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#glsl#clangformat() abort 6 | return { 7 | \ 'exe': 'clang-format', 8 | \ 'args': ['-assume-filename=' . expand('%:t')], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/gn.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#gn#enabled() abort 2 | return ['gn'] 3 | endfunction 4 | 5 | function! neoformat#formatters#gn#gn() abort 6 | return { 7 | \ 'exe': 'gn', 8 | \ 'args': ['format', '--stdin'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/go.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#go#enabled() abort 2 | return ['goimports', 'gofmt', 'gofumports', 'gofumpt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#go#gofmt() abort 6 | return { 7 | \ 'exe': 'gofmt', 8 | \ 'stdin': 1, 9 | \ } 10 | endfunction 11 | 12 | function! neoformat#formatters#go#goimports() abort 13 | return { 14 | \ 'exe': 'goimports', 15 | \ 'stdin': 1, 16 | \ } 17 | endfunction 18 | 19 | function! neoformat#formatters#go#gofumpt() abort 20 | return { 21 | \ 'exe': 'gofumpt', 22 | \ 'stdin': 1, 23 | \ } 24 | endfunction 25 | 26 | function! neoformat#formatters#go#gofumports() abort 27 | return { 28 | \ 'exe': 'gofumports', 29 | \ 'stdin': 1, 30 | \ } 31 | endfunction 32 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/graphql.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#graphql#enabled() abort 2 | return ['prettierd', 'prettier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#graphql#prettier() abort 6 | return { 7 | \ 'exe': 'prettier', 8 | \ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'graphql'], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#graphql#prettierd() abort 15 | return { 16 | \ 'exe': 'prettierd', 17 | \ 'args': ['"%:p"'], 18 | \ 'stdin': 1, 19 | \ } 20 | endfunction 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/haskell.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#haskell#enabled() abort 2 | return ['hindent', 'stylishhaskell', 'hfmt', 'brittany', 'sortimports', 'floskell', 'ormolu'] 3 | endfunction 4 | 5 | function! neoformat#formatters#haskell#hindent() abort 6 | return { 7 | \ 'exe' : 'hindent', 8 | \ 'args': ['--indent-size ' . shiftwidth()], 9 | \ 'stdin' : 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#haskell#stylishhaskell() abort 14 | return { 15 | \ 'exe': 'stylish-haskell', 16 | \ 'stdin': 1, 17 | \ } 18 | endfunction 19 | 20 | function! neoformat#formatters#haskell#hfmt() abort 21 | return { 22 | \ 'exe': 'hfmt', 23 | \ 'args': ['-'], 24 | \ 'stdin': 1, 25 | \ } 26 | endfunction 27 | 28 | function! neoformat#formatters#haskell#brittany() abort 29 | return { 30 | \ 'exe': 'brittany', 31 | \ 'stdin': 1, 32 | \ } 33 | endfunction 34 | 35 | function! neoformat#formatters#haskell#sortimports() abort 36 | return { 37 | \ 'exe': 'sort-imports', 38 | \ 'stdin': 1, 39 | \ } 40 | endfunction 41 | 42 | function! neoformat#formatters#haskell#floskell() abort 43 | return { 44 | \ 'exe': 'floskell', 45 | \ 'stdin': 1, 46 | \ } 47 | endfunction 48 | 49 | function! neoformat#formatters#haskell#ormolu() abort 50 | let opts = get(g:, 'ormolu_ghc_opt', []) 51 | if opts != [] 52 | let opts = '-o' . join(opts, ' -o') 53 | else 54 | let opts = '' 55 | endif 56 | return { 57 | \ 'exe' : 'ormolu', 58 | \ 'args': ['--stdin-input-file', '%:p', opts], 59 | \ 'stdin' : 1, 60 | \ } 61 | endfunction 62 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/hcl.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#hcl#enabled() abort 2 | return ['hclfmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#hcl#hclfmt() abort 6 | return { 7 | \ 'exe': 'hclfmt', 8 | \ 'stdin': 1 9 | \ } 10 | endfunction 11 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/html.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#html#enabled() abort 2 | return ['htmlbeautify', 'prettierd', 'prettier', 'tidy', 'prettydiff'] 3 | endfunction 4 | 5 | function! neoformat#formatters#html#tidy() abort 6 | return { 7 | \ 'exe': 'tidy', 8 | \ 'args': ['-quiet', 9 | \ '--indent auto', 10 | \ '--indent-spaces ' . shiftwidth(), 11 | \ '--vertical-space yes', 12 | \ '--tidy-mark no', 13 | \ '-wrap ' . &textwidth 14 | \ ], 15 | \ 'try_node_exe': 1, 16 | \ } 17 | endfunction 18 | 19 | function! neoformat#formatters#html#prettier() abort 20 | return { 21 | \ 'exe': 'prettier', 22 | \ 'args': ['--stdin-filepath', '"%:p"'], 23 | \ 'stdin': 1, 24 | \ 'try_node_exe': 1, 25 | \ } 26 | endfunction 27 | 28 | function! neoformat#formatters#html#prettierd() abort 29 | return { 30 | \ 'exe': 'prettierd', 31 | \ 'args': ['"%:p"'], 32 | \ 'stdin': 1, 33 | \ } 34 | endfunction 35 | 36 | function! neoformat#formatters#html#htmlbeautify() abort 37 | return { 38 | \ 'exe': 'html-beautify', 39 | \ 'args': ['--indent-size ' .shiftwidth()], 40 | \ 'stdin': 1, 41 | \ } 42 | endfunction 43 | 44 | function! neoformat#formatters#html#prettydiff() abort 45 | return { 46 | \ 'exe': 'prettydiff', 47 | \ 'args': ['mode:"beautify"', 48 | \ 'lang:"html"', 49 | \ 'readmethod:"filescreen"', 50 | \ 'endquietly:"quiet"', 51 | \ 'source:"%:p"'], 52 | \ 'no_append': 1 53 | \ } 54 | endfunction 55 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/htmldjango.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#htmldjango#enabled() abort 2 | return ['djlint'] 3 | endfunction 4 | 5 | function! neoformat#formatters#htmldjango#djlint() abort 6 | return { 7 | \ 'exe': 'djlint', 8 | \ 'args': ['-', '--reformat'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/jade.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#jade#enabled() abort 2 | return ['pugbeautifier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#jade#pugbeautifier() abort 6 | return neoformat#formatters#pug#pugbeautifier() 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/java.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#java#enabled() abort 2 | return ['uncrustify', 'astyle', 'clangformat', 'prettierd', 'prettier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#java#uncrustify() abort 6 | return { 7 | \ 'exe': 'uncrustify', 8 | \ 'args': ['-q', '-l JAVA'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | 14 | function! neoformat#formatters#java#astyle() abort 15 | return { 16 | \ 'exe': 'astyle', 17 | \ 'args': ['--mode=java'], 18 | \ 'stdin': 1, 19 | \ } 20 | endfunction 21 | 22 | 23 | function! neoformat#formatters#java#clangformat() abort 24 | return { 25 | \ 'exe': 'clang-format', 26 | \ 'args': ['-assume-filename=' . expand('%:t')], 27 | \ 'stdin': 1, 28 | \ } 29 | endfunction 30 | 31 | function! neoformat#formatters#java#prettier() abort 32 | return { 33 | \ 'exe': 'prettier', 34 | \ 'args': ['--stdin-filepath', '"%:p"'], 35 | \ 'stdin': 1, 36 | \ } 37 | endfunction 38 | 39 | function! neoformat#formatters#java#prettierd() abort 40 | return { 41 | \ 'exe': 'prettierd', 42 | \ 'args': ['"%:p"'], 43 | \ 'stdin': 1, 44 | \ } 45 | endfunction 46 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/javascript.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#javascript#enabled() abort 2 | return ['jsbeautify', 'standard', 'semistandard', 'prettierd', 'prettier', 'prettydiff', 'clangformat', 'esformatter', 'prettiereslint', 'eslint_d', 'denofmt', 'biome'] 3 | endfunction 4 | 5 | function! neoformat#formatters#javascript#jsbeautify() abort 6 | return { 7 | \ 'exe': 'js-beautify', 8 | \ 'args': ['--indent-size ' .shiftwidth()], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#javascript#clangformat() abort 15 | return { 16 | \ 'exe': 'clang-format', 17 | \ 'args': ['-assume-filename=' . expand('%:t')], 18 | \ 'stdin': 1, 19 | \ 'try_node_exe': 1, 20 | \ } 21 | endfunction 22 | 23 | function! neoformat#formatters#javascript#prettydiff() abort 24 | return { 25 | \ 'exe': 'prettydiff', 26 | \ 'args': ['mode:"beautify"', 27 | \ 'lang:"javascript"', 28 | \ 'readmethod:"filescreen"', 29 | \ 'endquietly:"quiet"', 30 | \ 'source:"%:p"'], 31 | \ 'no_append': 1 32 | \ } 33 | endfunction 34 | 35 | function! neoformat#formatters#javascript#esformatter() abort 36 | return { 37 | \ 'exe': 'esformatter', 38 | \ 'stdin': 1, 39 | \ 'try_node_exe': 1, 40 | \ } 41 | endfunction 42 | 43 | function! neoformat#formatters#javascript#prettier() abort 44 | return { 45 | \ 'exe': 'prettier', 46 | \ 'args': ['--stdin-filepath', '"%:p"'], 47 | \ 'stdin': 1, 48 | \ 'try_node_exe': 1, 49 | \ } 50 | endfunction 51 | 52 | function! neoformat#formatters#javascript#prettierd() abort 53 | return { 54 | \ 'exe': 'prettierd', 55 | \ 'args': ['"%:p"'], 56 | \ 'stdin': 1, 57 | \ } 58 | endfunction 59 | 60 | function! neoformat#formatters#javascript#prettiereslint() abort 61 | return { 62 | \ 'exe': 'prettier-eslint', 63 | \ 'args': ['--stdin', '--stdin-filepath', '"%:p"'], 64 | \ 'stdin': 1, 65 | \ 'try_node_exe': 1, 66 | \ } 67 | endfunction 68 | 69 | function! neoformat#formatters#javascript#eslint_d() abort 70 | return { 71 | \ 'exe': 'eslint_d', 72 | \ 'args': ['--stdin', '--stdin-filename', '"%:p"', '--fix-to-stdout'], 73 | \ 'stdin': 1, 74 | \ 'try_node_exe': 1, 75 | \ } 76 | endfunction 77 | 78 | function! neoformat#formatters#javascript#standard() abort 79 | return { 80 | \ 'exe': 'standard', 81 | \ 'args': ['--stdin','--fix'], 82 | \ 'stdin': 1, 83 | \ 'try_node_exe': 1, 84 | \ } 85 | endfunction 86 | 87 | function! neoformat#formatters#javascript#denofmt() abort 88 | return { 89 | \ 'exe': 'deno', 90 | \ 'args': ['fmt','--ext','js','-'], 91 | \ 'stdin': 1, 92 | \ } 93 | endfunction 94 | 95 | function! neoformat#formatters#javascript#semistandard() abort 96 | return { 97 | \ 'exe': 'semistandard', 98 | \ 'args': ['--stdin','--fix'], 99 | \ 'stdin': 1, 100 | \ 'try_node_exe': 1, 101 | \ } 102 | endfunction 103 | 104 | function! neoformat#formatters#javascript#biome() abort 105 | return { 106 | \ 'exe': 'biome', 107 | \ 'try_node_exe': 1, 108 | \ 'args': ['format', '--stdin-file-path="%:p"'], 109 | \ 'no_append': 1, 110 | \ 'stdin': 1, 111 | \ } 112 | endfunction 113 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/javascriptreact.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#javascriptreact#enabled() abort 2 | return ['jsbeautify', 'standard', 'semistandard', 'prettierd', 'prettier', 'prettydiff', 'esformatter', 'prettiereslint', 'eslint_d', 'denofmt', 'biome'] 3 | endfunction 4 | 5 | function! neoformat#formatters#javascriptreact#jsbeautify() abort 6 | return { 7 | \ 'exe': 'js-beautify', 8 | \ 'args': ['--indent-size ' .shiftwidth()], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#javascriptreact#prettydiff() abort 15 | return { 16 | \ 'exe': 'prettydiff', 17 | \ 'args': ['mode:"beautify"', 18 | \ 'lang:"javascript"', 19 | \ 'readmethod:"filescreen"', 20 | \ 'endquietly:"quiet"', 21 | \ 'source:"%:p"'], 22 | \ 'no_append': 1 23 | \ } 24 | endfunction 25 | 26 | function! neoformat#formatters#javascriptreact#esformatter() abort 27 | return { 28 | \ 'exe': 'esformatter', 29 | \ 'stdin': 1, 30 | \ 'try_node_exe': 1, 31 | \ } 32 | endfunction 33 | 34 | function! neoformat#formatters#javascriptreact#prettier() abort 35 | return { 36 | \ 'exe': 'prettier', 37 | \ 'args': ['--stdin-filepath', '"%:p"'], 38 | \ 'stdin': 1, 39 | \ 'try_node_exe': 1, 40 | \ } 41 | endfunction 42 | 43 | function! neoformat#formatters#javascriptreact#prettierd() abort 44 | return { 45 | \ 'exe': 'prettierd', 46 | \ 'args': ['"%:p"'], 47 | \ 'stdin': 1, 48 | \ } 49 | endfunction 50 | 51 | function! neoformat#formatters#javascriptreact#prettiereslint() abort 52 | return { 53 | \ 'exe': 'prettier-eslint', 54 | \ 'args': ['--stdin', '--stdin-filepath', '"%:p"'], 55 | \ 'stdin': 1, 56 | \ 'try_node_exe': 1, 57 | \ } 58 | endfunction 59 | 60 | function! neoformat#formatters#javascriptreact#eslint_d() abort 61 | return { 62 | \ 'exe': 'eslint_d', 63 | \ 'args': ['--stdin', '--stdin-filename', '"%:p"', '--fix-to-stdout'], 64 | \ 'stdin': 1, 65 | \ 'try_node_exe': 1, 66 | \ } 67 | endfunction 68 | 69 | function! neoformat#formatters#javascriptreact#standard() abort 70 | return { 71 | \ 'exe': 'standard', 72 | \ 'args': ['--stdin','--fix'], 73 | \ 'stdin': 1, 74 | \ 'try_node_exe': 1, 75 | \ } 76 | endfunction 77 | 78 | function! neoformat#formatters#javascriptreact#denofmt() abort 79 | return { 80 | \ 'exe': 'deno', 81 | \ 'args': ['fmt','--ext','jsx','-'], 82 | \ 'stdin': 1, 83 | \ } 84 | endfunction 85 | 86 | function! neoformat#formatters#javascriptreact#semistandard() abort 87 | return { 88 | \ 'exe': 'semistandard', 89 | \ 'args': ['--stdin','--fix'], 90 | \ 'stdin': 1, 91 | \ 'try_node_exe': 1, 92 | \ } 93 | endfunction 94 | 95 | function! neoformat#formatters#javascriptreact#biome() abort 96 | return { 97 | \ 'exe': 'biome', 98 | \ 'try_node_exe': 1, 99 | \ 'args': ['format', '--stdin-file-path="%:p"'], 100 | \ 'no_append': 1, 101 | \ 'stdin': 1, 102 | \ } 103 | endfunction 104 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/jinja.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#jinja#enabled() abort 2 | return ['prettydiff', 'htmlbeautify'] 3 | endfunction 4 | 5 | function! neoformat#formatters#jinja#htmlbeautify() abort 6 | return neoformat#formatters#html#htmlbeautify() 7 | endfunction 8 | 9 | function! neoformat#formatters#jinja#prettydiff() abort 10 | return neoformat#formatters#html#prettydiff() 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/json.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#json#enabled() abort 2 | return ['jsbeautify', 'prettydiff', 'prettierd', 'prettier', 'jq', 'fixjson', 'denofmt', 'topiary', 'biome'] 3 | endfunction 4 | 5 | function! neoformat#formatters#json#jsbeautify() abort 6 | return neoformat#formatters#javascript#jsbeautify() 7 | endfunction 8 | 9 | function! neoformat#formatters#json#prettydiff() abort 10 | return neoformat#formatters#javascript#prettydiff() 11 | endfunction 12 | 13 | function! neoformat#formatters#json#jq() abort 14 | return { 15 | \ 'exe': 'jq', 16 | \ 'args': ['.'], 17 | \ } 18 | endfunction 19 | 20 | function! neoformat#formatters#json#prettier() abort 21 | return { 22 | \ 'exe': 'prettier', 23 | \ 'args': ['--stdin-filepath', '"%:p"'], 24 | \ 'stdin': 1, 25 | \ 'try_node_exe': 1, 26 | \ } 27 | endfunction 28 | 29 | function! neoformat#formatters#json#prettierd() abort 30 | return { 31 | \ 'exe': 'prettierd', 32 | \ 'args': ['"%:p"'], 33 | \ 'stdin': 1, 34 | \ } 35 | endfunction 36 | 37 | function! neoformat#formatters#json#fixjson() abort 38 | let l:filename = fnamemodify(bufname('%'), ':t') 39 | return { 40 | \ 'exe': 'fixjson', 41 | \ 'args': ['--stdin-filename', l:filename], 42 | \ 'stdin': 1, 43 | \ 'try_node_exe': 1, 44 | \ } 45 | endfunction 46 | 47 | function! neoformat#formatters#json#denofmt() abort 48 | return { 49 | \ 'exe': 'deno', 50 | \ 'args': ['fmt','--ext','json','-'], 51 | \ 'stdin': 1, 52 | \ } 53 | endfunction 54 | 55 | function! neoformat#formatters#json#topiary() abort 56 | return { 57 | \ 'exe': 'topiary', 58 | \ 'no_append': 1, 59 | \ 'stdin': 1, 60 | \ 'args': ['format', '--merge-configuration', '--language', '"json"' ] 61 | \ } 62 | endfunction 63 | 64 | function! neoformat#formatters#json#biome() abort 65 | return { 66 | \ 'exe': 'biome', 67 | \ 'try_node_exe': 1, 68 | \ 'args': ['format', '--stdin-file-path="%:p"'], 69 | \ 'no_append': 1, 70 | \ 'stdin': 1, 71 | \ } 72 | endfunction 73 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/jsonc.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#jsonc#enabled() abort 2 | return ['prettierd', 'prettier', 'denofmt', 'biome'] 3 | endfunction 4 | 5 | function! neoformat#formatters#jsonc#prettier() abort 6 | return { 7 | \ 'exe': 'prettier', 8 | \ 'args': ['--stdin-filepath', '"%:p"'], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#jsonc#prettierd() abort 15 | return { 16 | \ 'exe': 'prettierd', 17 | \ 'args': ['"%:p"'], 18 | \ 'stdin': 1, 19 | \ } 20 | endfunction 21 | 22 | function! neoformat#formatters#jsonc#denofmt() abort 23 | return { 24 | \ 'exe': 'deno', 25 | \ 'args': ['fmt','--ext','jsonc','-'], 26 | \ 'stdin': 1, 27 | \ } 28 | endfunction 29 | 30 | function! neoformat#formatters#jsonc#biome() abort 31 | return { 32 | \ 'exe': 'biome', 33 | \ 'try_node_exe': 1, 34 | \ 'args': ['format', '--stdin-file-path="%:p"'], 35 | \ 'no_append': 1, 36 | \ 'stdin': 1, 37 | \ } 38 | endfunction 39 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/jsonnet.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#jsonnet#enabled() abort 2 | return ['jsonnetfmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#jsonnet#jsonnetfmt() abort 6 | return { 7 | \ 'exe': 'jsonnetfmt', 8 | \ 'args': ['-'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/just.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#just#enabled() abort 2 | return ['just'] 3 | endfunction 4 | 5 | function! neoformat#formatters#just#just() abort 6 | return { 7 | \ 'exe': 'just', 8 | \ 'args': ['--dump', '--justfile'], 9 | \ } 10 | endfunction 11 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/kotlin.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#kotlin#enabled() abort 2 | return ['ktlint', 'prettierd', 'prettier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#kotlin#ktlint() abort 6 | return { 7 | \ 'exe': 'ktlint', 8 | \ 'args': ['-F'], 9 | \ 'replace': 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#kotlin#prettier() abort 14 | return { 15 | \ 'exe': 'prettier', 16 | \ 'args': ['--stdin-filepath', '"%:p"'], 17 | \ 'stdin': 1, 18 | \ } 19 | endfunction 20 | 21 | function! neoformat#formatters#kotlin#prettierd() abort 22 | return { 23 | \ 'exe': 'prettierd', 24 | \ 'args': ['"%:p"'], 25 | \ 'stdin': 1, 26 | \ } 27 | endfunction 28 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/less.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#less#enabled() abort 2 | return ['stylelint', 'prettierd', 'prettier', 'csscomb', 'prettydiff'] 3 | endfunction 4 | 5 | function! neoformat#formatters#less#csscomb() abort 6 | return neoformat#formatters#css#csscomb() 7 | endfunction 8 | 9 | function! neoformat#formatters#less#prettydiff() abort 10 | return neoformat#formatters#css#prettydiff() 11 | endfunction 12 | 13 | function! neoformat#formatters#less#prettier() abort 14 | return neoformat#formatters#css#prettier() 15 | endfunction 16 | 17 | function! neoformat#formatters#less#prettierd() abort 18 | return neoformat#formatters#css#prettierd() 19 | endfunction 20 | 21 | function! neoformat#formatters#less#stylelint() abort 22 | return neoformat#formatters#css#stylelint() 23 | endfunction 24 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/lua.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#lua#enabled() abort 2 | return ['luaformatter', 'luafmt', 'luaformat', 'stylua'] 3 | endfunction 4 | 5 | function! neoformat#formatters#lua#luaformatter() abort 6 | return { 7 | \ 'exe': 'luaformatter' 8 | \ } 9 | endfunction 10 | 11 | function! neoformat#formatters#lua#luafmt() abort 12 | return { 13 | \ 'exe': 'luafmt', 14 | \ 'args': ['--stdin'], 15 | \ 'stdin': 1, 16 | \ } 17 | endfunction 18 | 19 | function! neoformat#formatters#lua#luaformat() abort 20 | return { 21 | \ 'exe': 'lua-format' 22 | \ } 23 | endfunction 24 | 25 | function! neoformat#formatters#lua#stylua() abort 26 | return { 27 | \ 'exe': 'stylua', 28 | \ 'args': ['--search-parent-directories', '--stdin-filepath', '"%:p"', '--', '-'], 29 | \ 'stdin': 1, 30 | \ } 31 | endfunction 32 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/markdown.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#markdown#enabled() abort 2 | return ['remark', 'prettierd', 'prettier', 'denofmt', 'mdformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#markdown#prettier() abort 6 | return { 7 | \ 'exe': 'prettier', 8 | \ 'args': ['--stdin-filepath', '"%:p"'], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#markdown#prettierd() abort 15 | return { 16 | \ 'exe': 'prettierd', 17 | \ 'args': ['"%:p"'], 18 | \ 'stdin': 1, 19 | \ } 20 | endfunction 21 | 22 | function! neoformat#formatters#markdown#remark() abort 23 | return { 24 | \ 'exe': 'remark', 25 | \ 'args': ['--no-color', '--silent'], 26 | \ 'stdin': 1, 27 | \ 'try_node_exe': 1, 28 | \ } 29 | endfunction 30 | 31 | function! neoformat#formatters#markdown#denofmt() abort 32 | return { 33 | \ 'exe': 'deno', 34 | \ 'args': ['fmt', '--ext', 'md', '-'], 35 | \ 'stdin': 1, 36 | \ } 37 | endfunction 38 | 39 | function! neoformat#formatters#markdown#mdformat() abort 40 | return { 41 | \ 'exe': 'mdformat', 42 | \ 'args': ['-'], 43 | \ 'stdin': 1, 44 | \ } 45 | endfunction 46 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/matlab.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#matlab#enabled() abort 2 | return ['matlabformatter'] 3 | endfunction 4 | 5 | function! neoformat#formatters#matlab#matlabformatter() abort 6 | return { 7 | \ 'exe': 'matlab_formatter.py', 8 | \ 'stdin': 0 9 | \ } 10 | endfunction 11 | 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/nginx.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#nginx#enabled() abort 2 | return ['nginxbeautifier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#nginx#nginxbeautifier() abort 6 | return { 7 | \ 'exe': 'nginxbeautifier', 8 | \ 'args': ['-i'], 9 | \ 'replace': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/nickel.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#nickel#enabled() abort 2 | return ['topiary'] 3 | endfunction 4 | 5 | function! neoformat#formatters#nickel#topiary() abort 6 | return { 7 | \ 'exe': 'topiary', 8 | \ 'stdin': 1, 9 | \ 'args': ['format', '--merge-configuration', '--language', '"nickel"' ] 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/nim.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#nim#enabled() abort 2 | return ['nimpretty','nph'] 3 | endfunction 4 | 5 | function! neoformat#formatters#nim#nph() abort 6 | return { 7 | \ 'exe': 'nph', 8 | \ 'replace': 1, 9 | \ } 10 | endfunction 11 | 12 | function! neoformat#formatters#nim#nimpretty() abort 13 | return { 14 | \ 'exe': 'nimpretty', 15 | \ 'args': ['--backup:off'], 16 | \ 'replace': 1, 17 | \ } 18 | endfunction 19 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/nix.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#nix#enabled() abort 2 | return ['nixfmt', 'nixpkgsfmt', 'alejandra'] 3 | endfunction 4 | 5 | function! neoformat#formatters#nix#nixfmt() abort 6 | return { 7 | \ 'exe': 'nixfmt', 8 | \ 'stdin': 1, 9 | \ } 10 | endfunction 11 | 12 | function! neoformat#formatters#nix#nixpkgsfmt() abort 13 | return { 14 | \ 'exe': 'nixpkgs-fmt', 15 | \ 'stdin': 1, 16 | \ } 17 | endfunction 18 | 19 | function! neoformat#formatters#nix#alejandra() abort 20 | return { 21 | \ 'exe': 'alejandra', 22 | \ 'args': ['--quiet'], 23 | \ 'stdin': 1, 24 | \ } 25 | endfunction 26 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/objc.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#objc#enabled() abort 2 | return ['uncrustify', 'clangformat', 'astyle'] 3 | endfunction 4 | 5 | function! neoformat#formatters#objc#uncrustify() abort 6 | return { 7 | \ 'exe': 'uncrustify', 8 | \ 'args': ['-q', '-l OC+'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#objc#clangformat() abort 14 | return neoformat#formatters#c#clangformat() 15 | endfunction 16 | 17 | function! neoformat#formatters#objc#astyle() abort 18 | return neoformat#formatters#c#astyle() 19 | endfunction 20 | 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/objcpp.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#objcpp#enabled() abort 2 | return ['uncrustify', 'clangformat', 'astyle'] 3 | endfunction 4 | 5 | function! neoformat#formatters#objcpp#uncrustify() abort 6 | return { 7 | \ 'exe': 'uncrustify', 8 | \ 'args': ['-q', '-l OC+'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#objcpp#clangformat() abort 14 | return neoformat#formatters#c#clangformat() 15 | endfunction 16 | 17 | function! neoformat#formatters#objcpp#astyle() abort 18 | return neoformat#formatters#c#astyle() 19 | endfunction 20 | 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/ocaml.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#ocaml#enabled() abort 2 | return ['ocamlformat', 'ocpindent', 'topiary'] 3 | endfunction 4 | 5 | function! neoformat#formatters#ocaml#ocpindent() abort 6 | return { 7 | \ 'exe': 'ocp-indent', 8 | \ } 9 | endfunction 10 | 11 | function! neoformat#formatters#ocaml#ocamlformat() abort 12 | return { 13 | \ 'exe': 'ocamlformat', 14 | \ 'no_append': 1, 15 | \ 'stdin': 1, 16 | \ 'args': ['--name', '"%:p"', '-'] 17 | \ } 18 | endfunction 19 | 20 | function! neoformat#formatters#ocaml#topiary() abort 21 | return { 22 | \ 'exe': 'topiary', 23 | \ 'stdin': 1, 24 | \ 'args': ['format', '--merge-configuration', '--language', '"ocaml"' ] 25 | \ } 26 | endfunction 27 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/opencl.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#opencl#enabled() abort 2 | return ['clangformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#opencl#clangformat() abort 6 | return neoformat#formatters#c#clangformat() 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/openscad.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#openscad#enabled() abort 2 | return ['openscadformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#openscad#openscadformat() abort 6 | return { 7 | \ 'exe': 'openscad-format', 8 | \ 'args': ['-d'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/pandoc.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#pandoc#enabled() abort 2 | return ['pandoc'] 3 | endfunction 4 | 5 | function! neoformat#formatters#pandoc#pandoc() abort 6 | let l:input_flags = ['markdown', 7 | \ '+abbreviations', 8 | \ '+autolink_bare_uris', 9 | \ '+markdown_attribute', 10 | \ '+mmd_header_identifiers', 11 | \ '+mmd_link_attributes', 12 | \ '+tex_math_double_backslash', 13 | \ '+emoji', 14 | \ '+task_lists', 15 | \ ] 16 | 17 | let l:target_flags = ['markdown', 18 | \ '+raw_tex', 19 | \ '-native_spans', 20 | \ '-simple_tables', 21 | \ '-multiline_tables', 22 | \ '-fenced_code_attributes', 23 | \ '+emoji', 24 | \ '+task_lists', 25 | \ ] 26 | 27 | return { 28 | \ 'exe': 'pandoc', 29 | \ 'args': [ 30 | \ '-f' , 31 | \ join(l:input_flags, ''), 32 | \ '-t', 33 | \ join(l:target_flags, ''), 34 | \ '-s', 35 | \ '--wrap=auto', 36 | \ '--atx-headers', 37 | \], 38 | \ 'stdin': 1, 39 | \ } 40 | endfunction 41 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/pawn.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#pawn#enabled() abort 2 | return ['uncrustify'] 3 | endfunction 4 | 5 | function! neoformat#formatters#pawn#uncrustify() abort 6 | return { 7 | \ 'exe': 'uncrustify', 8 | \ 'args': ['-q', '-l PAWN'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/perl.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#perl#enabled() abort 2 | return ['perltidy', 'perlimports'] 3 | endfunction 4 | 5 | function! neoformat#formatters#perl#perltidy() abort 6 | return { 7 | \ 'exe': 'perltidy', 8 | \ 'args': ['-q'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#perl#perlimports() abort 14 | return { 15 | \ 'exe': 'perlimports', 16 | \ 'args': ['--read-stdin', '--filename', '%:p'], 17 | \ 'stdin': 1, 18 | \ 'no_append': 1, 19 | \ } 20 | endfunction 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/php.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#php#enabled() abort 2 | return ['phpbeautifier', 'phpcsfixer', 'phpcbf', 'prettierd', 'prettier', 'laravelpint'] 3 | endfunction 4 | 5 | function! neoformat#formatters#php#phpbeautifier() abort 6 | return { 7 | \ 'exe': 'php_beautifier', 8 | \ } 9 | endfunction 10 | 11 | function! neoformat#formatters#php#phpcsfixer() abort 12 | return { 13 | \ 'exe': 'php-cs-fixer', 14 | \ 'args': ['fix', '-q'], 15 | \ 'replace': 1, 16 | \ } 17 | endfunction 18 | 19 | function! neoformat#formatters#php#phpcbf() abort 20 | return { 21 | \ 'exe': 'phpcbf', 22 | \ 'stdin': 1, 23 | \ 'args': ['-'], 24 | \ 'valid_exit_codes': [0,1], 25 | \ } 26 | endfunction 27 | 28 | function! neoformat#formatters#php#prettier() abort 29 | return { 30 | \ 'exe': 'prettier', 31 | \ 'args': ['--stdin-filepath', '"%:p"'], 32 | \ 'stdin': 1, 33 | \ 'try_node_exe': 1, 34 | \ } 35 | endfunction 36 | 37 | function! neoformat#formatters#php#prettierd() abort 38 | return { 39 | \ 'exe': 'prettierd', 40 | \ 'args': ['"%:p"'], 41 | \ 'stdin': 1, 42 | \ } 43 | endfunction 44 | 45 | function! neoformat#formatters#php#laravelpint() abort 46 | return { 47 | \ 'exe': 'pint', 48 | \ 'replace': 1, 49 | \ } 50 | endfunction 51 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/prisma.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#prisma#enabled() abort 2 | return ['prettier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#prisma#prettier() abort 6 | return { 7 | \ 'exe': 'prettier', 8 | \ 'args': ['--stdin-filepath', '"%:p"'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/proto.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#proto#enabled() abort 2 | return ['clangformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#proto#clangformat() abort 6 | return neoformat#formatters#c#clangformat() 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/ps1.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#ps1#enabled() abort 2 | return ['PSScriptAnalyzer', 'PowerShellBeautifier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#ps1#PowerShellBeautifier() abort 6 | return { 7 | \ 'exe' : 'Edit-DTWBeautifyScript', 8 | \ 'args' : ["-IndentType FourSpaces", "-StandardOutput"], 9 | \ 'stdin' : 0, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#ps1#PSScriptAnalyzer() abort 14 | return { 15 | \ 'exe' : 'Invoke-Formatter', 16 | \ 'args' : ['-ScriptDefinition (Get-Content ' . expand('%') . ' -Raw)'], 17 | \ 'stdin' : 0, 18 | \ 'no_append' : 1, 19 | \ } 20 | endfunction 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/pug.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#pug#enabled() abort 2 | return ['pugbeautifier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#pug#pugbeautifier() abort 6 | return { 7 | \ 'exe': 'pug-beautifier', 8 | \ 'args': ['-s 2'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/puppet.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#puppet#enabled() abort 2 | return ['puppetlint'] 3 | endfunction 4 | 5 | function! neoformat#formatters#puppet#puppetlint() abort 6 | return { 7 | \ 'exe': 'puppet-lint', 8 | \ 'args': ['--fix'], 9 | \ 'replace': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/purescript.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#purescript#enabled() abort 2 | return ['purstidy', 'purty'] 3 | endfunction 4 | 5 | function! neoformat#formatters#purescript#purstidy() abort 6 | return { 7 | \ 'exe': 'purs-tidy', 8 | \ 'args': ['format'], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#purescript#purty() abort 15 | return { 16 | \ 'exe': 'purty', 17 | \ 'args': ['-'], 18 | \ 'stdin': 1, 19 | \ 'try_node_exe': 1, 20 | \ } 21 | endfunction 22 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/python.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#python#enabled() abort 2 | return ['yapf', 'autopep8', 'black', 'isort', 'docformatter', 'pyment', 'pydevf', 'ruff'] 3 | endfunction 4 | 5 | function! neoformat#formatters#python#yapf() abort 6 | return { 7 | \ 'exe': 'yapf', 8 | \ 'stdin': 1, 9 | \ } 10 | endfunction 11 | 12 | function! neoformat#formatters#python#autopep8() abort 13 | return { 14 | \ 'exe': 'autopep8', 15 | \ 'args': ['-'], 16 | \ 'stdin': 1, 17 | \ } 18 | endfunction 19 | 20 | 21 | function! neoformat#formatters#python#isort() abort 22 | return { 23 | \ 'exe': 'isort', 24 | \ 'args': ['-', '--quiet',], 25 | \ 'stdin': 1, 26 | \ } 27 | endfunction 28 | 29 | 30 | function! neoformat#formatters#python#docformatter() abort 31 | return { 32 | \ 'exe': 'docformatter', 33 | \ 'args': ['-',], 34 | \ 'stdin': 1, 35 | \ } 36 | endfunction 37 | 38 | function! neoformat#formatters#python#black() abort 39 | return { 40 | \ 'exe': 'black', 41 | \ 'stdin': 1, 42 | \ 'args': ['-q', '-'], 43 | \ } 44 | endfunction 45 | 46 | 47 | function! neoformat#formatters#python#pyment() abort 48 | return { 49 | \ 'exe': 'pyment', 50 | \ 'stdin': 1, 51 | \ 'args': ['-w', '-'], 52 | \ } 53 | endfunction 54 | 55 | function! neoformat#formatters#python#pydevf() abort 56 | return { 57 | \ 'exe': 'pydevf', 58 | \ 'replace': 1, 59 | \ } 60 | endfunction 61 | 62 | function! neoformat#formatters#python#ruff() abort 63 | return { 64 | \ 'exe': 'ruff', 65 | \ 'stdin': 1, 66 | \ 'args': ['format', '-q', '-'], 67 | \ } 68 | endfunction 69 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/r.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#r#enabled() abort 2 | return ['styler', 'formatR'] 3 | endfunction 4 | 5 | function! neoformat#formatters#r#styler() abort 6 | return { 7 | \ 'exe': 'R', 8 | \ 'args': ['--slave', '--no-restore', '--no-save', '-e "styler::style_text(readr::read_file(file(\"stdin\")))"', '2>/dev/null'], 9 | \ 'stdin': 1, 10 | \} 11 | endfunction 12 | 13 | function! neoformat#formatters#r#formatR() abort 14 | return { 15 | \ 'exe': 'R', 16 | \ 'args': ['--slave', '--no-restore', '--no-save', '-e "formatR::tidy_source(\"stdin\", arrow=FALSE)"', '2>/dev/null'], 17 | \ 'stdin': 1, 18 | \} 19 | endfunction 20 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/reason.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#reason#enabled() abort 2 | return ['refmt', 'bsrefmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#reason#refmt() abort 6 | return { 7 | \ 'exe': 'refmt', 8 | \ 'stdin': 1, 9 | \ 'args': ["--interface=" . (expand('%:e') == "rei" ? "true" : "false")], 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#reason#bsrefmt() abort 15 | return { 16 | \ 'exe': 'bsrefmt', 17 | \ 'stdin': 1, 18 | \ 'args': ["--interface=" . (expand('%:e') == "rei" ? "true" : "false")], 19 | \ } 20 | endfunction 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/rego.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#rego#enabled() abort 2 | return ['opafmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#rego#opafmt() abort 6 | return { 7 | \ 'exe': 'opa', 8 | \ 'args': ['fmt'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/ruby.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#ruby#enabled() abort 2 | return ['rufo', 'rubybeautify', 'standard', 'rubocop', 'prettier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#ruby#rufo() abort 6 | return { 7 | \ 'exe': 'rufo', 8 | \ 'stdin': 1, 9 | \ 'valid_exit_codes': [0, 3] 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#ruby#rubybeautify() abort 14 | return { 15 | \ 'exe': 'ruby-beautify', 16 | \ 'args': ['--spaces', '-c ' . shiftwidth()], 17 | \ } 18 | endfunction 19 | 20 | let s:clean_output = "awk '/^====================$/{p++;if(p==1){next}}p'" 21 | 22 | function! neoformat#formatters#ruby#rubocop() abort 23 | return { 24 | \ 'exe': 'rubocop', 25 | \ 'args': ['--auto-correct', '--stdin', '"%:p"', '2>/dev/null', '|', s:clean_output], 26 | \ 'stdin': 1, 27 | \ 'stderr': 1 28 | \ } 29 | endfunction 30 | 31 | function! neoformat#formatters#ruby#standard() abort 32 | return { 33 | \ 'exe': 'standardrb', 34 | \ 'args': ['--fix', '--stdin', '"%:p"', '2>/dev/null', '|', s:clean_output], 35 | \ 'stdin': 1, 36 | \ 'stderr': 1 37 | \ } 38 | endfunction 39 | 40 | function! neoformat#formatters#ruby#prettier() abort 41 | return { 42 | \ 'exe': 'prettier', 43 | \ 'args': ['--stdin-filepath', '"%:p"'], 44 | \ 'stdin': 1, 45 | \ 'try_node_exe': 1, 46 | \ } 47 | endfunction 48 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/rust.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#rust#enabled() abort 2 | return ['rustfmt', 'topiary'] 3 | endfunction 4 | 5 | function! neoformat#formatters#rust#rustfmt() abort 6 | return { 7 | \ 'exe': 'rustfmt', 8 | \ 'stdin': 1, 9 | \ } 10 | endfunction 11 | 12 | function! neoformat#formatters#rust#topiary() abort 13 | return { 14 | \ 'exe': 'topiary', 15 | \ 'stdin': 1, 16 | \ 'args': ['format', '--merge-configuration', '--language', '"rust"' ] 17 | \ } 18 | endfunction 19 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/sass.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#sass#enabled() abort 2 | return ['sassconvert', 'stylelint', 'csscomb'] 3 | endfunction 4 | 5 | function! neoformat#formatters#sass#sassconvert() abort 6 | return { 7 | \ 'exe': 'sass-convert', 8 | \ 'args': ['-F sass', '-T sass', '-s'], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#sass#csscomb() abort 15 | return neoformat#formatters#css#csscomb() 16 | endfunction 17 | 18 | function! neoformat#formatters#sass#stylelint() abort 19 | return neoformat#formatters#css#stylelint() 20 | endfunction 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/sbt.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#sbt#enabled() abort 2 | return ['scalafmt'] 3 | endfunction 4 | 5 | " To understand sbt files on stdin, scalafmt needs to assume any old filename 6 | " that ends in .sbt. Using a dummy filename instead of the actual one is 7 | " required to support buffers of sbt filetype without the extension. 8 | function! neoformat#formatters#sbt#scalafmt() abort 9 | return { 10 | \ 'exe': 'scalafmt', 11 | \ 'args': ['--stdin', '--assume-filename', 'foo.sbt'], 12 | \ 'stdin': 1, 13 | \ } 14 | endfunction 15 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/scala.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#scala#enabled() abort 2 | return ['scalariform', 'scalafmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#scala#scalariform() abort 6 | return { 7 | \ 'exe': 'scalariform', 8 | \ 'args': ['--stdin'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#scala#scalafmt() abort 14 | return { 15 | \ 'exe': 'scalafmt', 16 | \ 'args': ['--stdin'], 17 | \ 'stdin': 1, 18 | \ } 19 | endfunction 20 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/scss.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#scss#enabled() abort 2 | return ['sassconvert', 'stylelint', 'stylefmt', 'prettierd', 'prettier', 'prettydiff', 'csscomb'] 3 | endfunction 4 | 5 | function! neoformat#formatters#scss#sassconvert() abort 6 | return { 7 | \ 'exe': 'sass-convert', 8 | \ 'args': ['-F scss', '-T scss', '--indent ' . (&expandtab ? shiftwidth() : 't')], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#scss#csscomb() abort 15 | return neoformat#formatters#css#csscomb() 16 | endfunction 17 | 18 | function! neoformat#formatters#scss#prettydiff() abort 19 | return neoformat#formatters#css#prettydiff() 20 | endfunction 21 | 22 | function! neoformat#formatters#scss#stylefmt() abort 23 | return neoformat#formatters#css#stylefmt() 24 | endfunction 25 | 26 | function! neoformat#formatters#scss#prettier() abort 27 | return neoformat#formatters#css#prettier() 28 | endfunction 29 | 30 | function! neoformat#formatters#scss#prettierd() abort 31 | return neoformat#formatters#css#prettierd() 32 | endfunction 33 | 34 | function! neoformat#formatters#scss#stylelint() abort 35 | return neoformat#formatters#css#stylelint() 36 | endfunction 37 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/sh.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#sh#enabled() abort 2 | return ['shfmt', 'topiary'] 3 | endfunction 4 | 5 | function! neoformat#formatters#sh#shfmt() abort 6 | let opts = neoformat#utils#var_default('shfmt_opt', '') 7 | return { 8 | \ 'exe': 'shfmt', 9 | \ 'args': ['-i ' . (&expandtab ? shiftwidth() : 0), opts], 10 | \ 'stdin': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#sh#topiary() abort 15 | return { 16 | \ 'exe': 'topiary', 17 | \ 'stdin': 1, 18 | \ 'args': ['format', '--merge-configuration', '--language', '"bash"' ] 19 | \ } 20 | endfunction 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/solidity.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#solidity#enabled() abort 2 | return ['forge', 'prettierd', 'prettier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#solidity#prettier() abort 6 | return { 7 | \ 'exe': 'prettier', 8 | \ 'args': ['--stdin-filepath', '"%:p"'], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#solidity#prettierd() abort 15 | return { 16 | \ 'exe': 'prettierd', 17 | \ 'args': ['"%:p"'], 18 | \ 'stdin': 1, 19 | \ } 20 | endfunction 21 | 22 | function! neoformat#formatters#solidity#forge() abort 23 | return { 24 | \ 'exe': 'forge', 25 | \ 'args': ['fmt', '--raw', '-'], 26 | \ 'stdin': 1 27 | \ } 28 | endfunction 29 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/sql.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#sql#enabled() abort 2 | return ['sqlformat', 'pg_format', 'sqlfmt', 'sleek', 'sqlformatter'] 3 | endfunction 4 | 5 | function! neoformat#formatters#sql#sqlformat() abort 6 | return { 7 | \ 'exe': 'sqlformat', 8 | \ 'args': ['--reindent', '-'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#sql#pg_format() abort 14 | return { 15 | \ 'exe': 'pg_format', 16 | \ 'args': ['-'], 17 | \ 'stdin': 1, 18 | \ } 19 | endfunction 20 | 21 | function! neoformat#formatters#sql#sqlfmt() abort 22 | return { 23 | \ 'exe': 'sqlfmt', 24 | \ 'args': [], 25 | \ 'stdin': 1, 26 | \ } 27 | endfunction 28 | 29 | function! neoformat#formatters#sql#sleek() abort 30 | return { 31 | \ 'exe': 'sleek', 32 | \ 'args': [], 33 | \ 'stdin': 1, 34 | \ } 35 | endfunction 36 | 37 | function! neoformat#formatters#sql#sqlformatter() abort 38 | return { 39 | \ 'exe': 'sql-formatter', 40 | \ 'args': [], 41 | \ 'stdin': 1, 42 | \ } 43 | endfunction 44 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/starlark.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#starlark#enabled() abort 2 | return ['buildifier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#starlark#buildifier() abort 6 | return { 7 | \ 'exe': 'buildifier', 8 | \ 'args': ['-path', expand('%:p')], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/svelte.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#svelte#enabled() abort 2 | return ['prettierd', 'prettier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#svelte#prettier() abort 6 | return { 7 | \ 'exe': 'prettier', 8 | \ 'args': ['--stdin-filepath', '"%:p"', '--parser=svelte', '--plugin-search-dir=.'], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#svelte#prettierd() abort 15 | return { 16 | \ 'exe': 'prettierd', 17 | \ 'args': ['"%:p"'], 18 | \ 'stdin': 1, 19 | \ } 20 | endfunction 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/swift.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#swift#enabled() abort 2 | return ['swiftformat', 'swift_format'] 3 | endfunction 4 | 5 | function! neoformat#formatters#swift#swiftformat() abort 6 | return { 7 | \ 'exe': 'swiftformat', 8 | \ 'stdin': 1 9 | \ } 10 | endfunction 11 | 12 | function! neoformat#formatters#swift#swift_format() abort 13 | return { 14 | \ 'exe': 'swift-format', 15 | \ 'stdin': 1 16 | \ } 17 | endfunction 18 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/systemverilog.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#systemverilog#enabled() abort 2 | return ['veribleverilogformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#systemverilog#veribleverilogformat() abort 6 | return neoformat#formatters#verilog#veribleverilogformat() 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/terraform.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#terraform#enabled() abort 2 | return ['terraform'] 3 | endfunction 4 | 5 | function! neoformat#formatters#terraform#terraform() abort 6 | return { 7 | \ 'exe': 'terraform', 8 | \ 'args': ['fmt', '-write', '-'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/tex.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#tex#enabled() abort 2 | return ['latexindent'] 3 | endfunction 4 | 5 | function! neoformat#formatters#tex#latexindent() abort 6 | let opts = neoformat#utils#var_default('latexindent_opt', '') 7 | return { 8 | \ 'exe': 'latexindent', 9 | \ 'args': [opts, '-g /dev/stderr', '2>/dev/null'], 10 | \ 'stdin': 1, 11 | \ } 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/tf.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#tf() abort 2 | return ['tf'] 3 | endfunction 4 | 5 | function! neoformat#formatters#tfm#tf() abort 6 | return { 7 | \ 'exe': 'terraform', 8 | \ 'args': ['fmt', '-write', '-'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/toml.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#toml#enabled() abort 2 | return ['taplo', 'topiary'] 3 | endfunction 4 | 5 | function! neoformat#formatters#toml#taplo() abort 6 | return { 7 | \ 'exe': 'taplo', 8 | \ 'args': ['fmt', '-'], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#toml#topiary() abort 15 | return { 16 | \ 'exe': 'topiary', 17 | \ 'stdin': 1, 18 | \ 'args': ['format', '--merge-configuration', '--language', '"toml"' ] 19 | \ } 20 | endfunction 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/typescript.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#typescript#enabled() abort 2 | return ['tsfmt', 'prettierd', 'prettier', 'prettiereslint', 'tslint', 'eslint_d', 'clangformat', 'denofmt', 'biome'] 3 | endfunction 4 | 5 | function! neoformat#formatters#typescript#tsfmt() abort 6 | return { 7 | \ 'exe': 'tsfmt', 8 | \ 'args': ['--replace', '--baseDir=%:h'], 9 | \ 'replace': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#typescript#prettier() abort 15 | return { 16 | \ 'exe': 'prettier', 17 | \ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'typescript'], 18 | \ 'stdin': 1, 19 | \ 'try_node_exe': 1, 20 | \ } 21 | endfunction 22 | 23 | function! neoformat#formatters#typescript#prettierd() abort 24 | return { 25 | \ 'exe': 'prettierd', 26 | \ 'args': ['"%:p"'], 27 | \ 'stdin': 1, 28 | \ } 29 | endfunction 30 | 31 | function! neoformat#formatters#typescript#prettiereslint() abort 32 | return { 33 | \ 'exe': 'prettier-eslint', 34 | \ 'args': ['--stdin', '--stdin-filepath', '"%:p"', '--parser', 'typescript'], 35 | \ 'stdin': 1, 36 | \ 'try_node_exe': 1, 37 | \ } 38 | endfunction 39 | 40 | function! neoformat#formatters#typescript#tslint() abort 41 | let args = ['--fix', '--force'] 42 | 43 | if filereadable('tslint.json') 44 | let args = ['-c tslint.json'] + args 45 | endif 46 | 47 | return { 48 | \ 'exe': 'tslint', 49 | \ 'args': args, 50 | \ 'replace': 1, 51 | \ 'try_node_exe': 1, 52 | \ } 53 | endfunction 54 | 55 | function! neoformat#formatters#typescript#eslint_d() abort 56 | return { 57 | \ 'exe': 'eslint_d', 58 | \ 'args': ['--stdin', '--stdin-filename', '"%:p"', '--fix-to-stdout'], 59 | \ 'stdin': 1, 60 | \ 'try_node_exe': 1, 61 | \ } 62 | endfunction 63 | 64 | function! neoformat#formatters#typescript#clangformat() abort 65 | return { 66 | \ 'exe': 'clang-format', 67 | \ 'args': ['-assume-filename=' . expand('%:t')], 68 | \ 'stdin': 1, 69 | \ 'try_node_exe': 1, 70 | \ } 71 | endfunction 72 | 73 | function! neoformat#formatters#typescript#denofmt() abort 74 | return { 75 | \ 'exe': 'deno', 76 | \ 'args': ['fmt','--ext','ts','-'], 77 | \ 'stdin': 1, 78 | \ } 79 | endfunction 80 | 81 | function! neoformat#formatters#typescript#biome() abort 82 | return { 83 | \ 'exe': 'biome', 84 | \ 'try_node_exe': 1, 85 | \ 'args': ['format', '--stdin-file-path="%:p"'], 86 | \ 'no_append': 1, 87 | \ 'stdin': 1, 88 | \ } 89 | endfunction 90 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/typescriptreact.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#typescriptreact#enabled() abort 2 | return ['tsfmt', 'prettierd', 'prettier', 'prettiereslint', 'tslint', 'eslint_d', 'clangformat', 'denofmt', 'biome'] 3 | endfunction 4 | 5 | function! neoformat#formatters#typescriptreact#tsfmt() abort 6 | return { 7 | \ 'exe': 'tsfmt', 8 | \ 'args': ['--replace', '--baseDir=%:h'], 9 | \ 'replace': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#typescriptreact#prettier() abort 15 | return { 16 | \ 'exe': 'prettier', 17 | \ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'typescript'], 18 | \ 'stdin': 1, 19 | \ 'try_node_exe': 1, 20 | \ } 21 | endfunction 22 | 23 | function! neoformat#formatters#typescriptreact#prettierd() abort 24 | return { 25 | \ 'exe': 'prettierd', 26 | \ 'args': ['"%:p"'], 27 | \ 'stdin': 1, 28 | \ } 29 | endfunction 30 | 31 | function! neoformat#formatters#typescriptreact#prettiereslint() abort 32 | return { 33 | \ 'exe': 'prettier-eslint', 34 | \ 'args': ['--stdin', '--stdin-filepath', '"%:p"', '--parser', 'typescript'], 35 | \ 'stdin': 1, 36 | \ 'try_node_exe': 1, 37 | \ } 38 | endfunction 39 | 40 | function! neoformat#formatters#typescriptreact#tslint() abort 41 | let args = ['--fix', '--force'] 42 | 43 | if filereadable('tslint.json') 44 | let args = ['-c tslint.json'] + args 45 | endif 46 | 47 | return { 48 | \ 'exe': 'tslint', 49 | \ 'args': args, 50 | \ 'replace': 1, 51 | \ 'try_node_exe': 1, 52 | \ } 53 | endfunction 54 | 55 | function! neoformat#formatters#typescriptreact#eslint_d() abort 56 | return { 57 | \ 'exe': 'eslint_d', 58 | \ 'args': ['--stdin', '--stdin-filename', '"%:p"', '--fix-to-stdout'], 59 | \ 'stdin': 1, 60 | \ 'try_node_exe': 1, 61 | \ } 62 | endfunction 63 | 64 | function! neoformat#formatters#typescriptreact#clangformat() abort 65 | return { 66 | \ 'exe': 'clang-format', 67 | \ 'args': ['-assume-filename=' . expand('%:t')], 68 | \ 'stdin': 1, 69 | \ 'try_node_exe': 1, 70 | \ } 71 | endfunction 72 | 73 | function! neoformat#formatters#typescriptreact#denofmt() abort 74 | return { 75 | \ 'exe': 'deno', 76 | \ 'args': ['fmt','--ext','tsx','-'], 77 | \ 'stdin': 1, 78 | \ } 79 | endfunction 80 | 81 | function! neoformat#formatters#typescriptreact#biome() abort 82 | return { 83 | \ 'exe': 'biome', 84 | \ 'try_node_exe': 1, 85 | \ 'args': ['format', '--stdin-file-path="%:p"'], 86 | \ 'no_append': 1, 87 | \ 'stdin': 1, 88 | \ } 89 | endfunction 90 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/typst.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#typst#enabled() abort 2 | return ['typstfmt', 'typstyle'] 3 | endfunction 4 | 5 | function! neoformat#formatters#typst#typstfmt() abort 6 | return { 7 | \ 'exe': 'typstfmt', 8 | \ 'stdin': 1, 9 | \ } 10 | endfunction 11 | 12 | function! neoformat#formatters#typst#typstyle() abort 13 | return { 14 | \ 'exe': 'typstyle', 15 | \ 'stdin': 1, 16 | \ } 17 | endfunction 18 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/v.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#v#enabled() abort 2 | return ['vformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#v#vformat() abort 6 | return { 7 | \ 'exe': 'v', 8 | \ 'args': ['fmt', '-w'], 9 | \ 'replace': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/vala.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#vala#uncrustify() abort 2 | return { 3 | \ 'exe': 'uncrustify', 4 | \ 'args': ['-q', '-l VALA'], 5 | \ 'stdin': 1, 6 | \ } 7 | endfunction 8 | 9 | function! neoformat#formatters#vala#enabled() abort 10 | return ['uncrustify'] 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/verilog.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#verilog#enabled() abort 2 | return ['veribleverilogformat'] 3 | endfunction 4 | 5 | function! neoformat#formatters#verilog#veribleverilogformat() abort 6 | return { 7 | \ 'exe': 'verible-verilog-format', 8 | \ } 9 | endfunction 10 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/vue.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#vue#enabled() abort 2 | return ['prettierd', 'prettier'] 3 | endfunction 4 | 5 | function! neoformat#formatters#vue#prettier() abort 6 | return { 7 | \ 'exe': 'prettier', 8 | \ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'vue'], 9 | \ 'stdin': 1, 10 | \ 'try_node_exe': 1, 11 | \ } 12 | endfunction 13 | 14 | function! neoformat#formatters#vue#prettierd() abort 15 | return { 16 | \ 'exe': 'prettierd', 17 | \ 'args': ['"%:p"'], 18 | \ 'stdin': 1, 19 | \ } 20 | endfunction 21 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/xhtml.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#xhtml#enabled() abort 2 | return ['tidy', 'prettydiff'] 3 | endfunction 4 | 5 | function! neoformat#formatters#xhtml#tidy() abort 6 | return { 7 | \ 'exe': 'tidy', 8 | \ 'args': ['-quiet', 9 | \ '-asxhtml', 10 | \ '--indent auto', 11 | \ '--indent-spaces '. shiftwidth(), 12 | \ '--vertical-space yes', 13 | \ '--tidy-mark no' 14 | \ ], 15 | \ 'stdin': 1, 16 | \ 'try_node_exe': 1, 17 | \ } 18 | endfunction 19 | 20 | function! neoformat#formatters#xhtml#prettydiff() abort 21 | return neoformat#formatters#html#prettydiff() 22 | endfunction 23 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/xml.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#xml#enabled() abort 2 | return ['tidy', 'prettydiff', 'prettierd', 'prettier', 'xmllint'] 3 | endfunction 4 | 5 | function! neoformat#formatters#xml#tidy() abort 6 | return { 7 | \ 'exe': 'tidy', 8 | \ 'args': ['-quiet', 9 | \ '-xml', 10 | \ '--indent auto', 11 | \ '--indent-spaces ' . shiftwidth(), 12 | \ '--vertical-space yes', 13 | \ '--tidy-mark no' 14 | \ ], 15 | \ 'stdin': 1, 16 | \ 'try_node_exe': 1, 17 | \ } 18 | endfunction 19 | 20 | function! neoformat#formatters#xml#prettydiff() abort 21 | return neoformat#formatters#html#prettydiff() 22 | endfunction 23 | 24 | function! neoformat#formatters#xml#prettier() abort 25 | return { 26 | \ 'exe': 'prettier', 27 | \ 'args': ['--stdin-filepath', '"%:p"'], 28 | \ 'stdin': 1, 29 | \ 'try_node_exe': 1, 30 | \ } 31 | endfunction 32 | 33 | function! neoformat#formatters#xml#prettierd() abort 34 | return { 35 | \ 'exe': 'prettierd', 36 | \ 'args': ['"%:p"'], 37 | \ 'stdin': 1, 38 | \ } 39 | endfunction 40 | 41 | function! neoformat#formatters#xml#xmllint() abort 42 | return { 43 | \ 'exe': 'xmllint', 44 | \ 'args': ['--format', '--quiet', '-'], 45 | \ 'stdin': 1, 46 | \ } 47 | endfunction 48 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/yaml.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#yaml#enabled() abort 2 | return ['pyaml', 'prettierd', 'prettier', 'google_yamlfmt', 'yamlfmt', 'yamlfix'] 3 | endfunction 4 | 5 | function! neoformat#formatters#yaml#pyaml() abort 6 | return { 7 | \ 'exe': 'python3', 8 | \ 'args': ['-m', 'pyaml'], 9 | \ 'stdin': 1, 10 | \ } 11 | endfunction 12 | 13 | function! neoformat#formatters#yaml#prettier() abort 14 | return { 15 | \ 'exe': 'prettier', 16 | \ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'yaml'], 17 | \ 'stdin': 1, 18 | \ 'try_node_exe': 1, 19 | \ } 20 | endfunction 21 | 22 | function! neoformat#formatters#yaml#prettierd() abort 23 | return { 24 | \ 'exe': 'prettierd', 25 | \ 'args': ['"%:p"'], 26 | \ 'stdin': 1, 27 | \ } 28 | endfunction 29 | 30 | function! neoformat#formatters#yaml#google_yamlfmt() abort 31 | return { 32 | \ 'exe': 'yamlfmt', 33 | \ 'args': ['-'], 34 | \ 'stdin': 1, 35 | \ } 36 | endfunction 37 | 38 | function! neoformat#formatters#yaml#yamlfmt() abort 39 | return { 40 | \ 'exe': 'yamlfmt', 41 | \ 'stdin': 1, 42 | \ } 43 | endfunction 44 | 45 | function! neoformat#formatters#yaml#yamlfix() abort 46 | return { 47 | \ 'exe': 'yamlfix', 48 | \ 'args': ['-'], 49 | \ 'stdin': 1, 50 | \ } 51 | endfunction 52 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/zig.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#zig#enabled() abort 2 | return ['zigfmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#zig#zigfmt() abort 6 | return { 7 | \ 'exe': 'zig', 8 | \ 'args': ['fmt', '--stdin'], 9 | \ 'stdin': 1 10 | \ } 11 | endfunction 12 | -------------------------------------------------------------------------------- /autoload/neoformat/formatters/zsh.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#zsh#enabled() abort 2 | return ['shfmt'] 3 | endfunction 4 | 5 | function! neoformat#formatters#zsh#shfmt() abort 6 | let opts = neoformat#utils#var_default('shfmt_opt', '') 7 | return { 8 | \ 'exe': 'shfmt', 9 | \ 'args': ['-i ' . (&expandtab ? shiftwidth() : 0), opts], 10 | \ 'stdin': 1, 11 | \ } 12 | endfunction 13 | -------------------------------------------------------------------------------- /autoload/neoformat/sugarss.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#formatters#sugarss#enabled() abort 2 | return ['stylelint'] 3 | endfunction 4 | 5 | function! neoformat#formatters#sugarss#stylelint() abort 6 | return neoformat#formatters#css#stylelint() 7 | endfunction 8 | -------------------------------------------------------------------------------- /autoload/neoformat/utils.vim: -------------------------------------------------------------------------------- 1 | function! neoformat#utils#log(msg) abort 2 | if neoformat#utils#should_be_verbose() 3 | return s:better_echo(a:msg) 4 | endif 5 | endfunction 6 | 7 | function! neoformat#utils#log_file_content(path) abort 8 | if neoformat#utils#should_be_verbose() 9 | return s:better_echo(readfile(a:path)) 10 | endif 11 | endfunction 12 | 13 | function! neoformat#utils#warn(msg) abort 14 | echohl WarningMsg | call s:better_echo(a:msg) | echohl NONE 15 | endfunction 16 | 17 | function! neoformat#utils#msg(msg) abort 18 | if exists('g:neoformat_only_msg_on_error') && g:neoformat_only_msg_on_error 19 | return 20 | endif 21 | return s:better_echo(a:msg) 22 | endfunction 23 | 24 | function! neoformat#utils#should_be_verbose() abort 25 | if !exists('g:neoformat_verbose') 26 | let g:neoformat_verbose = 0 27 | endif 28 | return &verbose || g:neoformat_verbose 29 | endfunction 30 | 31 | function! s:better_echo(msg) abort 32 | if type(a:msg) != type('') 33 | echom 'Neoformat: ' . string(a:msg) 34 | else 35 | echom 'Neoformat: ' . a:msg 36 | endif 37 | endfunction 38 | 39 | function! neoformat#utils#var(name) abort 40 | return neoformat#utils#var_default(a:name, 0) 41 | endfunction 42 | 43 | function! neoformat#utils#var_default(name, default) abort 44 | if exists('b:' . a:name) 45 | return get(b:, a:name) 46 | endif 47 | 48 | return get(g:, a:name, a:default) 49 | endfunction 50 | -------------------------------------------------------------------------------- /doc/neoformat.txt: -------------------------------------------------------------------------------- 1 | *neoformat.txt* A Neovim plugin for formatting. 2 | 3 | CONTENTS *neoformat-contents* 4 | 5 | Introduction |neoformat-introduction| 6 | Install |neoformat-install| 7 | Usage |neoformat-usage| 8 | Managing Undo History |neoformat-managing-undo-history| 9 | Supported Filetypes |neoformat-supported-filetypes| 10 | 11 | ============================================================================== 12 | INTRODUCTION *neoformat-introduction* 13 | 14 | A [Neovim](https://neovim.io) and Vim8 plugin for formatting code. 15 | 16 | *Neoformat* uses a variety of formatters for many filetypes. Currently, Neoformat 17 | will run a formatter using the current buffer data, and on success it will 18 | update the current buffer with the formatted text. On a formatter failure, 19 | Neoformat will try the next formatter defined for the filetype. 20 | 21 | By using `getbufline()` to read from the current buffer instead of file, 22 | Neoformat is able to format your buffer without you having to `:w` your file first. 23 | Also, by using `setline()`, marks, jumps, etc. are all maintained after formatting. 24 | 25 | Neoformat supports both sending buffer data to formatters via stdin, and also 26 | writing buffer data to `/tmp/` for formatters to read that do not support input 27 | via stdin. 28 | 29 | ============================================================================== 30 | INSTALL *neoformat-install* 31 | 32 | Install with [vim-plug](https://github.com/junegunn/vim-plug) 33 | > 34 | Plug 'sbdchd/neoformat' 35 | < 36 | ============================================================================== 37 | USAGE *neoformat-usage* 38 | 39 | Format the entire buffer, or visual selection of the buffer 40 | > 41 | :Neoformat 42 | 43 | 45 | :Neoformat jsbeautify 46 | 47 | Or format a visual selection of code in a different filetype 48 | 49 | *Note:* you must use a ! and pass the filetype of the selection 50 | 51 | > 52 | :Neoformat! python 53 | > 54 | You can also pass a formatter to use 55 | 56 | > 57 | :Neoformat! python yapf 58 | < 59 | 60 | Or perhaps run a formatter on save 61 | 62 | > 63 | augroup fmt 64 | autocmd! 65 | autocmd BufWritePre * undojoin | Neoformat 66 | augroup END 67 | < 68 | 69 | The |undojoin| command will put changes made by Neoformat into the same 70 | |undo-block| with the latest preceding change. See 71 | |neoformat-managing-undo-history|. 72 | 73 | 74 | ============================================================================== 75 | CURRENT LIMITATION(S) *neoformat-limitations* 76 | 77 | If a formatter is either not configured to use `stdin`, or is not able to read 78 | from `stdin`, then buffer data will be written to a file in `/tmp/neoformat/`, 79 | where the formatter will then read from 80 | 81 | ============================================================================== 82 | CONFIG *neoformat-config* 83 | 84 | Define custom formatters. 85 | 86 | Options: 87 | 88 | | `exe` | the name the formatter executable in the path | required 89 | | `args` | list of arguments | default: [] | optional 90 | | `replace` | overwrite the file, instead of updating the buffer | default: 0 | optional 91 | | `stdin` | send data to the stdin of the formatter | default 0 | optional 92 | | `stderr` | used to specify whether stderr output should be read along with 93 | the stdin, otherwise redirects stderr to `stderr.log` file in neoformat's 94 | temporary directory | default 0 | optional 95 | | `no_append` | do not append the `path` of the file to the formatter command, 96 | used when the `path` is in the middle of a command | default: 0 | 97 | optional 98 | | `env` | list of environment variables to prepend to the command | default: [] | optional 99 | 100 | | `valid_exit_codes` | list of valid exit codes for formatters who do not respect common unix practices | \[0] | optional 101 | | `try_node_exe` | attempt to find `exe` in a `node_modules/.bin` directory in the current working directory or one of its parents (requires setting `g:neoformat_try_node_exe`) | default: 0 | optional 102 | 103 | Example: 104 | 105 | Define custom formatters. 106 | > 107 | let g:neoformat_python_autopep8 = { 108 | \ 'exe': 'autopep8', 109 | \ 'args': ['-s 4', '-E'], 110 | \ 'replace': 1 " replace the file, instead of updating buffer (default: 0), 111 | \ 'stdin': 1, " send data to stdin of formatter (default: 0) 112 | \ 'valid_exit_codes': [0, 23], 113 | \ 'no_append': 1, 114 | \ } 115 | 116 | let g:neoformat_enabled_python = ['autopep8'] 117 | < 118 | Have Neoformat use &formatprg as a formatter 119 | > 120 | let g:neoformat_try_formatprg = 1 121 | < 122 | Enable basic formatting when a filetype is not found. Disabled by default. 123 | > 124 | " Enable alignment globally 125 | let g:neoformat_basic_format_align = 1 126 | 127 | " Enable tab to spaces conversion globally 128 | let g:neoformat_basic_format_retab = 1 129 | 130 | " Enable trimmming of trailing whitespace globally 131 | let g:neoformat_basic_format_trim = 1 132 | 133 | Run all enabled formatters (by default Neoformat stops after the first 134 | formatter succeeds) 135 | 136 | let g:neoformat_run_all_formatters = 1 137 | 138 | Above options can be activated or deactivated per buffer. For example: 139 | 140 | " runs all formatters for current buffer without tab to spaces conversion 141 | let b:neoformat_run_all_formatters = 1 142 | let b:neoformat_basic_format_retab = 0 143 | 144 | Have Neoformat only msg when there is an error 145 | > 146 | let g:neoformat_only_msg_on_error = 1 147 | < 148 | When debugging, you can enable either of following variables for extra logging. 149 | > 150 | let g:neoformat_verbose = 1 " only affects the verbosity of Neoformat 151 | " Or 152 | let &verbose = 1 " also increases verbosity of the editor as a whole 153 | < 154 | Have Neoformat look for a formatter executable in the `node_modules/.bin` 155 | directory in the current working directory or one of its parents (only applies 156 | to formatters with `try_node_exe` set to `1`): 157 | > 158 | let g:neoformat_try_node_exe = 1 159 | < 160 | 161 | ============================================================================== 162 | ADDING A NEW FORMATTER *neoformat-adding-new-formatter* 163 | 164 | Note: you should replace everything `{{ }}` accordingly 165 | 166 | 1. Create a file in `autoload/neoformat/formatters/{{ filetype }}.vim` if it does not 167 | already exist for your filetype. 168 | 169 | 2. Follow the following format 170 | 171 | See Config above for options 172 | > 173 | function! neoformat#formatters#{{ filetype }}#enabled() abort 174 | return ['{{ formatter name }}', '{{ other formatter name for filetype }}'] 175 | endfunction 176 | 177 | function! neoformat#formatters#{{ filetype }}#{{ formatter name }}() abort 178 | return { 179 | \ 'exe': '{{ formatter name }}', 180 | \ 'args': ['-s 4', '-q'], 181 | \ 'stdin': 1 182 | \ } 183 | endfunction 184 | 185 | function! neoformat#formatters#{{ filetype }}#{{ other formatter name }}() abort 186 | return {'exe': {{ other formatter name }} 187 | endfunction 188 | < 189 | 3. Update `README.md` and `doc/neoformat.txt` 190 | 191 | ============================================================================== 192 | MANAGING UNDO HISTORY *neoformat-managing-undo-history* 193 | 194 | If you use an |autocmd| to run Neoformat on save, and you have your editor 195 | configured to save automatically on |CursorHold| then you might run into 196 | problems reverting changes. Pressing |u| will undo the last change made by 197 | Neoformat instead of the change that you made yourself - and then Neoformat 198 | will run again redoing the change that you just reverted. To avoid this 199 | problem you can run Neoformat with the Vim |undojoin| command to put changes 200 | made by Neoformat into the same |undo-block| with the preceding change. For 201 | example: 202 | 203 | > 204 | augroup fmt 205 | autocmd! 206 | autocmd BufWritePre * undojoin | Neoformat 207 | augroup END 208 | < 209 | 210 | When |undojoin| is used this way pressing |u| will "skip over" the Neoformat 211 | changes - it will revert both the changes made by Neoformat and the change 212 | that caused Neoformat to be invoked. 213 | 214 | ============================================================================== 215 | SUPPORTED FILETYPES *neoformat-supported-filetypes* 216 | 217 | - Arduino 218 | - [`uncrustify`](http://uncrustify.sourceforge.net), 219 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 220 | [`astyle`](http://astyle.sourceforge.net) 221 | - Assembly 222 | - [`asmfmt`](https://github.com/klauspost/asmfmt) 223 | - Astro 224 | - [`prettier`](https://github.com/withastro/prettier-plugin-astro/) 225 | - Bazel 226 | - [`buildifier`](https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md) 227 | - Beancount 228 | - [`bean-format`](https://beancount.github.io/docs/running_beancount_and_generating_reports.html#bean-format) 229 | - Bib 230 | - [bibtex-tidy](https://github.com/FlamingTempura/bibtex-tidy) 231 | - [bibclean](https://github.com/tobywf/bibclean) 232 | - C 233 | - [`uncrustify`](http://uncrustify.sourceforge.net), 234 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 235 | [`astyle`](http://astyle.sourceforge.net) 236 | - C# 237 | - [`uncrustify`](http://uncrustify.sourceforge.net), 238 | [`astyle`](http://astyle.sourceforge.net) 239 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html) 240 | [`csharpier`](https://csharpier.com/) 241 | - C++ 242 | - [`uncrustify`](http://uncrustify.sourceforge.net), 243 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 244 | [`astyle`](http://astyle.sourceforge.net) 245 | - Cabal 246 | - [`cabal-fmt`](https://github.com/phadej/cabal-fmt) 247 | - CMake 248 | - [`cmake_format`](https://github.com/cheshirekow/cmake_format) 249 | - Crystal 250 | - `crystal tool format` (ships with [`crystal`](http://crystal-lang.org)) 251 | - CSS 252 | - `css-beautify` (ships with [`js-beautify`](https://github.com/beautify-web/js-beautify)), 253 | [`prettierd`](https://github.com/fsouza/prettierd), 254 | [`prettier`](https://github.com/prettier/prettier), 255 | [`prettydiff`](https://github.com/prettydiff/prettydiff), 256 | [`stylefmt`](https://github.com/morishitter/stylefmt), 257 | [`stylelint`](https://stylelint.io/), 258 | [`csscomb`](http://csscomb.com) 259 | - CSV 260 | - [`prettydiff`](https://github.com/prettydiff/prettydiff) 261 | - Cue 262 | - [`cue fmt`](https://cuelang.org/) 263 | - D 264 | - [`uncrustify`](http://uncrustify.sourceforge.net), 265 | [`dfmt`](https://github.com/Hackerpilot/dfmt) 266 | - Dart 267 | - [`dartfmt`](https://www.dartlang.org/tools/) 268 | - [`dart format`](https://dart.dev/tools/dart-format) 269 | - Dhall 270 | - [`dhall format`](https://dhall-lang.org) 271 | - dune 272 | - [`dune format`](https://github.com/ocaml/dune) 273 | - Elixir 274 | - [mix format](https://hexdocs.pm/mix/master/Mix.Tasks.Format.html) 275 | - Elm 276 | - [`elm-format`](https://github.com/avh4/elm-format) 277 | - Eruby 278 | - [`htmlbeautifier`](https://github.com/threedaymonk/htmlbeautifier) 279 | - Erlang 280 | - [`erlfmt`](https://github.com/WhatsApp/erlfmt) 281 | - Fish 282 | - [`fish_indent`](http://fishshell.com) 283 | - Fortran 284 | - [`fprettify`](https://github.com/pseewald/fprettify) 285 | - F# 286 | - [`fantomas`](https://github.com/fsprojects/fantomas) 287 | - GDScript 288 | - [`gdformat`](https://github.com/Scony/godot-gdscript-toolkit) 289 | - Gleam 290 | - [gleam format](https://github.com/gleam-lang/gleam/) 291 | - Go 292 | - [`gofmt`](https://golang.org/cmd/gofmt/), 293 | [`goimports`](https://godoc.org/golang.org/x/tools/cmd/goimports), 294 | [`gofumpt`](https://github.com/mvdan/gofumpt), 295 | [`gofumports`](https://github.com/mvdan/gofumpt) 296 | - GLSL 297 | - [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html) 298 | - GN 299 | - [`gn`](http://gn.googlesource.com/gn) 300 | - GraphQL 301 | - [`prettierd`](https://github.com/fsouza/prettierd), 302 | [`prettier`](https://github.com/prettier/prettier) 303 | - Haskell 304 | - [`stylishhaskell`](https://github.com/jaspervdj/stylish-haskell) 305 | - [`hindent`](https://github.com/chrisdone/hindent) 306 | - [`hfmt`](https://github.com/danstiner/hfmt) 307 | - [`brittany`](https://github.com/lspitzner/brittany) 308 | - [`sortimports`](https://github.com/evanrelf/sort-imports) 309 | - [`floskell`](https://github.com/ennocramer/floskell) 310 | - [`ormolu`](https://github.com/tweag/ormolu) 311 | `let g:ormolu_ghc_opt=["TypeApplications", "RankNTypes"]` 312 | - You must use formatter's name without "`-`" 313 | " right 314 | let g:neoformat_enabled_haskell = ['sortimports', 'stylishhaskell'] 315 | " wrong 316 | let g:neoformat_enabled_haskell = ['sort-imports', 'stylish-haskell'] 317 | - HCL 318 | - [`hclfmt`](https://github.com/hashicorp/hcl) 319 | - Puppet 320 | - [`puppet-lint`](https://github.com/rodjek/puppet-lint) 321 | - PureScript 322 | - [`purs-tidy`](https://github.com/natefaubion/purescript-tidy) 323 | - [`purty`](https://gitlab.com/joneshf/purty) 324 | - HTML 325 | - `html-beautify` (ships with [`js-beautify`](https://github.com/beautify-web/js-beautify)), 326 | [`prettierd`](https://github.com/fsouza/prettierd), 327 | [`prettier`](https://github.com/jlongster/prettier), 328 | [`prettydiff`](https://github.com/prettydiff/prettydiff) 329 | - HTMLDjango 330 | - [djlint](https://djlint.com/) 331 | - Jade 332 | - [`pug-beautifier`](https://github.com/vingorius/pug-beautifier) 333 | - Java 334 | - [`uncrustify`](http://uncrustify.sourceforge.net), 335 | [`astyle`](http://astyle.sourceforge.net) 336 | [`prettierd`](https://github.com/fsouza/prettierd), 337 | [`prettier`](https://github.com/prettier/prettier) 338 | - JavaScript 339 | - [`js-beautify`](https://github.com/beautify-web/js-beautify), 340 | [`prettierd`](https://github.com/fsouza/prettierd), 341 | [`prettier`](https://github.com/jlongster/prettier), 342 | [`prettydiff`](https://github.com/prettydiff/prettydiff), 343 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 344 | [`esformatter`](https://github.com/millermedeiros/esformatter/), 345 | [`prettier-eslint`](https://github.com/kentcdodds/prettier-eslint-cli), 346 | [`eslint_d`](https://github.com/mantoni/eslint_d.js), 347 | [`standard`](https://standardjs.com/), 348 | [`semistandard`](https://github.com/standard/semistandard), 349 | [`deno fmt`](https://deno.land/manual/tools/formatter), 350 | [`biome`](https://biomejs.dev) 351 | - JSON 352 | - [`js-beautify`](https://github.com/beautify-web/js-beautify), 353 | [`prettydiff`](https://github.com/prettydiff/prettydiff), 354 | [`prettierd`](https://github.com/fsouza/prettierd), 355 | [`prettier`](https://github.com/prettier/prettier), 356 | [`jq`](https://stedolan.github.io/jq/), 357 | [`fixjson`](https://github.com/rhysd/fixjson), 358 | [`deno fmt`](https://deno.land/manual/tools/formatter), 359 | [`topiary`](https://topiary.tweag.io), 360 | [`biome`](https://biomejs.dev) 361 | - Kotlin 362 | - [`ktlint`](https://github.com/shyiko/ktlint) 363 | [`prettierd`](https://github.com/fsouza/prettierd), 364 | [`prettier`](https://github.com/prettier/prettier) 365 | - LaTeX 366 | - [`latexindent`](https://github.com/cmhughes/latexindent.pl) 367 | - Less 368 | - [`csscomb`](http://csscomb.com), 369 | [`prettierd`](https://github.com/fsouza/prettierd), 370 | [`prettier`](https://github.com/prettier/prettier), 371 | [`prettydiff`](https://github.com/prettydiff/prettydiff), 372 | [`stylelint`](https://stylelint.io/) 373 | - Lua 374 | - [`luaformatter`](https://github.com/LuaDevelopmentTools/luaformatter) 375 | - [`lua-fmt`](https://github.com/trixnz/lua-fmt) 376 | - [`lua-format`](https://github.com/Koihik/LuaFormatter) 377 | - [`stylua`](https://github.com/JohnnyMorganz/StyLua) 378 | - Markdown 379 | - [`remark`](https://github.com/wooorm/remark) 380 | [`prettierd`](https://github.com/fsouza/prettierd), 381 | [`prettier`](https://github.com/prettier/prettier), 382 | [`deno fmt`](https://deno.land/manual/tools/formatter), 383 | [`mdformat`](https://github.com/executablebooks/mdformat) 384 | - Matlab 385 | - [`matlab-formatter-vscode`](https://github.com/affenwiesel/matlab-formatter-vscode) 386 | - Nginx 387 | - [nginxbeautifier](https://github.com/vasilevich/nginxbeautifier) 388 | - Nickel 389 | - [`topiary`](https://topiary.tweag.io) 390 | - Nim 391 | - nimpretty (ships with [nim](https://nim-lang.org/)), 392 | - Nix 393 | - [`nixfmt`](https://github.com/serokell/nixfmt) 394 | - [`nixpkgs-fmt`](https://github.com/nix-community/nixpkgs-fmt) 395 | - [`alejandra`](https://github.com/kamadorueda/alejandra) 396 | - Objective-C 397 | - [`uncrustify`](http://uncrustify.sourceforge.net), 398 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 399 | [`astyle`](http://astyle.sourceforge.net) 400 | - Objective-C++ 401 | - [`uncrustify`](http://uncrustify.sourceforge.net), 402 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 403 | [`astyle`](http://astyle.sourceforge.net) 404 | - OCaml 405 | - [`ocp-indent`](http://www.typerex.org/ocp-indent.html), 406 | [`ocamlformat`](https://github.com/ocaml-ppx/ocamlformat), 407 | [`topiary`](https://topiary.tweag.io) 408 | - OpenSCAD 409 | - [`openscad-format`](https://github.com/Maxattax97/openscad-format) 410 | - Pandoc Markdown 411 | - [`pandoc`](https://pandoc.org/MANUAL.html) 412 | - Pawn 413 | - [`uncrustify`](http://uncrustify.sourceforge.net) 414 | - Perl 415 | - [`perltidy`](http://perltidy.sourceforge.net) 416 | - [`perlimports`](https://github.com/perl-ide/App-perlimports) 417 | - PHP 418 | - [`php_beautifier`](http://pear.php.net/package/PHP_Beautifier) 419 | - [`php-cs-fixer`](http://cs.sensiolabs.org/) 420 | - [`phpcbf`](https://github.com/squizlabs/PHP_CodeSniffer) 421 | - [`prettierd`](https://github.com/fsouza/prettierd), 422 | [`prettier`](https://github.com/prettier/plugin-php) 423 | - [`laravel-pint`](https://github.com/laravel/pint), 424 | - PowerShell 425 | - [`PSScriptAnalyzer`](https://github.com/PowerShell/PSScriptAnalyzer), 426 | [`PowerShell-Beautifier`](https://github.com/DTW-DanWard/PowerShell-Beautifier) 427 | - Prisma 428 | - [`prettier`](https://github.com/umidbekk/prettier-plugin-prisma) 429 | - Proto 430 | - [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html) 431 | - Pug (formally Jade) 432 | - [`pug-beautifier`](https://github.com/vingorius/pug-beautifier) 433 | - Python 434 | - [`yapf`](https://github.com/google/yapf), 435 | [`autopep8`](https://github.com/hhatto/autopep8), 436 | [`black`](https://github.com/psf/black), 437 | [`pydevf`](https://github.com/fabioz/PyDev.Formatter), 438 | [`isort`](https://github.com/timothycrosley/isort), 439 | [`docformatter`](https://github.com/myint/docformatter), 440 | [`pyment`](https://github.com/dadadel/pyment), 441 | [`ruff`](https://github.com/astral-sh/ruff) 442 | - R 443 | - [`styler`](https://github.com/r-lib/styler), 444 | [`formatR`](https://github.com/yihui/formatR) 445 | - Reason 446 | - [`refmt`](https://github.com/facebook/reason) 447 | - [`bsrefmt`](https://github.com/bucklescript/bucklescript) 448 | - Rego 449 | - [`opa fmt`](https://www.openpolicyagent.org/docs/latest/cli/#opa-fmt) 450 | - Ruby 451 | - [`rufo`](https://github.com/asterite/rufo) 452 | - [`ruby-beautify`](https://github.com/erniebrodeur/ruby-beautify) 453 | - [`rubocop`](https://github.com/rubocop/rubocop) 454 | - [`standard`](https://github.com/testdouble/standard) 455 | - [`prettier`](https://github.com/prettier/plugin-ruby) 456 | - Rust 457 | - [`rustfmt`](https://github.com/rust-lang-nursery/rustfmt), 458 | [`topiary`](https://topiary.tweag.io) 459 | - Sass 460 | - [`sass-convert`](http://sass-lang.com/documentation/#executables), 461 | [`stylelint`](https://stylelint.io/), 462 | [`csscomb`](http://csscomb.com) 463 | - Sbt 464 | - [`scalafmt`](http://scalameta.org/scalafmt/) 465 | - Scala 466 | - [`scalariform`](https://github.com/scala-ide/scalariform), 467 | [`scalafmt`](http://scalameta.org/scalafmt/) 468 | - SCSS 469 | - [`sass-convert`](http://sass-lang.com/documentation/#executables), 470 | [`stylefmt`](https://github.com/morishitter/stylefmt), 471 | [`stylelint`](https://stylelint.io/) 472 | [`prettierd`](https://github.com/fsouza/prettierd), 473 | [`prettier`](https://github.com/prettier/prettier), 474 | [`prettydiff`](https://github.com/prettydiff/prettydiff), 475 | [`csscomb`](http://csscomb.com) 476 | - Shell 477 | - [`shfmt`](https://github.com/mvdan/sh), 478 | [`topiary`](https://topiary.tweag.io) 479 | - Solidity 480 | - [`prettierd`](https://github.com/fsouza/prettierd), 481 | [`prettier`](https://github.com/prettier-solidity/prettier-plugin-solidity) 482 | - SQL 483 | - [`sqlfmt`](https://github.com/jackc/sqlfmt) 484 | - `sqlformat` (ships with [`sqlparse`](https://github.com/andialbrecht/sqlparse)) 485 | - `pg_format` (ships with [`pgFormatter`](https://github.com/darold/pgFormatter)) 486 | - [`sleek`](https://github.com/nrempel/sleek) 487 | - [`sql-formatter`](https://github.com/sql-formatter-org/sql-formatter) 488 | - Starlark 489 | - [`buildifier`](https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md) 490 | - SugarSS 491 | - [`stylelint`](https://stylelint.io/) 492 | - Svelte 493 | - [`prettierd`](https://github.com/fsouza/prettierd), 494 | [`prettier-plugin-svelte`](https://github.com/UnwrittenFun/prettier-plugin-svelte) 495 | - Swift 496 | - [`Swiftformat`](https://github.com/nicklockwood/SwiftFormat) 497 | - Terraform 498 | - [`terraform`](https://www.terraform.io/docs/commands/fmt.html) 499 | - TypeScript 500 | - [`tsfmt`](https://github.com/vvakame/typescript-formatter), 501 | [`prettierd`](https://github.com/fsouza/prettierd), 502 | [`prettier`](https://github.com/prettier/prettier), 503 | [`prettier-eslint`](https://github.com/kentcdodds/prettier-eslint-cli), 504 | [`tslint`](https://palantir.github.io/tslint) 505 | [`eslint_d`](https://github.com/mantoni/eslint_d.js) 506 | [`clang-format`](http://clang.llvm.org/docs/ClangFormat.html), 507 | [`deno fmt`](https://deno.land/manual/tools/formatter), 508 | [`biome`](https://biomejs.dev) 509 | - Typst 510 | - [`typstfmt`](https://github.com/astrale-sharp/typstfmt) 511 | [`typstyle`](https://github.com/Enter-tainer/typstyle) 512 | - Toml 513 | - [`taplo`](https://taplo.tamasfe.dev/cli/usage/formatting.html), 514 | [`topiary`](https://topiary.tweag.io) 515 | - V 516 | - `v fmt` (ships with [`v`](https://vlang.io)) 517 | - VALA 518 | - [`uncrustify`](http://uncrustify.sourceforge.net) 519 | - Vue 520 | - [`prettier`](https://github.com/prettier/prettier), 521 | [`prettierd`](https://github.com/fsouza/prettierd) 522 | - XHTML 523 | - [`tidy`](http://www.html-tidy.org), 524 | [`prettydiff`](https://github.com/prettydiff/prettydiff) 525 | - XML 526 | - [`tidy`](http://www.html-tidy.org), 527 | [`prettydiff`](https://github.com/prettydiff/prettydiff) 528 | [`prettier`](https://github.com/prettier/prettier), 529 | [`prettierd`](https://github.com/fsouza/prettierd), 530 | [`xmllint`](https://gitlab.gnome.org/GNOME/libxml2) 531 | - YAML 532 | - [`pyaml`](https://pypi.python.org/pypi/pyaml), 533 | [`prettier`](https://github.com/prettier/prettier), 534 | [`prettierd`](https://github.com/fsouza/prettierd), 535 | [`yamlfmt`](https://github.com/mmlb/yamlfmt) (by @mmlb), 536 | [`yamlfmt`](https://github.com/google/yamlfmt) (by @google), 537 | [`yamlfix`](https://github.com/lyz-code/yamlfix) 538 | - zig 539 | - [`zigformat`](https://github.com/Himujjal/zigformat) 540 | [`zig fmt`](https://github.com/ziglang/zig) 541 | - zsh 542 | - [`shfmt`](https://github.com/mvdan/sh) 543 | 544 | ============================================================================== 545 | vim:tw=78:ts=8:ft=help:norl:noet:fen:noet: 546 | 547 | -------------------------------------------------------------------------------- /plugin/neoformat.vim: -------------------------------------------------------------------------------- 1 | if exists("g:loaded_neoformat") 2 | finish 3 | endif 4 | let g:loaded_neoformat = 1 5 | 6 | command! -nargs=? -bar -range=% -bang -complete=customlist,neoformat#CompleteFormatters Neoformat 7 | \ call neoformat#Neoformat(0, , , ) 8 | -------------------------------------------------------------------------------- /test/.gitignore: -------------------------------------------------------------------------------- 1 | venv/ 2 | -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | # Neoformat Tests 2 | 3 | Running tests 4 | 5 | ```bash 6 | # inside test/ 7 | 8 | ./install.sh 9 | 10 | python3 -m virtualenv venv 11 | pip install -r requirements.txt 12 | 13 | pytest -v test.py 14 | ``` 15 | -------------------------------------------------------------------------------- /test/after/cp.cp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sbdchd/neoformat/33cab6962999ca74824ee6dc6e627f406139d6ee/test/after/cp.cp -------------------------------------------------------------------------------- /test/after/cssbeautify-indent-6.css: -------------------------------------------------------------------------------- 1 | .body { 2 | color: red; 3 | } 4 | -------------------------------------------------------------------------------- /test/after/cssbeautify.css: -------------------------------------------------------------------------------- 1 | .body { 2 | color: red; 3 | } 4 | -------------------------------------------------------------------------------- /test/after/csscomb.css: -------------------------------------------------------------------------------- 1 | .body 2 | { 3 | color: red; 4 | } 5 | -------------------------------------------------------------------------------- /test/after/prettydiff.css: -------------------------------------------------------------------------------- 1 | .body { 2 | color: red; 3 | } 4 | 5 | -------------------------------------------------------------------------------- /test/after/tsfmt.ts: -------------------------------------------------------------------------------- 1 | module Geometry { 2 | export class Square { 3 | constructor(public sideLength: number = 0) { 4 | } 5 | area() { 6 | return Math.pow(this.sideLength, 2); 7 | } 8 | } 9 | } 10 | 11 | class Tuple { 12 | constructor(public item1: T1, public item2: T2) { } 13 | } 14 | -------------------------------------------------------------------------------- /test/after/yapf.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | pass 3 | -------------------------------------------------------------------------------- /test/autocomplete_test.vim: -------------------------------------------------------------------------------- 1 | let s:tests = {} 2 | " Utilities 3 | function! s:Run(function) 4 | let o = &filetype 5 | " let output = call(a:function, ['']) 6 | " call function(a:function) 7 | let output = call(a:function, []) 8 | let &filetype = o 9 | " expecting output to either be a 1 or 0 10 | let s:tests[a:function[2:]] = output 11 | return output 12 | endfunction 13 | 14 | function! s:Cleanup() 15 | let error = 0 16 | for test in keys(s:tests) 17 | if !s:tests[test] 18 | let error = 1 19 | endif 20 | echom test . ' : ' . s:tests[test] 21 | endfor 22 | 23 | if error 24 | " make vim exit with a non-zero value 25 | cquit! 26 | else 27 | qall! 28 | endif 29 | endfunction 30 | 31 | " Test Definitions 32 | function! s:valid_option() 33 | let &filetype = 'python' 34 | 35 | let g:neoformat_python_enabled = ['autopep8', 'yapf'] 36 | let out = neoformat#CompleteFormatters('auto','', 0) 37 | 38 | return ['autopep8'] == out 39 | endfunction 40 | 41 | function! s:invalid_option() 42 | let &filetype = 'javascript' 43 | 44 | let g:neoformat_python_enabled = ['autopep8'] 45 | let out = neoformat#CompleteFormatters('autopep8', '', 0) 46 | 47 | return [] == out 48 | endfunction 49 | 50 | function! s:formtprg_option() 51 | let &filetype = 'javascript' 52 | let &formatprg = 'testing' 53 | let out = neoformat#CompleteFormatters('test', '', 0) 54 | 55 | return [] == out 56 | endfunction 57 | 58 | " Run Tests 59 | call s:Run('s:valid_option') 60 | call s:Run('s:invalid_option') 61 | call s:Run('s:formtprg_option') 62 | 63 | 64 | " Check the outputs 65 | call s:Cleanup() 66 | -------------------------------------------------------------------------------- /test/before/cp.cp: -------------------------------------------------------------------------------- 1 | 'test' 2 | -------------------------------------------------------------------------------- /test/before/cssbeautify.css: -------------------------------------------------------------------------------- 1 | .body { 2 | color: red; 3 | } 4 | -------------------------------------------------------------------------------- /test/before/csscomb.css: -------------------------------------------------------------------------------- 1 | .body { 2 | color: red; 3 | } 4 | -------------------------------------------------------------------------------- /test/before/prettydiff.css: -------------------------------------------------------------------------------- 1 | .body { 2 | color: red; 3 | } 4 | -------------------------------------------------------------------------------- /test/before/tsfmt.ts: -------------------------------------------------------------------------------- 1 | module Geometry { 2 | export class Square { 3 | constructor(public sideLength: number = 0) { 4 | } 5 | area() { 6 | return Math.pow(this.sideLength, 2); 7 | } 8 | } 9 | } 10 | 11 | class Tuple { 12 | constructor(public item1: T1, public item2: T2) { } 13 | } 14 | -------------------------------------------------------------------------------- /test/before/yapf.py: -------------------------------------------------------------------------------- 1 | def main(): 2 | pass 3 | -------------------------------------------------------------------------------- /test/bin/exit64: -------------------------------------------------------------------------------- 1 | exit 64 2 | -------------------------------------------------------------------------------- /test/install.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [[ $OSTYPE == darwin* ]]; then 4 | OS='mac' 5 | elif [[ $OSTYPE == linux-gnu* ]]; then 6 | OS='linux' 7 | else 8 | OS='unknown' 9 | fi 10 | 11 | # Formatters 12 | npm install -g csscomb@3.1.7 13 | npm install -g prettydiff@99.0.1 14 | npm install -g js-beautify@1.6.2 # for css-beautify 15 | npm install -g typescript@2.0.6 16 | npm install -g typescript-formatter@4.0.1 17 | pip install yapf==0.14.0 18 | 19 | # Linter(s) 20 | if ! hash vint 2>/dev/null; then 21 | pip3 install vim-vint 22 | fi 23 | 24 | # Make sure neovim is installed 25 | if ! hash nvim 2>/dev/null; then 26 | echo "installing neovim" 27 | if [[ $OS == 'linux' ]]; then 28 | echo "installing nvim on linux" 29 | sudo add-apt-repository -y ppa:neovim-ppa/unstable 30 | sudo apt-get update 31 | sudo apt-get install -y neovim 32 | elif [[ $OS == 'mac' ]]; then 33 | echo "install nvim on mac" 34 | brew install neovim 35 | fi 36 | else 37 | echo "neovim already installed" 38 | fi 39 | 40 | # Vader 41 | if [ ! -d "$HOME/.vim/plugged/vader.vim" ]; then 42 | git clone https://github.com/junegunn/vader.vim.git ~/.vim/plugged/vader.vim 43 | fi 44 | 45 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" 46 | export PATH=$PATH:"$DIR"/bin 47 | echo $PATH 48 | -------------------------------------------------------------------------------- /test/neoformat.vader: -------------------------------------------------------------------------------- 1 | Before: 2 | function! g:CmdOutput(cmd) 3 | redir => out 4 | silent exe a:cmd 5 | redir END 6 | return out[1:] 7 | endfunction 8 | 9 | Execute (empty filetype): 10 | let &filetype = '' 11 | let out = g:CmdOutput('Neoformat') 12 | AssertEqual 'Neoformat: formatter not defined for filetype', out 13 | 14 | Execute (filetype without defined formatter): 15 | let &filetype = 'not_real_filetype' 16 | let out = g:CmdOutput('Neoformat') 17 | 18 | AssertEqual 'Neoformat: formatter not defined for ' . &filetype . ' filetype', out 19 | 20 | Execute (formatter defined for other filetype, but is called via user cmd): 21 | let &filetype = 'javascript' 22 | let out = g:CmdOutput('Neoformat autopep8') 23 | 24 | AssertEqual 'Neoformat: formatter definition for autopep8 not found', out 25 | 26 | Execute (user disabled all formatters for current (python) filetype): 27 | let g:neoformat_enabled_python= [] 28 | let &filetype = 'python' 29 | let out = g:CmdOutput('Neoformat') 30 | 31 | AssertEqual 'Neoformat: formatter not defined for ' . &filetype . ' filetype', out 32 | 33 | Execute (user disabled all formatters for current (python) filetype): 34 | let g:neoformat_enabled_python= ['not_real_formatter'] 35 | let &filetype = 'python' 36 | let out = g:CmdOutput('Neoformat') 37 | 38 | AssertEqual 'Neoformat: no change necessary', out 39 | 40 | Execute (invalid user cmd: formatter not defined): 41 | let out = g:CmdOutput('Neoformat not_a_real_formatter') 42 | 43 | AssertEqual 'Neoformat: formatter definition for not_a_real_formatter not found', out 44 | -------------------------------------------------------------------------------- /test/requirements.txt: -------------------------------------------------------------------------------- 1 | py==1.4.32 2 | pytest==3.0.5 3 | -------------------------------------------------------------------------------- /test/test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3.6 2 | 3 | import subprocess 4 | 5 | from os import listdir 6 | from shutil import copyfile 7 | 8 | def run_vim_cmd(cmd, filename=''): 9 | cmd = f'nvim -u vimrc -c "set verbose=1 | {cmd} | wq " --headless {filename}' 10 | return run_cmd(cmd) 11 | 12 | 13 | def run_cmd(cmd): 14 | return subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True).wait() 15 | 16 | 17 | def readlines(filename): 18 | with open(filename) as f: 19 | return f.readlines() 20 | 21 | 22 | def test_formatters(): 23 | ''' 24 | run formatters on entire buffer 25 | ''' 26 | for filename in listdir('before'): 27 | output_file = '/tmp/neoformat_' + filename 28 | formatter = filename.split('.')[0] 29 | cmd = f'nvim -u vimrc -c "set verbose=1 | Neoformat {formatter} | w! {output_file} | q! " --headless ./before/{filename}' 30 | run_cmd(cmd) 31 | before = readlines(output_file) 32 | after = readlines('./after/' + filename) 33 | assert before == after 34 | 35 | 36 | def test_visual_selection_multi_filetype(): 37 | ''' 38 | Format different filetypes in one file 39 | ''' 40 | filename_before = 'visual_selection_before.txt' 41 | output_file = '/tmp/neoformat_' + filename_before 42 | copyfile(filename_before, output_file) 43 | 44 | for test in [('python', 4, 7), ('css', 9, 9), ('css', 14, 15)]: 45 | (filetype, start_line, end_line) = test 46 | print(start_line) 47 | vim_cmd = f'{start_line},{end_line}Neoformat! {filetype}' 48 | cmd = f'nvim -u vimrc -c "set verbose=1 | {vim_cmd} | wq " --headless {output_file}' 49 | run_cmd(cmd) 50 | 51 | before = readlines(output_file) 52 | after = readlines('visual_selection_after.txt') 53 | assert before == after 54 | 55 | 56 | def test_visual_selection_with_filetype_and_formatter(): 57 | ''' 58 | Test that passing filetype and formatter to Neoformat! works 59 | ''' 60 | dir_before = 'visual_before/' 61 | dir_after = 'visual_after/' 62 | for filename in listdir(dir_before): 63 | (filetype, formatter, start_line, end_line) = filename.split('_') 64 | output_file = '/tmp/neoformat_' + filename 65 | cmd = f'nvim -u vimrc -c "set verbose=1 | {start_line},{end_line}Neoformat! {filetype} {formatter} | w! {output_file} | q! " --headless {dir_before + filename}' 66 | run_cmd(cmd) 67 | before = readlines(output_file) 68 | after = readlines(dir_after + filename) 69 | assert before == after 70 | 71 | 72 | def test_formatprg_with_neoformat(): 73 | ''' 74 | Test that formatprg is processed by neoformat 75 | ''' 76 | 77 | dir_before = 'before/' 78 | filename = 'cssbeautify.css' 79 | output_file = '/tmp/neoformat_fmt_prg_' + filename 80 | viml = ''' 81 | let &formatprg = 'css-beautify -s 6 -n' 82 | let g:neoformat_try_formatprg = 1 83 | ''' 84 | cmd = f'nvim -u vimrc -c "set verbose=1 | {viml} | Neoformat | w! {output_file} | q! " --headless {dir_before + filename}' 85 | run_cmd(cmd) 86 | before = readlines(output_file) 87 | after = readlines('./after/cssbeautify-indent-6.css') 88 | assert before == after 89 | 90 | 91 | def test_formatprg_without_enable(): 92 | ''' 93 | Test that formatprg isn't use when not enabled 94 | ''' 95 | 96 | dir_before = 'before/' 97 | filename = 'cssbeautify.css' 98 | output_file = '/tmp/neoformat_fmtprg_not_enabled' + filename 99 | viml = ''' 100 | let &formatprg = 'css-beautify -s 6 -n' 101 | ''' 102 | cmd = f'nvim -u vimrc -c "set verbose=1 | {viml} | Neoformat | w! {output_file} | q! " --headless {dir_before + filename}' 103 | run_cmd(cmd) 104 | before = readlines(output_file) 105 | after = readlines('./after/cssbeautify.css') 106 | assert before == after 107 | 108 | 109 | def test_vader(): 110 | ''' 111 | run *.vader tests 112 | ''' 113 | cmd = f'nvim -u vimrc -c "Vader! *.vader" --headless' 114 | exit_code = run_cmd(cmd) 115 | assert exit_code == 0 116 | 117 | 118 | def test_autocompletion(): 119 | ''' 120 | run the vim autocompletion tests 121 | ''' 122 | cmd = f'nvim -u vimrc -c "source autocomplete_test.vim" --headless' 123 | exit_code = run_cmd(cmd) 124 | assert exit_code == 0 125 | 126 | 127 | def test_viml_syntax(): 128 | ''' 129 | run vint to check vim syntax 130 | ''' 131 | exit_code = run_cmd('vint ../') 132 | assert exit_code == 0 133 | 134 | 135 | if __name__ == '__main__': 136 | # run all functions with names in the form of 'test_...' 137 | [func() for func in (val for key, val in vars().items() 138 | if key.startswith('test_'))] 139 | -------------------------------------------------------------------------------- /test/utils.vader: -------------------------------------------------------------------------------- 1 | Before: 2 | function! g:CmdOutput(cmd) 3 | redir => out 4 | silent exe 'call ' . a:cmd 5 | redir END 6 | return out[1:] 7 | endfunction 8 | 9 | Execute (test log util): 10 | let g:neoformat_verbose = 1 11 | let out = g:CmdOutput('neoformat#utils#log("test")') 12 | 13 | let g:neoformat_verbose = 0 14 | AssertEqual 'Neoformat: test', out 15 | 16 | Execute (test msg util): 17 | let g:neoformat_verbose = 0 18 | " vader persists g: variables between tests so we need to make sure it is zero 19 | let g:neoformat_only_msg_on_error = 0 20 | let out = g:CmdOutput('neoformat#utils#msg("test")') 21 | 22 | AssertEqual 'Neoformat: test', out 23 | 24 | Execute (test warn util): 25 | let g:neoformat_verbose = 0 26 | let out = g:CmdOutput('neoformat#utils#warn("test")') 27 | 28 | AssertEqual 'Neoformat: test', out 29 | 30 | Execute (msg when g:neoformat_only_msg_on_error is false): 31 | let g:neoformat_only_msg_on_error = 0 32 | 33 | let out = g:CmdOutput('neoformat#utils#msg("test")') 34 | 35 | AssertEqual 'Neoformat: test', out 36 | 37 | Execute (msg when g:neoformat_only_msg_on_error is true): 38 | let g:neoformat_only_msg_on_error = 1 39 | 40 | let out = g:CmdOutput('neoformat#utils#msg("test")') 41 | 42 | AssertEqual '', out 43 | 44 | Execute (msg when g:neoformat_only_msg_on_error is false): 45 | let g:neoformat_only_msg_on_error = 0 46 | 47 | let out = g:CmdOutput('neoformat#utils#warn("test")') 48 | 49 | AssertEqual 'Neoformat: test', out 50 | 51 | Execute (warn when g:neoformat_only_msg_on_error is true): 52 | let g:neoformat_only_msg_on_error = 1 53 | 54 | let out = g:CmdOutput('neoformat#utils#warn("test")') 55 | 56 | AssertEqual 'Neoformat: test', out 57 | -------------------------------------------------------------------------------- /test/vimrc: -------------------------------------------------------------------------------- 1 | filetype off 2 | set runtimepath+=$HOME/.vim/plugged/vader.vim 3 | set runtimepath+=../ 4 | filetype plugin indent on 5 | syntax enable 6 | autocmd! filetype css set shiftwidth=2 7 | autocmd! filetype python set shiftwidth=4 8 | autocmd! filetype javascript set shiftwidth=4 9 | autocmd! BufRead *.ts set filetype=typescript 10 | autocmd! BufRead *.cp set filetype=copy 11 | set nocompatible 12 | set noswapfile 13 | 14 | " seems like cp doesn't have standard exit codes 15 | let g:neoformat_copy_cp = { 16 | \ 'exe': 'exit64', 17 | \ 'valid_exit_codes': [1, 64], 18 | \ } 19 | -------------------------------------------------------------------------------- /test/visual_after/css_cssbeautify_3_4: -------------------------------------------------------------------------------- 1 | 2 | 3 | .test { 4 | color: blue; 5 | border: none; 6 | } 7 | 8 | 9 | -------------------------------------------------------------------------------- /test/visual_after/javascript_jsbeautify_3_4: -------------------------------------------------------------------------------- 1 | 2 | 3 | function main() { 4 | console.log('test') 5 | } 6 | -------------------------------------------------------------------------------- /test/visual_before/css_cssbeautify_3_4: -------------------------------------------------------------------------------- 1 | 2 | 3 | .test{color:blue; 4 | border:none;} 5 | 6 | 7 | -------------------------------------------------------------------------------- /test/visual_before/javascript_jsbeautify_3_4: -------------------------------------------------------------------------------- 1 | 2 | 3 | function main(){ 4 | console.log('test')} 5 | -------------------------------------------------------------------------------- /test/visual_selection_after.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | def main(): 5 | 6 | pass 7 | 8 | 9 | .body { 10 | color: red; 11 | } 12 | 13 | 14 | .textleft { 15 | text-align: left; 16 | } 17 | -------------------------------------------------------------------------------- /test/visual_selection_before.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | def main(): 5 | 6 | 7 | pass 8 | 9 | 10 | .body{color:red;} 11 | 12 | 13 | .textleft{ 14 | text-align:left;} 15 | --------------------------------------------------------------------------------