A Neovim plugin for formatting code.
Neoformat uses a variety of formatters for differing filetypes. Currently, Neoformat will run a formatter asynchronously, and on success it will update the current buffer with the formatted text. On a formatter failure, Neoformat will try the next formatter defined for the filetype.
The job control is based off of vim-go's.
Format the current file using its filetype
:Neoformat
Or specify a filetype
:Neoformat python
In order to preserve marks, jumps, etc., Neoformat uses Vim's setline()
function
to insert the formatted text. If the buffer is changed before the formatter has
completed, then the updated text will be put into the current buffer.
To prevent this, format jobs are cancelled when changing / closing the buffer.
So don't switch buffers before the the formatting is complete!
Define custom formatters.
let g:neoformat_python_autopep8 = {
\ 'exe': 'autopep8'
\ }
let g:neoformat_enabled_python = ['autopep8']
Enable basic formatting when a filetype is not found. Disabled by default.
" Enable alignment
let g:neoformat_basic_format_align = 1
" Enable tab to spaces conversion
let g:neoformat_basic_format_retab = 1
" Enable trimmming of trailing whitespace
let g:neoformat_basic_format_trim = 1
- C
- C#
- C++
- CSS
- D
- Elm
- Go
- Haskell
- HTML
- Jade
- Java
- Javascript
- JSON
- Markdown
- Objective-C
- Pawn
- Pug (formally Jade)
- Python
- Ruby
- SASS
- SCSS
- SQL
- sqlformat (ships with sqlparse)
- Typescript
- VALA
- XHTML
- XML