| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " Vim indent file | 
					
						
							| 
									
										
										
										
											2005-06-29 22:40:58 +00:00
										 |  |  | " Language:         Makefile | 
					
						
							|  |  |  | " Maintainer:       Nikolai Weibull <nikolai+work.vim@bitwi.se> | 
					
						
							|  |  |  | " Latest Revision:  2005-06-29 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | if exists("b:did_indent") | 
					
						
							|  |  |  |   finish | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | let b:did_indent = 1 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | setlocal indentexpr=GetMakeIndent() | 
					
						
							|  |  |  | setlocal indentkeys=!^F,o,O | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if exists("*GetMakeIndent") | 
					
						
							|  |  |  |   finish | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function s:GetStringWidth(line, str) | 
					
						
							|  |  |  |   let end = matchend(a:line, a:str) | 
					
						
							|  |  |  |   let width = 0 | 
					
						
							| 
									
										
										
										
											2005-06-29 22:40:58 +00:00
										 |  |  |   for c in a:line | 
					
						
							|  |  |  |     if c == "\t" | 
					
						
							|  |  |  |       let width += &ts - (width % &ts) | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |     else | 
					
						
							| 
									
										
										
										
											2005-06-29 22:40:58 +00:00
										 |  |  |       let width += 1 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |     endif | 
					
						
							| 
									
										
										
										
											2005-06-29 22:40:58 +00:00
										 |  |  |   endfor | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |   return width | 
					
						
							|  |  |  | endfunction | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function GetMakeIndent() | 
					
						
							| 
									
										
										
										
											2005-06-29 22:40:58 +00:00
										 |  |  |   let lnum = v:lnum - 1 | 
					
						
							|  |  |  |   if lnum == 0 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |     return 0 | 
					
						
							|  |  |  |   endif | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-06-29 22:40:58 +00:00
										 |  |  |   let line = getline(lnum) | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |   if line == '' | 
					
						
							| 
									
										
										
										
											2005-06-29 22:40:58 +00:00
										 |  |  |     return 0 | 
					
						
							|  |  |  |   elseif line =~ '^[^ \t#:][^#:]*:\{1,2}\%([^=:]\|$\)' | 
					
						
							|  |  |  |     return indent(lnum) + &ts | 
					
						
							|  |  |  |   elseif line =~ '^\s*\h\w*\s*+\==\s*.\+\\$' | 
					
						
							|  |  |  |     return s:GetStringWidth(line, '+\==\s*') | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |   endif | 
					
						
							|  |  |  | endfunction |