Vim plugin for XO
$ git clone --depth=1 https://github.com/xojs/vim-xo ~/.vim/bundle/vim-xo
Plugin 'xojs/vim-xo'
to ~/.vimrc
:PluginInstall
or $ vim +PluginInstall +qall
NeoBundle 'xojs/vim-xo'
to ~/.vimrc
:source ~/.vimrc
Plug 'xojs/vim-xo'
to ~/.vimrc
:PlugInstall
or $ vim +PlugInstall +qall
This plugin automatically registers XO as a syntax checker with Syntastic.
To activate XO, put the following in your .vimrc
file:
let g:syntastic_javascript_checkers = ['xo']
let g:syntastic_typescript_checkers = ['xo']
See the Syntastic docs for more.
Formatting with vim-autoformat
will just work (since this plugin uses npx xo
).
You do not need to install xo
globally (and if it is installed globally, then please remove it as global installation is deprecated).
Once you install vim-autoformat
, you will need to add the following to your ~/.vimrc
:
+" vim-autoformatter
+" https://github.com/vim-autoformat/vim-autoformat
+let g:autoformat_autoindent = 0
+let g:autoformat_retab = 0
+let g:autoformat_remove_trailing_spaces = 0
+let g:formatters_javascript = [ 'xo_javascript' ]
+let g:formatters_typescript = [ 'xo_typescript' ]
If you'd like your code to be formatted on save (instead of typing :Autoformat
in vim buffer), then also add this line to your ~/.vimrc
:
+au BufWrite * :Autoformat
See vim-autoformat's "How to use" section for more information.
MIT © Sindre Sorhus