| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " IDL (Interactive Data Language) indent file. | 
					
						
							| 
									
										
										
										
											2021-10-04 21:32:54 +01:00
										 |  |  | " Language:	IDL (ft=idlang) | 
					
						
							|  |  |  | " Maintainer:	Aleksandar Jelenak <ajelenak AT yahoo.com> (Invalid email address) | 
					
						
							|  |  |  | " 		Doug Kearns <dougkearns@gmail.com> | 
					
						
							| 
									
										
										
										
											2022-04-08 17:45:08 +01:00
										 |  |  | " Last change:	2022 Apr 06 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | " Only load this indent file when no other was loaded. | 
					
						
							|  |  |  | if exists("b:did_indent") | 
					
						
							|  |  |  |    finish | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | let b:did_indent = 1 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-05-18 21:49:28 +02:00
										 |  |  | setlocal indentkeys=o,O,0=endif,0=ENDIF,0=endelse,0=ENDELSE,0=endwhile,0=ENDWHILE,0=endfor,0=ENDFOR,0=endrep,0=ENDREP | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | setlocal indentexpr=GetIdlangIndent(v:lnum) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-08 17:45:08 +01:00
										 |  |  | let b:undo_indent = "setl inde< indk<" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  | " Only define the function once. | 
					
						
							|  |  |  | if exists("*GetIdlangIndent") | 
					
						
							|  |  |  |    finish | 
					
						
							|  |  |  | endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function GetIdlangIndent(lnum) | 
					
						
							|  |  |  |    " First non-empty line above the current line. | 
					
						
							|  |  |  |    let pnum = prevnonblank(v:lnum-1) | 
					
						
							|  |  |  |    " v:lnum is the first non-empty line -- zero indent. | 
					
						
							|  |  |  |    if pnum == 0 | 
					
						
							|  |  |  |       return 0 | 
					
						
							|  |  |  |    endif | 
					
						
							|  |  |  |    " Second non-empty line above the current line. | 
					
						
							|  |  |  |    let pnum2 = prevnonblank(pnum-1) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    " Current indent. | 
					
						
							|  |  |  |    let curind = indent(pnum) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    " Indenting of continued lines. | 
					
						
							|  |  |  |    if getline(pnum) =~ '\$\s*\(;.*\)\=$' | 
					
						
							|  |  |  |       if getline(pnum2) !~ '\$\s*\(;.*\)\=$' | 
					
						
							| 
									
										
										
										
											2017-06-13 18:12:01 +02:00
										 |  |  | 	 let curind = curind+shiftwidth() | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |       endif | 
					
						
							|  |  |  |    else | 
					
						
							|  |  |  |       if getline(pnum2) =~ '\$\s*\(;.*\)\=$' | 
					
						
							| 
									
										
										
										
											2017-06-13 18:12:01 +02:00
										 |  |  | 	 let curind = curind-shiftwidth() | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |       endif | 
					
						
							|  |  |  |    endif | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    " Indenting blocks of statements. | 
					
						
							|  |  |  |    if getline(v:lnum) =~? '^\s*\(endif\|endelse\|endwhile\|endfor\|endrep\)\>' | 
					
						
							|  |  |  |       if getline(pnum) =~? 'begin\>' | 
					
						
							| 
									
										
										
										
											2017-06-13 18:12:01 +02:00
										 |  |  |       elseif indent(v:lnum) > curind-shiftwidth() | 
					
						
							|  |  |  | 	 let curind = curind-shiftwidth() | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |       else | 
					
						
							|  |  |  | 	 return -1 | 
					
						
							|  |  |  |       endif | 
					
						
							|  |  |  |    elseif getline(pnum) =~? 'begin\>' | 
					
						
							| 
									
										
										
										
											2017-06-13 18:12:01 +02:00
										 |  |  |       if indent(v:lnum) < curind+shiftwidth() | 
					
						
							|  |  |  | 	 let curind = curind+shiftwidth() | 
					
						
							| 
									
										
										
										
											2004-06-13 20:20:40 +00:00
										 |  |  |       else | 
					
						
							|  |  |  | 	 return -1 | 
					
						
							|  |  |  |       endif | 
					
						
							|  |  |  |    endif | 
					
						
							|  |  |  |    return curind | 
					
						
							|  |  |  | endfunction | 
					
						
							|  |  |  | 
 |