Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,20 @@ See the [null-ls documentation](https://github.com/jose-elias-alvarez/null-ls.nv

### Vim

1. Run `cargo build --release`
2. Add `source /path/to/rubyfmt.vim` to your `~/.vimrc`
3. Add `let g:rubyfmt_path = /path/to/target/release/rubyfmt-main` beneath the source line
vim-plug:

```vim
Plug 'fables-tales/rubyfmt', { 'rtp': 'editor_plugins/vim' }
```

Native packages:

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about vim native packages, does this work for users who do not use plug?

@robacarp robacarp Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm by no means a vim-plugin expert. My understanding is that tools like vim-plug, pathogen, etc, all handle the "fetching of code and putting it in place" while vim itself handles loading of the plugin through the autoload system or the packs system. Using vim-plug or pathogen benefits the user in that they're able to run one command and take updates to all the packages installed.

So the instructions for installing without a plugin tool are simply to download the plugin itself and place it in the correct place. The formatting and placement of the files within the plugin is standardized by vim itself.

That said, I tested these instructions both with the plug pattern and the native package and saw the tool work correctly in both cases.


```sh
git clone https://github.com/fables-tales/rubyfmt ~/.rubyfmt
ln -s ~/.rubyfmt/editor_plugins/vim ~/.vim/pack/rubyfmt/start/rubyfmt
```

Set `g:rubyfmt_path` if `rubyfmt` is not on your `$PATH`.

### RubyMine (and JetBrains IDEs)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
let s:cpo_save = &cpo
set cpo&vim

let g:rubyfmt_path = '/Users/penelope/dev/rubyfmt/target/release/rubyfmt-main'

function! rubyfmt#format() abort
let l:bin_args = [g:rubyfmt_path, '-i']
let l:curw = winsaveview()
Expand Down Expand Up @@ -69,10 +67,5 @@ function! rubyfmt#show_errors(errors) abort
echom a:errors
endfunction

if !exists("s:rubyfmt_ac_set")
let s:rubyfmt_ac_set=1
autocmd FileType ruby autocmd! BufWritePre <buffer> call rubyfmt#format()
endif

let &cpo = s:cpo_save
unlet s:cpo_save
21 changes: 21 additions & 0 deletions editor_plugins/vim/plugin/rubyfmt.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
if exists('g:loaded_rubyfmt')
finish
endif
let g:loaded_rubyfmt = 1

let s:cpo_save = &cpo
set cpo&vim

" Path to the rubyfmt binary. Defaults to whatever is on $PATH; override in
" your vimrc, e.g. let g:rubyfmt_path = '/path/to/target/release/rubyfmt-main'
if !exists('g:rubyfmt_path')
let g:rubyfmt_path = 'rubyfmt'
endif

if !exists("s:rubyfmt_ac_set")
let s:rubyfmt_ac_set=1
autocmd FileType ruby autocmd! BufWritePre <buffer> call rubyfmt#format()
endif

let &cpo = s:cpo_save
unlet s:cpo_save