From 3f018165e7e7e919ee797e099781fae7d5a6cdb0 Mon Sep 17 00:00:00 2001 From: netcookies Date: Sat, 17 Sep 2016 15:48:51 +0800 Subject: [PATCH 1/5] Merging netcookies:master code from PR #14, to handle smaller outputs --- plugin/csscomb.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/csscomb.vim b/plugin/csscomb.vim index dae1b6b..c8713ab 100644 --- a/plugin/csscomb.vim +++ b/plugin/csscomb.vim @@ -16,6 +16,10 @@ function! g:CSScomb(count, line1, line2) echoerr split(systemOutput, "\n")[1] else let lines = readfile(tempFile) + if len(lines) Date: Tue, 13 Feb 2018 13:58:11 +0100 Subject: [PATCH 2/5] Allow passing extra arguments to CSScomb --- README.md | 2 ++ plugin/csscomb.vim | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dca0269..42c3ff7 100644 --- a/README.md +++ b/README.md @@ -56,4 +56,6 @@ Vim command: autocmd FileType css noremap bc :CSScomb " Automatically comb your CSS on save autocmd BufWritePre,FileWritePre *.css,*.less,*.scss,*.sass silent! :CSScomb +" Passing extra arguments to CSScomb +let g:CSScombArgumentsa = '--config ~/.csscomb.json --tty-mode' ``` diff --git a/plugin/csscomb.vim b/plugin/csscomb.vim index c8713ab..dc76118 100644 --- a/plugin/csscomb.vim +++ b/plugin/csscomb.vim @@ -6,12 +6,16 @@ let g:CSScombPluginDir = fnamemodify(expand(""), ":h") +if !exists('g:CSScombArguments') + let g:CSScombArguments = '' +endif + 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 ' . shellescape(tempFile)) + let systemOutput = system('csscomb ' . g:CSScombArguments . ' ' . shellescape(tempFile)) if len(systemOutput) echoerr split(systemOutput, "\n")[1] else From cc42212d12a94777504e73ac0d5594be82593aaa Mon Sep 17 00:00:00 2001 From: Andre Gil Date: Tue, 13 Feb 2018 14:23:23 +0100 Subject: [PATCH 3/5] Fixing misspelled instructions --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 42c3ff7..c1571cc 100644 --- a/README.md +++ b/README.md @@ -57,5 +57,5 @@ autocmd FileType css noremap bc :CSScomb " Automatically comb your CSS on save autocmd BufWritePre,FileWritePre *.css,*.less,*.scss,*.sass silent! :CSScomb " Passing extra arguments to CSScomb -let g:CSScombArgumentsa = '--config ~/.csscomb.json --tty-mode' +let g:CSScombArguments = '--config ~/.csscomb.json --tty-mode' ``` From 05521201e2e760c7d8fa3cfd763def3c42484d12 Mon Sep 17 00:00:00 2001 From: Andre Gil Date: Tue, 13 Feb 2018 14:38:27 +0100 Subject: [PATCH 4/5] Calling CSScomb in a different way. Should this be necessary? No. But CSScomb decided not to work in any other way for me (and I tried many!) --- plugin/csscomb.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/csscomb.vim b/plugin/csscomb.vim index dc76118..ba9978b 100644 --- a/plugin/csscomb.vim +++ b/plugin/csscomb.vim @@ -15,7 +15,7 @@ function! g:CSScomb(count, line1, line2) let tempFile = tempname() . '.' . &filetype call writefile(content, tempFile) - let systemOutput = system('csscomb ' . g:CSScombArguments . ' ' . shellescape(tempFile)) + let systemOutput = system('cat ' . shellescape(tempFile) . ' | csscomb ' . g:CSScombArguments . ' > ' shellescape(tempFile)) if len(systemOutput) echoerr split(systemOutput, "\n")[1] else From ba760777eefb6c069571b3e33b55c0976864b35a Mon Sep 17 00:00:00 2001 From: Andre Gil Date: Tue, 13 Feb 2018 14:45:06 +0100 Subject: [PATCH 5/5] Missed one dot --- plugin/csscomb.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/csscomb.vim b/plugin/csscomb.vim index ba9978b..1718157 100644 --- a/plugin/csscomb.vim +++ b/plugin/csscomb.vim @@ -15,7 +15,7 @@ function! g:CSScomb(count, line1, line2) let tempFile = tempname() . '.' . &filetype call writefile(content, tempFile) - let systemOutput = system('cat ' . shellescape(tempFile) . ' | csscomb ' . g:CSScombArguments . ' > ' shellescape(tempFile)) + let systemOutput = system('cat ' . shellescape(tempFile) . ' | csscomb ' . g:CSScombArguments . ' > ' . shellescape(tempFile)) if len(systemOutput) echoerr split(systemOutput, "\n")[1] else