Merge pull request #37529 from zeertzjq/vim-95bb4ef

vim-patch: runtime file updates
This commit is contained in:
zeertzjq
2026-01-24 09:15:41 +08:00
committed by GitHub
3 changed files with 69 additions and 48 deletions

View File

@@ -3,9 +3,8 @@
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Previous Maintainer: Dan Sharp
" Contributor: Johannes Zellner <johannes@zellner.org>
" Last Change: 2024 Jan 14
" 2024 May 23 by Riley Bruins ('commentstring')
" 2026 Jan 15 improved matchit support
" Riley Bruins <ribru17@gmail.com>
" Last Change: 2026 Jan 16
if exists("b:did_ftplugin")
finish
@@ -22,29 +21,52 @@ setlocal formatoptions+=crql
let b:undo_ftplugin = "setlocal com< cms< fo<"
" Csh: thanks to Johannes Zellner
" - Both foreach and end must appear alone on separate lines.
" - The words else and endif must appear at the beginning of input lines;
" the if must appear alone on its input line or after an else.
" - Each case label and the default label must appear at the start of a
" line.
" - while and end must appear alone on their input lines.
if exists("loaded_matchit") && !exists("b:match_words")
let s:line_start = '\%(^\s*\)\@<='
let b:match_words =
\ s:line_start .. 'if\s*!\?\s*(.*)\s*then\>:' ..
\ s:line_start .. 'else\s\+if\s*(.*)\s*then\>:' .. s:line_start .. 'else\>:' ..
\ s:line_start .. 'endif\>,' ..
\ s:line_start .. '\%(\<foreach\s\+\h\w*\|while\)\s*(:' ..
\ '\<break\>:\<continue\>:' ..
\ s:line_start .. 'end\>,' ..
\ s:line_start .. 'switch\s*(:' ..
\ s:line_start .. 'case\s\+:' .. s:line_start .. 'default\>:\<breaksw\>:' ..
\ s:line_start .. 'endsw\>'
unlet s:line_start
let b:undo_ftplugin ..= " | unlet! b:match_words"
let b:match_ignorecase = 0
let b:match_words = "CshMatchWords()"
let b:match_skip = "CshMatchSkip()"
let b:undo_ftplugin ..= " | unlet! b:match_ignorecase b:match_skip b:match_words"
endif
" skip single line 'if' commands
function CshMatchSkip()
return getline(".") =~# '^\s*if\>' && !s:CshIsIfThenCommand()
endfunction
function CshMatchWords()
let line_start = '\%(^\s*\)\@<='
let match_words =
\ line_start .. '\%(foreach\s\+\h\w*\s*(\|while\>\):' ..
\ '\<break\>:\<continue\>:' ..
\ line_start .. 'end\>,' ..
\ line_start .. 'switch\s*(:' ..
\ line_start .. 'case\s\+:' .. line_start .. 'default\>:\<breaksw\>:' ..
\ line_start .. 'endsw\>'
if expand("<cword>") =~# '\<if\>' && !s:CshIsIfThenCommand()
return match_words
else
return match_words .. "," ..
\ line_start .. 'if\>:' ..
\ line_start .. 'else\s\+if\>:' .. line_start .. 'else\>:' ..
\ line_start .. 'endif\>'
endif
endfunction
function s:CshIsIfThenCommand()
let lnum = line(".")
let line = getline(lnum)
" join continued lines
while lnum < line("$") && line =~ '^\%([^\\]\|\\\\\)*\\$'
let lnum += 1
let line = substitute(line, '\\$', '', '') .. getline(lnum)
endwhile
" TODO: confirm with syntax checks when the highlighting is more accurate
return line =~# '^\s*if\>.*\<then\s*\%(#.*\)\=$'
endfunction
if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
let b:browsefilter = "csh Scripts (*.csh)\t*.csh\n"
if has("win32")

View File

