Skip to content

xojs/vim-xo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vim-xo

Vim plugin for XO that provides Syntastic integration

Install

Using Pathogen

$ git clone --depth=1 https://github.com/xojs/vim-xo ~/.vim/bundle/vim-xo

Using Vundle

  1. Add Plugin 'xojs/vim-xo' to ~/.vimrc
  2. :PluginInstall or $ vim +PluginInstall +qall

Using NeoBundle

  1. Add NeoBundle 'xojs/vim-xo' to ~/.vimrc
  2. Re-open vim or execute :source ~/.vimrc

Using vim-plug

  1. Add Plug 'xojs/vim-xo' to ~/.vimrc
  2. :PlugInstall or $ vim +PlugInstall +qall

Features

Linting with Syntastic

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

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.

License

MIT © Sindre Sorhus