~gpanders/dotfiles

ref: 885174d3dacde7705891f7dc7934650f50697c87 dotfiles/vim/.vim/after/ftplugin/css.vim -rw-r--r-- 611 bytes
885174d3Greg Anders Update fzf configuration 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
" css filetype plugin
" Author: Greg Anders <greg@gpanders.com>

if &filetype !=# 'css'
  finish
endif

let g:css_format_on_write = 1

if executable('prettier')
  setlocal formatprg=prettier\ %
  let b:undo_ftplugin = get(b:, 'undo_ftplugin', '') . '|setl fp<'
  augroup css.vim.PreWrite
    autocmd!
    autocmd BufWritePre <buffer>
          \ if g:css_format_on_write |
          \   let view = winsaveview() |
          \   execute '%!' . &l:formatprg |
          \   call winrestview(view) |
          \   unlet view |
          \ endif
  augroup END
  let b:undo_ftplugin .= '|au! css.vim.PreWrite'
endif