@@ -1,10 +1,8 @@
" Vim syntax file
" Language: C-shell (csh)
" Maintainer: This runtime file is looking for a new maintainer.
" Former Maintainer: Charles E. Campbell
" Last Change: Aug 31, 2016
" Version: 14
" Former URL: http://www.drchip.org/astronaut/vim/index.html#SYNTAX_CSH
" Language: C-shell (csh)
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Former Maintainer: Charles E. Campbell
" Last Change: 2026 Jan 16
" quit when a syntax file was already loaded
if exists("b:current_syntax")
@@ -40,7 +38,7 @@ syn region cshDblQuote start=+^"+ skip=+\\\\\|\\"+ end=+"+ contains=cshSpecial
syn region cshSnglQuote start=+^'+ skip=+\\\\\|\\'+ end=+'+ contains=cshNoEndlineSQ,@Spell
syn region cshBckQuote start=+^`+ skip=+\\\\\|\\`+ end=+`+ contains=cshNoEndlineBQ,@Spell
syn cluster cshCommentGroup contains=cshTodo,@Spell
syn match cshComment "#.*$" contains=@cshCommentGroup
syn match cshComment "#.*" contains=@cshCommentGroup
" A bunch of useful csh keywords
syn keyword cshStatement alias end history onintr setenv unalias

View File

@@ -2,7 +2,7 @@
" Language: tcsh scripts
" Maintainer: Doug Kearns <dougkearns@gmail.com>
" Previous Maintainer: Gautam Iyer <gi1242+vim@NoSpam.com> where NoSpam=gmail (Original Author)
" Last Change: 2021 Oct 15
" Last Change: 2026 Jan 16
" Description: We break up each statement into a "command" and an "end" part.
" All groups are either a "command" or part of the "end" of a statement (ie
@@ -129,11 +129,12 @@ syn match tcshExprEnd contained '\v.*$'hs=e+1 contains=@tcshConditions
syn match tcshExprEnd contained '\v.{-};'hs=e contains=@tcshConditions
" ----- Comments: ----- {{{1
syn match tcshComment '#\s.*' contains=tcshTodo,tcshCommentTi,@Spell
syn match tcshComment '\v#($|\S.*)' contains=tcshTodo,tcshCommentTi
syn match tcshSharpBang '^#! .*$'
syn match tcshCommentTi contained '\v#\s*\u\w*(\s+\u\w*)*:'hs=s+1 contains=tcshTodo
syn match tcshTodo contained '\v\c<todo>'
syn match tcshSharpBang '\%^#!.*$'
syn match tcshComment '#.*' contains=tcshTodo,@Spell
syn match tcshTodo contained '\v%(^\s*#\s*)@<=\c<%(TODO|FIXME|XXX)>'
" TODO: leading whitespace match is needed to prevent keyword matching
syn match tcshLabel '^\s*\w\+:\ze\s*$'
" ----- Strings ----- {{{1
" Tcsh does not allow \" in strings unless the "backslash_quote" shell
@@ -141,14 +142,14 @@ syn match tcshTodo contained '\v\c<todo>'
" want VIM to assume that no backslash quote constructs exist.
" Backquotes are treated as commands, and are not contained in anything
if exists('tcsh_backslash_quote') && tcsh_backslash_quote == 0
syn region tcshSQuote keepend contained start="\v\\@<!'" end="'"
syn region tcshDQuote keepend contained start='\v\\@<!"' end='"' contains=@tcshVarList,tcshSpecial,@Spell
syn region tcshBQuote keepend start='\v\\@<!`' end='`' contains=@tcshStatements
if get(g:, 'tcsh_backslash_quote', 1)
syn region tcshSQuote contained start="'" skip="\v\\\\|\\'" end="'"
syn region tcshDQuote contained start='"' end='"' contains=@tcshVarList,tcshSpecial,@Spell
syn region tcshBQuote keepend matchgroup=tcshBQuoteGrp start='`' skip='\v\\\\|\\`' end='`' contains=@tcshStatements
else
syn region tcshSQuote contained start="\v\\@<!'" skip="\v\\\\|\\'" end="'"
syn region tcshDQuote contained start='\v\\@<!"' end='"' contains=@tcshVarList,tcshSpecial,@Spell
syn region tcshBQuote keepend matchgroup=tcshBQuoteGrp start='\v\\@<!`' skip='\v\\\\|\\`' end='`' contains=@tcshStatements
syn region tcshSQuote keepend contained start="'" end="'"
syn region tcshDQuote keepend contained start='"' end='"' contains=@tcshVarList,tcshSpecial,@Spell
syn region tcshBQuote keepend start='`' end='`' contains=@tcshStatements
endif
" ----- Variables ----- {{{1
@@ -181,8 +182,8 @@ syn match tcshRedir contained '\v\<|\>\>?\&?!?'
syn match tcshMeta contained '\v[]{}*?[]'
" Here documents (<<)
syn region tcshHereDoc contained matchgroup=tcshShellVar start='\v\<\<\s*\z(\h\w*)' end='^\z1$' contains=@tcshVarList,tcshSpecial
syn region tcshHereDoc contained matchgroup=tcshShellVar start="\v\<\<\s*'\z(\h\w*)'" start='\v\<\<\s*"\z(\h\w*)"$' start='\v\<\<\s*\\\z(\h\w*)$' end='^\z1$'
syn region tcshHereDoc contained matchgroup=tcshShellVar start='\v\<\<\s*\z(\h\w*)' end='^\z1$' contains=@tcshVarList,tcshSpecial fold
syn region tcshHereDoc contained matchgroup=tcshShellVar start="\v\<\<\s*'\z(\h\w*)'" start='\v\<\<\s*"\z(\h\w*)"$' start='\v\<\<\s*\\\z(\h\w*)$' end='^\z1$' fold
" Operators
syn match tcshOperator contained '&&\|!\~\|!=\|<<\|<=\|==\|=\~\|>=\|>>\|\*\|\^\|\~\|||\|!\|%\|&\|+\|-\|/\|<\|>\||'
@@ -226,10 +227,9 @@ hi def link tcshExprVar tcshUsrVar
hi def link tcshExprOp tcshOperator
hi def link tcshExprEnd tcshOperator
hi def link tcshComment Comment
hi def link tcshCommentTi Preproc
hi def link tcshSharpBang tcshCommentTi
hi def link tcshSharpBang PreProc
hi def link tcshTodo Todo
hi def link tcshSQuote Constant
hi def link tcshSQuote String
hi def link tcshDQuote tcshSQuote
hi def link tcshBQuoteGrp Include
hi def link tcshVarError Error
@@ -245,6 +245,7 @@ hi def link tcshOperator Operator
hi def link tcshNumber Number
hi def link tcshArgument Special
hi def link tcshSpecial SpecialChar
hi def link tcshLabel Label
" }}}
let &cpo = s:oldcpo