Skip to content

Commit 497786f

Browse files
committed
Merge pull request csscomb#9 from faceleg/feature/javascript
Updated plugin to use the nodejs csscomb implementation
2 parents 4871f44 + 7f48e70 commit 497786f

File tree

4 files changed

+33
-1596
lines changed

4 files changed

+33
-1596
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,36 @@ For more info, online demo and tests see [csscomb.com](http://csscomb.com/)
1010

1111
## The Requirements
1212

13-
CSScomb is written in pure PHP, without any external libraries or dependencies.
14-
See details at [wiki](https://github.com/miripiruni/CSScomb/wiki/Requirements).
13+
CSScomb is written in pure JavaScript. Install with:
1514

15+
```BASH
16+
npm install -g csscomb
17+
```
1618

1719
## Installation
1820

1921
### With Pathogen
2022

2123
```
2224
cd ~/.vim/bundle
23-
git clone https://github.com/miripiruni/CSScomb-for-Vim.git
25+
git clone https://github.com/csscomb/vim-csscomb.git
2426
```
2527

2628
### With Vundle
2729
Add this to .vimrc:
2830
```
29-
Bundle 'git://github.com/miripiruni/CSScomb-for-Vim.git'
31+
Bundle 'git://github.com/csscomb/vim-csscomb.git'
32+
```
33+
34+
### With NeoBundle
35+
Add this to .vimrc:
36+
```
37+
NeoBundle 'csscomb/vim-csscomb'
3038
```
3139

3240
### Manual without plugins manager
3341
```
34-
git clone https://github.com/miripiruni/CSScomb-for-Vim.git csscomb
42+
git clone https://github.com/csscomb/vim-csscomb.git csscomb
3543
cp -r csscomb/plugin/* ~/.vim/plugin/
3644
```
3745

@@ -40,3 +48,12 @@ Vim command:
4048
```
4149
:CSScomb
4250
```
51+
52+
## Suggested Configuration
53+
54+
```VIML
55+
" Map bc to run CSScomb. bc stands for beautify css
56+
autocmd FileType css noremap <buffer> <leader>bc :CSScomb<CR>
57+
" Automatically comb your CSS on save
58+
autocmd BufWritePre,FileWritePre *.css,*.less,*.scss,*.sass silent! :CSScomb<CR>
59+
```

plugin/csscomb.vim

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,17 @@
77
let g:CSScombPluginDir = fnamemodify(expand("<sfile>"), ":h")
88

99
function! g:CSScomb(count, line1, line2)
10-
let content = join(getline(a:line1, a:line2), "\n")
11-
let res = system("php ".fnameescape(g:CSScombPluginDir."/exec.php"), content)
12-
let lines = split(res, "\n")
13-
call setline(a:line1, lines)
10+
let content = getline(a:line1, a:line2)
11+
12+
let tempFile = tempname() . '.' . &filetype
13+
call writefile(content, tempFile)
14+
let systemOutput = system('csscomb ' . shellescape(tempFile))
15+
if len(systemOutput)
16+
echoerr split(systemOutput, "\n")[1]
17+
else
18+
let lines = readfile(tempFile)
19+
call setline(a:line1, lines)
20+
endif
1421
endfunction
1522

1623
command! -nargs=? -range=% CSScomb :call g:CSScomb(<count>, <line1>, <line2>, <f-args>)

plugin/exec.php

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)