robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
521e91e1c4
master
1" Vim indent file 2" Language: tf (TinyFugue) 3" Maintainer: Christian J. Robinson <heptite@gmail.com> 4" URL: http://www.vim.org/scripts/script.php?script_id=174 5" Last Change: 2022 Apr 25 6 7" Only load this indent file when no other was loaded. 8if exists ( "b:did_indent" ) 9finish 10endif 11let b: did_indent = 1 12 13setlocal indentexpr = GetTFIndent () 14setlocal indentkeys -= 0{,0}indentkeys -= 0#indentkeys -= : 15setlocal indentkeys += =/endif,=/then,=/else,=/done,0; 16 17let b: undo_indent = "setlocal indentexpr< indentkeys<" 18 19" Only define the function once: 20if exists ( "*GetTFIndent" ) 21finish 22endif 23 24function GetTFIndent () 25" Find a non-blank line above the current line: 26let lnum = prevnonblank ( v: lnum - 1 ) 27 28" No indent for the start of the file: 29if lnum == 0 30return 0 31endif 32 33let ind = indent ( lnum ) 34let line = getline ( lnum ) 35 36" No indentation if the previous line didn't end with "\": 37" (Could be annoying, but it lets you know if you made a mistake.) 38if line !~ '\\$' 39return 0 40endif 41 42if line =~ '\(/def.*\\\|/for.*\(%;\s*\)\@\<!\\\)$' 43let ind = ind + shiftwidth () 44elseif line =~ '\(/if\|/else\|/then\)' 45if line !~ '/endif' 46let ind = ind + shiftwidth () 47endif 48elseif line =~ '/while' 49if line !~ '/done' 50let ind = ind + shiftwidth () 51endif 52endif 53 54let line = getline ( v: lnum ) 55 56if line =~ '\(/else\|/endif\|/then\)' 57if line !~ '/if' 58let ind = ind - shiftwidth () 59endif 60elseif line =~ '/done' 61if line !~ '/while' 62let ind = ind - shiftwidth () 63endif 64endif 65 66" Comments at the beginning of a line: 67if line =~ '^\s*;' 68let ind = 0 69endif 70 71 72return ind 73 74endfunction