Skip to content

Commit

Permalink
added ruby formatter, updated readme + minor changes 🐙
Browse files Browse the repository at this point in the history
  • Loading branch information
sbdchd committed Mar 15, 2016
1 parent 0ce6db0 commit 9066aa1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,27 @@
A [Neovim](https://neovim.io) plugin for formatting code.

Neoformat uses a variety of formatters for differing filetypes. Currently, Neoformat
will run a formatter *asynchronously*, and if succeeds it will update the current
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](https://github.com/fatih/vim-go).

## Current Issues

In order to preserve marks, jumps, etc., Neoformat uses the `setline()` in Vim to
In order to preserve marks, jumps, etc., Neoformat uses the `setline()` function in Vim to
input the formatted text. If the buffer is changed before the formatter has completed,
then the updated text will be put into the current buffer.

So don't switch buffers while formatting!

## Supported Filetypes

- javascript: [jsbeautify](https://github.com/beautify-web/js-beautify)
- python: [autopep8](https://github.com/hhatto/autopep8)
- go: gofmt, goimports
- javascript
- [jsbeautify](https://github.com/beautify-web/js-beautify)
- python
- [autopep8](https://github.com/hhatto/autopep8)
- go
- [gofmt](https://golang.org/cmd/gofmt/), [goimports](https://godoc.org/golang.org/x/tools/cmd/goimports)
- ruby
- [ruby-beautify](https://github.com/erniebrodeur/ruby-beautify)
7 changes: 5 additions & 2 deletions autoload/neoformat.vim
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ endfunction


function! g:neoformat#Neoformat(start) abort
if !has('nvim')
echom 'Neoformat: Neovim is currently required to run this plugin'
return
endif

" start argument is used for selecting different formatters
" usually after the first one fails
if !exists('a:start')
Expand Down Expand Up @@ -198,5 +203,3 @@ function! g:neoformat#Neoformat(start) abort

call g:neoformat#NeoformatRun(l:cmd)
endfunction


8 changes: 8 additions & 0 deletions plugin/defaults.vim
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,11 @@ let g:neoformat#go#goimports = {
\ }

let g:neoformat#enabled#go = ['goimports', 'gofmt']

" Ruby
let g:neoformat#ruby#rubybeautify = {
\ 'exe': 'ruby-beautify',
\ 'flags': ['--spaces', '-c 2']
\ }

let g:neoformat#enabled#ruby = ['rubybeautify']

0 comments on commit 9066aa1

Please sign in to comment.