diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2017-02-02 23:23:52 +0100 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2017-02-02 23:23:52 +0100 | 
| commit | 6e9529be4e0c2b0b42e5eb51fad1c34bae6f56fc (patch) | |
| tree | 4bdaa1decc2241814e5de4de04d3ee39df4b3684 /autoload | |
| parent | 462bb76e06c9efa66cc4bae098dcc5497dd1069d (diff) | |
| download | vim-polyglot-6e9529be4e0c2b0b42e5eb51fad1c34bae6f56fc.tar.gz vim-polyglot-6e9529be4e0c2b0b42e5eb51fad1c34bae6f56fc.zip | |
Change scss provider to cakebaker, closes #173v2.14.0
Diffstat (limited to '')
| -rw-r--r-- | autoload/scss_indent.vim | 41 | 
1 files changed, 41 insertions, 0 deletions
| diff --git a/autoload/scss_indent.vim b/autoload/scss_indent.vim new file mode 100644 index 00000000..cc9fc033 --- /dev/null +++ b/autoload/scss_indent.vim @@ -0,0 +1,41 @@ +if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'scss') == -1 +   +" 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 + +endif | 
