1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 12:50:04 +08:00

feat(bundle#neoformat): Update neoformat from 1a49552c to f1b6cd50

This commit is contained in:
Zhao Zuohong 2021-11-11 15:00:17 +08:00 committed by GitHub
parent f8280b55f7
commit 362485ea23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 289 additions and 52 deletions

View File

@ -11,7 +11,7 @@ In `bundle/` directory, there are two kinds of plugins: forked plugins without c
- [defx.nvim](https://github.com/Shougo/defx.nvim/tree/df5e6ea6734dc002919ea41786668069fa0b497d)
- [dein.vim](https://github.com/Shougo/dein.vim/tree/772ae08cef5e712b2b31b4aaee908fc853accd94)
- [neoformat](https://github.com/sbdchd/neoformat/tree/1a49552cdaddeaaa766a6f0016effe530634b39f)
- [neoformat](https://github.com/sbdchd/neoformat/tree/f1b6cd506b72be0a2aaf529105320ec929683920)
- [indent-blankline.nvim](https://github.com/lukas-reineke/indent-blankline.nvim/tree/17a83ea765831cb0cc64f768b8c3f43479b90bbe)
- [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig/tree/507f8a570ac2b8b8dabdd0f62da3b3194bf822f8)
- [deoplete-lsp](https://github.com/deoplete-plugins/deoplete-lsp/tree/6299a22bedfb4f814d95cb0010291501472f8fd0)

View File

@ -57,7 +57,9 @@ The `undojoin` command will put changes made by Neoformat into the same
[Managing Undo History](#managing-undo-history).
## Install
The best way to install Neoformat is with your favorite plugin manager for Vim, such as [vim-plug](https://github.com/junegunn/vim-plug):
```viml
Plug 'sbdchd/neoformat'
```
@ -74,16 +76,17 @@ Define custom formatters.
Options:
| name | description | default | optional / required |
| ------------------ | ----------------------------------------------------------------------------------------------------------------- | ------- | ------------------- |
| `exe` | the name the formatter executable in the path | n/a | **required** |
| `args` | list of arguments | \[] | optional |
| `replace` | overwrite the file, instead of updating the buffer | 0 | optional |
| `stdin` | send data to the stdin of the formatter | 0 | optional |
| `stderr` | capture stderr output from formatter | 0 | optional |
| `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 |
| `env` | list of environment variable definitions to be prepended to the formatter command | \[] | optional |
| `valid_exit_codes` | list of valid exit codes for formatters who do not respect common unix practices | \[0] | optional |
| name | description | default | optional / required |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | ------------------- |
| `exe` | the name the formatter executable in the path | n/a | **required** |
| `args` | list of arguments | \[] | optional |
| `replace` | overwrite the file, instead of updating the buffer | 0 | optional |
| `stdin` | send data to the stdin of the formatter | 0 | optional |
| `stderr` | capture stderr output from formatter | 0 | optional |
| `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 |
| `env` | list of environment variable definitions to be prepended to the formatter command | \[] | optional |
| `valid_exit_codes` | list of valid exit codes for formatters who do not respect common unix practices | \[0] | optional |
| `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 |
Example:
@ -155,6 +158,14 @@ let g:neoformat_verbose = 1 " only affects the verbosity of Neoformat
let &verbose = 1 " also increases verbosity of the editor as a whole
```
Have Neoformat look for a formatter executable in the `node_modules/.bin`
directory in the current working directory or one of its parents (only applies
to formatters with `try_node_exe` set to `1`):
```viml
let g:neoformat_try_node_exe = 1
```
## Adding a New Formatter
Note: you should replace everything `{{ }}` accordingly
@ -247,15 +258,23 @@ that caused Neoformat to be invoked.
[`prettier`](https://github.com/prettier/prettier)
- CSV
- [`prettydiff`](https://github.com/prettydiff/prettydiff)
- Cue
- [`cue fmt`](https://cuelang.org/)
- D
- [`uncrustify`](http://uncrustify.sourceforge.net),
[`dfmt`](https://github.com/Hackerpilot/dfmt)
- Dart
- [`dartfmt`](https://www.dartlang.org/tools/)
- [`dart format`](https://dart.dev/tools/dart-format)
- Dhall
- [`dhall format`](https://dhall-lang.org)
- dune
- [`dune format`](https://github.com/ocaml/dune)
- Ebuild
- [`shfmt`](https://github.com/mvdan/sh)
```vim
let g:shfmt_opt="-ci"
```
- Elixir
- [`mix format`](https://hexdocs.pm/mix/master/Mix.Tasks.Format.html)
- Elm
@ -264,6 +283,8 @@ that caused Neoformat to be invoked.
- [`erlfmt`](https://github.com/WhatsApp/erlfmt)
- Fish
- [`fish_indent`](http://fishshell.com)
- Fortran
- [`fprettify`](https://github.com/pseewald/fprettify)
- F#
- [`fantomas`](https://github.com/fsprojects/fantomas)
- GDScript
@ -297,9 +318,12 @@ that caused Neoformat to be invoked.
" wrong
let g:neoformat_enabled_haskell = ['sort-imports', 'stylish-haskell']
```
- Toml
- [`taplo`](https://taplo.tamasfe.dev/cli)
- Puppet
- [`puppet-lint`](https://github.com/rodjek/puppet-lint)
- PureScript
- [`purs-tidy`](https://github.com/natefaubion/purescript-tidy)
- [`purty`](https://gitlab.com/joneshf/purty)
- HTML
- `html-beautify` (ships with [`js-beautify`](https://github.com/beautify-web/js-beautify)),
@ -321,13 +345,17 @@ that caused Neoformat to be invoked.
[`eslint_d`](https://github.com/mantoni/eslint_d.js),
[`standard`](https://standardjs.com/),
[`semistandard`](https://github.com/standard/semistandard),
[`deno fmt`](https://deno.land/manual/tools/formatter),
[`deno fmt`](https://deno.land/manual/tools/formatter)
- JSON
- [`js-beautify`](https://github.com/beautify-web/js-beautify),
[`prettydiff`](https://github.com/prettydiff/prettydiff),
[`prettier`](https://github.com/prettier/prettier),
[`jq`](https://stedolan.github.io/jq/),
[`fixjson`](https://github.com/rhysd/fixjson)
[`deno fmt`](https://deno.land/manual/tools/formatter)
- JSONC (JSON with comments)
- [`prettier`](https://github.com/prettier/prettier)
[`deno fmt`](https://deno.land/manual/tools/formatter)
- Kotlin
- [`ktlint`](https://github.com/shyiko/ktlint),
[`prettier`](https://github.com/prettier/prettier)
@ -342,9 +370,11 @@ that caused Neoformat to be invoked.
- [`luaformatter`](https://github.com/LuaDevelopmentTools/luaformatter)
- [`lua-fmt`](https://github.com/trixnz/lua-fmt)
- [`lua-format`](https://github.com/Koihik/LuaFormatter)
- [`stylua`](https://github.com/JohnnyMorganz/StyLua)
- Markdown
- [`remark`](https://github.com/wooorm/remark)
[`prettier`](https://github.com/prettier/prettier)
[`deno fmt`](https://deno.land/manual/tools/formatter)
- Matlab
- [`matlab-formatter-vscode`](https://github.com/affenwiesel/matlab-formatter-vscode)
- Nginx

View File

@ -1,3 +1,6 @@
" Set global flag to allow checking in custom user config
let g:neoformat = 1
function! neoformat#Neoformat(bang, user_input, start_line, end_line) abort
let view = winsaveview()
let search = @/
@ -141,10 +144,10 @@ function! s:neoformat(bang, user_input, start_line, end_line) abort
endif
endfor
if len(formatters_failed) > 0
call neoformat#utils#msg('formatters ' . join(formatters_failed, ', ') . ' failed to run')
call neoformat#utils#msg('formatters ' . join(formatters_failed, ", ") . ' failed to run')
endif
if len(formatters_changed) > 0
call neoformat#utils#msg(join(formatters_changed, ', ') . ' formatted buffer')
call neoformat#utils#msg(join(formatters_changed, ", ") . ' formatted buffer')
elseif len(formatters_failed) == 0
call neoformat#utils#msg('no change necessary')
endif
@ -196,7 +199,7 @@ function! neoformat#CompleteFormatters(ArgLead, CmdLine, CursorPos) abort
\ "fnamemodify(v:val, ':t:r')"))),
\ "v:val =~? '^" . a:ArgLead . "'")
endif
if a:ArgLead =~# '[^A-Za-z0-9]'
if a:ArgLead =~ '[^A-Za-z0-9]'
return []
endif
let filetype = s:split_filetypes(&filetype)
@ -220,6 +223,15 @@ function! s:split_filetypes(filetype) abort
return split(a:filetype, '\.')[0]
endfunction
function! s:get_node_exe(exe) abort
let node_exe = findfile('node_modules/.bin/' . a:exe, getcwd() . ';')
if !empty(node_exe) && executable(node_exe)
return node_exe
endif
return a:exe
endfunction
function! s:generate_cmd(definition, filetype) abort
let executable = get(a:definition, 'exe', '')
if executable == ''
@ -227,8 +239,14 @@ function! s:generate_cmd(definition, filetype) abort
return {}
endif
if &shell =~# '\v%(powershell|pwsh)'
if system('[bool](Get-Command ' . executable . ' -ErrorAction SilentlyContinue)') !~# 'True'
if exists('g:neoformat_try_node_exe')
\ && g:neoformat_try_node_exe
\ && get(a:definition, 'try_node_exe', 0)
let executable = s:get_node_exe(executable)
endif
if &shell =~ '\v%(powershell|pwsh)'
if system('[bool](Get-Command ' . executable . ' -ErrorAction SilentlyContinue)') !~ 'True'
call neoformat#utils#log('executable: ' . executable . ' is not a cmdlet, function, script file, or an executable program')
return {}
endif
@ -250,8 +268,8 @@ function! s:generate_cmd(definition, filetype) abort
let filename = expand('%:t')
let tmp_dir = has('win32') ? expand('$TEMP/neoformat', 1) :
\ exists('$TMPDIR') ? expand('$TMPDIR/neoformat', 1) :
let tmp_dir = has('win32') ? expand('$TEMP/neoformat') :
\ exists('$TMPDIR') ? expand('$TMPDIR/neoformat') :
\ '/tmp/neoformat'
if !isdirectory(tmp_dir)
@ -259,7 +277,7 @@ function! s:generate_cmd(definition, filetype) abort
endif
if get(a:definition, 'replace', 0)
let path = !using_stdin ? expand(tmp_dir . '/' . fnameescape(filename), 1) : ''
let path = !using_stdin ? expand(tmp_dir . '/' . fnameescape(filename)) : ''
else
let path = !using_stdin ? tempname() : ''
endif

View File

@ -5,6 +5,8 @@ endfunction
function! neoformat#formatters#bzl#buildifier() abort
return {
\ 'exe': 'buildifier',
\ 'stdin': 1
\ 'args': ['-path', expand('%:p')],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -4,6 +4,8 @@ endfunction
function! neoformat#formatters#cmake#cmakeformat() abort
return {
\ 'exe': 'cmake-format'
\ 'exe': 'cmake-format',
\ 'args': ['-'],
\ 'stdin': 1,
\ }
endfunction

View File

@ -13,7 +13,8 @@ endfunction
function! neoformat#formatters#css#csscomb() abort
return {
\ 'exe': 'csscomb',
\ 'replace': 1
\ 'replace': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -34,6 +35,7 @@ function! neoformat#formatters#css#stylefmt() abort
return {
\ 'exe': 'stylefmt',
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -41,7 +43,8 @@ function! neoformat#formatters#css#prettier() abort
return {
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'css'],
\ 'stdin': 1
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -50,5 +53,6 @@ function! neoformat#formatters#css#stylelint() abort
\ 'exe': 'stylelint',
\ 'args': ['--fix', '--stdin-filename', '"%:t"'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -0,0 +1,11 @@
function! neoformat#formatters#cue#enabled() abort
return ['cue']
endfunction
function! neoformat#formatters#cue#cue() abort
return {
\ 'exe': 'cue',
\ 'args': ['fmt', '-'],
\ 'stdin': 1
\ }
endfunction

View File

@ -1,5 +1,5 @@
function! neoformat#formatters#dart#enabled() abort
return ['dartfmt']
return ['dartfmt', 'format']
endfunction
function! neoformat#formatters#dart#dartfmt() abort
@ -8,3 +8,11 @@ function! neoformat#formatters#dart#dartfmt() abort
\ 'stdin': 1,
\ }
endfunction
function! neoformat#formatters#dart#format() abort
return {
\ 'exe': 'dart',
\ 'args': ['format'],
\ 'replace': 1,
\ }
endfunction

View File

@ -0,0 +1,13 @@
function! neoformat#formatters#ebuild#enabled() abort
return ['shfmt']
endfunction
function! neoformat#formatters#ebuild#shfmt() abort
let opts = get(g:, 'shfmt_opt', '')
return {
\ 'exe': 'shfmt',
\ 'args': ['-i ' . (&expandtab ? shiftwidth() : 0), opts],
\ 'stdin': 1,
\ }
endfunction

View File

@ -7,5 +7,6 @@ function! neoformat#formatters#elm#elmformat() abort
\ 'exe': 'elm-format',
\ 'args': ['--stdin', '--elm-version=0.19'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -0,0 +1,11 @@
function! neoformat#formatters#fortran#enabled() abort
return ['fprettify']
endfunction
function! neoformat#formatters#fortran#fprettify() abort
return {
\ 'exe': 'fprettify',
\ 'args': ['--silent'],
\ 'stdin': 1
\ }
endfunction

View File

@ -6,6 +6,7 @@ function! neoformat#formatters#graphql#prettier() abort
return {
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'graphql'],
\ 'stdin': 1
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -11,7 +11,8 @@ function! neoformat#formatters#html#tidy() abort
\ '--vertical-space yes',
\ '--tidy-mark no',
\ '-wrap ' . &textwidth
\ ]
\ ],
\ 'try_node_exe': 1,
\ }
endfunction
@ -20,6 +21,7 @@ function! neoformat#formatters#html#prettier() abort
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -7,6 +7,7 @@ function! neoformat#formatters#javascript#jsbeautify() abort
\ 'exe': 'js-beautify',
\ 'args': ['--indent-size ' .shiftwidth()],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -14,7 +15,8 @@ function! neoformat#formatters#javascript#clangformat() abort
return {
\ 'exe': 'clang-format',
\ 'args': ['-assume-filename=' . expand('%:t')],
\ 'stdin': 1
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -34,6 +36,7 @@ function! neoformat#formatters#javascript#esformatter() abort
return {
\ 'exe': 'esformatter',
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -42,6 +45,7 @@ function! neoformat#formatters#javascript#prettier() abort
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -50,6 +54,7 @@ function! neoformat#formatters#javascript#prettiereslint() abort
\ 'exe': 'prettier-eslint',
\ 'args': ['--stdin', '--stdin-filepath', '"%:p"'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -58,6 +63,7 @@ function! neoformat#formatters#javascript#eslint_d() abort
\ 'exe': 'eslint_d',
\ 'args': ['--stdin', '--stdin-filename', '"%:p"', '--fix-to-stdout'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -66,6 +72,7 @@ function! neoformat#formatters#javascript#standard() abort
\ 'exe': 'standard',
\ 'args': ['--stdin','--fix'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -82,5 +89,6 @@ function! neoformat#formatters#javascript#semistandard() abort
\ 'exe': 'semistandard',
\ 'args': ['--stdin','--fix'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -7,6 +7,7 @@ function! neoformat#formatters#javascriptreact#jsbeautify() abort
\ 'exe': 'js-beautify',
\ 'args': ['--indent-size ' .shiftwidth()],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -26,6 +27,7 @@ function! neoformat#formatters#javascriptreact#esformatter() abort
return {
\ 'exe': 'esformatter',
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -34,6 +36,7 @@ function! neoformat#formatters#javascriptreact#prettier() abort
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -42,6 +45,7 @@ function! neoformat#formatters#javascriptreact#prettiereslint() abort
\ 'exe': 'prettier-eslint',
\ 'args': ['--stdin', '--stdin-filepath', '"%:p"'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -50,6 +54,7 @@ function! neoformat#formatters#javascriptreact#eslint_d() abort
\ 'exe': 'eslint_d',
\ 'args': ['--stdin', '--stdin-filename', '"%:p"', '--fix-to-stdout'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -58,6 +63,7 @@ function! neoformat#formatters#javascriptreact#standard() abort
\ 'exe': 'standard',
\ 'args': ['--stdin','--fix'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -74,5 +80,6 @@ function! neoformat#formatters#javascriptreact#semistandard() abort
\ 'exe': 'semistandard',
\ 'args': ['--stdin','--fix'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -1,5 +1,5 @@
function! neoformat#formatters#json#enabled() abort
return ['jsbeautify', 'prettydiff', 'prettier', 'jq', 'fixjson']
return ['jsbeautify', 'prettydiff', 'prettier', 'jq', 'fixjson', 'denofmt']
endfunction
function! neoformat#formatters#json#jsbeautify() abort
@ -20,8 +20,9 @@ endfunction
function! neoformat#formatters#json#prettier() abort
return {
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'json'],
\ 'args': ['--stdin-filepath', '"%:p"'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -31,5 +32,14 @@ function! neoformat#formatters#json#fixjson() abort
\ 'exe': 'fixjson',
\ 'args': ['--stdin-filename', l:filename],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
function! neoformat#formatters#json#denofmt() abort
return {
\ 'exe': 'deno',
\ 'args': ['fmt','-'],
\ 'stdin': 1,
\ }
endfunction

View File

@ -0,0 +1,20 @@
function! neoformat#formatters#jsonc#enabled() abort
return ['prettier', 'denofmt']
endfunction
function! neoformat#formatters#jsonc#prettier() abort
return {
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
function! neoformat#formatters#jsonc#denofmt() abort
return {
\ 'exe': 'deno',
\ 'args': ['fmt','-'],
\ 'stdin': 1,
\ }
endfunction

View File

@ -1,5 +1,5 @@
function! neoformat#formatters#lua#enabled() abort
return ['luaformatter', 'luafmt', 'luaformat']
return ['luaformatter', 'luafmt', 'luaformat', 'stylua']
endfunction
function! neoformat#formatters#lua#luaformatter() abort
@ -21,3 +21,11 @@ function! neoformat#formatters#lua#luaformat() abort
\ 'exe': 'lua-format'
\ }
endfunction
function! neoformat#formatters#lua#stylua() abort
return {
\ 'exe': 'stylua',
\ 'args': ['--search-parent-directories', '--stdin-filepath', '"%:p"', '--', '-'],
\ 'stdin': 1,
\ }
endfunction

View File

@ -1,5 +1,5 @@
function! neoformat#formatters#markdown#enabled() abort
return ['remark', 'prettier']
return ['remark', 'prettier', 'denofmt']
endfunction
function! neoformat#formatters#markdown#prettier() abort
@ -7,6 +7,7 @@ function! neoformat#formatters#markdown#prettier() abort
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -15,5 +16,14 @@ function! neoformat#formatters#markdown#remark() abort
\ 'exe': 'remark',
\ 'args': ['--no-color', '--silent'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
function! neoformat#formatters#markdown#denofmt() abort
return {
\ 'exe': 'deno',
\ 'args': ['fmt','-'],
\ 'stdin': 1,
\ }
endfunction

View File

@ -1,5 +1,14 @@
function! neoformat#formatters#purescript#enabled() abort
return ['purty']
return ['purstidy', 'purty']
endfunction
function! neoformat#formatters#purescript#purstidy() abort
return {
\ 'exe': 'purs-tidy',
\ 'args': ['format'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
function! neoformat#formatters#purescript#purty() abort
@ -7,5 +16,6 @@ function! neoformat#formatters#purescript#purty() abort
\ 'exe': 'purty',
\ 'args': ['-'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -7,6 +7,7 @@ function! neoformat#formatters#reason#refmt() abort
\ 'exe': 'refmt',
\ 'stdin': 1,
\ 'args': ["--interface=" . (expand('%:e') == "rei" ? "true" : "false")],
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -5,10 +5,6 @@ endfunction
function! neoformat#formatters#rust#rustfmt() abort
return {
\ 'exe': 'rustfmt',
\ 'args': ['--config hard_tabs=' . (&expandtab ? 'false' : 'true') .
\ ',tab_spaces=' . shiftwidth() .
\ ',max_width=' . &textwidth
\ ],
\ 'stdin': 1,
\ }
endfunction

View File

@ -7,6 +7,7 @@ function! neoformat#formatters#sass#sassconvert() abort
\ 'exe': 'sass-convert',
\ 'args': ['-F sass', '-T sass', '-s'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -7,6 +7,7 @@ function! neoformat#formatters#scss#sassconvert() abort
\ 'exe': 'sass-convert',
\ 'args': ['-F scss', '-T scss', '--indent ' . (&expandtab ? shiftwidth() : 't')],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -4,7 +4,9 @@ endfunction
function! neoformat#formatters#starlark#buildifier() abort
return {
\ 'exe': 'buildifier',
\ 'stdin': 1
\ }
\ 'exe': 'buildifier',
\ 'args': ['-path', expand('%:p')],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -5,7 +5,8 @@ endfunction
function! neoformat#formatters#svelte#prettier() abort
return {
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '--parser=svelte', '--plugin-search-dir=.', '"%:p"'],
\ 'args': ['--stdin-filepath', '"%:p"', '--parser=svelte', '--plugin-search-dir=.'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -5,7 +5,7 @@ endfunction
function! neoformat#formatters#tex#latexindent() abort
return {
\ 'exe': 'latexindent',
\ 'args': ['-sl', '-g /dev/stderr', '2>/dev/null'],
\ 'args': ['-g /dev/stderr', '2>/dev/null'],
\ 'stdin': 1,
\ }
endfunction

View File

@ -0,0 +1,11 @@
function! neoformat#formatters#tf() abort
return ['tf']
endfunction
function! neoformat#formatters#tfm#tf() abort
return {
\ 'exe': 'terraform',
\ 'args': ['fmt', '-write', '-'],
\ 'stdin': 1
\ }
endfunction

View File

@ -0,0 +1,12 @@
function! neoformat#formatters#toml#enabled() abort
return ['taplo']
endfunction
function! neoformat#formatters#toml#taplo() abort
return {
\ 'exe': 'taplo',
\ 'args': ['fmt', '-'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -6,7 +6,8 @@ function! neoformat#formatters#typescript#tsfmt() abort
return {
\ 'exe': 'tsfmt',
\ 'args': ['--replace', '--baseDir=%:h'],
\ 'replace': 1
\ 'replace': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -14,7 +15,8 @@ function! neoformat#formatters#typescript#prettier() abort
return {
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'typescript'],
\ 'stdin': 1
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -23,6 +25,7 @@ function! neoformat#formatters#typescript#prettiereslint() abort
\ 'exe': 'prettier-eslint',
\ 'args': ['--stdin', '--stdin-filepath', '"%:p"', '--parser', 'typescript'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -36,7 +39,8 @@ function! neoformat#formatters#typescript#tslint() abort
return {
\ 'exe': 'tslint',
\ 'args': args,
\ 'replace': 1
\ 'replace': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -45,6 +49,7 @@ function! neoformat#formatters#typescript#eslint_d() abort
\ 'exe': 'eslint_d',
\ 'args': ['--stdin', '--stdin-filename', '"%:p"', '--fix-to-stdout'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -52,7 +57,8 @@ function! neoformat#formatters#typescript#clangformat() abort
return {
\ 'exe': 'clang-format',
\ 'args': ['-assume-filename=' . expand('%:t')],
\ 'stdin': 1
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -6,7 +6,8 @@ function! neoformat#formatters#typescriptreact#tsfmt() abort
return {
\ 'exe': 'tsfmt',
\ 'args': ['--replace', '--baseDir=%:h'],
\ 'replace': 1
\ 'replace': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -14,7 +15,8 @@ function! neoformat#formatters#typescriptreact#prettier() abort
return {
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'typescript'],
\ 'stdin': 1
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -23,6 +25,7 @@ function! neoformat#formatters#typescriptreact#prettiereslint() abort
\ 'exe': 'prettier-eslint',
\ 'args': ['--stdin', '--stdin-filepath', '"%:p"', '--parser', 'typescript'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -36,7 +39,8 @@ function! neoformat#formatters#typescriptreact#tslint() abort
return {
\ 'exe': 'tslint',
\ 'args': args,
\ 'replace': 1
\ 'replace': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -45,6 +49,7 @@ function! neoformat#formatters#typescriptreact#eslint_d() abort
\ 'exe': 'eslint_d',
\ 'args': ['--stdin', '--stdin-filename', '"%:p"', '--fix-to-stdout'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -52,7 +57,8 @@ function! neoformat#formatters#typescriptreact#clangformat() abort
return {
\ 'exe': 'clang-format',
\ 'args': ['-assume-filename=' . expand('%:t')],
\ 'stdin': 1
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -6,6 +6,7 @@ function! neoformat#formatters#vue#prettier() abort
return {
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'vue'],
\ 'stdin': 1
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -13,6 +13,7 @@ function! neoformat#formatters#xhtml#tidy() abort
\ '--tidy-mark no'
\ ],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -13,6 +13,7 @@ function! neoformat#formatters#xml#tidy() abort
\ '--tidy-mark no'
\ ],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction
@ -25,6 +26,7 @@ function! neoformat#formatters#xml#prettier() abort
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"'],
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -14,6 +14,7 @@ function! neoformat#formatters#yaml#prettier() abort
return {
\ 'exe': 'prettier',
\ 'args': ['--stdin-filepath', '"%:p"', '--parser', 'yaml'],
\ 'stdin': 1
\ 'stdin': 1,
\ 'try_node_exe': 1,
\ }
endfunction

View File

@ -98,6 +98,7 @@ Options:
| `env` | list of environment variables to prepend to the command | default: [] | optional
| `valid_exit_codes` | list of valid exit codes for formatters who do not respect common unix practices | \[0] | optional
| `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
Example:
@ -150,6 +151,13 @@ When debugging, you can enable either of following variables for extra logging.
" Or
let &verbose = 1 " also increases verbosity of the editor as a whole
<
Have Neoformat look for a formatter executable in the `node_modules/.bin`
directory in the current working directory or one of its parents (only applies
to formatters with `try_node_exe` set to `1`):
>
let g:neoformat_try_node_exe = 1
<
==============================================================================
ADDING A NEW FORMATTER *neoformat-adding-new-formatter*
@ -245,11 +253,14 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
[`csscomb`](http://csscomb.com)
- CSV
- [`prettydiff`](https://github.com/prettydiff/prettydiff)
- Cue
- [`cue fmt`](https://cuelang.org/)
- D
- [`uncrustify`](http://uncrustify.sourceforge.net),
[`dfmt`](https://github.com/Hackerpilot/dfmt)
- Dart
- [`dartfmt`](https://www.dartlang.org/tools/)
- [`dart format`](https://dart.dev/tools/dart-format)
- Dhall
- [`dhall format`](https://dhall-lang.org)
- dune
@ -262,6 +273,8 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
- [`erlfmt`](https://github.com/WhatsApp/erlfmt)
- Fish
- [`fish_indent`](http://fishshell.com)
- Fortran
- [`fprettify`](https://github.com/pseewald/fprettify)
- F#
- [`fantomas`](https://github.com/fsprojects/fantomas)
- GDScript
@ -294,6 +307,7 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
- Puppet
- [`puppet-lint`](https://github.com/rodjek/puppet-lint)
- PureScript
- [`purs-tidy`](https://github.com/natefaubion/purescript-tidy)
- [`purty`](https://gitlab.com/joneshf/purty)
- HTML
- `html-beautify` (ships with [`js-beautify`](https://github.com/beautify-web/js-beautify)),
@ -322,6 +336,7 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
[`prettier`](https://github.com/prettier/prettier),
[`jq`](https://stedolan.github.io/jq/),
[`fixjson`](https://github.com/rhysd/fixjson)
[`deno fmt`](https://deno.land/manual/tools/formatter)
- Kotlin
- [`ktlint`](https://github.com/shyiko/ktlint)
[`prettier`](https://github.com/prettier/prettier)
@ -336,9 +351,11 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
- [`luaformatter`](https://github.com/LuaDevelopmentTools/luaformatter)
- [`lua-fmt`](https://github.com/trixnz/lua-fmt)
- [`lua-format`](https://github.com/Koihik/LuaFormatter)
- [`stylua`](https://github.com/JohnnyMorganz/StyLua)
- Markdown
- [`remark`](https://github.com/wooorm/remark)
[`prettier`](https://github.com/prettier/prettier),
[`deno fmt`](https://deno.land/manual/tools/formatter)
- Matlab
- [`matlab-formatter-vscode`](https://github.com/affenwiesel/matlab-formatter-vscode)
- Nginx
@ -430,6 +447,8 @@ SUPPORTED FILETYPES *neoformat-supported-filetypes*
[`eslint_d`](https://github.com/mantoni/eslint_d.js)
[`clang-format`](http://clang.llvm.org/docs/ClangFormat.html),
[`deno fmt`](https://deno.land/manual/tools/formatter)
- Toml
- [`taplo`](https://taplo.tamasfe.dev/cli)
- V
- `v fmt` (ships with [`v`](https://vlang.io))
- VALA

0
bundle/neoformat/test/bin/exit64 Normal file → Executable file
View File

0
bundle/neoformat/test/install.sh Normal file → Executable file
View File