summaryrefslogtreecommitdiffstats
path: root/runtime/indent/idlang.vim
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 08:50:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 08:50:31 +0000
commitaed8ce9da277f5ecffe968b324f242c41c3b752a (patch)
treed2e538394cb7a8a7c42a4aac6ccf1a8e3256999b /runtime/indent/idlang.vim
parentInitial commit. (diff)
downloadvim-aed8ce9da277f5ecffe968b324f242c41c3b752a.tar.xz
vim-aed8ce9da277f5ecffe968b324f242c41c3b752a.zip
Adding upstream version 2:9.0.1378.upstream/2%9.0.1378upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'runtime/indent/idlang.vim')
-rw-r--r--runtime/indent/idlang.vim65
1 files changed, 65 insertions, 0 deletions
diff --git a/runtime/indent/idlang.vim b/runtime/indent/idlang.vim
new file mode 100644
index 0000000..1519865
--- /dev/null
+++ b/runtime/indent/idlang.vim
@@ -0,0 +1,65 @@
+" IDL (Interactive Data Language) indent file.
+" Language: IDL (ft=idlang)
+" Maintainer: Aleksandar Jelenak <ajelenak AT yahoo.com> (Invalid email address)
+" Doug Kearns <dougkearns@gmail.com>
+" Last change: 2022 Apr 06
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal indentkeys=o,O,0=endif,0=ENDIF,0=endelse,0=ENDELSE,0=endwhile,0=ENDWHILE,0=endfor,0=ENDFOR,0=endrep,0=ENDREP
+
+setlocal indentexpr=GetIdlangIndent(v:lnum)
+
+let b:undo_indent = "setl inde< indk<"
+
+" 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*\(;.*\)\=$'
+ let curind = curind+shiftwidth()
+ endif
+ else
+ if getline(pnum2) =~ '\$\s*\(;.*\)\=$'
+ let curind = curind-shiftwidth()
+ endif
+ endif
+
+ " Indenting blocks of statements.
+ if getline(v:lnum) =~? '^\s*\(endif\|endelse\|endwhile\|endfor\|endrep\)\>'
+ if getline(pnum) =~? 'begin\>'
+ elseif indent(v:lnum) > curind-shiftwidth()
+ let curind = curind-shiftwidth()
+ else
+ return -1
+ endif
+ elseif getline(pnum) =~? 'begin\>'
+ if indent(v:lnum) < curind+shiftwidth()
+ let curind = curind+shiftwidth()
+ else
+ return -1
+ endif
+ endif
+ return curind
+endfunction
+