f030aaabf59d4cc296605f0b0b9840121510d24d
[webi-installers/.git] / vim-prettier / README.md
1 ---
2 title: vim-prettier
3 homepage: https://github.com/prettier/vim-prettier
4 tagline: |
5   vim-prettier adds Prettier support for Vim.
6 ---
7
8 To update (replacing the current version) run `webi vim-prettier`.
9
10 ## Cheat Sheet
11
12 > `vim-prettier` is a vim plugin wrapper for prettier, pre-configured with
13 > custom default prettier settings.
14
15 You'll also need `ALE`, [`syntastic`](https://webinstall.dev/vim-syntastic), or
16 similar.
17
18 ### How to install by hand
19
20 ```bash
21 git clone --depth=1 https://github.com/prettier/vim-prettier ~/.vim/pack/plugins/start/vim-prettier
22 ```
23
24 ### How to configure your `.vimrc`
25
26 ```vim
27 " don't check syntax immediately on open or on quit
28 let g:syntastic_check_on_open = 1
29 let g:syntastic_check_on_wq = 0
30
31 " we also want to get rid of accidental trailing whitespace on save
32 autocmd BufWritePre * :%s/\s\+$//e
33 ```
34
35 ```vim
36 """""""""""""""""""""""""""
37 " Prettier-specific options "
38 """""""""""""""""""""""""""
39
40 " format as-you-type is quite annoying, so we turn it off
41 let g:prettier#autoformat = 0
42
43 " list all of the extensions for which prettier should run
44 autocmd BufWritePre .babelrc,.eslintrc,.jshintrc,*.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
45 ```
46
47 ### How to install Prettier
48
49 With `webi`:
50
51 ```bash
52 webi prettier
53 ```
54
55 With `node`:
56
57 ```bash
58 npm install -g prettier@2
59 ```