robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
138922497f
master
1" Vim filetype plugin file 2" Language: csh 3" Maintainer: Doug Kearns <dougkearns@gmail.com> 4" Previous Maintainer: Dan Sharp 5" Contributor: Johannes Zellner <johannes@zellner.org> 6" Riley Bruins <ribru17@gmail.com> 7" Last Change: 2026 Jan 16 8 9if exists ( "b:did_ftplugin" ) 10finish 11endif 12let b: did_ftplugin = 1 13 14let s: save_cpo = & cpo 15set cpo -= C 16 17setlocal comments = :# 18setlocal commentstring = #\ %s 19setlocal formatoptions -= t 20setlocal formatoptions += crql 21 22let b: undo_ftplugin = "setlocal com< cms< fo<" 23 24if exists ( "loaded_matchit" ) && ! exists ( "b:match_words" ) 25let b: match_ignorecase = 0 26let b: match_words = "CshMatchWords()" 27let b: match_skip = "CshMatchSkip()" 28let b: undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_skip b:match_words" 29endif 30 31" skip single line 'if' commands 32function CshMatchSkip () 33return getline ( "." ) =~# '^\s*if\>' && ! s: CshIsIfThenCommand () 34endfunction 35 36function CshMatchWords () 37let line_start = '\%(^\s*\)\@<=' 38let match_words = 39 \line_start .. '\%(foreach\s\+\h\w*\s*(\|while\>\):' .. 40 \'\<break\>:\<continue\>:' .. 41 \line_start .. 'end\>,' .. 42 \line_start .. 'switch\s*(:' .. 43 \line_start .. 'case\s\+:' .. line_start .. 'default\>:\<breaksw\>:' .. 44 \line_start .. 'endsw\>' 45 46if expand ( "<cword>" ) =~# '\<if\>' && ! s: CshIsIfThenCommand () 47return match_words 48else 49return match_words .. "," .. 50 \line_start .. 'if\>:' .. 51 \line_start .. 'else\s\+if\>:' .. line_start .. 'else\>:' .. 52 \line_start .. 'endif\>' 53endif 54endfunction 55 56function s: CshIsIfThenCommand () 57let lnum = line ( "." ) 58let line = getline ( lnum ) 59 60" join continued lines 61while lnum < line ( "$" ) && line =~ '^\%([^\\]\|\\\\\)*\\$' 62let lnum += 1 63let line = substitute ( line , '\\$' , '' , '' ) .. getline ( lnum ) 64endwhile 65 66" TODO: confirm with syntax checks when the highlighting is more accurate 67return line =~# '^\s*if\>.*\<then\s*\%(#.*\)\=$' 68endfunction 69 70if ( has ( "gui_win32" ) || has ( "gui_gtk" )) && ! exists ( "b:browsefilter" ) 71let b: browsefilter = "csh Scripts (*.csh)\t*.csh\n" 72if has ( "win32" ) 73let b: browsefilter ..= "All Files (*.*)\t*\n" 74else 75let b: browsefilter ..= "All Files (*)\t*\n" 76endif 77let b: csh_set_browsefilter = 1 78let b: undo_ftplugin ..= " | unlet! b:browsefilter b:csh_set_browsefilter" 79endif 80 81let & cpo = s: save_cpo 82unlet s: save_cpo