Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: po (gettext) |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 3 | " Maintainer: Dwayne Bailey <dwayne@translate.org.za> |
Bram Moolenaar | f2571c6 | 2015-06-09 19:44:55 +0200 | [diff] [blame] | 4 | " Last Change: 2015 Jun 07 |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 5 | " Contributors: Dwayne Bailey (Most advanced syntax highlighting) |
| 6 | " Leonardo Fontenelle (Spell checking) |
Bram Moolenaar | 0065906 | 2010-09-21 22:34:02 +0200 | [diff] [blame] | 7 | " Nam SungHyun <namsh@kldp.org> (Original maintainer) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 8 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 9 | " quit when a syntax file was already loaded |
| 10 | if exists("b:current_syntax") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 11 | finish |
| 12 | endif |
Bram Moolenaar | 9a7224b | 2012-04-30 15:56:52 +0200 | [diff] [blame] | 13 | let s:keepcpo= &cpo |
| 14 | set cpo&vim |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 15 | |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 16 | syn sync minlines=10 |
| 17 | |
| 18 | " Identifiers |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 19 | syn match poStatementMsgCTxt "^msgctxt" |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 20 | syn match poStatementMsgidplural "^msgid_plural" contained |
| 21 | syn match poPluralCaseN "[0-9]" contained |
| 22 | syn match poStatementMsgstr "^msgstr\(\[[0-9]\]\)" contains=poPluralCaseN |
| 23 | |
| 24 | " Simple HTML and XML highlighting |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 25 | syn match poHtml "<\_[^<>]\+>" contains=poHtmlTranslatables,poLineBreak |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 26 | syn match poHtmlNot +"<[^<]\+>"+ms=s+1,me=e-1 |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 27 | syn region poHtmlTranslatables start=+\(abbr\|alt\|content\|summary\|standby\|title\)=\\"+ms=e-1 end=+\\"+ contained contains=@Spell |
| 28 | syn match poLineBreak +"\n"+ contained |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 29 | |
| 30 | " Translation blocks |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 31 | syn region poMsgCTxt matchgroup=poStatementMsgCTxt start=+^msgctxt "+rs=e-1 matchgroup=poStringCTxt end=+^msgid "+me=s-1 contains=poStringCTxt |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 32 | syn region poMsgID matchgroup=poStatementMsgid start=+^msgid "+rs=e-1 matchgroup=poStringID end=+^msgstr\(\|\[[\]0\[]\]\) "+me=s-1 contains=poStringID,poStatementMsgidplural,poStatementMsgid |
| 33 | syn region poMsgSTR matchgroup=poStatementMsgstr start=+^msgstr\(\|\[[\]0\[]\]\) "+rs=e-1 matchgroup=poStringSTR end=+\n\n+me=s-1 contains=poStringSTR,poStatementMsgstr |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 34 | syn region poStringCTxt start=+"+ skip=+\\\\\|\\"+ end=+"+ |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 35 | syn region poStringID start=+"+ skip=+\\\\\|\\"+ end=+"+ contained |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 36 | \ contains=poSpecial,poFormat,poCommentKDE,poPluralKDE,poKDEdesktopFile,poHtml,poAcceleratorId,poHtmlNot,poVariable |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 37 | syn region poStringSTR start=+"+ skip=+\\\\\|\\"+ end=+"+ contained |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 38 | \ contains=@Spell,poSpecial,poFormat,poHeaderItem,poCommentKDEError,poHeaderUndefined,poPluralKDEError,poMsguniqError,poKDEdesktopFile,poHtml,poAcceleratorStr,poHtmlNot,poVariable |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 39 | |
| 40 | " Header and Copyright |
Bram Moolenaar | 0065906 | 2010-09-21 22:34:02 +0200 | [diff] [blame] | 41 | syn 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 |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 42 | syn match poHeaderUndefined "\(PACKAGE VERSION\|YEAR-MO-DA HO:MI+ZONE\|FULL NAME <EMAIL@ADDRESS>\|LANGUAGE <LL@li.org>\|CHARSET\|ENCODING\|INTEGER\|EXPRESSION\)" contained |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 43 | syn 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 | |
Viktor Szépe | dbf749b | 2023-10-16 09:53:37 +0200 | [diff] [blame] | 45 | " Translation comment block including: translator comment, automatic comments, flags and locations |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 46 | syn match poComment "^#.*$" |
| 47 | syn keyword poFlagFuzzy fuzzy contained |
| 48 | syn match poCommentTranslator "^# .*$" contains=poCopyrightUnset |
| 49 | syn match poCommentAutomatic "^#\..*$" |
| 50 | syn match poCommentSources "^#:.*$" |
| 51 | syn match poCommentFlags "^#,.*$" contains=poFlagFuzzy |
Bram Moolenaar | f2571c6 | 2015-06-09 19:44:55 +0200 | [diff] [blame] | 52 | syn match poDiffOld '\(^#| "[^{]*+}\|{+[^}]*+}\|{+[^}]*\|"$\)' contained |
| 53 | syn match poDiffNew '\(^#| "[^{]*-}\|{-[^}]*-}\|{-[^}]*\|"$\)' contained |
| 54 | syn match poCommentDiff "^#|.*$" contains=poDiffOld,poDiffNew |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 55 | |
| 56 | " Translations (also includes header fields as they appear in a translation msgstr) |
| 57 | syn region poCommentKDE start=+"_: +ms=s+1 end="\\n" end="\"\n^msgstr"me=s-1 contained |
| 58 | syn region poCommentKDEError start=+"\(\|\s\+\)_:+ms=s+1 end="\\n" end=+"\n\n+me=s-1 contained |
| 59 | syn match poPluralKDE +"_n: +ms=s+1 contained |
| 60 | syn region poPluralKDEError start=+"\(\|\s\+\)_n:+ms=s+1 end="\"\n\n"me=s-1 contained |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 61 | syn match poSpecial contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" |
| 62 | syn match poFormat "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([diuoxXfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained |
| 63 | syn match poFormat "%%" contained |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 64 | |
| 65 | " msguniq and msgcat conflicts |
| 66 | syn region poMsguniqError matchgroup=poMsguniqErrorMarkers start="#-#-#-#-#" end='#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)\\n' contained |
| 67 | |
| 68 | " Obsolete messages |
| 69 | syn match poObsolete "^#\~.*$" |
| 70 | |
| 71 | " KDE Name= handling |
| 72 | syn 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 |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 75 | syn match poAcceleratorId contained "[^&_~][&_~]\(\a\|\d\)[^:]"ms=s+1,me=e-1 |
| 76 | syn match poAcceleratorStr contained "[^&_~][&_~]\(\a\|\d\)[^:]"ms=s+1,me=e-1 contains=@Spell |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 77 | |
| 78 | " Variables simple |
| 79 | syn match poVariable contained "%\d" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 80 | |
| 81 | " Define the default highlighting. |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 82 | " Only when an item doesn't have highlighting yet |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 83 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 84 | hi def link poCommentSources PreProc |
| 85 | hi def link poComment Comment |
| 86 | hi def link poCommentAutomatic Comment |
| 87 | hi def link poCommentTranslator Comment |
| 88 | hi def link poCommentFlags Special |
| 89 | hi def link poCommentDiff Comment |
| 90 | hi def link poCopyrightUnset Todo |
| 91 | hi def link poFlagFuzzy Todo |
| 92 | hi def link poDiffOld Todo |
| 93 | hi def link poDiffNew Special |
| 94 | hi def link poObsolete Comment |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 95 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 96 | hi def link poStatementMsgid Statement |
| 97 | hi def link poStatementMsgstr Statement |
| 98 | hi def link poStatementMsgidplural Statement |
| 99 | hi def link poStatementMsgCTxt Statement |
| 100 | hi def link poPluralCaseN Constant |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 101 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 102 | hi def link poStringCTxt Comment |
| 103 | hi def link poStringID String |
| 104 | hi def link poStringSTR String |
| 105 | hi def link poCommentKDE Comment |
| 106 | hi def link poCommentKDEError Error |
| 107 | hi def link poPluralKDE Comment |
| 108 | hi def link poPluralKDEError Error |
| 109 | hi def link poHeaderItem Identifier |
| 110 | hi def link poHeaderUndefined Todo |
| 111 | hi def link poKDEdesktopFile Identifier |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 112 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 113 | hi def link poHtml Identifier |
| 114 | hi def link poHtmlNot String |
| 115 | hi def link poHtmlTranslatables String |
| 116 | hi def link poLineBreak String |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 117 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 118 | hi def link poFormat poSpecial |
| 119 | hi def link poSpecial Special |
| 120 | hi def link poAcceleratorId Special |
| 121 | hi def link poAcceleratorStr Special |
| 122 | hi def link poVariable Special |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 123 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 124 | hi def link poMsguniqError Special |
| 125 | hi def link poMsguniqErrorMarkers Comment |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 126 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 127 | |
| 128 | let b:current_syntax = "po" |
| 129 | |
Bram Moolenaar | 9a7224b | 2012-04-30 15:56:52 +0200 | [diff] [blame] | 130 | let &cpo = s:keepcpo |
| 131 | unlet s:keepcpo |
| 132 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 133 | " vim:set ts=8 sts=2 sw=2 noet: |