diff runtime/syntax/sed.vim @ 30875:3295247d97a5

Update runtime files Commit: https://github.com/vim/vim/commit/3c053a1a5ad2a3c924929e11f2b9af20a8b901e2 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Oct 16 13:11:12 2022 +0100 Update runtime files
author Bram Moolenaar <Bram@vim.org>
date Sun, 16 Oct 2022 14:15:06 +0200
parents 46763b01cd9a
children
line wrap: on
line diff
--- a/runtime/syntax/sed.vim
+++ b/runtime/syntax/sed.vim
@@ -1,30 +1,42 @@
 " Vim syntax file
-" Language:	sed
-" Maintainer:	Haakon Riiser <hakonrk@fys.uio.no>
-" URL:		http://folk.uio.no/hakonrk/vim/syntax/sed.vim
-" Last Change:	2010 May 29
+" Language:		sed
+" Maintainer:		Doug Kearns <dougkearns@gmail.com>
+" Previous Maintainer:	Haakon Riiser <hakonrk@fys.uio.no>
+" Contributor:		Jack Haden-Enneking
+" Last Change:		2022 Oct 15
 
 " quit when a syntax file was already loaded
 if exists("b:current_syntax")
-    finish
+  finish
 endif
 
+syn keyword sedTodo	contained TODO FIXME XXX
+
 syn match sedError	"\S"
 
 syn match sedWhitespace "\s\+" contained
 syn match sedSemicolon	";"
 syn match sedAddress	"[[:digit:]$]"
 syn match sedAddress	"\d\+\~\d\+"
-syn region sedAddress   matchgroup=Special start="[{,;]\s*/\(\\/\)\="lc=1 skip="[^\\]\(\\\\\)*\\/" end="/I\=" contains=sedTab,sedRegexpMeta
-syn region sedAddress   matchgroup=Special start="^\s*/\(\\/\)\=" skip="[^\\]\(\\\\\)*\\/" end="/I\=" contains=sedTab,sedRegexpMeta
-syn match sedComment	"^\s*#.*$"
-syn match sedFunction	"[dDgGhHlnNpPqQx=]\s*\($\|;\)" contains=sedSemicolon,sedWhitespace
+syn region sedAddress	matchgroup=Special start="[{,;]\s*/\%(\\/\)\="lc=1 skip="[^\\]\%(\\\\\)*\\/" end="/I\=" contains=sedTab,sedRegexpMeta
+syn region sedAddress	matchgroup=Special start="^\s*/\%(\\/\)\=" skip="[^\\]\%(\\\\\)*\\/" end="/I\=" contains=sedTab,sedRegexpMeta
+syn match sedFunction	"[dDgGhHlnNpPqQx=]\s*\%($\|;\)" contains=sedSemicolon,sedWhitespace
+if exists("g:sed_dialect") && g:sed_dialect ==? "bsd"
+  syn match sedComment	"^\s*#.*$" contains=sedTodo
+else
+  syn match sedFunction	"[dDgGhHlnNpPqQx=]\s*\ze#" contains=sedSemicolon,sedWhitespace
+  syn match sedComment	"#.*$" contains=sedTodo
+endif
 syn match sedLabel	":[^;]*"
-syn match sedLineCont	"^\(\\\\\)*\\$" contained
-syn match sedLineCont	"[^\\]\(\\\\\)*\\$"ms=e contained
+syn match sedLineCont	"^\%(\\\\\)*\\$" contained
+syn match sedLineCont	"[^\\]\%(\\\\\)*\\$"ms=e contained
 syn match sedSpecial	"[{},!]"
-if exists("highlight_sedtabs")
-    syn match sedTab	"\t" contained
+
+" continue to silently support the old name
+let s:highlight_tabs = v:false
+if exists("g:highlight_sedtabs") || get(g:, "sed_highlight_tabs", 0)
+  let s:highlight_tabs = v:true
+  syn match sedTab	"\t" contained
 endif
 
 " Append/Change/Insert
@@ -34,39 +46,39 @@ syn region sedBranch	matchgroup=sedFunct
 syn region sedRW	matchgroup=sedFunction start="[rw]" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace
 
 " Substitution/transform with various delimiters
