robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
ab20681c52
master
1" Vim indent file 2" Language: KDL 3" Author: Aram Drevekenin <aram@poor.dev> 4" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com> 5" Last Change: 2024-06-16 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 = KdlIndent () 14let b: undo_indent = "setlocal indentexpr<" 15 16function ! KdlIndent (...) 17let line = substitute ( getline ( v: lnum ), '//.*$' , '' , '' ) 18let previousNum = prevnonblank ( v: lnum - 1 ) 19let previous = substitute ( getline ( previousNum ), '//.*$' , '' , '' ) 20 21let l: indent = indent ( previousNum ) 22if previous =~ "{" && previous !~ "}" 23let l: indent += shiftwidth () 24endif 25if line =~ "}" && line !~ "{" 26let l: indent -= shiftwidth () 27endif 28return l: indent 29endfunction 30" vim: sw=2 sts=2 et