annotate runtime/syntax/gitattributes.vim @ 34684:faf891660963 v9.1.0223

patch 9.1.0223: code duplication in loop to add active text properties Commit: https://github.com/vim/vim/commit/1134fdd1b369119d0d6992e3120bb5f7c788b697 Author: Dylan Thacker-Smith <dylan.ah.smith@gmail.com> Date: Thu Mar 28 11:49:46 2024 +0100 patch 9.1.0223: code duplication in loop to add active text properties Problem: There are two dense conditions with duplication that needs to be kept in sync between the while loop break condition and the condition to skip certain text properties. Solution: Refactor the loop by moving while loop conditions into the body of the while loop so they can be shared with skip conditions. `break` and an `active` variable are used to handle the outcome of these merged conditions. (Dylan Thacker-Smith) closes: #14307 Signed-off-by: Dylan Thacker-Smith <dylan.ah.smith@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Thu, 28 Mar 2024 12:00:05 +0100
parents fee9eccee266
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30202
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
1 " Vim syntax file
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
2 " Language: git attributes
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
3 " Maintainer: ObserverOfTime <chronobserver@disroot.org>
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
4 " Filenames: .gitattributes, *.git/info/attributes
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
5 " Last Change: 2022 Sep 09
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
6
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
7 if exists('b:current_syntax')
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
8 finish
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
9 endif
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
10
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
11 let s:cpo_save = &cpoptions
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
12 set cpoptions&vim
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
13
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
14 " Comment
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
15 syn keyword gitattributesTodo contained TODO FIXME XXX
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
16 syn match gitattributesComment /^\s*#.*/ contains=gitattributesTodo
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
17
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
18 " Pattern
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
19 syn match gitattributesPattern /^\s*#\@!\(".\+"\|\S\+\)/ skipwhite
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
20 \ nextgroup=gitattributesAttrPrefixed,gitattributesAttrAssigned skipwhite
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
21 \ contains=gitattributesGlob,gitattributesRange,gitattributesSeparator
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
22 syn match gitattributesGlob /\\\@1<![?*]/ contained
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
23 syn match gitattributesRange /\\\@1<!\[.\{-}\]/ contained
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
24 syn match gitattributesSeparator '/' contained
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
25
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
26 " Attribute
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
27 syn match gitattributesAttrPrefixed /[!-]\?[A-Za-z0-9_.][-A-Za-z0-9_.]*/
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
28 \ transparent contained skipwhite
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
29 \ nextgroup=gitattributesAttrPrefixed,gitattributesAttrAssigned
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
30 \ contains=gitattributesPrefix,gitattributesName
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
31 syn match gitattributesAttrAssigned /[A-Za-z0-9_.][-A-Za-z0-9_.]*=\S\+/
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
32 \ transparent contained skipwhite
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
33 \ nextgroup=gitattributesAttrPrefixed,gitattributesAttrAssigned
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
34 \ contains=gitattributesName,gitattributesAssign,gitattributesBoolean,gitattributesString
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
35 syn match gitattributesName /[A-Za-z0-9_.][-A-Za-z0-9_.]*/
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
36 \ contained nextgroup=gitattributesAssign
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
37 syn match gitattributesPrefix /[!-]/ contained
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
38 \ nextgroup=gitAttributesName
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
39 syn match gitattributesAssign '=' contained
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
40 \ nextgroup=gitattributesBoolean,gitattributesString
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
41 syn match gitattributesString /=\@1<=\S\+/ contained
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
42 syn keyword gitattributesBoolean true false contained
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
43
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
44 " Macro
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
45 syn match gitattributesMacro /^\s*\[attr\]\s*\S\+/
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
46 \ nextgroup=gitattributesAttribute skipwhite
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
47
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
48 hi def link gitattributesAssign Operator
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
49 hi def link gitattributesBoolean Boolean
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
50 hi def link gitattributesComment Comment
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
51 hi def link gitattributesGlob Special
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
52 hi def link gitattributesMacro Define
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
53 hi def link gitattributesName Identifier
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
54 hi def link gitattributesPrefix SpecialChar
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
55 hi def link gitattributesRange Special
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
56 hi def link gitattributesSeparator Delimiter
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
57 hi def link gitattributesString String
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
58 hi def link gitattributesTodo Todo
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
59
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
60 let b:current_syntax = 'gitattributes'
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
61
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
62 let &cpoptions = s:cpo_save
fee9eccee266 Update runtime files
Bram Moolenaar <Bram@vim.org>
parents:
diff changeset
63 unlet s:cpo_save