-syn region sedFlagwrite	    matchgroup=sedFlag start="w" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace contained
-syn match sedFlag	    "[[:digit:]gpI]*w\=" contains=sedFlagwrite contained
+syn region sedFlagWrite	    matchgroup=sedFlag start="w" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace contained
+syn match sedFlag	    "[[:digit:]gpI]*w\=" contains=sedFlagWrite contained
 syn match sedRegexpMeta	    "[.*^$]" contained
 syn match sedRegexpMeta	    "\\." contains=sedTab contained
 syn match sedRegexpMeta	    "\[.\{-}\]" contains=sedTab contained
 syn match sedRegexpMeta	    "\\{\d\*,\d*\\}" contained
-syn match sedRegexpMeta	    "\\(.\{-}\\)" contains=sedTab contained
-syn match sedReplaceMeta    "&\|\\\($\|.\)" contains=sedTab contained
+syn match sedRegexpMeta	    "\\%(.\{-}\\)" contains=sedTab contained
+syn match sedReplaceMeta    "&\|\\\%($\|.\)" contains=sedTab contained
 
 " Metacharacters: $ * . \ ^ [ ~
 " @ is used as delimiter and treated on its own below
-let __at = char2nr("@")
-let __sed_i = char2nr(" ") " ASCII: 32, EBCDIC: 64
+let s:at = char2nr("@")
+let s:i = char2nr(" ") " ASCII: 32, EBCDIC: 64
 if has("ebcdic")
-    let __sed_last = 255
+  let s:last = 255
 else
-    let __sed_last = 126
+  let s:last = 126
 endif
-let __sed_metacharacters = '$*.\^[~'
-while __sed_i <= __sed_last
-    let __sed_delimiter = escape(nr2char(__sed_i), __sed_metacharacters)
-	if __sed_i != __at
-	    exe 'syn region sedAddress matchgroup=Special start=@\\'.__sed_delimiter.'\(\\'.__sed_delimiter.'\)\=@ skip=@[^\\]\(\\\\\)*\\'.__sed_delimiter.'@ end=@'.__sed_delimiter.'I\=@ contains=sedTab'
-	    exe 'syn region sedRegexp'.__sed_i  'matchgroup=Special start=@'.__sed_delimiter.'\(\\\\\|\\'.__sed_delimiter.'\)*@ skip=@[^\\'.__sed_delimiter.']\(\\\\\)*\\'.__sed_delimiter.'@ end=@'.__sed_delimiter.'@me=e-1 contains=sedTab,sedRegexpMeta keepend contained nextgroup=sedReplacement'.__sed_i
-	    exe 'syn region sedReplacement'.__sed_i 'matchgroup=Special start=@'.__sed_delimiter.'\(\\\\\|\\'.__sed_delimiter.'\)*@ skip=@[^\\'.__sed_delimiter.']\(\\\\\)*\\'.__sed_delimiter.'@ end=@'.__sed_delimiter.'@ contains=sedTab,sedReplaceMeta keepend contained nextgroup=sedFlag'
-	endif
-    let __sed_i = __sed_i + 1
+let s:metacharacters = '$*.\^[~'
+while s:i <= s:last
+  let s:delimiter = escape(nr2char(s:i), s:metacharacters)
+  if s:i != s:at
+    exe 'syn region sedAddress matchgroup=Special start=@\\'.s:delimiter.'\%(\\'.s:delimiter.'\)\=@ skip=@[^\\]\%(\\\\\)*\\'.s:delimiter.'@ end=@'.s:delimiter.'[IM]\=@ contains=sedTab'
+    exe 'syn region sedRegexp'.s:i  'matchgroup=Special start=@'.s:delimiter.'\%(\\\\\|\\'.s:delimiter.'\)*@ skip=@[^\\'.s:delimiter.']\%(\\\\\)*\\'.s:delimiter.'@ end=@'.s:delimiter.'@me=e-1 contains=sedTab,sedRegexpMeta keepend contained nextgroup=sedReplacement'.s:i
+    exe 'syn region sedReplacement'.s:i 'matchgroup=Special start=@'.s:delimiter.'\%(\\\\\|\\'.s:delimiter.'\)*@ skip=@[^\\'.s:delimiter.']\%(\\\\\)*\\'.s:delimiter.'@ end=@'.s:delimiter.'@ contains=sedTab,sedReplaceMeta keepend contained nextgroup=@sedFlags'
+  endif
+  let s:i = s:i + 1
 endwhile
-syn region sedAddress matchgroup=Special start=+\\@\(\\@\)\=+ skip=+[^\\]\(\\\\\)*\\@+ end=+@I\=+ contains=sedTab,sedRegexpMeta
-syn region sedRegexp64 matchgroup=Special start=+@\(\\\\\|\\@\)*+ skip=+[^\\@]\(\\\\\)*\\@+ end=+@+me=e-1 contains=sedTab,sedRegexpMeta keepend contained nextgroup=sedReplacement64
-syn region sedReplacement64 matchgroup=Special start=+@\(\\\\\|\\@\)*+ skip=+[^\\@]\(\\\\\)*\\@+ end=+@+ contains=sedTab,sedReplaceMeta keepend contained nextgroup=sedFlag
+syn region sedAddress matchgroup=Special start=+\\@\%(\\@\)\=+ skip=+[^\\]\%(\\\\\)*\\@+ end=+@I\=+ contains=sedTab,sedRegexpMeta
+syn region sedRegexp64 matchgroup=Special start=+@\%(\\\\\|\\@\)*+ skip=+[^\\@]\%(\\\\\)*\\@+ end=+@+me=e-1 contains=sedTab,sedRegexpMeta keepend contained nextgroup=sedReplacement64
+syn region sedReplacement64 matchgroup=Special start=+@\%(\\\\\|\\@\)*+ skip=+[^\\@]\%(\\\\\)*\\@+ end=+@+ contains=sedTab,sedReplaceMeta keepend contained nextgroup=sedFlag
 
-" Since the syntax for the substituion command is very similar to the
+" Since the syntax for the substitution command is very similar to the
 " syntax for the transform command, I use the same pattern matching
 " for both commands.  There is one problem -- the transform command
 " (y) does not allow any flags.  To save memory, I ignore this problem.
@@ -80,7 +92,7 @@ hi def link sedComment		Comment
 hi def link sedDelete		Function
 hi def link sedError		Error
 hi def link sedFlag		Type
-hi def link sedFlagwrite		Constant
+hi def link sedFlagWrite	Constant
 hi def link sedFunction		Function
 hi def link sedLabel		Label
 hi def link sedLineCont		Special
@@ -88,23 +100,24 @@ hi def link sedPutHoldspc	Function
 hi def link sedReplaceMeta	Special
 hi def link sedRegexpMeta	Special
 hi def link sedRW		Constant
-hi def link sedSemicolon		Special
+hi def link sedSemicolon	Special
 hi def link sedST		Function
 hi def link sedSpecial		Special
+hi def link sedTodo		Todo
 hi def link sedWhitespace	NONE
-if exists("highlight_sedtabs")
-hi def link sedTab		Todo
+if s:highlight_tabs
+  hi def link sedTab		Todo
 endif
-let __sed_i = char2nr(" ") " ASCII: 32, EBCDIC: 64
-while __sed_i <= __sed_last
-exe "hi def link sedRegexp".__sed_i		"Macro"
-exe "hi def link sedReplacement".__sed_i	"NONE"
-let __sed_i = __sed_i + 1
+let s:i = char2nr(" ") " ASCII: 32, EBCDIC: 64
+while s:i <= s:last
+  exe "hi def link sedRegexp".s:i	"Macro"
+  exe "hi def link sedReplacement".s:i	"NONE"
+  let s:i = s:i + 1
 endwhile
 
-
-unlet __sed_i __sed_last __sed_delimiter __sed_metacharacters
+unlet s:i s:last s:delimiter s:metacharacters s:at
+unlet s:highlight_tabs
 
 let b:current_syntax = "sed"
 
-" vim: sts=4 sw=4 ts=8
+" vim: nowrap sw=2 sts=2 ts=8 noet: