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> |
Eisuke Kawashima | 511eb84 | 2024-11-28 18:00:09 +0100 | [diff] [blame] | 4 | " Last Change: 2024 Nov 28 |
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) |
Eisuke Kawashima | 511eb84 | 2024-11-28 18:00:09 +0100 | [diff] [blame] | 8 | " Eisuke Kawashima (add format-flags: #16132) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 10 | " quit when a syntax file was already loaded |
| 11 | if exists("b:current_syntax") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 12 | finish |
| 13 | endif |
Bram Moolenaar | 9a7224b | 2012-04-30 15:56:52 +0200 | [diff] [blame] | 14 | let s:keepcpo= &cpo |
| 15 | set cpo&vim |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 16 | |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 17 | syn sync minlines=10 |
| 18 | |
| 19 | " Identifiers |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 20 | syn match poStatementMsgCTxt "^msgctxt" |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 21 | syn match poStatementMsgidplural "^msgid_plural" contained |
| 22 | syn match poPluralCaseN "[0-9]" contained |
| 23 | syn match poStatementMsgstr "^msgstr\(\[[0-9]\]\)" contains=poPluralCaseN |
| 24 | |
| 25 | " Simple HTML and XML highlighting |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 26 | syn match poHtml "<\_[^<>]\+>" contains=poHtmlTranslatables,poLineBreak |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 27 | syn match poHtmlNot +"<[^<]\+>"+ms=s+1,me=e-1 |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 28 | syn region poHtmlTranslatables start=+\(abbr\|alt\|content\|summary\|standby\|title\)=\\"+ms=e-1 end=+\\"+ contained contains=@Spell |
| 29 | syn match poLineBreak +"\n"+ contained |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 30 | |
| 31 | " Translation blocks |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 32 | 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] | 33 | syn region poMsgID matchgroup=poStatementMsgid start=+^msgid "+rs=e-1 matchgroup=poStringID end=+^msgstr\(\|\[[\]0\[]\]\) "+me=s-1 contains=poStringID,poStatementMsgidplural,poStatementMsgid |
| 34 | 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] | 35 | syn region poStringCTxt start=+"+ skip=+\\\\\|\\"+ end=+"+ |
Eisuke Kawashima | 511eb84 | 2024-11-28 18:00:09 +0100 | [diff] [blame] | 36 | syn region poStringID start=+"+ skip=+\\\\\|\\"+ end=+"+ contained |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 37 | \ contains=poSpecial,poFormat,poCommentKDE,poPluralKDE,poKDEdesktopFile,poHtml,poAcceleratorId,poHtmlNot,poVariable |
Eisuke Kawashima | 511eb84 | 2024-11-28 18:00:09 +0100 | [diff] [blame] | 38 | syn region poStringSTR start=+"+ skip=+\\\\\|\\"+ end=+"+ contained |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 39 | \ 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] | 40 | |
| 41 | " Header and Copyright |
Bram Moolenaar | 0065906 | 2010-09-21 22:34:02 +0200 | [diff] [blame] | 42 | 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] | 43 | 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] | 44 | 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 |
| 45 | |
Viktor Szépe | dbf749b | 2023-10-16 09:53:37 +0200 | [diff] [blame] | 46 | " Translation comment block including: translator comment, automatic comments, flags and locations |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 47 | syn match poComment "^#.*$" |
| 48 | syn keyword poFlagFuzzy fuzzy contained |
Eisuke Kawashima | 511eb84 | 2024-11-28 18:00:09 +0100 | [diff] [blame] | 49 | |
| 50 | syn match poFlagFormat /\<\%(no-\)\?awk-format\>/ contained |
| 51 | syn match poFlagFormat /\<\%(no-\)\?boost-format\>/ contained |
| 52 | syn match poFlagFormat /\<\%(no-\)\?c++-format\>/ contained |
| 53 | syn match poFlagFormat /\<\%(no-\)\?c-format\>/ contained |
| 54 | syn match poFlagFormat /\<\%(no-\)\?csharp-format\>/ contained |
| 55 | syn match poFlagFormat /\<\%(no-\)\?elisp-format\>/ contained |
| 56 | syn match poFlagFormat /\<\%(no-\)\?gcc-internal-format\>/ contained |
| 57 | syn match poFlagFormat /\<\%(no-\)\?gfc-internal-format\>/ contained |
| 58 | syn match poFlagFormat /\<\%(no-\)\?java-format\>/ contained |
| 59 | syn match poFlagFormat /\<\%(no-\)\?java-printf-format\>/ contained |
| 60 | syn match poFlagFormat /\<\%(no-\)\?javascript-format\>/ contained |
| 61 | syn match poFlagFormat /\<\%(no-\)\?kde-format\>/ contained |
| 62 | syn match poFlagFormat /\<\%(no-\)\?librep-format\>/ contained |
| 63 | syn match poFlagFormat /\<\%(no-\)\?lisp-format\>/ contained |
| 64 | syn match poFlagFormat /\<\%(no-\)\?lua-format\>/ contained |
| 65 | syn match poFlagFormat /\<\%(no-\)\?objc-format\>/ contained |
| 66 | syn match poFlagFormat /\<\%(no-\)\?object-pascal-format\>/ contained |
| 67 | syn match poFlagFormat /\<\%(no-\)\?perl-brace-format\>/ contained |
| 68 | syn match poFlagFormat /\<\%(no-\)\?perl-format\>/ contained |
| 69 | syn match poFlagFormat /\<\%(no-\)\?php-format\>/ contained |
| 70 | syn match poFlagFormat /\<\%(no-\)\?python-brace-format\>/ contained |
| 71 | syn match poFlagFormat /\<\%(no-\)\?python-format\>/ contained |
| 72 | syn match poFlagFormat /\<\%(no-\)\?qt-format\>/ contained |
| 73 | syn match poFlagFormat /\<\%(no-\)\?qt-plural-format\>/ contained |
| 74 | syn match poFlagFormat /\<\%(no-\)\?ruby-format\>/ contained |
| 75 | syn match poFlagFormat /\<\%(no-\)\?scheme-format\>/ contained |
| 76 | syn match poFlagFormat /\<\%(no-\)\?sh-format\>/ contained |
| 77 | syn match poFlagFormat /\<\%(no-\)\?smalltalk-format\>/ contained |
| 78 | syn match poFlagFormat /\<\%(no-\)\?tcl-format\>/ contained |
| 79 | syn match poFlagFormat /\<\%(no-\)\?ycp-format\>/ contained |
| 80 | |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 81 | syn match poCommentTranslator "^# .*$" contains=poCopyrightUnset |
Eisuke Kawashima | 511eb84 | 2024-11-28 18:00:09 +0100 | [diff] [blame] | 82 | syn match poCommentAutomatic "^#\..*$" |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 83 | syn match poCommentSources "^#:.*$" |
Eisuke Kawashima | 511eb84 | 2024-11-28 18:00:09 +0100 | [diff] [blame] | 84 | syn match poCommentFlags "^#,.*$" contains=poFlagFuzzy,poFlagFormat |
| 85 | syn match poCommentPrevious "^#|.*$" |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 86 | |
| 87 | " Translations (also includes header fields as they appear in a translation msgstr) |
| 88 | syn region poCommentKDE start=+"_: +ms=s+1 end="\\n" end="\"\n^msgstr"me=s-1 contained |
| 89 | syn region poCommentKDEError start=+"\(\|\s\+\)_:+ms=s+1 end="\\n" end=+"\n\n+me=s-1 contained |
| 90 | syn match poPluralKDE +"_n: +ms=s+1 contained |
| 91 | 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] | 92 | syn match poSpecial contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)" |
| 93 | syn match poFormat "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([diuoxXfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained |
| 94 | syn match poFormat "%%" contained |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 95 | |
| 96 | " msguniq and msgcat conflicts |
| 97 | syn region poMsguniqError matchgroup=poMsguniqErrorMarkers start="#-#-#-#-#" end='#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)-\("\n"\|\)#\("\n"\|\)\\n' contained |
| 98 | |
| 99 | " Obsolete messages |
Eisuke Kawashima | 511eb84 | 2024-11-28 18:00:09 +0100 | [diff] [blame] | 100 | syn match poObsolete "^#\~.*$" |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 101 | |
| 102 | " KDE Name= handling |
| 103 | syn match poKDEdesktopFile "\"\(Name\|Comment\|GenericName\|Description\|Keywords\|About\)="ms=s+1,me=e-1 |
| 104 | |
| 105 | " Accelerator keys - this messes up if the preceding or following char is a multibyte unicode char |
Eisuke Kawashima | 511eb84 | 2024-11-28 18:00:09 +0100 | [diff] [blame] | 106 | syn match poAcceleratorId contained "[^&_~][&_~]\(\a\|\d\)[^:]"ms=s+1,me=e-1 |
Bram Moolenaar | 446cb83 | 2008-06-24 21:56:24 +0000 | [diff] [blame] | 107 | 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] | 108 | |
| 109 | " Variables simple |
| 110 | syn match poVariable contained "%\d" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 111 | |
| 112 | " Define the default highlighting. |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 113 | " Only when an item doesn't have highlighting yet |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 114 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 115 | hi def link poCommentSources PreProc |
| 116 | hi def link poComment Comment |
| 117 | hi def link poCommentAutomatic Comment |
| 118 | hi def link poCommentTranslator Comment |
| 119 | hi def link poCommentFlags Special |
Eisuke Kawashima | 511eb84 | 2024-11-28 18:00:09 +0100 | [diff] [blame] | 120 | hi def link poCommentPrevious Comment |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 121 | hi def link poCopyrightUnset Todo |
| 122 | hi def link poFlagFuzzy Todo |
Eisuke Kawashima | 511eb84 | 2024-11-28 18:00:09 +0100 | [diff] [blame] | 123 | hi def link poFlagFormat Todo |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 124 | hi def link poObsolete Comment |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 125 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 126 | hi def link poStatementMsgid Statement |
| 127 | hi def link poStatementMsgstr Statement |
| 128 | hi def link poStatementMsgidplural Statement |
| 129 | hi def link poStatementMsgCTxt Statement |
| 130 | hi def link poPluralCaseN Constant |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 131 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 132 | hi def link poStringCTxt Comment |
| 133 | hi def link poStringID String |
| 134 | hi def link poStringSTR String |
| 135 | hi def link poCommentKDE Comment |
| 136 | hi def link poCommentKDEError Error |
| 137 | hi def link poPluralKDE Comment |
| 138 | hi def link poPluralKDEError Error |
| 139 | hi def link poHeaderItem Identifier |
| 140 | hi def link poHeaderUndefined Todo |
| 141 | hi def link poKDEdesktopFile Identifier |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 142 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 143 | hi def link poHtml Identifier |
| 144 | hi def link poHtmlNot String |
| 145 | hi def link poHtmlTranslatables String |
| 146 | hi def link poLineBreak String |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 147 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 148 | hi def link poFormat poSpecial |
| 149 | hi def link poSpecial Special |
| 150 | hi def link poAcceleratorId Special |
| 151 | hi def link poAcceleratorStr Special |
| 152 | hi def link poVariable Special |
Bram Moolenaar | d114dbe | 2005-06-22 22:29:18 +0000 | [diff] [blame] | 153 | |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 154 | hi def link poMsguniqError Special |
| 155 | hi def link poMsguniqErrorMarkers Comment |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 156 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 157 | |
| 158 | let b:current_syntax = "po" |
| 159 | |
Bram Moolenaar | 9a7224b | 2012-04-30 15:56:52 +0200 | [diff] [blame] | 160 | let &cpo = s:keepcpo |
| 161 | unlet s:keepcpo |
| 162 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 163 | " vim:set ts=8 sts=2 sw=2 noet: |