view runtime/indent/sass.vim @ 34244:d15d40bf532b

runtime(doc): correct Vim patch for Wayland support Commit: https://github.com/vim/vim/commit/8fecb472c4a3f0f1ea364422424c56d1e0771b3e Author: Christian Brabandt <cb@256bit.org> Date: Tue Jan 30 23:37:41 2024 +0100 runtime(doc): correct Vim patch for Wayland support Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Tue, 30 Jan 2024 23:45:03 +0100
parents 92fd65eac53a
children
line wrap: on
line source

" Vim indent file
" Language:	Sass
" Maintainer:	Tim Pope <vimNOSPAM@tpope.org>
" Last Change:	2023 Dec 28

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

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

let b:undo_indent = "setl ai< inde< indk<"

" 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 line = substitute(line,'^\s\+','','')
  let indent = indent(lnum)
  if line !~ s:property && line !~ s:extend && cline =~ s:property
    return indent + shiftwidth()
  else
    return -1
  endif
endfunction

" vim:set sw=2: