annotate runtime/syntax/sed.vim @ 32214:a4dafbd8b7d5 v9.0.1438

patch 9.0.1438: .fs files are falsely recognized as forth files Commit: https://github.com/vim/vim/commit/065088d5549e7711668321cc5a77c9a9b684b142 Author: Johan Kotlinski <kotlinski@gmail.com> Date: Sun Apr 2 20:29:38 2023 +0100 patch 9.0.1438: .fs files are falsely recognized as forth files Problem: .fs files are falsely recognized as forth files. Solution: Check 100 lines for something that looks like forth. (Johan Kotlinski, closes #12219, closes #11988)
author Bram Moolenaar <Bram@vim.org>
date Sun, 02 Apr 2023 21:30:05 +0200
parents 3295247d97a5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax file
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
2 " Language: sed
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
3 " Maintainer: Doug Kearns <dougkearns@gmail.com>
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
4 " Previous Maintainer: Haakon Riiser <hakonrk@fys.uio.no>
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
5 " Contributor: Jack Haden-Enneking
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
6 " Last Change: 2022 Oct 15
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
8 " quit when a syntax file was already loaded
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
9 if exists("b:current_syntax")
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
10 finish
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
13 syn keyword sedTodo contained TODO FIXME XXX
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
14
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 syn match sedError "\S"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 syn match sedWhitespace "\s\+" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 syn match sedSemicolon ";"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 syn match sedAddress "[[:digit:]$]"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 syn match sedAddress "\d\+\~\d\+"
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
21 syn region sedAddress matchgroup=Special start="[{,;]\s*/\%(\\/\)\="lc=1 skip="[^\\]\%(\\\\\)*\\/" end="/I\=" contains=sedTab,sedRegexpMeta
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
22 syn region sedAddress matchgroup=Special start="^\s*/\%(\\/\)\=" skip="[^\\]\%(\\\\\)*\\/" end="/I\=" contains=sedTab,sedRegexpMeta
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
23 syn match sedFunction "[dDgGhHlnNpPqQx=]\s*\%($\|;\)" contains=sedSemicolon,sedWhitespace
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
24 if exists("g:sed_dialect") && g:sed_dialect ==? "bsd"
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
25 syn match sedComment "^\s*#.*$" contains=sedTodo
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
26 else
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
27 syn match sedFunction "[dDgGhHlnNpPqQx=]\s*\ze#" contains=sedSemicolon,sedWhitespace
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
28 syn match sedComment "#.*$" contains=sedTodo
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
29 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 syn match sedLabel ":[^;]*"
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
31 syn match sedLineCont "^\%(\\\\\)*\\$" contained
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
32 syn match sedLineCont "[^\\]\%(\\\\\)*\\$"ms=e contained
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 syn match sedSpecial "[{},!]"
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
34
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
35 " continue to silently support the old name
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
36 let s:highlight_tabs = v:false
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
37 if exists("g:highlight_sedtabs") || get(g:, "sed_highlight_tabs", 0)
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
38 let s:highlight_tabs = v:true
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
39 syn match sedTab "\t" contained
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 " Append/Change/Insert
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 syn region sedACI matchgroup=sedFunction start="[aci]\\$" matchgroup=NONE end="^.*$" contains=sedLineCont,sedTab
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 syn region sedBranch matchgroup=sedFunction start="[bt]" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 syn region sedRW matchgroup=sedFunction start="[rw]" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 " Substitution/transform with various delimiters
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
49 syn region sedFlagWrite matchgroup=sedFlag start="w" matchgroup=sedSemicolon end=";\|$" contains=sedWhitespace contained
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
50 syn match sedFlag "[[:digit:]gpI]*w\=" contains=sedFlagWrite contained
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 syn match sedRegexpMeta "[.*^$]" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 syn match sedRegexpMeta "\\." contains=sedTab contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 syn match sedRegexpMeta "\[.\{-}\]" contains=sedTab contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 syn match sedRegexpMeta "\\{\d\*,\d*\\}" contained
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
55 syn match sedRegexpMeta "\\%(.\{-}\\)" contains=sedTab contained
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
56 syn match sedReplaceMeta "&\|\\\%($\|.\)" contains=sedTab contained
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " Metacharacters: $ * . \ ^ [ ~
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 " @ is used as delimiter and treated on its own below
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
60 let s:at = char2nr("@")
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
61 let s:i = char2nr(" ") " ASCII: 32, EBCDIC: 64
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 if has("ebcdic")
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
63 let s:last = 255
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 else
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
65 let s:last = 126
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 endif
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
67 let s:metacharacters = '$*.\^[~'
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
68 while s:i <= s:last
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
69 let s:delimiter = escape(nr2char(s:i), s:metacharacters)
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
70 if s:i != s:at
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
71 exe 'syn region sedAddress matchgroup=Special start=@\\'.s:delimiter.'\%(\\'.s:delimiter.'\)\=@ skip=@[^\\]\%(\\\\\)*\\'.s:delimiter.'@ end=@'.s:delimiter.'[IM]\=@ contains=sedTab'
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
72 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
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
73 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'
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
74 endif
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
75 let s:i = s:i + 1
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 endwhile
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
77 syn region sedAddress matchgroup=Special start=+\\@\%(\\@\)\=+ skip=+[^\\]\%(\\\\\)*\\@+ end=+@I\=+ contains=sedTab,sedRegexpMeta
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
78 syn region sedRegexp64 matchgroup=Special start=+@\%(\\\\\|\\@\)*+ skip=+[^\\@]\%(\\\\\)*\\@+ end=+@+me=e-1 contains=sedTab,sedRegexpMeta keepend contained nextgroup=sedReplacement64
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
79 syn region sedReplacement64 matchgroup=Special start=+@\%(\\\\\|\\@\)*+ skip=+[^\\@]\%(\\\\\)*\\@+ end=+@+ contains=sedTab,sedReplaceMeta keepend contained nextgroup=sedFlag
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
81 " Since the syntax for the substitution command is very similar to the
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 " syntax for the transform command, I use the same pattern matching
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 " for both commands. There is one problem -- the transform command
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 " (y) does not allow any flags. To save memory, I ignore this problem.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 syn match sedST "[sy]" nextgroup=sedRegexp\d\+
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
10051
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
88 hi def link sedAddress Macro
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
89 hi def link sedACI NONE
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
90 hi def link sedBranch Label
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
91 hi def link sedComment Comment
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
92 hi def link sedDelete Function
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
93 hi def link sedError Error
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
94 hi def link sedFlag Type
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
95 hi def link sedFlagWrite Constant
10051
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
96 hi def link sedFunction Function
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
97 hi def link sedLabel Label
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
98 hi def link sedLineCont Special
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
99 hi def link sedPutHoldspc Function
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
100 hi def link sedReplaceMeta Special
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
101 hi def link sedRegexpMeta Special
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
102 hi def link sedRW Constant
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
103 hi def link sedSemicolon Special
10051
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
104 hi def link sedST Function
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
105 hi def link sedSpecial Special
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
106 hi def link sedTodo Todo
10051
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
107 hi def link sedWhitespace NONE
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
108 if s:highlight_tabs
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
109 hi def link sedTab Todo
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
110 endif
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
111 let s:i = char2nr(" ") " ASCII: 32, EBCDIC: 64
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
112 while s:i <= s:last
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
113 exe "hi def link sedRegexp".s:i "Macro"
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
114 exe "hi def link sedReplacement".s:i "NONE"
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
115 let s:i = s:i + 1
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 2231
diff changeset
116 endwhile
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
118 unlet s:i s:last s:delimiter s:metacharacters s:at
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
119 unlet s:highlight_tabs
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 let b:current_syntax = "sed"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122
30875
3295247d97a5 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents: 10051
diff changeset
123 " vim: nowrap sw=2 sts=2 ts=8 noet: