view runtime/indent/sass.vim @ 10410:783a75eca83a v8.0.0099

commit https://github.com/vim/vim/commit/73095288da839f7c738a49baa109773e76106806 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Nov 24 17:47:07 2016 +0100 patch 8.0.0099 Problem: Popup menu always appears above the cursor when it is in the lower half of the screen. (Matt Gardner) Solution: Compute the available space better. (Hirohito Higashi, closes #1241)
author Christian Brabandt <cb@256bit.org>
date Thu, 24 Nov 2016 18:00:05 +0100
parents 43efa4f5a8ea
children 63b0b7b79b25
line wrap: on
line source

" Vim indent file
" Language:	Sass
" Maintainer:	Tim Pope <vimNOSPAM@tpope.org>
" Last Change:	2016 Aug 29

if exists("b:did_indent")
  finish
endif
let b:did_indent = 1

setlocal autoindent sw=2 et
setlocal indentexpr=GetSassIndent()
setlocal indentkeys=o,O,*<Return>,<:>,!^F

" Only define the function once.
if exists("*GetSassIndent")
  finish
endif

let s:property = '^\s*:\|^\s*[[:alnum:]#{}-]\+\%(:\|\s*=\)'
let s:extend = '^\s*\%(@extend\|@include\|+\)'

function! GetSassIndent()
  let lnum = prevnonblank(v:lnum-1)
  let line = substitute(getline(lnum),'\s\+$','','')
  let cline = substitute(substitute(getline(v:lnum),'\s\+$','',''),'^\s\+','','')
  let lastcol = strlen(line)
  let line = substitute(line,'^\s\+','','')
  let indent = indent(lnum)
  let cindent = indent(v:lnum)
  if line !~ s:property && line !~ s:extend && cline =~ s:property
    return indent + (exists('*shiftwidth') ? shiftwidth() : &sw)
  else
    return -1
  endif
endfunction

" vim:set sw=2: