Last active
December 17, 2015 14:19
-
-
Save morganrallen/5623956 to your computer and use it in GitHub Desktop.
Auto compile LESS to CSS on write. Also will allow you to compile a parent script by putting /* lessc-parent: "main" */ on the top line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function LessToCss() | |
let match = matchstr(getline(1), '...lessc-parent: "\zs.\{-}\ze"') | |
if strlen(match) > 0 | |
let current_file = match . ".less" | |
let filename = match | |
el | |
let current_file = shellescape(expand('%:p')) | |
let filename = shellescape(expand('%:r')) | |
endif | |
let command = "silent !lessc --line-numbers=mediaquery " . current_file . " " . filename . ".css" | |
execute command | |
endfunction | |
autocmd BufWritePost,FileWritePost *.less call LessToCss() | |
autocmd BufReadPost,FileReadPost *.less set ft=css |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment