robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Sean Dewarvim-patch:partial:b59ae59a5870 (#21170)868d8d6962

master
1.4 KiB55 linesraw
1" Vim indent file
2" Language:    Oblivion Language (obl)
3" Original Creator: Kat <katisntgood@gmail.com>
4" Maintainer:  Kat <katisntgood@gmail.com>
5" Created:     01 November 2021
6" Last Change: 13 November 2022
7
8if exists("b:did_indent")
9  finish
10endif
11let b:did_indent = 1
12let b:undo_indent = 'setlocal indentkeys< indentexpr<'
13
14setlocal indentexpr=GetOblIndent()
15setlocal indentkeys+==~endif,=~else,=~loop,=~end
16
17if exists("*GetOblIndent")
18  finish
19endif
20let s:keepcpo = &cpo
21set cpo&vim
22
23let s:SKIP_LINES = '^\s*\(;.*\)'
24function! GetOblIndent()
25
26  let lnum = prevnonblank(v:lnum - 1)
27  let cur_text = getline(v:lnum)
28  if lnum == 0
29    return 0
30  endif
31  let prev_text = getline(lnum)
32  let found_cont = 0
33  let ind = indent(lnum)
34
35  " indent next line on start terms
36  let i = match(prev_text, '\c^\s*\(\s\+\)\?\(\(if\|while\|foreach\|begin\|else\%[if]\)\>\)')
37  if i >= 0
38    let ind += shiftwidth()
39    if strpart(prev_text, i, 1) == '|' && has('syntax_items')
40          \ && synIDattr(synID(lnum, i, 1), "name") =~ '\(Comment\|String\)$'
41      let ind -= shiftwidth()
42    endif
43  endif
44  " indent current line on end/else terms
45  if cur_text =~ '\c^\s*\(\s\+\)\?\(\(loop\|endif\|else\%[if]\)\>\)'
46    let ind = ind - shiftwidth()
47  " if we are at a begin block just go to column 0
48  elseif cur_text =~ '\c^\s*\(\s\+\)\?\(\(begin\|end\)\>\)'
49    let ind = 0
50  endif
51  return ind
52endfunction
53
54let &cpo = s:keepcpo
55unlet s:keepcpo