Skip to content

Commit 5e478d5

Browse files
authored
Simplifies installation into vim with a plugin (#907)
* Organizes the vim plugin into autoload and plugin * Updates vim install instructions in readme
1 parent 081d3af commit 5e478d5

3 files changed

Lines changed: 35 additions & 10 deletions

File tree

README.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,20 @@ See the [null-ls documentation](https://github.com/jose-elias-alvarez/null-ls.nv
127127

128128
### Vim
129129

130-
1. Run `cargo build --release`
131-
2. Add `source /path/to/rubyfmt.vim` to your `~/.vimrc`
132-
3. Add `let g:rubyfmt_path = /path/to/target/release/rubyfmt-main` beneath the source line
130+
vim-plug:
131+
132+
```vim
133+
Plug 'fables-tales/rubyfmt', { 'rtp': 'editor_plugins/vim' }
134+
```
135+
136+
Native packages:
137+
138+
```sh
139+
git clone https://github.com/fables-tales/rubyfmt ~/.rubyfmt
140+
ln -s ~/.rubyfmt/editor_plugins/vim ~/.vim/pack/rubyfmt/start/rubyfmt
141+
```
142+
143+
Set `g:rubyfmt_path` if `rubyfmt` is not on your `$PATH`.
133144

134145
### RubyMine (and JetBrains IDEs)
135146

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
let s:cpo_save = &cpo
22
set cpo&vim
33

4-
let g:rubyfmt_path = '/Users/penelope/dev/rubyfmt/target/release/rubyfmt-main'
5-
64
function! rubyfmt#format() abort
75
let l:bin_args = [g:rubyfmt_path, '-i']
86
let l:curw = winsaveview()
@@ -69,10 +67,5 @@ function! rubyfmt#show_errors(errors) abort
6967
echom a:errors
7068
endfunction
7169

72-
if !exists("s:rubyfmt_ac_set")
73-
let s:rubyfmt_ac_set=1
74-
autocmd FileType ruby autocmd! BufWritePre <buffer> call rubyfmt#format()
75-
endif
76-
7770
let &cpo = s:cpo_save
7871
unlet s:cpo_save
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
if exists('g:loaded_rubyfmt')
2+
finish
3+
endif
4+
let g:loaded_rubyfmt = 1
5+
6+
let s:cpo_save = &cpo
7+
set cpo&vim
8+
9+
" Path to the rubyfmt binary. Defaults to whatever is on $PATH; override in
10+
" your vimrc, e.g. let g:rubyfmt_path = '/path/to/target/release/rubyfmt-main'
11+
if !exists('g:rubyfmt_path')
12+
let g:rubyfmt_path = 'rubyfmt'
13+
endif
14+
15+
if !exists("s:rubyfmt_ac_set")
16+
let s:rubyfmt_ac_set=1
17+
autocmd FileType ruby autocmd! BufWritePre <buffer> call rubyfmt#format()
18+
endif
19+
20+
let &cpo = s:cpo_save
21+
unlet s:cpo_save

0 commit comments

Comments
 (0)