forked from csscomb/vim-csscomb
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcsscomb.vim
More file actions
25 lines (21 loc) · 871 Bytes
/
csscomb.vim
File metadata and controls
25 lines (21 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"=============================================================================
" File: csscomb.vim
" Author: Aleksandr Batsuev (alex@batsuev.com)
" WebPage: https://github.com/batsuev/csscomb-vim
" License: MIT
let g:CSScombPluginDir = fnamemodify(expand("<sfile>"), ":h")
function! g:CSScomb(count, line1, line2)
let content = getline(a:line1, a:line2)
let tempFile = tempname() . '.' . &filetype
call writefile(content, tempFile)
let systemOutput = system('csscomb -c ~/.csscomb.json ' . shellescape(tempFile))
if len(systemOutput)
echoerr split(systemOutput, "\n")[1]
else
let lines = readfile(tempFile)
exec a:line1.",".a:line2."delete"
let a:line0 = a:line1-1
call append(a:line0, lines)
endif
endfunction
command! -nargs=? -range=% CSScomb :call g:CSScomb(<count>, <line1>, <line2>, <f-args>)