From d496ce9353e34e54a338a7e202461b3a5521fecc Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Thu, 12 Sep 2013 17:39:09 +0200 Subject: [PATCH] Add scss support --- autoload/scss_indent.vim | 37 +++++++++++++++++++++++++++++++++++++ build.sh | 1 + ftdetect/scss.vim | 1 + 3 files changed, 39 insertions(+) create mode 100644 autoload/scss_indent.vim create mode 100644 ftdetect/scss.vim diff --git a/autoload/scss_indent.vim b/autoload/scss_indent.vim new file mode 100644 index 0000000..2e57ab2 --- /dev/null +++ b/autoload/scss_indent.vim @@ -0,0 +1,37 @@ +" usage: +" set indentexpr=scss_indent#GetIndent(v:lnum) +fun! scss_indent#GetIndent(lnum) + " { -> increase indent + " } -> decrease indent + if a:lnum == 1 + " start at 0 indentation + return 0 + endif + + " try to find last line ending with { or } + " ignoring // comments + let regex = '\([{}]\)\%(\/\/.*\)\?$' + let nr = search(regex, 'bnW') + if nr > 0 + let last = indent(nr) + let m = matchlist(getline(nr), regex) + let m_curr = matchlist(getline(a:lnum), regex) + echoe string(m).string(m_curr) + if !empty(m_curr) && m_curr[1] == '}' && m[1] == '{' + " last was open, current is close, use same indent + return last + elseif !empty(m_curr) && m_curr[1] == '}' && m[1] == '}' + " } line and last line was }: decrease + return last - &sw + endif + if m[1] == '{' + " line after {: increase indent + return last + &sw + else + " line after } or { - same indent + return last + endif + else + return 0 + endif +endfun diff --git a/build.sh b/build.sh index 6e4ea96..4342df8 100755 --- a/build.sh +++ b/build.sh @@ -70,6 +70,7 @@ syntax 'elixir-lang/vim-elixir' & syntax 'jimenezrick/vimerl' & syntax 'tpope/vim-git' & syntax 'skwp/vim-rspec' & +syntax 'cakebaker/scss-syntax.vim' & wait diff --git a/ftdetect/scss.vim b/ftdetect/scss.vim new file mode 100644 index 0000000..900752e --- /dev/null +++ b/ftdetect/scss.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.scss set filetype=scss.css