Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,36 @@ For more info, online demo and tests see [csscomb.com](http://csscomb.com/)

## The Requirements

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

```BASH
npm install -g csscomb
```

## Installation

### With Pathogen

```
cd ~/.vim/bundle
git clone https://github.com/miripiruni/CSScomb-for-Vim.git
git clone https://github.com/csscomb/vim-csscomb.git
```

### With Vundle
Add this to .vimrc:
```
Bundle 'git://github.com/miripiruni/CSScomb-for-Vim.git'
Bundle 'git://github.com/csscomb/vim-csscomb.git'
```

### With NeoBundle
Add this to .vimrc:
```
NeoBundle 'csscomb/vim-csscomb'
```

### Manual without plugins manager
```
git clone https://github.com/miripiruni/CSScomb-for-Vim.git csscomb
git clone https://github.com/csscomb/vim-csscomb.git csscomb
cp -r csscomb/plugin/* ~/.vim/plugin/
```

Expand All @@ -40,3 +48,12 @@ Vim command:
```
:CSScomb
```

## Suggested Configuration

```VIML
" Map bc to run CSScomb. bc stands for beautify css
autocmd FileType css noremap <buffer> <leader>bc :CSScomb<CR>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why css only?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oversight, fixed

" Automatically comb your CSS on save
autocmd BufWritePre,FileWritePre *.css,*.less,*.scss,*.sass silent! :CSScomb<CR>
```
15 changes: 11 additions & 4 deletions plugin/csscomb.vim
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
let g:CSScombPluginDir = fnamemodify(expand("<sfile>"), ":h")

function! g:CSScomb(count, line1, line2)
let content = join(getline(a:line1, a:line2), "\n")
let res = system("php ".fnameescape(g:CSScombPluginDir."/exec.php"), content)
let lines = split(res, "\n")
call setline(a:line1, lines)
let content = getline(a:line1, a:line2)

let tempFile = tempname() . '.' . &filetype
call writefile(content, tempFile)
let systemOutput = system('csscomb ' . shellescape(tempFile))
if len(systemOutput)
echoerr split(systemOutput, "\n")[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea to show errors

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to @istro

else
let lines = readfile(tempFile)
call setline(a:line1, lines)
endif
endfunction

command! -nargs=? -range=% CSScomb :call g:CSScomb(<count>, <line1>, <line2>, <f-args>)
6 changes: 0 additions & 6 deletions plugin/exec.php

This file was deleted.

Loading