codekingpro/portable-devtools
114k
1" Vim indent file2" Language: ChaiScript3" Maintainer: Jason Turner <lefticus 'at' gmail com>4" Last Change: 2022 Apr 065 6" Only load this indent file when no other was loaded.7if exists("b:did_indent")8 finish9endif10let b:did_indent = 111 12setlocal indentexpr=GetChaiScriptIndent()13setlocal autoindent14 15let b:undo_indent = "setl ai< inde<"16 17" Only define the function once.18if exists("*GetChaiScriptIndent")19 finish20endif21 22function! GetChaiScriptIndent()23 " Find a non-blank line above the current line.24 let lnum = prevnonblank(v:lnum - 1)25 26 " Hit the start of the file, use zero indent.27 if lnum == 028 return 029 endif30 31 " Add a 'shiftwidth' after lines that start a block:32 " lines containing a {33 let ind = indent(lnum)34 let flag = 035 let prevline = getline(lnum)36 if prevline =~ '^.*{.*'37 let ind = ind + shiftwidth()38 let flag = 139 endif40 41 " Subtract a 'shiftwidth' after lines containing a { followed by a }42 " to keep it balanced43 if flag == 1 && prevline =~ '.*{.*}.*'44 let ind = ind - shiftwidth()45 endif46 47 " Subtract a 'shiftwidth' on lines ending with }48 if getline(v:lnum) =~ '^\s*\%(}\)'49 let ind = ind - shiftwidth()50 endif51 52 return ind53endfunction54 