vim

Fork of vim, an acceptable text editor
git clone git://git.laack.co/vim.git
Log | Files | Refs | README | LICENSE

tcsh.vim (1381B)


      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.
      8 if exists("b:did_indent")
      9     finish
     10 endif
     11 
     12 let b:did_indent = 1
     13 
     14 setlocal indentexpr=TcshGetIndent()
     15 setlocal indentkeys+=e,0=end
     16 setlocal indentkeys-=0{,0},0),:,0#
     17 
     18 let b:undo_indent = "setl inde< indk<"
     19 
     20 " Only define the function once.
     21 if exists("*TcshGetIndent")
     22     finish
     23 endif
     24 
     25 function TcshGetIndent()
     26     " Find a non-blank line above the current line.
     27     let lnum = prevnonblank(v:lnum - 1)
     28 
     29     " Hit the start of the file, use zero indent.
     30     if lnum == 0
     31 	return 0
     32     endif
     33 
     34     " Add indent if previous line begins with while or foreach
     35     " OR line ends with case <str>:, default:, else, then or \
     36     let ind = indent(lnum)
     37     let line = getline(lnum)
     38     if line =~ '\v^\s*%(while|foreach)>|^\s*%(case\s.*:|default:|else)\s*$|%(<then|\\)$'
     39 	let ind = ind + shiftwidth()
     40     endif
     41 
     42     if line =~ '\v^\s*breaksw>'
     43 	let ind = ind - shiftwidth()
     44     endif
     45 
     46     " Subtract indent if current line has on end, endif, endsw, case commands
     47     let line = getline(v:lnum)
     48     if line =~ '\v^\s*%(else|end|endif|endsw)\s*$'
     49 	let ind = ind - shiftwidth()
     50     endif
     51 
     52     return ind
     53 endfunction