xref: /vim-8.2.3635/runtime/syntax/po.vim (revision f37506f6)
1" Vim syntax file
2" Language:	po (gettext)
3" Maintainer:	Dwayne Bailey <[email protected]>
4" Last Change:	2015 Jun 07
5" Contributors: Dwayne Bailey (Most advanced syntax highlighting)
6"               Leonardo Fontenelle (Spell checking)
7"               Nam SungHyun <[email protected]> (Original maintainer)
8
9" quit when a syntax file was already loaded
10if exists("b:current_syntax")
11  finish
12endif
13let s:keepcpo= &cpo
14set cpo&vim
15
16syn sync minlines=10
17
18" Identifiers
19syn match  poStatementMsgCTxt "^msgctxt"
20syn match  poStatementMsgidplural "^msgid_plural" contained
21syn match  poPluralCaseN "[0-9]" contained
22syn match  poStatementMsgstr "^msgstr\(\[[0-9]\]\)" contains=poPluralCaseN
23
24" Simple HTML and XML highlighting
25syn match  poHtml "<\_[^<>]\+>" contains=poHtmlTranslatables,poLineBreak
26syn match  poHtmlNot +"<[^<]\+>"+ms=s+1,me=e-1
27syn region poHtmlTranslatables start=+\(abbr\|alt\|content\|summary\|standby\|title\)=\\"+ms=e-1 end=+\\"+ contained contains=@Spell
28syn match poLineBreak +"\n"+ contained
29
30" Translation blocks
31syn region     poMsgCTxt	matchgroup=poStatementMsgCTxt start=+^msgctxt "+rs=e-1 matchgroup=poStringCTxt end=+^msgid "+me=s-1 contains=poStringCTxt
32syn region     poMsgID	matchgroup=poStatementMsgid start=+^msgid "+rs=e-1 matchgroup=poStringID end=+^msgstr\(\|\[[\]0\[]\]\) "+me=s-1 contains=poStringID,poStatementMsgidplural,poStatementMsgid
33syn region     poMsgSTR	matchgroup=poStatementMsgstr start=+^msgstr\(\|\[[\]0\[]\]\) "+rs=e-1 matchgroup=poStringSTR end=+\n\n+me=s-1 contains=poStringSTR,poStatementMsgstr
34syn region poStringCTxt	start=+"+ skip=+\\\\\|\\"+ end=+"+
35syn region poStringID	start=+"+ skip=+\\\\\|\\"+ end=+"+ contained
36                            \ contains=poSpecial,poFormat,poCommentKDE,poPluralKDE,poKDEdesktopFile,poHtml,poAcceleratorId,poHtmlNot,poVariable
37syn region poStringSTR	start=+"+ skip=+\\\\\|\\"+ end=+"+ contained
38                            \ contains=@Spell,poSpecial,poFormat,poHeaderItem,poCommentKDEError,poHeaderUndefined,poPluralKDEError,poMsguniqError,poKDEdesktopFile,poHtml,poAcceleratorStr,poHtmlNot,poVariable
39
40" Header and Copyright
41syn match     poHeaderItem "\(Project-Id-Version\|Report-Msgid-Bugs-To\|POT-Creation-Date\|PO-Revision-Date\|Last-Translator\|Language-Team\|Language\|MIME-Version\|Content-Type\|Content-Transfer-Encoding\|Plural-Forms\|X-Generator\): " contained
42syn match     poHeaderUndefined "\(PACKAGE VERSION\|YEAR-MO-DA HO:MI+ZONE\|FULL NAME <EMAIL@ADDRESS>\|LANGUAGE <[email protected]>\|CHARSET\|ENCODING\|INTEGER\|EXPRESSION\)" contained
43syn match     poCopyrightUnset "SOME DESCRIPTIVE TITLE\|FIRST AUTHOR <EMAIL@ADDRESS>, YEAR\|Copyright (C) YEAR Free Software Foundation, Inc\|YEAR THE PACKAGE\'S COPYRIGHT HOLDER\|PACKAGE" contained
44
45" Translation comment block including: translator comment, automatic coments, flags and locations
46syn match     poComment "^#.*$"
47syn keyword   poFlagFuzzy fuzzy contained
48syn match     poCommentTranslator "^# .*$" contains=poCopyrightUnset
49syn match     poCommentAutomatic "^#\..*$"
50syn match     poCommentSources	"^#:.*$"
51syn match     poCommentFlags "^#,.*$" contains=poFlagFuzzy
52syn match     poDiffOld '\(^#| "[^{]*+}\|{+[^}]*+}\|{+[^}]*\|"$\)' contained
53syn match     poDiffNew '\(^#| "[^{]*-}\|{-[^}]*-}\|{-[^}]*\|"$\)' contained
54syn match     poCommentDiff "^#|.*$" contains=poDiffOld,poDiffNew
55
56" Translations (also includes header fields as they appear in a translation msgstr)
57syn region poCommentKDE	  start=+"_: +ms=s+1 end="\\n" end="\"\n^msgstr"me=s-1 contained
58syn region poCommentKDEError  start=+"\(\|\s\+\)_:+ms=s+1 end="\\n" end=+"\n\n+me=s-1 contained
59syn match  poPluralKDE   +"_n: +ms=s+1 contained
60syn region poPluralKDEError   start=+"\(\|\s\+\)_n:+ms=s+1 end="\"\n\n"me=s-1 contained
61syn match  poSpecial	contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
62syn match  poFormat	"%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([diuoxXfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained
63syn match  poFormat	"%%" contained
64
65" msguniq and msgcat conflicts
66syn region poMsguniqError matchgroup=poMsguniqErrorMarkers  start="#-#-#-#-#"  end='#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)\\n' contained
67
68" Obsolete messages
69syn match poObsolete "^#\~.*$"
70
71" KDE Name= handling
72syn match poKDEdesktopFile "\"\(Name\|Comment\|GenericName\|Description\|Keywords\|About\)="ms=s+1,me=e-1
73
74" Accelerator keys - this messes up if the preceding or following char is a multibyte unicode char
75syn match poAcceleratorId  contained "[^&_~][&_~]\(\a\|\d\)[^:]"ms=s+1,me=e-1
76syn match poAcceleratorStr  contained "[^&_~][&_~]\(\a\|\d\)[^:]"ms=s+1,me=e-1 contains=@Spell
77
78" Variables simple
79syn match poVariable contained "%\d"
80
81" Define the default highlighting.
82" Only when an item doesn't have highlighting yet
83
84hi def link poCommentSources    PreProc
85hi def link poComment	     Comment
86hi def link poCommentAutomatic  Comment
87hi def link poCommentTranslator Comment
88hi def link poCommentFlags      Special
89hi def link poCommentDiff       Comment
90hi def link poCopyrightUnset    Todo
91hi def link poFlagFuzzy         Todo
92hi def link poDiffOld           Todo
93hi def link poDiffNew          Special
94hi def link poObsolete         Comment
95
96hi def link poStatementMsgid   Statement
97hi def link poStatementMsgstr  Statement
98hi def link poStatementMsgidplural  Statement
99hi def link poStatementMsgCTxt Statement
100hi def link poPluralCaseN      Constant
101
102hi def link poStringCTxt	    Comment
103hi def link poStringID	    String
104hi def link poStringSTR	    String
105hi def link poCommentKDE       Comment
106hi def link poCommentKDEError  Error
107hi def link poPluralKDE        Comment
108hi def link poPluralKDEError   Error
109hi def link poHeaderItem       Identifier
110hi def link poHeaderUndefined  Todo
111hi def link poKDEdesktopFile   Identifier
112
113hi def link poHtml              Identifier
114hi def link poHtmlNot           String
115hi def link poHtmlTranslatables String
116hi def link poLineBreak         String
117
118hi def link poFormat	    poSpecial
119hi def link poSpecial	    Special
120hi def link poAcceleratorId    Special
121hi def link poAcceleratorStr   Special
122hi def link poVariable         Special
123
124hi def link poMsguniqError        Special
125hi def link poMsguniqErrorMarkers Comment
126
127
128let b:current_syntax = "po"
129
130let &cpo = s:keepcpo
131unlet s:keepcpo
132
133" vim:set ts=8 sts=2 sw=2 noet:
134