| 
									
										
										
										
											2008-07-13 17:41:49 +00:00
										 |  |  | " Vim indent file | 
					
						
							| 
									
										
										
										
											2010-05-21 12:05:36 +02:00
										 |  |  | " Language:	Sass | 
					
						
							|  |  |  | " Maintainer:	Tim Pope <vimNOSPAM@tpope.org> | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  | " Last Change:	2016 Aug 29 | 
					
						
							| 
									
										
										
										
											2008-07-13 17:41:49 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  | let s:property = '^\s*:\|^\s*[[:alnum:]#{}-]\+\%(:\|\s*=\)' | 
					
						
							|  |  |  | let s:extend = '^\s*\%(@extend\|@include\|+\)' | 
					
						
							| 
									
										
										
										
											2008-07-13 17:41:49 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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) | 
					
						
							| 
									
										
										
										
											2013-06-01 14:50:56 +02:00
										 |  |  |   if line !~ s:property && line !~ s:extend && cline =~ s:property | 
					
						
							| 
									
										
										
										
											2016-08-30 23:26:57 +02:00
										 |  |  |     return indent + (exists('*shiftwidth') ? shiftwidth() : &sw) | 
					
						
							| 
									
										
										
										
											2008-07-13 17:41:49 +00:00
										 |  |  |   else | 
					
						
							|  |  |  |     return -1 | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  | endfunction | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | " vim:set sw=2: |