robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
fc1cdb8821
master
1" Vim indent file 2" Language: C-shell (tcsh) 3" Maintainer: Doug Kearns <dougkearns@gmail.com> 4" Previous Maintainer: Gautam Iyer <gi1242+vim@NoSpam.com> where NoSpam=gmail (Original Author) 5" Last Change: 2021 Oct 15 6 7" Only load this indent file when no other was loaded. 8if exists ( "b:did_indent" ) 9finish 10endif 11 12let b: did_indent = 1 13 14setlocal indentexpr = TcshGetIndent () 15setlocal indentkeys += e,0=end 16setlocal indentkeys -= 0{,0},0),:,0# 17 18let b: undo_indent = "setl inde< indk<" 19 20" Only define the function once. 21if exists ( "*TcshGetIndent" ) 22finish 23endif 24 25function TcshGetIndent () 26" Find a non-blank line above the current line. 27let lnum = prevnonblank ( v: lnum - 1 ) 28 29" Hit the start of the file, use zero indent. 30if lnum == 0 31return 0 32endif 33 34" Add indent if previous line begins with while or foreach 35" OR line ends with case <str>:, default:, else, then or \ 36let ind = indent ( lnum ) 37let line = getline ( lnum ) 38if line =~ '\v^\s*%(while|foreach)>|^\s*%(case\s.*:|default:|else)\s*$|%(<then|\\)$' 39let ind = ind + shiftwidth () 40endif 41 42if line =~ '\v^\s*breaksw>' 43let ind = ind - shiftwidth () 44endif 45 46" Subtract indent if current line has on end, endif, endsw, case commands 47let line = getline ( v: lnum ) 48if line =~ '\v^\s*%(else|end|endif|endsw)\s*$' 49let ind = ind - shiftwidth () 50endif 51 52return ind 53endfunction