diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-02 12:45:09 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2021-05-02 12:53:49 -0400 |
commit | 3bc852cabf5326079c710c772d5e925f3b151c3a (patch) | |
tree | d18aae5e5541374596a3f2f9a053966009dbbe2b | |
parent | 7e36c9a2d3ddcb8b31e318e25767cfb32fa69391 (diff) | |
download | rneovim-3bc852cabf5326079c710c772d5e925f3b151c3a.tar.gz rneovim-3bc852cabf5326079c710c772d5e925f3b151c3a.tar.bz2 rneovim-3bc852cabf5326079c710c772d5e925f3b151c3a.zip |
vim-patch:11e3c5ba8203
Update runtime files
https://github.com/vim/vim/commit/11e3c5ba820325b69cb56f70e13c21d7b8808d33
-rw-r--r-- | runtime/doc/ft_raku.txt | 126 | ||||
-rw-r--r-- | runtime/doc/usr_12.txt | 4 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 20 | ||||
-rw-r--r-- | runtime/ftplugin/perl6.vim | 77 | ||||
-rw-r--r-- | runtime/ftplugin/r.vim | 4 | ||||
-rw-r--r-- | runtime/ftplugin/raku.vim | 127 | ||||
-rw-r--r-- | runtime/ftplugin/rhelp.vim | 4 | ||||
-rw-r--r-- | runtime/ftplugin/rmd.vim | 4 | ||||
-rw-r--r-- | runtime/ftplugin/rnoweb.vim | 4 | ||||
-rw-r--r-- | runtime/ftplugin/rrst.vim | 4 | ||||
-rw-r--r-- | runtime/indent/raku.vim (renamed from runtime/indent/perl6.vim) | 21 | ||||
-rw-r--r-- | runtime/indent/rmd.vim | 32 | ||||
-rw-r--r-- | runtime/indent/vim.vim | 5 | ||||
-rw-r--r-- | runtime/syntax/perl6.vim | 2242 | ||||
-rw-r--r-- | runtime/syntax/r.vim | 38 | ||||
-rw-r--r-- | runtime/syntax/raku.vim | 1971 | ||||
-rw-r--r-- | runtime/syntax/rmd.vim | 44 | ||||
-rw-r--r-- | runtime/syntax/rnoweb.vim | 4 |
18 files changed, 2347 insertions, 2384 deletions
diff --git a/runtime/doc/ft_raku.txt b/runtime/doc/ft_raku.txt new file mode 100644 index 0000000000..26ada8a140 --- /dev/null +++ b/runtime/doc/ft_raku.txt @@ -0,0 +1,126 @@ +*vim-raku.txt* The Raku programming language filetype + + *vim-raku* + +Vim-raku provides syntax highlighting, indentation, and other support for +editing Raku programs. + +1. Using Unicode in your Raku files |raku-unicode| + +============================================================================== +1. Using Unicode in your Raku files *raku-unicode* + +Defining new operators using Unicode symbols is a good way to make your +Raku program easy to read. See: +https://perl6advent.wordpress.com/2012/12/18/day-18-formulas-resistance-is-futile/ + +While Raku does define ASCII alternatives for some common operators (see +https://docs.raku.org/language/unicode_ascii), using the full range of +Unicode operators is highly desirable. Your operating system provides input +facilities, but using the features built in to Vim may be preferable. + +The natural way to produce these symbols in Vim is to use digraph shortcuts +(:help |digraphs-use|). Many of them are defined; type `:digraphs` to get +the list. A convenient way to read the list of digraphs is to save them in a +file. From the shell: > + vim +'redir >/tmp/vim-digraphs-listing.txt' +digraphs +'redir END' +q + +Some of them are available with standard Vim digraphs: + << « /0 ∅ !< ≮ ~ + >> » Ob ∘ !> ≯ ~ + ., … 00 ∞ (C ⊂ ~ + (U ∩ -: ÷ )C ⊃ ~ + )U ∪ (_ ⊆ >= ≥ ~ + ?= ≅ )_ ⊇ =< ≤ ~ + (- ∈ ?= ≅ != ≠ ~ + -) ∋ ?- ≃ ~ + +The Greek alphabet is available with '*' followed by a similar Latin symbol: + *p π ~ + *t τ ~ + *X × ~ + +Numbers, subscripts and superscripts are available with 's' and 'S': + 0s ₀ 0S ⁰ ~ + 1s ₁ 1S ¹ ~ + 2s ₂ 9S ⁹ ~ + +But some don´t come defined by default. Those are digraph definitions you can +add in your ~/.vimrc file. > + exec 'digraph \\ '.char2nr('∖') + exec 'digraph \< '.char2nr('≼') + exec 'digraph \> '.char2nr('≽') + exec 'digraph (L '.char2nr('⊈') + exec 'digraph )L '.char2nr('⊉') + exec 'digraph (/ '.char2nr('⊄') + exec 'digraph )/ '.char2nr('⊅') + exec 'digraph )/ '.char2nr('⊅') + exec 'digraph U+ '.char2nr('⊎') + exec 'digraph 0- '.char2nr('⊖') + " Euler's constant + exec 'digraph ne '.char2nr('𝑒') + " Raku's atomic operations marker + exec 'digraph @@ '.char2nr('⚛') + +Alternatively, you can write Insert mode abbreviations that convert ASCII- +based operators into their single-character Unicode equivalent. > + iabbrev <buffer> !(<) ⊄ + iabbrev <buffer> !(<=) ⊈ + iabbrev <buffer> !(>) ⊅ + iabbrev <buffer> !(>=) ⊉ + iabbrev <buffer> !(cont) ∌ + iabbrev <buffer> !(elem) ∉ + iabbrev <buffer> != ≠ + iabbrev <buffer> (&) ∩ + iabbrev <buffer> (+) ⊎ + iabbrev <buffer> (-) ∖ + iabbrev <buffer> (.) ⊍ + iabbrev <buffer> (<) ⊂ + iabbrev <buffer> (<+) ≼ + iabbrev <buffer> (<=) ⊆ + iabbrev <buffer> (>) ⊃ + iabbrev <buffer> (>+) ≽ + iabbrev <buffer> (>=) ⊇ + iabbrev <buffer> (\|) ∪ + iabbrev <buffer> (^) ⊖ + iabbrev <buffer> (atomic) ⚛ + iabbrev <buffer> (cont) ∋ + iabbrev <buffer> (elem) ∈ + iabbrev <buffer> * × + iabbrev <buffer> **0 ⁰ + iabbrev <buffer> **1 ¹ + iabbrev <buffer> **2 ² + iabbrev <buffer> **3 ³ + iabbrev <buffer> **4 ⁴ + iabbrev <buffer> **5 ⁵ + iabbrev <buffer> **6 ⁶ + iabbrev <buffer> **7 ⁷ + iabbrev <buffer> **8 ⁸ + iabbrev <buffer> **9 ⁹ + iabbrev <buffer> ... … + iabbrev <buffer> / ÷ + iabbrev <buffer> << « + iabbrev <buffer> <<[=]<< «=« + iabbrev <buffer> <<[=]>> «=» + iabbrev <buffer> <= ≤ + iabbrev <buffer> =~= ≅ + iabbrev <buffer> >= ≥ + iabbrev <buffer> >> » + iabbrev <buffer> >>[=]<< »=« + iabbrev <buffer> >>[=]>> »=» + iabbrev <buffer> Inf ∞ + iabbrev <buffer> atomic-add-fetch ⚛+= + iabbrev <buffer> atomic-assign ⚛= + iabbrev <buffer> atomic-fetch ⚛ + iabbrev <buffer> atomic-dec-fetch --⚛ + iabbrev <buffer> atomic-fetch-dec ⚛-- + iabbrev <buffer> atomic-fetch-inc ⚛++ + iabbrev <buffer> atomic-inc-fetch ++⚛ + iabbrev <buffer> atomic-sub-fetch ⚛−= + iabbrev <buffer> e 𝑒 + iabbrev <buffer> o ∘ + iabbrev <buffer> pi π + iabbrev <buffer> set() ∅ + iabbrev <buffer> tau τ +< + vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/runtime/doc/usr_12.txt b/runtime/doc/usr_12.txt index 21efa36a25..51a25b1593 100644 --- a/runtime/doc/usr_12.txt +++ b/runtime/doc/usr_12.txt @@ -180,14 +180,14 @@ after it. That way you don't have this problem again. The |:global| command can be combined with the |:move| command to move all the lines before the first line, resulting in a reversed file. The command is: > - :global/^/m 0 + :global/^/move 0 Abbreviated: > :g/^/m 0 The "^" regular expression matches the beginning of the line (even if the line -is blank). The |:move| command moves the matching line to after the mythical +is blank). The |:move| command moves the matching line to after the imaginary zeroth line, so the current matching line becomes the first line of the file. As the |:global| command is not confused by the changing line numbering, |:global| proceeds to match all remaining lines of the file and puts each as diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 081b3ece1c..4cba5a33d0 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -115,12 +115,20 @@ if you are impatient. FOUR KINDS OF NUMBERS -Numbers can be decimal, hexadecimal, octal or binary. A hexadecimal number -starts with "0x" or "0X". For example "0x1f" is decimal 31. An octal number -starts with a zero. "017" is decimal 15. A binary number starts with "0b" or -"0B". For example "0b101" is decimal 5. Careful: don't put a zero before a -decimal number, it will be interpreted as an octal number! - The ":echo" command always prints decimal numbers. Example: > +Numbers can be decimal, hexadecimal, octal or binary. + +A hexadecimal number starts with "0x" or "0X". For example "0x1f" is decimal +31. + +An octal number starts with "0o", "0O" or a zero and another digit. "0o17" is +decimal 15. Using just a zero prefix is not supported in Vim9 script. + +A binary number starts with "0b" or "0B". For example "0b101" is decimal 5. + +A decimal number is just digits. Careful: don't put a zero before a decimal +number, it will be interpreted as an octal number in legacy script! + +The ":echo" command always prints decimal numbers. Example: > :echo 0x7f 0o36 < 127 30 ~ diff --git a/runtime/ftplugin/perl6.vim b/runtime/ftplugin/perl6.vim deleted file mode 100644 index 0467bea0c2..0000000000 --- a/runtime/ftplugin/perl6.vim +++ /dev/null @@ -1,77 +0,0 @@ -" Vim filetype plugin file -" Language: Perl 6 -" Maintainer: vim-perl <vim-perl@googlegroups.com> -" Homepage: https://github.com/vim-perl/vim-perl -" Bugs/requests: https://github.com/vim-perl/vim-perl/issues -" Last Change: 2020 Apr 15 -" Contributors: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com> -" -" Based on ftplugin/perl.vim by Dan Sharp <dwsharp at hotmail dot com> - -if exists("b:did_ftplugin") | finish | endif -let b:did_ftplugin = 1 - -" Make sure the continuation lines below do not cause problems in -" compatibility mode. -let s:save_cpo = &cpo -set cpo-=C - -setlocal formatoptions-=t -setlocal formatoptions+=crqol -setlocal keywordprg=p6doc - -setlocal comments=:# -setlocal commentstring=#%s - -" Change the browse dialog on Win32 to show mainly Perl-related files -if has("gui_win32") - let b:browsefilter = "Perl Source Files (*.pl)\t*.pl\n" . - \ "Perl Modules (*.pm)\t*.pm\n" . - \ "Perl Documentation Files (*.pod)\t*.pod\n" . - \ "All Files (*.*)\t*.*\n" -endif - -" Provided by Ned Konz <ned at bike-nomad dot com> -"--------------------------------------------- -setlocal include=\\<\\(use\\\|require\\)\\> -setlocal includeexpr=substitute(substitute(v:fname,'::','/','g'),'$','.pm','') -setlocal define=[^A-Za-z_] - -" The following line changes a global variable but is necessary to make -" gf and similar commands work. Thanks to Andrew Pimlott for pointing out -" the problem. If this causes a " problem for you, add an -" after/ftplugin/perl6.vim file that contains -" set isfname-=: -set isfname+=: -setlocal iskeyword=48-57,_,A-Z,a-z,:,- - -" Set this once, globally. -if !exists("perlpath") - if executable("perl6") - try - if &shellxquote != '"' - let perlpath = system('perl6 -e "@*INC.join(q/,/).say"') - else - let perlpath = system("perl6 -e '@*INC.join(q/,/).say'") - endif - let perlpath = substitute(perlpath,',.$',',,','') - catch /E145:/ - let perlpath = ".,," - endtry - else - " If we can't call perl to get its path, just default to using the - " current directory and the directory of the current file. - let perlpath = ".,," - endif -endif - -let &l:path=perlpath -"--------------------------------------------- - -" Undo the stuff we changed. -let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isk<" . - \ " | unlet! b:browsefilter" - -" Restore the saved compatibility options. -let &cpo = s:save_cpo -unlet s:save_cpo diff --git a/runtime/ftplugin/r.vim b/runtime/ftplugin/r.vim index 4ea3073922..a78afa2e7e 100644 --- a/runtime/ftplugin/r.vim +++ b/runtime/ftplugin/r.vim @@ -2,7 +2,7 @@ " Language: R " Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com> " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Tue Apr 07, 2015 04:38PM +" Last Change: Sat Aug 15, 2020 11:37AM " Only do this when not yet done for this buffer if exists("b:did_ftplugin") @@ -20,7 +20,7 @@ setlocal formatoptions-=t setlocal commentstring=#\ %s setlocal comments=:#',:###,:##,:# -if has("gui_win32") && !exists("b:browsefilter") +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter = "R Source Files (*.R)\t*.R\n" . \ "Files that include R (*.Rnw *.Rd *.Rmd *.Rrst)\t*.Rnw;*.Rd;*.Rmd;*.Rrst\n" . \ "All Files (*.*)\t*.*\n" diff --git a/runtime/ftplugin/raku.vim b/runtime/ftplugin/raku.vim new file mode 100644 index 0000000000..941222bd38 --- /dev/null +++ b/runtime/ftplugin/raku.vim @@ -0,0 +1,127 @@ +" Vim filetype plugin file +" Language: Raku +" Maintainer: vim-perl <vim-perl@googlegroups.com> +" Homepage: https://github.com/Raku/vim-raku +" Bugs/requests: https://github.com/Raku/vim-raku/issues +" Last Change: 2021-04-16 +" Contributors: Hinrik Örn Sigurðsson <hinrik.sig@gmail.com> +" +" Based on ftplugin/perl.vim by Dan Sharp <dwsharp at hotmail dot com> + +if exists("b:did_ftplugin") | finish | endif +let b:did_ftplugin = 1 + +" Make sure the continuation lines below do not cause problems in +" compatibility mode. +let s:save_cpo = &cpo +set cpo-=C + +setlocal formatoptions-=t +setlocal formatoptions+=crqol +setlocal keywordprg=p6doc + +setlocal comments=:#\|,:#=,:# +setlocal commentstring=#%s + +" Provided by Ned Konz <ned at bike-nomad dot com> +"--------------------------------------------- +setlocal include=\\<\\(use\\\|require\\)\\> +setlocal includeexpr=substitute(v:fname,'::','/','g') +setlocal suffixesadd=.rakumod,.rakudoc,.pm6,.pm +setlocal define=[^A-Za-z_] + +" The following line changes a global variable but is necessary to make +" gf and similar commands work. Thanks to Andrew Pimlott for pointing out +" the problem. If this causes a problem for you, add an +" after/ftplugin/raku.vim file that contains +" set isfname-=: +set isfname+=: +setlocal iskeyword=@,48-57,_,192-255,- + +" Raku exposes its CompUnits through $*REPO, but mapping module names to +" compunit paths is nontrivial. Probably it's more convenient to rely on +" people using zef, which has a handy store of sources for modules it has +" installed. +func s:compareReverseFtime(a, b) + let atime = getftime(a:a) + let btime = getftime(a:b) + return atime > btime ? -1 : atime == btime ? 0 : 1 +endfunc + +let &l:path = "lib,." +if exists('$RAKULIB') + let &l:path = &l:path . "," . $RAKULIB +endif +let &l:path = &l:path . "," . join( + \ sort(glob("~/.zef/store/*/*/lib", 0, 1), "s:compareReverseFtime"), + \ ',') + +" Convert ascii-based ops into their single-character unicode equivalent +if get(g:, 'raku_unicode_abbrevs', 0) + iabbrev <buffer> !(<) ⊄ + iabbrev <buffer> !(<=) ⊈ + iabbrev <buffer> !(>) ⊅ + iabbrev <buffer> !(>=) ⊉ + iabbrev <buffer> !(cont) ∌ + iabbrev <buffer> !(elem) ∉ + iabbrev <buffer> != ≠ + iabbrev <buffer> (&) ∩ + iabbrev <buffer> (+) ⊎ + iabbrev <buffer> (-) ∖ + iabbrev <buffer> (.) ⊍ + iabbrev <buffer> (<) ⊂ + iabbrev <buffer> (<+) ≼ + iabbrev <buffer> (<=) ⊆ + iabbrev <buffer> (>) ⊃ + iabbrev <buffer> (>+) ≽ + iabbrev <buffer> (>=) ⊇ + iabbrev <buffer> (\|) ∪ + iabbrev <buffer> (^) ⊖ + iabbrev <buffer> (atomic) ⚛ + iabbrev <buffer> (cont) ∋ + iabbrev <buffer> (elem) ∈ + iabbrev <buffer> * × + iabbrev <buffer> **0 ⁰ + iabbrev <buffer> **1 ¹ + iabbrev <buffer> **2 ² + iabbrev <buffer> **3 ³ + iabbrev <buffer> **4 ⁴ + iabbrev <buffer> **5 ⁵ + iabbrev <buffer> **6 ⁶ + iabbrev <buffer> **7 ⁷ + iabbrev <buffer> **8 ⁸ + iabbrev <buffer> **9 ⁹ + iabbrev <buffer> ... … + iabbrev <buffer> / ÷ + iabbrev <buffer> << « + iabbrev <buffer> <<[=]<< «=« + iabbrev <buffer> <<[=]>> «=» + iabbrev <buffer> <= ≤ + iabbrev <buffer> =~= ≅ + iabbrev <buffer> >= ≥ + iabbrev <buffer> >> » + iabbrev <buffer> >>[=]<< »=« + iabbrev <buffer> >>[=]>> »=» + iabbrev <buffer> Inf ∞ + iabbrev <buffer> atomic-add-fetch ⚛+= + iabbrev <buffer> atomic-assign ⚛= + iabbrev <buffer> atomic-fetch ⚛ + iabbrev <buffer> atomic-dec-fetch --⚛ + iabbrev <buffer> atomic-fetch-dec ⚛-- + iabbrev <buffer> atomic-fetch-inc ⚛++ + iabbrev <buffer> atomic-inc-fetch ++⚛ + iabbrev <buffer> atomic-sub-fetch ⚛−= + iabbrev <buffer> e 𝑒 + iabbrev <buffer> o ∘ + iabbrev <buffer> pi π + iabbrev <buffer> set() ∅ + iabbrev <buffer> tau τ +endif + +" Undo the stuff we changed. +let b:undo_ftplugin = "setlocal fo< com< cms< inc< inex< def< isf< isk< kp< path<" . + \ " | unlet! b:browsefilter" + +" Restore the saved compatibility options. +let &cpo = s:save_cpo +unlet s:save_cpo diff --git a/runtime/ftplugin/rhelp.vim b/runtime/ftplugin/rhelp.vim index fdac38f3e9..d0b546d62d 100644 --- a/runtime/ftplugin/rhelp.vim +++ b/runtime/ftplugin/rhelp.vim @@ -2,7 +2,7 @@ " Language: R help file " Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com> " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Tue Apr 07, 2015 04:37PM +" Last Change: Sat Aug 15, 2020 12:01PM " Only do this when not yet done for this buffer if exists("b:did_ftplugin") @@ -17,7 +17,7 @@ set cpo&vim setlocal iskeyword=@,48-57,_,. -if has("gui_win32") && !exists("b:browsefilter") +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" . \ "All Files (*.*)\t*.*\n" endif diff --git a/runtime/ftplugin/rmd.vim b/runtime/ftplugin/rmd.vim index 7b0db8dbb5..2ee72ffc6c 100644 --- a/runtime/ftplugin/rmd.vim +++ b/runtime/ftplugin/rmd.vim @@ -2,7 +2,7 @@ " Language: R Markdown file " Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com> " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Sun Jul 22, 2018 06:51PM +" Last Change: Sat Aug 15, 2020 12:03PM " Original work by Alex Zvoleff (adjusted from R help for rmd by Michel Kuhlmann) " Only do this when not yet done for this buffer @@ -46,7 +46,7 @@ runtime ftplugin/pandoc.vim " Don't load another plugin for this buffer let b:did_ftplugin = 1 -if has("gui_win32") && !exists("b:browsefilter") +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" . \ "All Files (*.*)\t*.*\n" endif diff --git a/runtime/ftplugin/rnoweb.vim b/runtime/ftplugin/rnoweb.vim index e184399dcb..dc5f1b5e06 100644 --- a/runtime/ftplugin/rnoweb.vim +++ b/runtime/ftplugin/rnoweb.vim @@ -2,7 +2,7 @@ " Language: Rnoweb " Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com> " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Tue Apr 07, 2015 04:37PM +" Last Change: Sat Aug 15, 2020 12:02PM " Only do this when not yet done for this buffer if exists("b:did_ftplugin") @@ -24,7 +24,7 @@ setlocal iskeyword=@,48-57,_,. setlocal suffixesadd=.bib,.tex setlocal comments=b:%,b:#,b:##,b:###,b:#' -if has("gui_win32") && !exists("b:browsefilter") +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" . \ "All Files (*.*)\t*.*\n" endif diff --git a/runtime/ftplugin/rrst.vim b/runtime/ftplugin/rrst.vim index 3e82847d35..a56fd6478e 100644 --- a/runtime/ftplugin/rrst.vim +++ b/runtime/ftplugin/rrst.vim @@ -2,7 +2,7 @@ " Language: reStructuredText documentation format with R code " Maintainer: Jakson Alves de Aquino <jalvesaq@gmail.com> " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Wed Nov 01, 2017 10:47PM +" Last Change: Sat Aug 15, 2020 12:02PM " Original work by Alex Zvoleff " Only do this when not yet done for this buffer @@ -37,7 +37,7 @@ if !exists("g:rrst_dynamic_comments") || (exists("g:rrst_dynamic_comments") && g setlocal formatexpr=FormatRrst() endif -if has("gui_win32") && !exists("b:browsefilter") +if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") let b:browsefilter = "R Source Files (*.R *.Rnw *.Rd *.Rmd *.Rrst)\t*.R;*.Rnw;*.Rd;*.Rmd;*.Rrst\n" . \ "All Files (*.*)\t*.*\n" endif diff --git a/runtime/indent/perl6.vim b/runtime/indent/raku.vim index 51c7923182..3f9b49ec77 100644 --- a/runtime/indent/perl6.vim +++ b/runtime/indent/raku.vim @@ -36,7 +36,7 @@ let b:did_indent = 1 " Is syntax highlighting active ? let b:indent_use_syntax = has("syntax") -setlocal indentexpr=GetPerl6Indent() +setlocal indentexpr=GetRakuIndent() " we reset it first because the Perl 5 indent file might have been loaded due " to a .pl/pm file extension, and indent files don't clean up afterwards @@ -50,7 +50,7 @@ endif let s:cpo_save = &cpo set cpo-=C -function! GetPerl6Indent() +function! GetRakuIndent() " Get the line to be indented let cline = getline(v:lnum) @@ -60,11 +60,6 @@ function! GetPerl6Indent() return 0 endif - " Don't reindent coments on first column - if cline =~ '^#' - return 0 - endif - " Get current syntax item at the line's first char let csynid = '' if b:indent_use_syntax @@ -72,7 +67,7 @@ function! GetPerl6Indent() endif " Don't reindent POD and heredocs - if csynid =~ "^p6Pod" + if csynid =~ "^rakuPod" return indent(v:lnum) endif @@ -92,7 +87,7 @@ function! GetPerl6Indent() let skippin = 2 while skippin let synid = synIDattr(synID(lnum,1,0),"name") - if (synid =~ "^p6Pod" || synid =~ "p6Comment") + if (synid =~ "^rakuPod" || synid =~ "rakuComment") let lnum = prevnonblank(lnum - 1) if lnum == 0 return 0 @@ -107,19 +102,19 @@ function! GetPerl6Indent() endif if line =~ '[<«\[{(]\s*\(#[^)}\]»>]*\)\=$' - let ind = ind + shiftwidth() + let ind = ind + &sw endif if cline =~ '^\s*[)}\]»>]' - let ind = ind - shiftwidth() + let ind = ind - &sw endif " Indent lines that begin with 'or' or 'and' if cline =~ '^\s*\(or\|and\)\>' if line !~ '^\s*\(or\|and\)\>' - let ind = ind + shiftwidth() + let ind = ind + &sw endif elseif line =~ '^\s*\(or\|and\)\>' - let ind = ind - shiftwidth() + let ind = ind - &sw endif return ind diff --git a/runtime/indent/rmd.vim b/runtime/indent/rmd.vim index 83fe4e4fed..8fd57257fa 100644 --- a/runtime/indent/rmd.vim +++ b/runtime/indent/rmd.vim @@ -2,7 +2,7 @@ " Language: Rmd " Author: Jakson Alves de Aquino <jalvesaq@gmail.com> " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Sun Aug 19, 2018 09:14PM +" Last Change: Sun Mar 28, 2021 08:05PM " Only load this indent file when no other was loaded. @@ -13,7 +13,7 @@ runtime indent/r.vim let s:RIndent = function(substitute(&indentexpr, "()", "", "")) let b:did_indent = 1 -setlocal indentkeys=0{,0},:,!^F,o,O,e +setlocal indentkeys=0{,0},<:>,!^F,o,O,e setlocal indentexpr=GetRmdIndent() if exists("*GetRmdIndent") @@ -23,6 +23,21 @@ endif let s:cpo_save = &cpo set cpo&vim +" Simple Python indentation algorithm +function s:GetPyIndent() + let plnum = prevnonblank(v:lnum - 1) + let pline = getline(plnum) + let cline = getline(v:lnum) + if pline =~ '^s```\s*{\s*python ' + return 0 + elseif pline =~ ':$' + return indent(plnum) + &shiftwidth + elseif cline =~ 'else:$' + return indent(plnum) - &shiftwidth + endif + return indent(plnum) +endfunction + function s:GetMdIndent() let pline = getline(v:lnum - 1) let cline = getline(v:lnum) @@ -37,13 +52,14 @@ function s:GetMdIndent() endfunction function s:GetYamlIndent() - let pline = getline(v:lnum - 1) + let plnum = prevnonblank(v:lnum - 1) + let pline = getline(plnum) if pline =~ ':\s*$' - return indent(v:lnum) + shiftwidth() + return indent(plnum) + shiftwidth() elseif pline =~ '^\s*- ' return indent(v:lnum) + 2 endif - return indent(prevnonblank(v:lnum - 1)) + return indent(plnum) endfunction function GetRmdIndent() @@ -52,9 +68,11 @@ function GetRmdIndent() endif if search('^[ \t]*```{r', "bncW") > search('^[ \t]*```$', "bncW") return s:RIndent() - elseif v:lnum > 1 && search('^---$', "bnW") == 1 && - \ (search('^---$', "nW") > v:lnum || search('^...$', "nW") > v:lnum) + elseif v:lnum > 1 && (search('^---$', "bnW") == 1 && + \ (search('^---$', "nW") > v:lnum || search('^\.\.\.$', "nW") > v:lnum)) return s:GetYamlIndent() + elseif search('^[ \t]*```{python', "bncW") > search('^[ \t]*```$', "bncW") + return s:GetPyIndent() else return s:GetMdIndent() endif diff --git a/runtime/indent/vim.vim b/runtime/indent/vim.vim index 3cebf299f1..ee3d39490d 100644 --- a/runtime/indent/vim.vim +++ b/runtime/indent/vim.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Vim script " Maintainer: Bram Moolenaar <Bram@vim.org> -" Last Change: 2021 Feb 18 +" Last Change: 2021 Apr 18 " Only load this indent file when no other was loaded. if exists("b:did_indent") @@ -71,7 +71,8 @@ function GetVimIndentIntern() " End of heredoc: use indent of matching start line let lnum = v:lnum - 1 while lnum > 0 - if synIDattr(synID(lnum, 1, 1), "name") !~ 'vimLetHereDoc' + let attr = synIDattr(synID(lnum, 1, 1), "name") + if attr != '' && attr !~ 'vimLetHereDoc' return indent(lnum) endif let lnum -= 1 diff --git a/runtime/syntax/perl6.vim b/runtime/syntax/perl6.vim deleted file mode 100644 index 62ddc456e2..0000000000 --- a/runtime/syntax/perl6.vim +++ /dev/null @@ -1,2242 +0,0 @@ -" Vim syntax file -" Language: Perl 6 -" Maintainer: vim-perl <vim-perl@googlegroups.com> -" Homepage: https://github.com/vim-perl/vim-perl/tree/master -" Bugs/requests: https://github.com/vim-perl/vim-perl/issues -" Last Change: 2020 Apr 15 - -" Contributors: Luke Palmer <fibonaci@babylonia.flatirons.org> -" Moritz Lenz <moritz@faui2k3.org> -" Hinrik Örn Sigurðsson <hinrik.sig@gmail.com> -" -" This is a big undertaking. Perl 6 is the sort of language that only Perl -" can parse. But I'll do my best to get vim to. -" -" You can associate the extension ".pl" with the filetype "perl6" by setting -" autocmd BufNewFile,BufRead *.pl setf perl6 -" in your ~/.vimrc. But that will infringe on Perl 5, so you might want to -" put a modeline near the beginning or end of your Perl 6 files instead: -" # vim: filetype=perl6 - -" TODO: -" * Deal with s:Perl5// -" * m:s// is a match, not a substitution -" * Make these highlight as strings, not operators: -" <==> <=:=> <===> <=~> <« »> «>» «<» -" * Allow more keywords to match as function calls(leave() is export(), etc) -" * Optimization: use nextgroup instead of lookaround (:help syn-nextgroup) -" * Fix s''' substitutions being matched as package names -" * Match s/// and m/// better, so things like "$s/" won't match -" * Add more support for folding (:help syn-fold) -" * Add more syntax syncing hooks (:help syn-sync) -" * Q//: -" :to, :heredoc -" interpolate \q:s{$scalar} (though the spec isn't very clear on it) -" -" Impossible TODO?: -" * Unspace -" * Unicode bracketing characters for quoting (there are so many) -" * Various tricks depending on context. I.e. we can't know when Perl -" expects «*» to be a string or a hyperoperator. The latter is presumably -" more common, so that's what we assume. -" * Selective highlighting of Pod formatting codes with the :allow option -" * Arbitrary number, order, and negation of adverbs to Q//, q//, qq//. -" Currently only the first adverb is considered significant. Anything -" more would require an exponential amount of regexes, making this -" already slow syntax file even slower. -" -" If you want to have Pir code inside Q:PIR// strings highlighted, do: -" let perl6_embedded_pir=1 -" -" The above requires pir.vim, which you can find in Parrot's repository: -" https://svn.parrot.org/parrot/trunk/editor/ -" -" Some less than crucial things have been made optional to speed things up. -" Look at the comments near the if/else branches in this file to see exactly -" which features are affected. "perl6_extended_all" enables everything. -" -" The defaults are: -" -" unlet perl6_extended_comments -" unlet perl6_extended_q -" unlet perl6_extended_all - -" quit when a syntax file was already loaded -if exists("b:current_syntax") - finish -endif -let s:keepcpo= &cpo -set cpo&vim - -" identifiers -syn match p6Normal display "\K\%(\k\|[-']\K\@=\)*" - -" This is used in the for loops below -" Don't use the "syn keyword" construct because that always has higher -" priority than matches/regions, so the words can't be autoquoted with -" the "=>" and "p5=>" operators. All the lookaround stuff is to make sure -" we don't match them as part of some other identifier. -let s:before_keyword = " display \"\\%(\\k\\|\\K\\@<=[-']\\)\\@<!\\%(" -let s:after_keyword = "\\)\\%(\\k\\|[-']\\K\\@=\\)\\@!\"" - -" Billions of keywords -let s:keywords = { - \ "p6Attention": [ - \ "ACHTUNG ATTN ATTENTION FIXME NB TODO TBD WTF XXX NOTE", - \ ], - \ "p6DeclareRoutine": [ - \ "macro sub submethod method multi proto only rule token regex category", - \ ], - \ "p6Module": [ - \ "module class role package enum grammar slang subset", - \ ], - \ "p6Variable": [ - \ "self", - \ ], - \ "p6Include": [ - \ "use require", - \ ], - \ "p6Conditional": [ - \ "if else elsif unless", - \ ], - \ "p6VarStorage": [ - \ "let my our state temp has constant", - \ ], - \ "p6Repeat": [ - \ "for loop repeat while until gather given", - \ ], - \ "p6FlowControl": [ - \ "take do when next last redo return contend maybe defer", - \ "default exit make continue break goto leave async lift", - \ ], - \ "p6TypeConstraint": [ - \ "is as but trusts of returns handles where augment supersede", - \ ], - \ "p6ClosureTrait": [ - \ "BEGIN CHECK INIT START FIRST ENTER LEAVE KEEP", - \ "UNDO NEXT LAST PRE POST END CATCH CONTROL TEMP", - \ ], - \ "p6Exception": [ - \ "die fail try warn", - \ ], - \ "p6Property": [ - \ "prec irs ofs ors export deep binary unary reparsed rw parsed cached", - \ "readonly defequiv will ref copy inline tighter looser equiv assoc", - \ "required", - \ ], - \ "p6Number": [ - \ "NaN Inf", - \ ], - \ "p6Pragma": [ - \ "oo fatal", - \ ], - \ "p6Type": [ - \ "Object Any Junction Whatever Capture Match", - \ "Signature Proxy Matcher Package Module Class", - \ "Grammar Scalar Array Hash KeyHash KeySet KeyBag", - \ "Pair List Seq Range Set Bag Mapping Void Undef", - \ "Failure Exception Code Block Routine Sub Macro", - \ "Method Submethod Regex Str Blob Char Byte", - \ "Codepoint Grapheme StrPos StrLen Version Num", - \ "Complex num complex Bit bit bool True False", - \ "Increasing Decreasing Ordered Callable AnyChar", - \ "Positional Associative Ordering KeyExtractor", - \ "Comparator OrderingPair IO KitchenSink Role", - \ "Int int int1 int2 int4 int8 int16 int32 int64", - \ "Rat rat rat1 rat2 rat4 rat8 rat16 rat32 rat64", - \ "Buf buf buf1 buf2 buf4 buf8 buf16 buf32 buf64", - \ "UInt uint uint1 uint2 uint4 uint8 uint16 uint32", - \ "uint64 Abstraction utf8 utf16 utf32", - \ ], - \ "p6Operator": [ - \ "div x xx mod also leg cmp before after eq ne le lt", - \ "gt ge eqv ff fff and andthen Z X or xor", - \ "orelse extra m mm rx s tr", - \ ], -\ } - -for [group, words] in items(s:keywords) - let s:words_space = join(words, " ") - let s:temp = split(s:words_space) - let s:words = join(s:temp, "\\|") - exec "syn match ". group ." ". s:before_keyword . s:words . s:after_keyword -endfor -unlet s:keywords s:words_space s:temp s:words - -" More operators -" Don't put a "\+" at the end of the character class. That makes it so -" greedy that the "%" " in "+%foo" won't be allowed to match as a sigil, -" among other things -syn match p6Operator display "[-+/*~?|=^!%&,<>.;\\]" -syn match p6Operator display "\%(:\@<!::\@!\|::=\|\.::\)" -" these require whitespace on the left side -syn match p6Operator display "\%(\s\|^\)\@<=\%(xx=\|p5=>\)" -" "i" requires a digit to the left, and no keyword char to the right -syn match p6Operator display "\d\@<=i\k\@!" -" index overloading -syn match p6Operator display "\%(&\.(\@=\|@\.\[\@=\|%\.{\@=\)" - -" all infix operators except nonassocative ones -let s:infix_a = [ - \ "div % mod +& +< +> \\~& ?& \\~< \\~> +| +\\^ \\~| \\~\\^ ?| ?\\^ xx x", - \ "\\~ && & also <== ==> <<== ==>> == != < <= > >= \\~\\~ eq ne lt le gt", - \ "ge =:= === eqv before after \\^\\^ min max \\^ff ff\\^ \\^ff\\^", - \ "\\^fff fff\\^ \\^fff\\^ fff ff ::= := \\.= => , : p5=> Z minmax", - \ "\\.\\.\\. and andthen or orelse xor \\^ += -= /= \\*= \\~= //= ||=", - \ "+ - \\*\\* \\* // / \\~ || |", -\ ] -" nonassociative infix operators -let s:infix_n = "but does <=> leg cmp \\.\\. \\.\\.\\^\\^ \\^\\.\\. \\^\\.\\.\\^" - -let s:infix_a_long = join(s:infix_a, " ") -let s:infix_a_words = split(s:infix_a_long) -let s:infix_a_pattern = join(s:infix_a_words, "\\|") - -let s:infix_n_words = split(s:infix_n) -let s:infix_n_pattern = join(s:infix_n_words, "\\|") - -let s:both = [s:infix_a_pattern, s:infix_n_pattern] -let s:infix = join(s:both, "\\|") - -let s:infix_assoc = "!\\?\\%(" . s:infix_a_pattern . "\\)" -let s:infix = "!\\?\\%(" . s:infix . "\\)" - -unlet s:infix_a s:infix_a_long s:infix_a_words s:infix_a_pattern -unlet s:infix_n s:infix_n_pattern s:both - -" [+] reduce -exec "syn match p6ReduceOp display \"\\k\\@<!\\[[R\\\\]\\?!\\?". s:infix_assoc ."]\\%(«\\|<<\\)\\?\"" -unlet s:infix_assoc - -" Reverse and cross operators (Rop, Xop) -exec "syn match p6ReverseCrossOp display \"[RX]". s:infix ."\"" - -" q() or whatever() is always a function call -syn match p6Normal display "\K\%(\k\|[-']\K\@=\)*(\@=" - -" basically all builtins that can be followed by parentheses -let s:routines = [ - \ "eager hyper substr index rindex grep map sort join lines hints chmod", - \ "split reduce min max reverse truncate zip cat roundrobin classify", - \ "first sum keys values pairs defined delete exists elems end kv any", - \ "all one wrap shape key value name pop push shift splice unshift floor", - \ "ceiling abs exp log log10 rand sign sqrt sin cos tan round strand", - \ "roots cis unpolar polar atan2 pick chop p5chop chomp p5chomp lc", - \ "lcfirst uc ucfirst capitalize normalize pack unpack quotemeta comb", - \ "samecase sameaccent chars nfd nfc nfkd nfkc printf sprintf caller", - \ "evalfile run runinstead nothing want bless chr ord gmtime time eof", - \ "localtime gethost getpw chroot getlogin getpeername kill fork wait", - \ "perl graphs codes bytes clone print open read write readline say seek", - \ "close opendir readdir slurp pos fmt vec link unlink symlink uniq pair", - \ "asin atan sec cosec cotan asec acosec acotan sinh cosh tanh asinh", - \ "acos acosh atanh sech cosech cotanh sech acosech acotanh asech ok", - \ "plan_ok dies_ok lives_ok skip todo pass flunk force_todo use_ok isa_ok", - \ "diag is_deeply isnt like skip_rest unlike cmp_ok eval_dies_ok nok_error", - \ "eval_lives_ok approx is_approx throws_ok version_lt plan eval succ pred", - \ "times nonce once signature new connect operator undef undefine sleep", - \ "from to infix postfix prefix circumfix postcircumfix minmax lazy count", - \ "unwrap getc pi e context void quasi body each contains rewinddir subst", - \ "can isa flush arity assuming rewind callwith callsame nextwith nextsame", - \ "attr eval_elsewhere none srand trim trim_start trim_end lastcall WHAT", - \ "WHERE HOW WHICH VAR WHO WHENCE ACCEPTS REJECTS does not true iterator by", - \ "re im invert flip", -\ ] - -" we want to highlight builtins like split() though, so this comes afterwards -" TODO: check if this would be faster as one big regex -let s:words_space = join(s:routines, " ") -let s:temp = split(s:words_space) -let s:words = join(s:temp, "\\|") -exec "syn match p6Routine ". s:before_keyword . s:words . s:after_keyword -unlet s:before_keyword s:after_keyword s:words_space s:temp s:words s:routines - -" packages, must come after all the keywords -syn match p6Normal display "\%(::\)\@<=\K\%(\k\|[-']\K\@=\)*" -syn match p6Normal display "\K\%(\k\|[-']\K\@=\)*\%(::\)\@=" - -" some standard packages -syn match p6Type display "\%(::\|\k\|\K\@<=[-']\)\@<!\%(Order\%(::Same\|::Increase\|::Decrease\)\?\)\%(\k\|[-']\K\@=\)\@!" -syn match p6Type display "\%(::\|\k\|\K\@<=[-']\)\@<!\%(Bool\%(::True\|::False\)\?\)\%(\k\|[-']\K\@=\)\@!" - - -syn match p6Shebang display "\%^#!.*" -syn match p6BlockLabel display "\%(^\s*\)\@<=\h\w*\s*::\@!\_s\@=" -syn match p6Number display "\k\@<!_\@!\%(\d\|__\@!\)\+_\@<!\%([eE]_\@!+\?\%(\d\|_\)\+\)\?_\@<!" -syn match p6Float display "\k\@<!_\@!\%(\d\|__\@!\)\+_\@<![eE]_\@!-\%(\d\|_\)\+" -syn match p6Float display "\k\@<!_\@<!\%(\d\|__\@!\)*_\@<!\.\@<!\._\@!\.\@!\a\@!\%(\d\|_\)\+_\@<!\%([eE]_\@!\%(\d\|_\)\+\)\?" - -syn match p6NumberBase display "[obxd]" contained -syn match p6Number display "\<0\%(o[0-7][0-7_]*\)\@=" nextgroup=p6NumberBase -syn match p6Number display "\<0\%(b[01][01_]*\)\@=" nextgroup=p6NumberBase -syn match p6Number display "\<0\%(x\x[[:xdigit:]_]*\)\@=" nextgroup=p6NumberBase -syn match p6Number display "\<0\%(d\d[[:digit:]_]*\)\@=" nextgroup=p6NumberBase -syn match p6Number display "\%(\<0o\)\@<=[0-7][0-7_]*" -syn match p6Number display "\%(\<0b\)\@<=[01][01_]*" -syn match p6Number display "\%(\<0x\)\@<=\x[[:xdigit:]_]*" -syn match p6Number display "\%(\<0d\)\@<=\d[[:digit:]_]*" - -syn match p6Version display "\<v\d\@=" nextgroup=p6VersionNum -syn match p6VersionNum display "\d\+" nextgroup=p6VersionDot contained -syn match p6VersionDot display "\.\%(\d\|\*\)\@=" nextgroup=p6VersionNum contained - -" try to distinguish the "is" function from the "is" trail auxiliary -syn match p6Routine display "\%(\%(\S\k\@<!\|^\)\s*\)\@<=is\>" - -" does is a type constraint sometimes -syn match p6TypeConstraint display "does\%(\s*\%(\k\|[-']\K\@=\)\)\@=" - -" int is a type sometimes -syn match p6Type display "\<int\>\%(\s*(\|\s\+\d\)\@!" - -" these Routine names are also Properties, if preceded by "is" -syn match p6Property display "\%(is\s\+\)\@<=\%(signature\|context\|also\|shape\)" - -" The sigil in ::*Package -syn match p6PackageTwigil display "\%(::\)\@<=\*" - -" $<match> -syn region p6MatchVarSigil - \ matchgroup=p6Variable - \ start="\$\%(<<\@!\)\@=" - \ end=">\@<=" - \ contains=p6MatchVar - -syn region p6MatchVar - \ matchgroup=p6Twigil - \ start="<" - \ end=">" - \ contained - -" Contextualizers -syn match p6Context display "\<\%(item\|list\|slice\|hash\)\>" -syn match p6Context display "\%(\$\|@\|%\|&\|@@\)(\@=" - -" the "$" placeholder in "$var1, $, var2 = @list" -syn match p6Placeholder display "\%(,\s*\)\@<=\$\%(\K\|\%([.^*?=!~]\|:\@<!::\@!\)\)\@!" -syn match p6Placeholder display "\$\%(\K\|\%([.^*?=!~]\|:\@<!::\@!\)\)\@!\%(,\s*\)\@=" - -" Quoting - -" one cluster for every quote adverb -syn cluster p6Interp_s - \ add=p6InterpScalar -syn cluster p6Interp_scalar - \ add=p6InterpScalar - -syn cluster p6Interp_a - \ add=p6InterpArray -syn cluster p6Interp_array - \ add=p6InterpArray - -syn cluster p6Interp_h - \ add=p6InterpHash -syn cluster p6Interp_hash - \ add=p6InterpHash - -syn cluster p6Interp_f - \ add=p6InterpFunction -syn cluster p6Interp_f - \ add=p6InterpFunction - -syn cluster p6Interp_c - \ add=p6InterpClosure -syn cluster p6Interp_closure - \ add=p6InterpClosure - - -if exists("perl6_extended_q") || exists("perl6_extended_all") - syn cluster p6Interp_ww - \ add=p6StringSQ - \ add=p6StringDQ - syn cluster p6Interp_quotewords - \ add=p6StringSQ - \ add=p6StringDQ -endif - -syn cluster p6Interp_q - \ add=p6EscQQ - \ add=p6EscBackSlash -syn cluster p6Interp_single - \ add=p6EscQQ - \ add=p6EscBackSlash - -syn cluster p6Interp_b - \ add=@p6Interp_q - \ add=p6Escape - \ add=p6EscOpenCurly - \ add=p6EscCodePoint - \ add=p6EscHex - \ add=p6EscOct - \ add=p6EscOctOld - \ add=p6EscNull -syn cluster p6Interp_backslash - \ add=@p6Interp_q - \ add=p6Escape - \ add=p6EscOpenCurly - \ add=p6EscCodePoint - \ add=p6EscHex - \ add=p6EscOct - \ add=p6EscOctOld - \ add=p6EscNull - -syn cluster p6Interp_qq - \ add=@p6Interp_scalar - \ add=@p6Interp_array - \ add=@p6Interp_hash - \ add=@p6Interp_function - \ add=@p6Interp_closure - \ add=@p6Interp_backslash -syn cluster p6Interp_double - \ add=@p6Interp_scalar - \ add=@p6Interp_array - \ add=@p6Interp_hash - \ add=@p6Interp_function - \ add=@p6Interp_closure - \ add=@p6Interp_backslash - -syn region p6InterpScalar - \ start="\ze\z(\$\%(\%(\%(\d\+\|!\|/\|¢\)\|\%(\%(\%([.^*?=!~]\|:\@<!::\@!\)\K\@=\)\?\K\%(\k\|[-']\K\@=\)*\)\%(\.\%(\K\%(\k\|[-']\K\@=\)*\)\|\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)*\)\.\?\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)\)" - \ start="\ze\z(\$\%(\%(\%(\%([.^*?=!~]\|:\@<!::\@!\)\K\@=\)\?\K\%(\k\|[-']\K\@=\)*\)\|\%(\d\+\|!\|/\|¢\)\)\)" - \ end="\z1\zs" - \ contained - \ contains=TOP - \ keepend - -syn region p6InterpScalar - \ matchgroup=p6Context - \ start="\$\ze()\@!" - \ skip="([^)]*)" - \ end=")\zs" - \ contained - \ contains=TOP - -syn region p6InterpArray - \ start="\ze\z(@\$*\%(\%(\%(!\|/\|¢\)\|\%(\%(\%([.^*?=!~]\|:\@<!::\@!\)\K\@=\)\?\K\%(\k\|[-']\K\@=\)*\)\%(\.\%(\K\%(\k\|[-']\K\@=\)*\)\|\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)*\)\.\?\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)\)" - \ end="\z1\zs" - \ contained - \ contains=TOP - \ keepend - -syn region p6InterpArray - \ matchgroup=p6Context - \ start="@\ze()\@!" - \ start="@@\ze()\@!" - \ skip="([^)]*)" - \ end=")\zs" - \ contained - \ contains=TOP - -syn region p6InterpHash - \ start="\ze\z(%\$*\%(\%(\%(!\|/\|¢\)\|\%(\%(\%([.^*?=!~]\|:\@<!::\@!\)\K\@=\)\?\K\%(\k\|[-']\K\@=\)*\)\%(\.\%(\K\%(\k\|[-']\K\@=\)*\)\|\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)*\)\.\?\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)\)" - \ end="\z1\zs" - \ contained - \ contains=TOP - \ keepend - -syn region p6InterpHash - \ matchgroup=p6Context - \ start="%\ze()\@!" - \ skip="([^)]*)" - \ end=")\zs" - \ contained - \ contains=TOP - -syn region p6InterpFunction - \ start="\ze\z(&\%(\%(!\|/\|¢\)\|\%(\%(\%([.^*?=!~]\|:\@<!::\@!\)\K\@=\)\?\K\%(\k\|[-']\K\@=\)*\%(\.\%(\K\%(\k\|[-']\K\@=\)*\)\|\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)*\)\.\?\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)\)" - \ end="\z1\zs" - \ contained - \ contains=TOP - \ keepend - -syn region p6InterpFunction - \ matchgroup=p6Context - \ start="&\ze()\@!" - \ skip="([^)]*)" - \ end=")\zs" - \ contained - \ contains=TOP - -syn region p6InterpClosure - \ start="\\\@<!{}\@!" - \ skip="{[^}]*}" - \ end="}" - \ contained - \ contains=TOP - \ keepend - -" generic escape -syn match p6Escape display "\\\S" contained - -" escaped closing delimiters -syn match p6EscQuote display "\\'" contained -syn match p6EscDoubleQuote display "\\\"" contained -syn match p6EscCloseAngle display "\\>" contained -syn match p6EscCloseFrench display "\\»" contained -syn match p6EscBackTick display "\\`" contained -syn match p6EscForwardSlash display "\\/" contained -syn match p6EscVerticalBar display "\\|" contained -syn match p6EscExclamation display "\\!" contained -syn match p6EscComma display "\\," contained -syn match p6EscDollar display "\\\$" contained -syn match p6EscCloseCurly display "\\}" contained -syn match p6EscCloseBracket display "\\\]" contained - -" misc escapes -syn match p6EscOctOld display "\\\d\{1,3}" contained -syn match p6EscNull display "\\0\d\@!" contained -syn match p6EscCodePoint display "\%(\\c\)\@<=\%(\d\|\S\|\[\)\@=" contained nextgroup=p6CodePoint -syn match p6EscHex display "\%(\\x\)\@<=\%(\x\|\[\)\@=" contained nextgroup=p6HexSequence -syn match p6EscOct display "\%(\\o\)\@<=\%(\o\|\[\)\@=" contained nextgroup=p6OctSequence -syn match p6EscQQ display "\\qq" contained nextgroup=p6QQSequence -syn match p6EscOpenCurly display "\\{" contained -syn match p6EscHash display "\\#" contained -syn match p6EscBackSlash display "\\\\" contained - -syn region p6QQSequence - \ matchgroup=p6Escape - \ start="\[" - \ skip="\[[^\]]*]" - \ end="]" - \ contained - \ transparent - \ contains=@p6Interp_qq - -syn match p6CodePoint display "\%(\d\+\|\S\)" contained -syn region p6CodePoint - \ matchgroup=p6Escape - \ start="\[" - \ end="]" - \ contained - -syn match p6HexSequence display "\x\+" contained -syn region p6HexSequence - \ matchgroup=p6Escape - \ start="\[" - \ end="]" - \ contained - -syn match p6OctSequence display "\o\+" contained -syn region p6OctSequence - \ matchgroup=p6Escape - \ start="\[" - \ end="]" - \ contained - -" matches :key, :!key, :$var, :key<var>, etc -" Since we don't know in advance how the adverb ends, we use a trick. -" Consume nothing with the start pattern (\ze at the beginning), -" while capturing the whole adverb into \z1 and then putting it before -" the match start (\zs) of the end pattern. -syn region p6Adverb - \ start="\ze\z(:!\?\K\%(\k\|[-']\K\@=\)*\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\?\)" - \ start="\ze\z(:!\?[@$%]\$*\%(::\|\%(\$\@<=\d\+\|!\|/\|¢\)\|\%(\%([.^*?=!~]\|:\@<!::\@!\)\K\)\|\%(\K\%(\k\|[-']\K\@=\)*\)\)\)" - \ end="\z1\zs" - \ contained - \ contains=TOP - \ keepend - -" <words> -" FIXME: not sure how to distinguish this from the "less than" operator -" in all cases. For now, it matches if any of the following is true: -" -" * There is whitespace missing on either side of the "<", since -" people tend to put spaces around "less than" -" * It comes after "enum", "for", "any", "all", or "none" -" * It's the first or last thing on a line (ignoring whitespace) -" * It's preceded by "= " -" -" It never matches when: -" -" * Preceded by [<+~=] (e.g. <<foo>>, =<$foo>) -" * Followed by [-=] (e.g. <--, <=, <==) -syn region p6StringAngle - \ matchgroup=p6Quote - \ start="\%(\<\%(enum\|for\|any\|all\|none\)\>\s*(\?\s*\)\@<=<\%(<\|=>\|[-=]\{1,2}>\@!\)\@!" - \ start="\%(\s\|[<+~=]\)\@<!<\%(<\|=>\|[-=]\{1,2}>\@!\)\@!" - \ start="[<+~=]\@<!<\%(\s\|<\|=>\|[-=]\{1,2}>\@!\)\@!" - \ start="\%(^\s*\)\@<=<\%(<\|=>\|[-=]\{1,2}>\@!\)\@!" - \ start="[<+~=]\@<!<\%(\s*$\)\@=" - \ start="\%(=\s\+\)\@=<\%(<\|=>\|[-=]\{1,2}>\@!\)\@!" - \ skip="\\\@<!\\>" - \ end=">" - \ contains=p6InnerAnglesOne,p6EscBackSlash,p6EscCloseAngle - -syn region p6InnerAnglesOne - \ matchgroup=p6StringAngle - \ start="<" - \ skip="\\\@<!\\>" - \ end=">" - \ transparent - \ contained - \ contains=p6InnerAnglesOne - -" <<words>> -syn region p6StringAngles - \ matchgroup=p6Quote - \ start="<<=\@!" - \ skip="\\\@<!\\>" - \ end=">>" - \ contains=p6InnerAnglesTwo,@p6Interp_qq,p6Comment,p6EscHash,p6EscCloseAngle,p6Adverb,p6StringSQ,p6StringDQ - -syn region p6InnerAnglesTwo - \ matchgroup=p6StringAngles - \ start="<<" - \ skip="\\\@<!\\>" - \ end=">>" - \ transparent - \ contained - \ contains=p6InnerAnglesTwo - -" «words» -syn region p6StringFrench - \ matchgroup=p6Quote - \ start="«" - \ skip="\\\@<!\\»" - \ end="»" - \ contains=p6InnerFrench,@p6Interp_qq,p6Comment,p6EscHash,p6EscCloseFrench,p6Adverb,p6StringSQ,p6StringDQ - -syn region p6InnerFrench - \ matchgroup=p6StringFrench - \ start="«" - \ skip="\\\@<!\\»" - \ end="»" - \ transparent - \ contained - \ contains=p6InnerFrench - -" 'string' -syn region p6StringSQ - \ matchgroup=p6Quote - \ start="'" - \ skip="\\\@<!\\'" - \ end="'" - \ contains=@p6Interp_q,p6EscQuote - -" "string" -syn region p6StringDQ - \ matchgroup=p6Quote - \ start=+"+ - \ skip=+\\\@<!\\"+ - \ end=+"+ - \ contains=@p6Interp_qq,p6EscDoubleQuote - -" Q// and friends. - -syn match p6QuoteQ display "\%([Qq]\%(ww\|to\|[qwxsahfcb]\)\?\)\>" nextgroup=p6QPairs skipwhite skipempty -syn match p6QPairs contained transparent skipwhite skipempty nextgroup=p6StringQ,p6StringQ_PIR "\%(\_s*:!\?\K\%(\k\|[-']\K\@=\)*\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\?\)*" - -if exists("perl6_embedded_pir") - syn include @p6PIR syntax/pir.vim -endif - -" hardcoded set of delimiters -let s:delims = [ - \ ["\\\"", "\\\"", "p6EscDoubleQuote", "\\\\\\@<!\\\\\\\""], - \ ["'", "'", "p6EscQuote", "\\\\\\@<!\\\\'"], - \ ["/", "/", "p6EscForwardSlash", "\\\\\\@<!\\\\/"], - \ ["`", "`", "p6EscBackTick", "\\\\\\@<!\\\\`"], - \ ["|", "|", "p6EscVerticalBar", "\\\\\\@<!\\\\|"], - \ ["!", "!", "p6EscExclamation", "\\\\\\@<!\\\\!"], - \ [",", ",", "p6EscComma", "\\\\\\@<!\\\\,"], - \ ["\\$", "\\$", "p6EscDollar", "\\\\\\@<!\\\\\\$"], - \ ["{", "}", "p6EscCloseCurly", "\\%(\\\\\\@<!\\\\}\\|{[^}]*}\\)"], - \ ["<", ">", "p6EscCloseAngle", "\\%(\\\\\\@<!\\\\>\\|<[^>]*>\\)"], - \ ["«", "»", "p6EscCloseFrench", "\\%(\\\\\\@<!\\\\»\\|«[^»]*»\\)"], - \ ["\\\[", "]", "p6EscCloseBracket", "\\%(\\\\\\@<!\\\\]\\|\\[^\\]]*]\\)"], - \ ["\\s\\@<=(", ")", "p6EscCloseParen", "\\%(\\\\\\@<!\\\\)\\|([^)]*)\\)"], -\ ] - -" double and triple delimiters too -if exists("perl6_extended_q") || exists("perl6_extended_all") - call add(s:delims, ["««", "»»", "p6EscCloseFrench", "\\%(\\\\\\@<!\\\\»»\\|««\\%([^»]\\|»»\\@!\\)*»»\\)"]) - call add(s:delims, ["«««", "»»»", "p6EscCloseFrench", "\\%(\\\\\\@<!\\\\»»»\\|«««\\%([^»]\\|»\\%(»»\\)\\@!\\)*»»»\\)"]) - call add(s:delims, ["{{", "}}", "p6EscCloseCurly", "\\%(\\\\\\@<!\\\\}}\\|{{\\%([^}]\\|}}\\@!\\)*}}\\)"]) - call add(s:delims, ["{{{", "}}}", "p6EscCloseCurly", "\\%(\\\\\\@<!\\\\}}}\\|{{{\\%([^}]\\|}\\%(}}\\)\\@!\\)*}}}\\)"]) - call add(s:delims, ["\\\[\\\[", "]]", "p6EscCloseBracket", "\\%(\\\\\\@<!\\\\]]\\|\\[\\[\\%([^\\]]\\|]]\\@!\\)*]]\\)"]) - call add(s:delims, ["\\\[\\\[\\\[", "]]]", "p6EscCloseBracket", "\\%(\\\\\\@<!\\\\]]]\\|\\[\\[\\[\\%([^\\]]\\|]\\%(]]\\)\\@!\\)*]]]\\)"]) - call add(s:delims, ["\\s\\@<=((", "))", "p6EscCloseParen", "\\%(\\\\\\@<!\\\\))\\|((\\%([^)]\\|))\\@!\\)*))\\)"]) - call add(s:delims, ["\\s\\@<=(((", ")))", "p6EscCloseParen", "\\%(\\\\\\@<!\\\\)))\\|(((\\%([^)]\\|)\\%())\\)\\@!\\)*)))\\)"]) - call add(s:delims, ["\\s\\@<=<<", ">>", "p6EscCloseAngle", "\\%(\\\\\\@<!\\\\>>\\|<<\\%([^>]\\|>>\\@!\\)*>>\\)"]) - call add(s:delims, ["\\s\\@<=<<<", ">>>", "p6EscCloseAngle", "\\%(\\\\\\@<!\\\\>>>\\|<<<\\%([^>]\\|>\\%(>>\\)\\@!\\)*>>>\\)"]) -endif - -if !exists("perl6_extended_q") && !exists("perl6_extended_all") - " simple version, no special highlighting within the string - for [start_delim, end_delim, end_group, skip] in s:delims - exec "syn region p6StringQ matchgroup=p6Quote start=\"".start_delim."\" skip=\"".skip."\" end=\"".end_delim."\" contains=".end_group." contained" - endfor - - if exists("perl6_embedded_pir") - " highlight embedded PIR code - for [start_delim, end_delim, end_group, skip] in s:delims - exec "syn region p6StringQ_PIR matchgroup=p6Quote start=\"\\%(Q\\s*:PIR\\s*\\)\\@<=".start_delim."\" skip=\"".skip."\" end=\"".end_delim."\" contains=@p6PIR,".end_group." contained" - endfor - endif -else - let s:before = "syn region p6StringQ matchgroup=p6Quote start=\"\\%(" - let s:after = "\\%(\\_s*:!\\?\\K\\%(\\k\\|[-']\\K\\@=\\)*\\%(([^)]*)\\|\\[[^\\]]*]\\|<[^>]*>\\|«[^»]*»\\|{[^}]*}\\)\\?\\)*\\_s*\\)\\@<=" - - let s:adverbs = [ - \ ["s", "scalar"], - \ ["a", "array"], - \ ["h", "hash"], - \ ["f", "function"], - \ ["c", "closure"], - \ ["b", "backslash"], - \ ["w", "words"], - \ ["ww", "quotewords"], - \ ["x", "exec"], - \ ] - - " these can't be conjoined with q and qq (e.g. as qqq and qqqq) - let s:q_adverbs = [ - \ ["q", "single"], - \ ["qq", "double"], - \ ] - - for [start_delim, end_delim, end_group, skip] in s:delims - " Q, q, and qq with any number of (ignored) adverbs - exec s:before ."Q". s:after .start_delim."\" end=\"". end_delim ."\""." contained" - exec s:before ."q". s:after .start_delim ."\" skip=\"". skip ."\" end=\"". end_delim ."\" contains=". end_group .",@p6Interp_q"." contained" - exec s:before ."qq". s:after .start_delim ."\" skip=\"". skip ."\" end=\"". end_delim ."\" contains=". end_group .",@p6Interp_qq"." contained" - - for [short, long] in s:adverbs - " Qs, qs, qqs, Qa, qa, qqa, etc, with ignored adverbs - exec s:before ."Q".short. s:after .start_delim ."\" end=\"". end_delim ."\" contains=@p6Interp_".long." contained" - exec s:before ."q".short. s:after .start_delim ."\" skip=\"". skip ."\" end=\"". end_delim ."\" contains=". end_group .",@p6Interp_q,@p6Interp_".long." contained" - exec s:before ."qq".short. s:after .start_delim ."\" skip=\"". skip ."\" end=\"". end_delim ."\" contains=". end_group .",@p6Interp_qq,@p6Interp_".long." contained" - - " Q, q, and qq, with one significant adverb - exec s:before ."Q\\s*:\\%(".short."\\|".long."\\)". s:after .start_delim ."\" end=\"". end_delim ."\" contains=@p6Interp_".long." contained" - for [q_short, q_long] in s:q_adverbs - exec s:before ."Q\\s*:\\%(".q_short."\\|".q_long."\\)". s:after .start_delim ."\" end=\"". end_delim ."\" contains=@p6Interp_".q_long." contained" - endfor - exec s:before ."q\\s*:\\%(".short."\\|".long."\\)". s:after .start_delim ."\" skip=\"". skip ."\" end=\"". end_delim ."\" contains=". end_group .",@p6Interp_q,@p6Interp_".long." contained" - exec s:before ."qq\\s*:\\%(".short."\\|".long."\\)". s:after .start_delim ."\" skip=\"". skip ."\" end=\"". end_delim ."\" contains=". end_group .",@p6Interp_qq,@p6Interp_".long." contained" - - for [short2, long2] in s:adverbs - " Qs, qs, qqs, Qa, qa, qqa, etc, with one significant adverb - exec s:before ."Q".short."\\s*:\\%(".short2."\\|".long2."\\)". s:after .start_delim ."\" end=\"". end_delim ."\" contains=@p6Interp_".long.",@p6Interp_".long2." contained" - for [q_short2, q_long2] in s:q_adverbs - exec s:before ."Q".short."\\s*:\\%(".q_short2."\\|".q_long2."\\)". s:after .start_delim ."\" end=\"". end_delim ."\" contains=@p6Interp_".long.",@p6Interp_".q_long2." contained" - endfor - exec s:before ."q".short."\\s*:\\%(".short2."\\|".long2."\\)". s:after .start_delim ."\" skip=\"". skip ."\" end=\"". end_delim ."\" contains=". end_group .",@p6Interp_q,@p6Interp_".long.",@p6Interp_".long2." contained" - exec s:before ."qq".short."\\s*:\\%(".short2."\\|".long2."\\)". s:after .start_delim ."\" skip=\"". skip ."\" end=\"". end_delim ."\" contains=". end_group .",@p6Interp_qq,@p6Interp_".long.",@p6Interp_".long2." contained" - endfor - endfor - endfor - unlet s:before s:after s:adverbs s:q_adverbs -endif -unlet s:delims - -" Match these so something else above can't. E.g. the "q" in "role q { }" -" should not be considered a string -syn match p6Normal display "\%(\<\%(role\|grammar\|slang\)\s\+\)\@<=\K\%(\k\|[-']\K\@=\)*" - -" :key -syn match p6Operator display ":\@<!::\@!!\?" nextgroup=p6Key -syn match p6Key display "\k\%(\k\|[-']\K\@=\)*" contained - -" => and p5=> autoquoting -syn match p6StringP5Auto display "\K\%(\k\|[-']\K\@=\)*\ze\s\+p5=>" -syn match p6StringAuto display "\K\%(\k\|[-']\K\@=\)*\ze\%(p5\)\@<!=>" -syn match p6StringAuto display "\K\%(\k\|[-']\K\@=\)*\ze\s\+=>" -syn match p6StringAuto display "\K\%(\k\|[-']\K\@=\)*p5\ze=>" - -" Hyperoperators. Needs to come after the quoting operators (<>, «», etc) -exec "syn match p6HyperOp display \"»" .s:infix."»\\?\"" -exec "syn match p6HyperOp display \"«\\?".s:infix."«\"" -exec "syn match p6HyperOp display \"»" .s:infix."«\"" -exec "syn match p6HyperOp display \"«" .s:infix. "»\"" - -exec "syn match p6HyperOp display \">>" .s:infix."\\%(>>\\)\\?\"" -exec "syn match p6HyperOp display \"\\%(<<\\)\\?".s:infix."<<\"" -exec "syn match p6HyperOp display \">>" .s:infix."<<\"" -exec "syn match p6HyperOp display \"<<" .s:infix.">>\"" -unlet s:infix - -" Regexes and grammars - -syn match p6RegexName display "\%(\<\%(regex\|rule\|token\)\s\+\)\@<=\K\%(\k\|[-']\K\@=\)*" nextgroup=p6RegexBlockCrap skipwhite skipempty -syn match p6RegexBlockCrap "[^{]*" nextgroup=p6RegexBlock skipwhite skipempty transparent contained - -syn region p6RegexBlock - \ matchgroup=p6Normal - \ start="{" - \ end="}" - \ contained - \ contains=@p6Regexen,@p6Variables - -" Perl 6 regex bits - -syn cluster p6Regexen - \ add=p6RxMeta - \ add=p6RxEscape - \ add=p6EscHex - \ add=p6EscOct - \ add=p6EscNull - \ add=p6RxAnchor - \ add=p6RxCapture - \ add=p6RxGroup - \ add=p6RxAlternation - \ add=p6RxAdverb - \ add=p6RxAdverbArg - \ add=p6RxStorage - \ add=p6RxAssertion - \ add=p6RxQuoteWords - \ add=p6RxClosure - \ add=p6RxStringSQ - \ add=p6RxStringDQ - \ add=p6Comment - -syn match p6RxMeta display contained ".\%(\k\|\s\)\@<!" -syn match p6RxAnchor display contained "[$^]" -syn match p6RxEscape display contained "\\\S" -syn match p6RxCapture display contained "[()]" -syn match p6RxAlternation display contained "|" -syn match p6RxRange display contained "\.\." - -syn region p6RxClosure - \ matchgroup=p6Normal - \ start="{" - \ end="}" - \ contained - \ containedin=p6RxClosure - \ contains=TOP -syn region p6RxGroup - \ matchgroup=p6StringSpecial2 - \ start="\[" - \ end="]" - \ contained - \ contains=@p6Regexen,@p6Variables -syn region p6RxAssertion - \ matchgroup=p6StringSpecial2 - \ start="<" - \ end=">" - \ contained - \ contains=@p6Regexen,@p6Variables,p6RxCharClass,p6RxAssertCall -syn region p6RxAssertCall - \ matchgroup=p6Normal - \ start="\%(::\|\%(\K\%(\k\|[-']\K\@=\)*\)\)\@<=(\@=" - \ end=")\@<=" - \ contained - \ contains=TOP -syn region p6RxCharClass - \ matchgroup=p6StringSpecial2 - \ start="\%(<[-!+?]\?\)\@<=\[" - \ skip="\\]" - \ end="]" - \ contained - \ contains=p6RxRange,p6RxEscape,p6EscHex,p6EscOct,p6EscNull -syn region p6RxQuoteWords - \ matchgroup=p6StringSpecial2 - \ start="< " - \ end=">" - \ contained -syn region p6RxAdverb - \ start="\ze\z(:!\?\K\%(\k\|[-']\K\@=\)*\)" - \ end="\z1\zs" - \ contained - \ contains=TOP - \ keepend -syn region p6RxAdverbArg - \ start="\%(:!\?\K\%(\k\|[-']\K\@=\)*\)\@<=(" - \ skip="([^)]*)" - \ end=")" - \ contained - \ contains=TOP -syn region p6RxStorage - \ matchgroup=p6Operator - \ start="\%(^\s*\)\@<=:\%(my\>\|temp\>\)\@=" - \ end="$" - \ contains=TOP - \ contained - -" Perl 5 regex bits - -syn cluster p6RegexP5Base - \ add=p6RxP5Escape - \ add=p6RxP5Oct - \ add=p6RxP5Hex - \ add=p6RxP5EscMeta - \ add=p6RxP5CodePoint - \ add=p6RxP5Prop - -" normal regex stuff -syn cluster p6RegexP5 - \ add=@p6RegexP5Base - \ add=p6RxP5Quantifier - \ add=p6RxP5Meta - \ add=p6RxP5QuoteMeta - \ add=p6RxP5ParenMod - \ add=p6RxP5Verb - \ add=p6RxP5Count - \ add=p6RxP5Named - \ add=p6RxP5ReadRef - \ add=p6RxP5WriteRef - \ add=p6RxP5CharClass - \ add=p6RxP5Anchor - -" inside character classes -syn cluster p6RegexP5Class - \ add=@p6RegexP5Base - \ add=p6RxP5Posix - \ add=p6RxP5Range - -syn match p6RxP5Escape display contained "\\\S" -syn match p6RxP5CodePoint display contained "\\c\S\@=" nextgroup=p6RxP5CPId -syn match p6RxP5CPId display contained "\S" -syn match p6RxP5Oct display contained "\\\%(\o\{1,3}\)\@=" nextgroup=p6RxP5OctSeq -syn match p6RxP5OctSeq display contained "\o\{1,3}" -syn match p6RxP5Anchor display contained "[\^$]" -syn match p6RxP5Hex display contained "\\x\%({\x\+}\|\x\{1,2}\)\@=" nextgroup=p6RxP5HexSeq -syn match p6RxP5HexSeq display contained "\x\{1,2}" -syn region p6RxP5HexSeq - \ matchgroup=p6RxP5Escape - \ start="{" - \ end="}" - \ contained -syn region p6RxP5Named - \ matchgroup=p6RxP5Escape - \ start="\%(\\N\)\@<={" - \ end="}" - \ contained -syn match p6RxP5Quantifier display contained "\%([+*]\|(\@<!?\)" -syn match p6RxP5ReadRef display contained "\\[1-9]\d\@!" -syn match p6RxP5ReadRef display contained "\\k<\@=" nextgroup=p6RxP5ReadRefId -syn region p6RxP5ReadRefId - \ matchgroup=p6RxP5Escape - \ start="<" - \ end=">" - \ contained -syn match p6RxP5WriteRef display contained "\\g\%(\d\|{\)\@=" nextgroup=p6RxP5WriteRefId -syn match p6RxP5WriteRefId display contained "\d\+" -syn region p6RxP5WriteRefId - \ matchgroup=p6RxP5Escape - \ start="{" - \ end="}" - \ contained -syn match p6RxP5Prop display contained "\\[pP]\%(\a\|{\)\@=" nextgroup=p6RxP5PropId -syn match p6RxP5PropId display contained "\a" -syn region p6RxP5PropId - \ matchgroup=p6RxP5Escape - \ start="{" - \ end="}" - \ contained -syn match p6RxP5Meta display contained "[(|).]" -syn match p6RxP5ParenMod display contained "(\@<=?\@=" nextgroup=p6RxP5Mod,p6RxP5ModName,p6RxP5Code -syn match p6RxP5Mod display contained "?\%(<\?=\|<\?!\|[#:|]\)" -syn match p6RxP5Mod display contained "?-\?[impsx]\+" -syn match p6RxP5Mod display contained "?\%([-+]\?\d\+\|R\)" -syn match p6RxP5Mod display contained "?(DEFINE)" -syn match p6RxP5Mod display contained "?\%(&\|P[>=]\)" nextgroup=p6RxP5ModDef -syn match p6RxP5ModDef display contained "\h\w*" -syn region p6RxP5ModName - \ matchgroup=p6StringSpecial - \ start="?'" - \ end="'" - \ contained -syn region p6RxP5ModName - \ matchgroup=p6StringSpecial - \ start="?P\?<" - \ end=">" - \ contained -syn region p6RxP5Code - \ matchgroup=p6StringSpecial - \ start="??\?{" - \ end="})\@=" - \ contained - \ contains=TOP -syn match p6RxP5EscMeta display contained "\\[?*.{}()[\]|\^$]" -syn match p6RxP5Count display contained "\%({\d\+\%(,\%(\d\+\)\?\)\?}\)\@=" nextgroup=p6RxP5CountId -syn region p6RxP5CountId - \ matchgroup=p6RxP5Escape - \ start="{" - \ end="}" - \ contained -syn match p6RxP5Verb display contained "(\@<=\*\%(\%(PRUNE\|SKIP\|THEN\)\%(:[^)]*\)\?\|\%(MARK\|\):[^)]*\|COMMIT\|F\%(AIL\)\?\|ACCEPT\)" -syn region p6RxP5QuoteMeta - \ matchgroup=p6RxP5Escape - \ start="\\Q" - \ end="\\E" - \ contained - \ contains=@p6Variables,p6EscBackSlash -syn region p6RxP5CharClass - \ matchgroup=p6StringSpecial - \ start="\[\^\?" - \ skip="\\]" - \ end="]" - \ contained - \ contains=@p6RegexP5Class -syn region p6RxP5Posix - \ matchgroup=p6RxP5Escape - \ start="\[:" - \ end=":]" - \ contained -syn match p6RxP5Range display contained "-" - -" 'string' inside a regex -syn region p6RxStringSQ - \ matchgroup=p6Quote - \ start="'" - \ skip="\\\@<!\\'" - \ end="'" - \ contained - \ contains=p6EscQuote,p6EscBackSlash - -" "string" inside a regex -syn region p6RxStringDQ - \ matchgroup=p6Quote - \ start=+"+ - \ skip=+\\\@<!\\"+ - \ end=+"+ - \ contained - \ contains=p6EscDoubleQuote,p6EscBackSlash - -" $!, $var, $!var, $::var, $package::var $*::package::var, etc -" Thus must come after the matches for the "$" regex anchor, but before -" the match for the $ regex delimiter -syn cluster p6Variables - \ add=p6VarSlash - \ add=p6VarExclam - \ add=p6VarMatch - \ add=p6VarNum - \ add=p6Variable - -syn match p6VarSlash display "\$/" -syn match p6VarExclam display "\$!" -syn match p6VarMatch display "\$¢" -syn match p6VarNum display "\$\d\+" -syn match p6Variable display "\%(@@\|[@&$%]\$*\)\%(::\|\%(\%([.^*?=!~]\|:\@<!::\@!\)\K\)\|\K\)\@=" nextgroup=p6Twigil,p6VarName,p6PackageScope -syn match p6VarName display "\K\%(\k\|[-']\K\@=\)*" contained -syn match p6Twigil display "\%([.^*?=!~]\|:\@<!::\@!\)\K\@=" nextgroup=p6PackageScope,p6VarName contained -syn match p6PackageScope display "\%(\K\%(\k\|[-']\K\@=\)*\)\?::" nextgroup=p6PackageScope,p6VarName contained - -" Perl 6 regex regions - -" /foo/ -" Below some hacks to recognise the // variant. This is virtually impossible -" to catch in all cases as the / is used in so many other ways, but these -" should be the most obvious ones. -" TODO: mostly stolen from perl.vim, might need more work -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\%(\<\%(split\|while\|until\|if\|unless\)\|\.\.\|[-+*!~(\[{=]\)\s*\)\@<=//\@!" - \ start="^//\@!" - \ start=+\s\@<=/[^[:space:][:digit:]$@%=]\@=\%(/\_s*\%([([{$@%&*[:digit:]"'`]\|\_s\w\|[[:upper:]_abd-fhjklnqrt-wyz]\)\)\@!/\@!+ - \ skip="\\/" - \ end="/" - \ contains=@p6Regexen,p6Variable,p6VarExclam,p6VarMatch,p6VarNum - -" m/foo/, mm/foo/, rx/foo/ -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<\%(mm\?\|rx\)\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=//\@!" - \ skip="\\/" - \ end="/" - \ keepend - \ contains=@p6Regexen,p6Variable,p6VarExclam,p6VarMatch,p6VarNum - -" m!foo!, mm!foo!, rx!foo! -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<\%(mm\?\|rx\)\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=!!\@!" - \ skip="\\!" - \ end="!" - \ keepend - \ contains=@p6Regexen,p6Variable,p6VarSlash,p6VarMatch,p6VarNum - -" m$foo$, mm$foo$, rx$foo$, m|foo|, mm|foo|, rx|foo|, etc -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<\%(mm\?\|rx\)\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=\z([\"'`|,$]\)\$\@!" - \ skip="\\\z1" - \ end="\z1" - \ keepend - \ contains=@p6Regexen,@p6Variables - -" m (foo), mm (foo), rx (foo) -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<\%(mm\?\|rx\)\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s\+\)\@<=()\@!)\@!" - \ skip="\\)" - \ end=")" - \ contains=@p6Regexen,@p6Variables - -" m[foo], mm[foo], rx[foo] -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<\%(mm\?\|rx\)\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=\[]\@!]\@!" - \ skip="\\]" - \ end="]" - \ contains=@p6Regexen,@p6Variables - -" m{foo}, mm{foo}, rx{foo} -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<\%(mm\?\|rx\)\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<={}\@!}\@!" - \ skip="\\}" - \ end="}" - \ contains=@p6Regexen,@p6Variables - -" m<foo>, mm<foo>, rx<foo> -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<\%(mm\?\|rx\)\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=<>\@!>\@!" - \ skip="\\>" - \ end=">" - \ contains=@p6Regexen,@p6Variables - -" m«foo», mm«foo», rx«foo» -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<\%(mm\?\|rx\)\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=«»\@!»\@!" - \ skip="\\»" - \ end="»" - \ contains=@p6Regexen,@p6Variables - -" Substitutions - -" s/foo/bar/ -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<s\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=/" - \ skip="\\/" - \ end="/"me=e-1 - \ keepend - \ contains=@p6Regexen,p6Variable,p6VarExclam,p6VarMatch,p6VarNum - \ nextgroup=p6Substitution - -syn region p6Substitution - \ matchgroup=p6Quote - \ start="/" - \ skip="\\/" - \ end="/" - \ contained - \ keepend - \ contains=@p6Interp_qq - -" s!foo!bar! -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<s\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=!" - \ skip="\\!" - \ end="!"me=e-1 - \ keepend - \ contains=@p6Regexen,p6Variable,p6VarSlash,p6VarMatch,p6VarNum - \ nextgroup=p6Substitution - -syn region p6Substitution - \ matchgroup=p6Quote - \ start="!" - \ skip="\\!" - \ end="!" - \ contained - \ keepend - \ contains=@p6Interp_qq - -" s$foo$bar$, s|foo|bar, etc -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<s\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=\z([\"'`|,$]\)" - \ skip="\\\z1" - \ end="\z1"me=e-1 - \ keepend - \ contains=@p6Regexen,@p6Variables - \ nextgroup=p6Substitution - -syn region p6Substitution - \ matchgroup=p6Quote - \ start="\z([\"'`|,$]\)" - \ skip="\\\z1" - \ end="\z1" - \ contained - \ keepend - \ contains=@p6Interp_qq - -" s{foo} -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<s\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<={}\@!" - \ skip="\\}" - \ end="}" - \ contains=@p6Regexen,@p6Variables - -" s[foo] -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<s\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=\[]\@!" - \ skip="\\]" - \ end="]" - \ contains=@p6Regexen,@p6Variables - -" s<foo> -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<s\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=<>\@!" - \ skip="\\>" - \ end=">" - \ contains=@p6Regexen,@p6Variables - -" s«foo» -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<s\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=«»\@!" - \ skip="\\»" - \ end="»" - \ contains=@p6Regexen,@p6Variables - -" s (foo) -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<s\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s\+\)\@<=()\@!" - \ skip="\\)" - \ end=")" - \ contains=@p6Regexen,@p6Variables - -" Perl 5 regex regions - -" m:P5// -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<m\s*:P\%(erl\)\?5\s*\)\@<=/" - \ skip="\\/" - \ end="/" - \ contains=@p6RegexP5,p6Variable,p6VarExclam,p6VarMatch,p6VarNum - -" m:P5!! -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<m\s*:P\%(erl\)\?5\s*\)\@<=!" - \ skip="\\!" - \ end="!" - \ contains=@p6RegexP5,p6Variable,p6VarSlash,p6VarMatch,p6VarNum - -" m:P5$$, m:P5||, etc -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<m\s*:P\%(erl\)\?5\s*\)\@<=\z([\"'`|,$]\)" - \ skip="\\\z1" - \ end="\z1" - \ contains=@p6RegexP5,@p6Variables - -" m:P5 () -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<m\s*:P\%(erl\)\?5\s\+\)\@<=()\@!" - \ skip="\\)" - \ end=")" - \ contains=@p6RegexP5,@p6Variables - -" m:P5[] -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<m\s*:P\%(erl\)\?5\s*\)\@<=[]\@!" - \ skip="\\]" - \ end="]" - \ contains=@p6RegexP5,@p6Variables - -" m:P5{} -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<m\s*:P\%(erl\)\?5\s*\)\@<={}\@!" - \ skip="\\}" - \ end="}" - \ contains=@p6RegexP5,p6Variables - -" m:P5<> -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<m\s*:P\%(erl\)\?5\s*\)\@<=<>\@!" - \ skip="\\>" - \ end=">" - \ contains=@p6RegexP5,p6Variables - -" m:P5«» -syn region p6Match - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<m\s*:P\%(erl\)\?5\s*\)\@<=«»\@!" - \ skip="\\»" - \ end="»" - \ contains=@p6RegexP5,p6Variables - -" Transliteration - -" tr/foo/bar/, tr|foo|bar, etc -syn region p6String - \ matchgroup=p6Quote - \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@<!\<tr\%(\s*:!\?\k\%(\k\|[-']\K\@=\)*\%(([^)]*)\)\?\)*\s*\)\@<=\z([/\"'`|!,$]\)" - \ skip="\\\z1" - \ end="\z1"me=e-1 - \ contains=p6RxRange - \ nextgroup=p6Transliteration - -syn region p6Transliteration - \ matchgroup=p6Quote - \ start="\z([/\"'`|!,$]\)" - \ skip="\\\z1" - \ end="\z1" - \ contained - \ contains=@p6Interp_qq - -" Comments - -" normal end-of-line comment -syn match p6Comment display "#.*" contains=p6Attention - -" Multiline comments. Arbitrary numbers of opening brackets are allowed, -" but we only define regions for 1 to 3 -syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#(" - \ skip="([^)]*)" - \ end=")" - \ matchgroup=p6Error - \ start="^#(" - \ contains=p6Attention,p6Comment -syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#\[" - \ skip="\[[^\]]*]" - \ end="]" - \ matchgroup=p6Error - \ start="^#\[" - \ contains=p6Attention,p6Comment -syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#{" - \ skip="{[^}]*}" - \ end="}" - \ matchgroup=p6Error - \ start="^#{" - \ contains=p6Attention,p6Comment -syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#<" - \ skip="<[^>]*>" - \ end=">" - \ matchgroup=p6Error - \ start="^#<" - \ contains=p6Attention,p6Comment -syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#«" - \ skip="«[^»]*»" - \ end="»" - \ matchgroup=p6Error - \ start="^#«" - \ contains=p6Attention,p6Comment - -" double and triple delimiters -if exists("perl6_extended_comments") || exists("perl6_extended_all") - syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#((" - \ skip="((\%([^)\|))\@!]\)*))" - \ end="))" - \ matchgroup=p6Error - \ start="^#((" - \ contains=p6Attention,p6Comment - syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#(((" - \ skip="(((\%([^)]\|)\%())\)\@!\)*)))" - \ end=")))" - \ matchgroup=p6Error - \ start="^#(((" - \ contains=p6Attention,p6Comment - - syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#\[\[" - \ skip="\[\[\%([^\]]\|]]\@!\)*]]" - \ end="]]" - \ matchgroup=p6Error - \ start="^#\[\[" - \ contains=p6Attention,p6Comment - syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#\[\[\[" - \ skip="\[\[\[\%([^\]]\|]\%(]]\)\@!\)*]]]" - \ end="]]]" - \ matchgroup=p6Error - \ start="^#\[\[\[" - \ contains=p6Attention,p6Comment - - syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#{{" - \ skip="{{\%([^}]\|}}\@!\)*}}" - \ end="}}" - \ matchgroup=p6Error - \ start="^#{{" - \ contains=p6Attention,p6Comment - syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#{{{" - \ skip="{{{\%([^}]\|}\%(}}\)\@!\)*}}}" - \ end="}}}" - \ matchgroup=p6Error - \ start="^#{{{" - \ contains=p6Attention,p6Comment - - syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#<<" - \ skip="<<\%([^>]\|>>\@!\)*>>" - \ end=">>" - \ matchgroup=p6Error - \ start="^#<<" - \ contains=p6Attention,p6Comment - syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#<<<" - \ skip="<<<\%([^>]\|>\%(>>\)\@!\)*>>>" - \ end=">>>" - \ matchgroup=p6Error - \ start="^#<<<" - \ contains=p6Attention,p6Comment - - syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#««" - \ skip="««\%([^»]\|»»\@!\)*»»" - \ end="»»" - \ matchgroup=p6Error - \ start="^#««" - \ contains=p6Attention,p6Comment - syn region p6Comment - \ matchgroup=p6Comment - \ start="^\@<!#«««" - \ skip="«««\%([^»]\|»\%(»»\)\@!\)*»»»" - \ end="»»»" - \ matchgroup=p6Error - \ start="^#«««" - \ contains=p6Attention,p6Comment -endif - -" Pod - -" Abbreviated blocks (implicit code forbidden) -syn region p6PodAbbrRegion - \ matchgroup=p6PodPrefix - \ start="^=\ze\K\k*" - \ end="^\ze\%(\s*$\|=\K\)" - \ contains=p6PodAbbrNoCodeType - \ keepend - -syn region p6PodAbbrNoCodeType - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - \ contains=p6PodName,p6PodAbbrNoCode - -syn match p6PodName contained ".\+" contains=@p6PodFormat -syn match p6PodComment contained ".\+" - -syn region p6PodAbbrNoCode - \ start="^" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - \ contains=@p6PodFormat - -" Abbreviated blocks (everything is code) -syn region p6PodAbbrRegion - \ matchgroup=p6PodPrefix - \ start="^=\zecode\>" - \ end="^\ze\%(\s*$\|=\K\)" - \ contains=p6PodAbbrCodeType - \ keepend - -syn region p6PodAbbrCodeType - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - \ contains=p6PodName,p6PodAbbrCode - -syn region p6PodAbbrCode - \ start="^" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - -" Abbreviated blocks (everything is a comment) -syn region p6PodAbbrRegion - \ matchgroup=p6PodPrefix - \ start="^=\zecomment\>" - \ end="^\ze\%(\s*$\|=\K\)" - \ contains=p6PodAbbrCommentType - \ keepend - -syn region p6PodAbbrCommentType - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - \ contains=p6PodComment,p6PodAbbrNoCode - -" Abbreviated blocks (implicit code allowed) -syn region p6PodAbbrRegion - \ matchgroup=p6PodPrefix - \ start="^=\ze\%(pod\|item\|nested\|\u\+\)\>" - \ end="^\ze\%(\s*$\|=\K\)" - \ contains=p6PodAbbrType - \ keepend - -syn region p6PodAbbrType - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - \ contains=p6PodName,p6PodAbbr - -syn region p6PodAbbr - \ start="^" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - \ contains=@p6PodFormat,p6PodImplicitCode - -" Abbreviated block to end-of-file -syn region p6PodAbbrRegion - \ matchgroup=p6PodPrefix - \ start="^=\zeEND\>" - \ end="\%$" - \ contains=p6PodAbbrEOFType - \ keepend - -syn region p6PodAbbrEOFType - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="\%$" - \ contained - \ contains=p6PodName,p6PodAbbrEOF - -syn region p6PodAbbrEOF - \ start="^" - \ end="\%$" - \ contained - \ contains=@p6PodNestedBlocks,@p6PodFormat,p6PodImplicitCode - -" Directives -syn region p6PodDirectRegion - \ matchgroup=p6PodPrefix - \ start="^=\%(config\|use\)\>" - \ end="^\ze\%([^=]\|=\K\|\s*$\)" - \ contains=p6PodDirectArgRegion - \ keepend - -syn region p6PodDirectArgRegion - \ matchgroup=p6PodType - \ start="\S\+" - \ end="^\ze\%([^=]\|=\K\|\s*$\)" - \ contained - \ contains=p6PodDirectConfigRegion - -syn region p6PodDirectConfigRegion - \ start="" - \ end="^\ze\%([^=]\|=\K\|\s*$\)" - \ contained - \ contains=@p6PodConfig - -" =encoding is a special directive -syn region p6PodDirectRegion - \ matchgroup=p6PodPrefix - \ start="^=encoding\>" - \ end="^\ze\%([^=]\|=\K\|\s*$\)" - \ contains=p6PodEncodingArgRegion - \ keepend - -syn region p6PodEncodingArgRegion - \ matchgroup=p6PodName - \ start="\S\+" - \ end="^\ze\%([^=]\|=\K\|\s*$\)" - \ contained - -" Paragraph blocks (implicit code forbidden) -syn region p6PodParaRegion - \ matchgroup=p6PodPrefix - \ start="^=for\>" - \ end="^\ze\%(\s*$\|=\K\)" - \ contains=p6PodParaNoCodeTypeRegion - \ keepend - \ extend - -syn region p6PodParaNoCodeTypeRegion - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - \ contains=p6PodParaNoCode,p6PodParaConfigRegion - -syn region p6PodParaConfigRegion - \ start="" - \ end="^\ze\%([^=]\|=\k\@<!\)" - \ contained - \ contains=@p6PodConfig - -syn region p6PodParaNoCode - \ start="^[^=]" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - \ contains=@p6PodFormat - -" Paragraph blocks (everything is code) -syn region p6PodParaRegion - \ matchgroup=p6PodPrefix - \ start="^=for\>\ze\s*code\>" - \ end="^\ze\%(\s*$\|=\K\)" - \ contains=p6PodParaCodeTypeRegion - \ keepend - \ extend - -syn region p6PodParaCodeTypeRegion - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - \ contains=p6PodParaCode,p6PodParaConfigRegion - -syn region p6PodParaCode - \ start="^[^=]" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - -" Paragraph blocks (implicit code allowed) -syn region p6PodParaRegion - \ matchgroup=p6PodPrefix - \ start="^=for\>\ze\s*\%(pod\|item\|nested\|\u\+\)\>" - \ end="^\ze\%(\s*$\|=\K\)" - \ contains=p6PodParaTypeRegion - \ keepend - \ extend - -syn region p6PodParaTypeRegion - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - \ contains=p6PodPara,p6PodParaConfigRegion - -syn region p6PodPara - \ start="^[^=]" - \ end="^\ze\%(\s*$\|=\K\)" - \ contained - \ contains=@p6PodFormat,p6PodImplicitCode - -" Paragraph block to end-of-file -syn region p6PodParaRegion - \ matchgroup=p6PodPrefix - \ start="^=for\>\ze\s\+END\>" - \ end="\%$" - \ contains=p6PodParaEOFTypeRegion - \ keepend - \ extend - -syn region p6PodParaEOFTypeRegion - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="\%$" - \ contained - \ contains=p6PodParaEOF,p6PodParaConfigRegion - -syn region p6PodParaEOF - \ start="^[^=]" - \ end="\%$" - \ contained - \ contains=@p6PodNestedBlocks,@p6PodFormat,p6PodImplicitCode - -" Delimited blocks (implicit code forbidden) -syn region p6PodDelimRegion - \ matchgroup=p6PodPrefix - \ start="^=begin\>" - \ end="^=end\>" - \ contains=p6PodDelimNoCodeTypeRegion - \ keepend - \ extend - -syn region p6PodDelimNoCodeTypeRegion - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="^\ze=end\>" - \ contained - \ contains=p6PodDelimNoCode,p6PodDelimConfigRegion - -syn region p6PodDelimConfigRegion - \ start="" - \ end="^\ze\%([^=]\|=\K\|\s*$\)" - \ contained - \ contains=@p6PodConfig - -syn region p6PodDelimNoCode - \ start="^" - \ end="^\ze=end\>" - \ contained - \ contains=@p6PodNestedBlocks,@p6PodFormat - -" Delimited blocks (everything is code) -syn region p6PodDelimRegion - \ matchgroup=p6PodPrefix - \ start="^=begin\>\ze\s*code\>" - \ end="^=end\>" - \ contains=p6PodDelimCodeTypeRegion - \ keepend - \ extend - -syn region p6PodDelimCodeTypeRegion - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="^\ze=end\>" - \ contained - \ contains=p6PodDelimCode,p6PodDelimConfigRegion - -syn region p6PodDelimCode - \ start="^" - \ end="^\ze=end\>" - \ contained - \ contains=@p6PodNestedBlocks - -" Delimited blocks (implicit code allowed) -syn region p6PodDelimRegion - \ matchgroup=p6PodPrefix - \ start="^=begin\>\ze\s*\%(pod\|item\|nested\|\u\+\)\>" - \ end="^=end\>" - \ contains=p6PodDelimTypeRegion - \ keepend - \ extend - -syn region p6PodDelimTypeRegion - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="^\ze=end\>" - \ contained - \ contains=p6PodDelim,p6PodDelimConfigRegion - -syn region p6PodDelim - \ start="^" - \ end="^\ze=end\>" - \ contained - \ contains=@p6PodNestedBlocks,@p6PodFormat,p6PodImplicitCode - -" Delimited block to end-of-file -syn region p6PodDelimRegion - \ matchgroup=p6PodPrefix - \ start="^=begin\>\ze\s\+END\>" - \ end="\%$" - \ contains=p6PodDelimEOFTypeRegion - \ extend - -syn region p6PodDelimEOFTypeRegion - \ matchgroup=p6PodType - \ start="\K\k*" - \ end="\%$" - \ contained - \ contains=p6PodDelimEOF,p6PodDelimConfigRegion - -syn region p6PodDelimEOF - \ start="^" - \ end="\%$" - \ contained - \ contains=@p6PodNestedBlocks,@p6PodFormat,p6PodImplicitCode - -syn cluster p6PodConfig - \ add=p6PodConfigOperator - \ add=p6PodExtraConfig - \ add=p6StringAuto - \ add=p6PodAutoQuote - \ add=p6StringSQ - -syn region p6PodParens - \ start="(" - \ end=")" - \ contained - \ contains=p6Number,p6StringSQ - -syn match p6PodAutoQuote display contained "=>" -syn match p6PodConfigOperator display contained ":!\?" nextgroup=p6PodConfigOption -syn match p6PodConfigOption display contained "[^[:space:](<]\+" nextgroup=p6PodParens,p6StringAngle -syn match p6PodExtraConfig display contained "^=" -syn match p6PodVerticalBar display contained "|" -syn match p6PodColon display contained ":" -syn match p6PodSemicolon display contained ";" -syn match p6PodComma display contained "," -syn match p6PodImplicitCode display contained "^\s.*" - -syn region p6PodDelimEndRegion - \ matchgroup=p6PodType - \ start="\%(^=end\>\)\@<=" - \ end="\K\k*" - -" These may appear inside delimited blocks -syn cluster p6PodNestedBlocks - \ add=p6PodAbbrRegion - \ add=p6PodDirectRegion - \ add=p6PodParaRegion - \ add=p6PodDelimRegion - \ add=p6PodDelimEndRegion - -" Pod formatting codes - -syn cluster p6PodFormat - \ add=p6PodFormatOne - \ add=p6PodFormatTwo - \ add=p6PodFormatThree - \ add=p6PodFormatFrench - -" Balanced angles found inside formatting codes. Ensures proper nesting. - -syn region p6PodFormatAnglesOne - \ matchgroup=p6PodFormat - \ start="<" - \ skip="<[^>]*>" - \ end=">" - \ transparent - \ contained - \ contains=p6PodFormatAnglesFrench,p6PodFormatAnglesOne - -syn region p6PodFormatAnglesTwo - \ matchgroup=p6PodFormat - \ start="<<" - \ skip="<<[^>]*>>" - \ end=">>" - \ transparent - \ contained - \ contains=p6PodFormatAnglesFrench,p6PodFormatAnglesOne,p6PodFormatAnglesTwo - -syn region p6PodFormatAnglesThree - \ matchgroup=p6PodFormat - \ start="<<<" - \ skip="<<<[^>]*>>>" - \ end=">>>" - \ transparent - \ contained - \ contains=p6PodFormatAnglesFrench,p6PodFormatAnglesOne,p6PodFormatAnglesTwo,p6PodFormatAnglesThree - -syn region p6PodFormatAnglesFrench - \ matchgroup=p6PodFormat - \ start="«" - \ skip="«[^»]*»" - \ end="»" - \ transparent - \ contained - \ contains=p6PodFormatAnglesFrench,p6PodFormatAnglesOne,p6PodFormatAnglesTwo,p6PodFormatAnglesThree - -" All formatting codes - -syn region p6PodFormatOne - \ matchgroup=p6PodFormatCode - \ start="\u<" - \ skip="<[^>]*>" - \ end=">" - \ contained - \ contains=p6PodFormatAnglesOne,p6PodFormatFrench,p6PodFormatOne - -syn region p6PodFormatTwo - \ matchgroup=p6PodFormatCode - \ start="\u<<" - \ skip="<<[^>]*>>" - \ end=">>" - \ contained - \ contains=p6PodFormatAnglesTwo,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo - -syn region p6PodFormatThree - \ matchgroup=p6PodFormatCode - \ start="\u<<<" - \ skip="<<<[^>]*>>>" - \ end=">>>" - \ contained - \ contains=p6PodFormatAnglesThree,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree - -syn region p6PodFormatFrench - \ matchgroup=p6PodFormatCode - \ start="\u«" - \ skip="«[^»]*»" - \ end="»" - \ contained - \ contains=p6PodFormatAnglesFrench,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree - -" C<> and V<> don't allow nested formatting formatting codes - -syn region p6PodFormatOne - \ matchgroup=p6PodFormatCode - \ start="[CV]<" - \ skip="<[^>]*>" - \ end=">" - \ contained - \ contains=p6PodFormatAnglesOne - -syn region p6PodFormatTwo - \ matchgroup=p6PodFormatCode - \ start="[CV]<<" - \ skip="<<[^>]*>>" - \ end=">>" - \ contained - \ contains=p6PodFormatAnglesTwo - -syn region p6PodFormatThree - \ matchgroup=p6PodFormatCode - \ start="[CV]<<<" - \ skip="<<<[^>]*>>>" - \ end=">>>" - \ contained - \ contains=p6PodFormatAnglesThree - -syn region p6PodFormatFrench - \ matchgroup=p6PodFormatCode - \ start="[CV]«" - \ skip="«[^»]*»" - \ end="»" - \ contained - \ contains=p6PodFormatAnglesFrench - -" L<> can have a "|" separator - -syn region p6PodFormatOne - \ matchgroup=p6PodFormatCode - \ start="L<" - \ skip="<[^>]*>" - \ end=">" - \ contained - \ contains=p6PodFormatAnglesOne,p6PodFormatFrench,p6PodFormatOne,p6PodVerticalBar - -syn region p6PodFormatTwo - \ matchgroup=p6PodFormatCode - \ start="L<<" - \ skip="<<[^>]*>>" - \ end=">>" - \ contained - \ contains=p6PodFormatAnglesTwo,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodVerticalBar - -syn region p6PodFormatThree - \ matchgroup=p6PodFormatCode - \ start="L<<<" - \ skip="<<<[^>]*>>>" - \ end=">>>" - \ contained - \ contains=p6PodFormatAnglesThree,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree,p6PodVerticalBar - -syn region p6PodFormatFrench - \ matchgroup=p6PodFormatCode - \ start="L«" - \ skip="«[^»]*»" - \ end="»" - \ contained - \ contains=p6PodFormatAnglesFrench,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree,p6PodVerticalBar - -" E<> can have a ";" separator - -syn region p6PodFormatOne - \ matchgroup=p6PodFormatCode - \ start="E<" - \ skip="<[^>]*>" - \ end=">" - \ contained - \ contains=p6PodFormatAnglesOne,p6PodFormatFrench,p6PodFormatOne,p6PodSemiColon - -syn region p6PodFormatTwo - \ matchgroup=p6PodFormatCode - \ start="E<<" - \ skip="<<[^>]*>>" - \ end=">>" - \ contained - \ contains=p6PodFormatAnglesTwo,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodSemiColon - -syn region p6PodFormatThree - \ matchgroup=p6PodFormatCode - \ start="E<<<" - \ skip="<<<[^>]*>>>" - \ end=">>>" - \ contained - \ contains=p6PodFormatAnglesThree,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree,p6PodSemiColon - -syn region p6PodFormatFrench - \ matchgroup=p6PodFormatCode - \ start="E«" - \ skip="«[^»]*»" - \ end="»" - \ contained - \ contains=p6PodFormatAnglesFrench,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree,p6PodSemiColon - -" M<> can have a ":" separator - -syn region p6PodFormatOne - \ matchgroup=p6PodFormatCode - \ start="M<" - \ skip="<[^>]*>" - \ end=">" - \ contained - \ contains=p6PodFormatAnglesOne,p6PodFormatFrench,p6PodFormatOne,p6PodColon - -syn region p6PodFormatTwo - \ matchgroup=p6PodFormatCode - \ start="M<<" - \ skip="<<[^>]*>>" - \ end=">>" - \ contained - \ contains=p6PodFormatAnglesTwo,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodColon - -syn region p6PodFormatThree - \ matchgroup=p6PodFormatCode - \ start="M<<<" - \ skip="<<<[^>]*>>>" - \ end=">>>" - \ contained - \ contains=p6PodFormatAnglesThree,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree,p6PodColon - -syn region p6PodFormatFrench - \ matchgroup=p6PodFormatCode - \ start="M«" - \ skip="«[^»]*»" - \ end="»" - \ contained - \ contains=p6PodFormatAnglesFrench,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree,p6PodColon - -" D<> can have "|" and ";" separators - -syn region p6PodFormatOne - \ matchgroup=p6PodFormatCode - \ start="D<" - \ skip="<[^>]*>" - \ end=">" - \ contained - \ contains=p6PodFormatAnglesOne,p6PodFormatFrench,p6PodFormatOne,p6PodVerticalBar,p6PodSemiColon - -syn region p6PodFormatTwo - \ matchgroup=p6PodFormatCode - \ start="D<<" - \ skip="<<[^>]*>>" - \ end=">>" - \ contained - \ contains=p6PodFormatAngleTwo,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodVerticalBar,p6PodSemiColon - -syn region p6PodFormatThree - \ matchgroup=p6PodFormatCode - \ start="D<<<" - \ skip="<<<[^>]*>>>" - \ end=">>>" - \ contained - \ contains=p6PodFormatAnglesThree,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree,p6PodVerticalBar,p6PodSemiColon - -syn region p6PodFormatFrench - \ matchgroup=p6PodFormatCode - \ start="D«" - \ skip="«[^»]*»" - \ end="»" - \ contained - \ contains=p6PodFormatAnglesFrench,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree,p6PodVerticalBar,p6PodSemiColon - -" X<> can have "|", "," and ";" separators - -syn region p6PodFormatOne - \ matchgroup=p6PodFormatCode - \ start="X<" - \ skip="<[^>]*>" - \ end=">" - \ contained - \ contains=p6PodFormatAnglesOne,p6PodFormatFrench,p6PodFormatOne,p6PodVerticalBar,p6PodSemiColon,p6PodComma - -syn region p6PodFormatTwo - \ matchgroup=p6PodFormatCode - \ start="X<<" - \ skip="<<[^>]*>>" - \ end=">>" - \ contained - \ contains=p6PodFormatAnglesTwo,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodVerticalBar,p6PodSemiColon,p6PodComma - -syn region p6PodFormatThree - \ matchgroup=p6PodFormatCode - \ start="X<<<" - \ skip="<<<[^>]*>>>" - \ end=">>>" - \ contained - \ contains=p6PodFormatAnglesThree,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree,p6PodVerticalBar,p6PodSemiColon,p6PodComma - -syn region p6PodFormatFrench - \ matchgroup=p6PodFormatCode - \ start="X«" - \ skip="«[^»]*»" - \ end="»" - \ contained - \ contains=p6PodFormatAnglesFrench,p6PodFormatFrench,p6PodFormatOne,p6PodFormatTwo,p6PodFormatThree,p6PodVerticalBar,p6PodSemiColon,p6PodComma - -" Define the default highlighting. -" Only when an item doesn't have highlighting yet - -hi def link p6EscOctOld p6Error -hi def link p6PackageTwigil p6Twigil -hi def link p6StringAngle p6String -hi def link p6StringFrench p6String -hi def link p6StringAngles p6String -hi def link p6StringSQ p6String -hi def link p6StringDQ p6String -hi def link p6StringQ p6String -hi def link p6RxStringSQ p6String -hi def link p6RxStringDQ p6String -hi def link p6Substitution p6String -hi def link p6Transliteration p6String -hi def link p6StringAuto p6String -hi def link p6StringP5Auto p6String -hi def link p6Key p6String -hi def link p6Match p6String -hi def link p6RegexBlock p6String -hi def link p6RxP5CharClass p6String -hi def link p6RxP5QuoteMeta p6String -hi def link p6RxCharClass p6String -hi def link p6RxQuoteWords p6String -hi def link p6ReduceOp p6Operator -hi def link p6ReverseCrossOp p6Operator -hi def link p6HyperOp p6Operator -hi def link p6QuoteQ p6Operator -hi def link p6RxRange p6StringSpecial -hi def link p6RxAnchor p6StringSpecial -hi def link p6RxP5Anchor p6StringSpecial -hi def link p6CodePoint p6StringSpecial -hi def link p6RxMeta p6StringSpecial -hi def link p6RxP5Range p6StringSpecial -hi def link p6RxP5CPId p6StringSpecial -hi def link p6RxP5Posix p6StringSpecial -hi def link p6RxP5Mod p6StringSpecial -hi def link p6RxP5HexSeq p6StringSpecial -hi def link p6RxP5OctSeq p6StringSpecial -hi def link p6RxP5WriteRefId p6StringSpecial -hi def link p6HexSequence p6StringSpecial -hi def link p6OctSequence p6StringSpecial -hi def link p6RxP5Named p6StringSpecial -hi def link p6RxP5PropId p6StringSpecial -hi def link p6RxP5Quantifier p6StringSpecial -hi def link p6RxP5CountId p6StringSpecial -hi def link p6RxP5Verb p6StringSpecial -hi def link p6Escape p6StringSpecial2 -hi def link p6EscNull p6StringSpecial2 -hi def link p6EscHash p6StringSpecial2 -hi def link p6EscQQ p6StringSpecial2 -hi def link p6EscQuote p6StringSpecial2 -hi def link p6EscDoubleQuote p6StringSpecial2 -hi def link p6EscBackTick p6StringSpecial2 -hi def link p6EscForwardSlash p6StringSpecial2 -hi def link p6EscVerticalBar p6StringSpecial2 -hi def link p6EscExclamation p6StringSpecial2 -hi def link p6EscDollar p6StringSpecial2 -hi def link p6EscOpenCurly p6StringSpecial2 -hi def link p6EscCloseCurly p6StringSpecial2 -hi def link p6EscCloseBracket p6StringSpecial2 -hi def link p6EscCloseAngle p6StringSpecial2 -hi def link p6EscCloseFrench p6StringSpecial2 -hi def link p6EscBackSlash p6StringSpecial2 -hi def link p6RxEscape p6StringSpecial2 -hi def link p6RxCapture p6StringSpecial2 -hi def link p6RxAlternation p6StringSpecial2 -hi def link p6RxP5 p6StringSpecial2 -hi def link p6RxP5ReadRef p6StringSpecial2 -hi def link p6RxP5Oct p6StringSpecial2 -hi def link p6RxP5Hex p6StringSpecial2 -hi def link p6RxP5EscMeta p6StringSpecial2 -hi def link p6RxP5Meta p6StringSpecial2 -hi def link p6RxP5Escape p6StringSpecial2 -hi def link p6RxP5CodePoint p6StringSpecial2 -hi def link p6RxP5WriteRef p6StringSpecial2 -hi def link p6RxP5Prop p6StringSpecial2 - -hi def link p6Property Tag -hi def link p6Attention Todo -hi def link p6Type Type -hi def link p6Error Error -hi def link p6BlockLabel Label -hi def link p6Float Float -hi def link p6Normal Normal -hi def link p6Package Normal -hi def link p6PackageScope Normal -hi def link p6Number Number -hi def link p6VersionNum Number -hi def link p6String String -hi def link p6Repeat Repeat -hi def link p6Keyword Keyword -hi def link p6Pragma Keyword -hi def link p6Module Keyword -hi def link p6DeclareRoutine Keyword -hi def link p6VarStorage Special -hi def link p6FlowControl Special -hi def link p6NumberBase Special -hi def link p6Twigil Special -hi def link p6StringSpecial2 Special -hi def link p6VersionDot Special -hi def link p6Comment Comment -hi def link p6Include Include -hi def link p6Shebang PreProc -hi def link p6ClosureTrait PreProc -hi def link p6Routine Function -hi def link p6Operator Operator -hi def link p6Version Operator -hi def link p6Context Operator -hi def link p6Quote Delimiter -hi def link p6TypeConstraint PreCondit -hi def link p6Exception Exception -hi def link p6Placeholder Identifier -hi def link p6Variable Identifier -hi def link p6VarSlash Identifier -hi def link p6VarNum Identifier -hi def link p6VarExclam Identifier -hi def link p6VarMatch Identifier -hi def link p6VarName Identifier -hi def link p6MatchVar Identifier -hi def link p6RxP5ReadRefId Identifier -hi def link p6RxP5ModDef Identifier -hi def link p6RxP5ModName Identifier -hi def link p6Conditional Conditional -hi def link p6StringSpecial SpecialChar - -hi def link p6PodAbbr p6Pod -hi def link p6PodAbbrEOF p6Pod -hi def link p6PodAbbrNoCode p6Pod -hi def link p6PodAbbrCode p6PodCode -hi def link p6PodPara p6Pod -hi def link p6PodParaEOF p6Pod -hi def link p6PodParaNoCode p6Pod -hi def link p6PodParaCode p6PodCode -hi def link p6PodDelim p6Pod -hi def link p6PodDelimEOF p6Pod -hi def link p6PodDelimNoCode p6Pod -hi def link p6PodDelimCode p6PodCode -hi def link p6PodImplicitCode p6PodCode -hi def link p6PodExtraConfig p6PodPrefix -hi def link p6PodVerticalBar p6PodFormatCode -hi def link p6PodColon p6PodFormatCode -hi def link p6PodSemicolon p6PodFormatCode -hi def link p6PodComma p6PodFormatCode -hi def link p6PodFormatOne p6PodFormat -hi def link p6PodFormatTwo p6PodFormat -hi def link p6PodFormatThree p6PodFormat -hi def link p6PodFormatFrench p6PodFormat - -hi def link p6PodType Type -hi def link p6PodConfigOption String -hi def link p6PodCode PreProc -hi def link p6Pod Comment -hi def link p6PodComment Comment -hi def link p6PodAutoQuote Operator -hi def link p6PodConfigOperator Operator -hi def link p6PodPrefix Statement -hi def link p6PodName Identifier -hi def link p6PodFormatCode SpecialChar -hi def link p6PodFormat SpecialComment - - -" Syncing to speed up processing -"syn sync match p6SyncPod groupthere p6PodAbbrRegion "^=\K\k*\>" -"syn sync match p6SyncPod groupthere p6PodDirectRegion "^=\%(config\|use\|encoding\)\>" -"syn sync match p6SyncPod groupthere p6PodParaRegion "^=for\>" -"syn sync match p6SyncPod groupthere p6PodDelimRegion "^=begin\>" -"syn sync match p6SyncPod groupthere p6PodDelimEndRegion "^=end\>" - -" Let's just sync whole file, the other methods aren't reliable (or I don't -" know how to use them reliably) -syn sync fromstart - -setlocal foldmethod=syntax - -let b:current_syntax = "perl6" - -let &cpo = s:keepcpo -unlet s:keepcpo - -" vim:ts=8:sts=4:sw=4:expandtab:ft=vim diff --git a/runtime/syntax/r.vim b/runtime/syntax/r.vim index 9e25dae363..a8100cfded 100644 --- a/runtime/syntax/r.vim +++ b/runtime/syntax/r.vim @@ -5,7 +5,7 @@ " Tom Payne <tom@tompayne.org> " Contributor: Johannes Ranke <jranke@uni-bremen.de> " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Wed Aug 01, 2018 10:10PM +" Last Change: Sun Mar 28, 2021 01:47PM " Filenames: *.R *.r *.Rhistory *.Rt " " NOTE: The highlighting of R functions might be defined in @@ -53,12 +53,12 @@ syn match rCommentTodo contained "\(BUG\|FIXME\|NOTE\|TODO\):" syn match rTodoParen contained "\(BUG\|FIXME\|NOTE\|TODO\)\s*(.\{-})\s*:" contains=rTodoKeyw,rTodoInfo transparent syn keyword rTodoKeyw BUG FIXME NOTE TODO contained syn match rTodoInfo "(\zs.\{-}\ze)" contained -syn match rComment contains=@Spell,rCommentTodo,rTodoParen,rOBlock "#.*" +syn match rComment contains=@Spell,rCommentTodo,rTodoParen "#.*" " Roxygen if g:r_syntax_hl_roxygen " A roxygen block can start at the beginning of a file (first version) and - " after a blank line (second version). It ends when a line that does not + " after a blank line (second version). It ends when a line appears that does not " contain a roxygen comment. In the following comments, any line containing " a roxygen comment marker (one or two hash signs # followed by a single " quote ' and preceded only by whitespace) is called a roxygen line. A @@ -71,6 +71,12 @@ if g:r_syntax_hl_roxygen syn match rOTitleBlock "\%^\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag syn match rOTitleBlock "^\s*\n\(\s*#\{1,2}' .*\n\)\{1,}" contains=rOCommentKey,rOTitleTag + " A title as part of a block is always at the beginning of the block, i.e. + " either at the start of a file or after a completely empty line. + syn match rOTitle "\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag + syn match rOTitle "^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag + syn match rOTitleTag contained "@title" + " When a roxygen block has a title and additional content, the title " consists of one or more roxygen lines (as little as possible are matched), " followed either by an empty roxygen line @@ -87,16 +93,15 @@ if g:r_syntax_hl_roxygen syn region rOBlockNoTitle start="\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*\n\(\s*#\{1,2}'.*\n\)\{-}\s*#\{1,2}' @describeIn" end="^\s*\(#\{1,2}'\)\@!" contains=rOTag,rOExamples,@Spell keepend fold syn region rOBlockNoTitle start="^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*\n\(\s*#\{1,2}'.*\n\)\{-}\s*#\{1,2}' @describeIn" end="^\s*\(#\{1,2}'\)\@!" contains=rOTag,rOExamples,@Spell keepend fold - " A title as part of a block is always at the beginning of the block, i.e. - " either at the start of a file or after a completely empty line. - syn match rOTitle "\%^\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag - syn match rOTitle "^\s*\n\(\s*#\{1,2}' .*\n\)\{-1,}\s*#\{1,2}'\s*$" contained contains=rOCommentKey,rOTitleTag - syn match rOTitleTag contained "@title" - syn match rOCommentKey "^\s*#\{1,2}'" contained - syn region rOExamples start="^#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOTag fold + syn region rOExamples start="^\s*#\{1,2}' @examples.*"rs=e+1,hs=e+1 end="^\(#\{1,2}' @.*\)\@=" end="^\(#\{1,2}'\)\@!" contained contains=rOTag fold + + " R6 classes may contain roxygen lines independent of roxygen blocks + syn region rOR6Class start=/R6Class(/ end=/)/ transparent contains=ALLBUT,rError,rBraceError,rCurlyError fold + syn match rOR6Block "#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained + syn match rOR6Block "^\s*#\{1,2}'.*" contains=rOTag,rOExamples,@Spell containedin=rOR6Class contained - " rOTag list generated from the lists in + " rOTag list originally generated from the lists that were available in " https://github.com/klutometis/roxygen/R/rd.R and " https://github.com/klutometis/roxygen/R/namespace.R " using s/^ \([A-Za-z0-9]*\) = .*/ syn match rOTag contained "@\1"/ @@ -155,7 +160,10 @@ if g:r_syntax_hl_roxygen syn match rOTag contained "@S3method" syn match rOTag contained "@useDynLib" " other + syn match rOTag contained "@eval" syn match rOTag contained "@include" + syn match rOTag contained "@includeRmd" + syn match rOTag contained "@order" endif @@ -186,6 +194,11 @@ syn match rSpecial display contained "\\U\x\{1,8}" syn match rSpecial display contained "\\u{\x\{1,4}}" syn match rSpecial display contained "\\U{\x\{1,8}}" +" Raw string +syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)(/ end=/)\z2\z1/ keepend +syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\){/ end=/}\z2\z1/ keepend +syn region rRawString matchgroup=rRawStrDelim start=/[rR]\z(['"]\)\z(-*\)\[/ end=/\]\z2\z1/ keepend + " Statement syn keyword rStatement break next return syn keyword rConditional if else @@ -354,6 +367,8 @@ hi def link rOperator Operator hi def link rOpError Error hi def link rParenError Error hi def link rPreProc PreProc +hi def link rRawString String +hi def link rRawStrDelim Delimiter hi def link rRepeat Repeat hi def link rSpecial SpecialChar hi def link rStatement Statement @@ -366,6 +381,7 @@ if g:r_syntax_hl_roxygen hi def link rOTitleBlock Title hi def link rOBlock Comment hi def link rOBlockNoTitle Comment + hi def link rOR6Block Comment hi def link rOTitle Title hi def link rOCommentKey Comment hi def link rOExamples SpecialComment diff --git a/runtime/syntax/raku.vim b/runtime/syntax/raku.vim new file mode 100644 index 0000000000..1bf9b4994c --- /dev/null +++ b/runtime/syntax/raku.vim @@ -0,0 +1,1971 @@ +" Vim syntax file +" Language: Raku +" Maintainer: vim-perl <vim-perl@googlegroups.com> +" Homepage: https://github.com/Raku/vim-raku +" Bugs/requests: https://github.com/Raku/vim-raku/issues +" Last Change: 2021-04-16 + +" Contributors: Luke Palmer <fibonaci@babylonia.flatirons.org> +" Moritz Lenz <moritz@faui2k3.org> +" Hinrik Örn Sigurðsson <hinrik.sig@gmail.com> +" +" This is a big undertaking. +" +" The ftdetect/raku.vim file in this repository takes care of setting the +" right filetype for Raku files. To set it explicitly you can also add this +" line near the bottom of your source file: +" # vim: filetype=raku + +" TODO: +" * Go over the list of keywords/types to see what's deprecated/missing +" * Add more support for folding (:help syn-fold) +" +" If you want to have Pir code inside Q:PIR// strings highlighted, do: +" let raku_embedded_pir=1 +" +" The above requires pir.vim, which you can find in Parrot's repository: +" https://github.com/parrot/parrot/tree/master/editor +" +" To highlight Perl 5 regexes (m:P5//): +" let raku_perl5_regexes=1 +" +" To enable folding: +" let raku_fold=1 + +if version < 704 | throw "raku.vim uses regex syntax which Vim <7.4 doesn't support. Try 'make fix_old_vim' in the vim-perl repository." | endif + +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif +let s:keepcpo= &cpo +set cpo&vim + +" Patterns which will be interpolated by the preprocessor (tools/preproc.pl): +" +" @@IDENT_NONDIGIT@@ "[A-Za-z_\xC0-\xFF]" +" @@IDENT_CHAR@@ "[A-Za-z_\xC0-\xFF0-9]" +" @@IDENTIFIER@@ "\%(@@IDENT_NONDIGIT@@\%(@@IDENT_CHAR@@\|[-']@@IDENT_NONDIGIT@@\@=\)*\)" +" @@IDENTIFIER_START@@ "@@IDENT_CHAR@@\@1<!\%(@@IDENT_NONDIGIT@@[-']\)\@2<!" +" @@IDENTIFIER_END@@ "\%(@@IDENT_CHAR@@\|[-']@@IDENT_NONDIGIT@@\)\@!" +" @@METAOP@@ #\%(\d\|[@%$][.?^=[:alpha:]]\)\@!\%(\.\|[^[{('".[:space:]]\)\+# +" @@ADVERBS@@ "\%(\_s*:!\?@@IDENTIFIER@@\%(([^)]*)\)\?\)*" +" +" Same but escaped, for use in string eval +" @@IDENT_NONDIGIT_Q@@ "[A-Za-z_\\xC0-\\xFF]" +" @@IDENT_CHAR_Q@@ "[A-Za-z_\\xC0-\\xFF0-9]" +" @@IDENTIFIER_Q@@ "\\%(@@IDENT_NONDIGIT_Q@@\\%(@@IDENT_CHAR_Q@@\\|[-']@@IDENT_NONDIGIT_Q@@\\@=\\)*\\)" +" @@IDENTIFIER_START_Q@@ "@@IDENT_CHAR_Q@@\\@1<!\\%(@@IDENT_NONDIGIT_Q@@[-']\\)\\@2<!" +" @@IDENTIFIER_END_Q@@ "\\%(@@IDENT_CHAR_Q@@\\|[-']@@IDENT_NONDIGIT_Q@@\\)\\@!" + +" Identifiers (subroutines, methods, constants, classes, roles, etc) +syn match rakuIdentifier display "\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + +let s:keywords = { + \ "rakuInclude": [ + \ "use require import unit", + \ ], + \ "rakuConditional": [ + \ "if else elsif unless with orwith without once", + \ ], + \ "rakuVarStorage": [ + \ "let my our state temp has constant", + \ ], + \ "rakuRepeat": [ + \ "for loop repeat while until gather given", + \ "supply react race hyper lazy quietly", + \ ], + \ "rakuFlowControl": [ + \ "take take-rw do when next last redo return return-rw", + \ "start default exit make continue break goto leave", + \ "proceed succeed whenever emit done", + \ ], + \ "rakuClosureTrait": [ + \ "BEGIN CHECK INIT FIRST ENTER LEAVE KEEP", + \ "UNDO NEXT LAST PRE POST END CATCH CONTROL", + \ "DOC QUIT CLOSE COMPOSE", + \ ], + \ "rakuException": [ + \ "die fail try warn", + \ ], + \ "rakuPragma": [ + \ "MONKEY-GUTS MONKEY-SEE-NO-EVAL MONKEY-TYPING MONKEY", + \ "experimental fatal isms lib newline nqp precompilation", + \ "soft strict trace variables worries", + \ ], + \ "rakuOperator": [ + \ "div xx x mod also leg cmp before after eq ne le lt not", + \ "gt ge eqv ff fff and andthen or xor orelse lcm gcd o", + \ "unicmp notandthen minmax", + \ ], + \ "rakuType": [ + \ "int int1 int2 int4 int8 int16 int32 int64", + \ "rat rat1 rat2 rat4 rat8 rat16 rat32 rat64", + \ "buf buf1 buf2 buf4 buf8 buf16 buf32 buf64", + \ "blob blob1 blob2 blob4 blob8 blob16 blob32 blob64", + \ "uint uint1 uint2 uint4 uint8 uint16 uint32 bit bool", + \ "uint64 utf8 utf16 utf32 bag set mix complex", + \ "num num32 num64 long longlong Pointer size_t str void", + \ "ulong ulonglong ssize_t atomicint", + \ ], +\ } + +" These can be immediately followed by parentheses +let s:types = [ + \ "Object Any Cool Junction Whatever Capture Match", + \ "Signature Proxy Matcher Package Module Class", + \ "Grammar Scalar Array Hash KeyHash KeySet KeyBag", + \ "Pair List Seq Range Set Bag Map Mapping Void Undef", + \ "Failure Exception Code Block Routine Sub Macro", + \ "Method Submethod Regex Str Blob Char Byte Parcel", + \ "Codepoint Grapheme StrPos StrLen Version Num", + \ "Complex Bit True False Order Same Less More", + \ "Increasing Decreasing Ordered Callable AnyChar", + \ "Positional Associative Ordering KeyExtractor", + \ "Comparator OrderingPair IO KitchenSink Role", + \ "Int Rat Buf UInt Abstraction Numeric Real", + \ "Nil Mu SeekFromBeginning SeekFromEnd SeekFromCurrent", +\ ] + +" We explicitly enumerate the alphanumeric infix operators allowed after [RSXZ] +" to avoid matching package names that start with those letters. +let s:alpha_metaops = [ + \ "div mod gcd lcm xx x does but cmp leg eq ne gt ge lt le before after eqv", + \ "min max not so andthen and or orelse unicmp coll minmax", +\ ] +let s:words_space = join(s:alpha_metaops, " ") +let s:temp = split(s:words_space) +let s:alpha_metaops_or = join(s:temp, "\\|") + +" We don't use "syn keyword" here because that always has higher priority +" than matches/regions, which would prevent these words from matching as +" autoquoted strings before "=>". +syn match rakuKeywordStart display "\%(\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\)\@!\)\@=[A-Za-z_\xC0-\xFF0-9]\@1<!\%([A-Za-z_\xC0-\xFF][-']\)\@2<!" + \ nextgroup=rakuAttention,rakuVariable,rakuInclude,rakuConditional,rakuVarStorage,rakuRepeat,rakuFlowControl,rakuClosureTrait,rakuException,rakuNumber,rakuPragma,rakuType,rakuOperator,rakuIdentifier + +for [s:group, s:words_list] in items(s:keywords) + let s:words_space = join(s:words_list, " ") + let s:temp = split(s:words_space) + let s:words = join(s:temp, "\\|") + exec "syn match ". s:group ." display \"[.^]\\@1<!\\%(". s:words . "\\)(\\@!\\%([A-Za-z_\\xC0-\\xFF0-9]\\|[-'][A-Za-z_\\xC0-\\xFF]\\)\\@!\" contained" +endfor + +let s:words_space = join(s:types, " ") +let s:temp = split(s:words_space) +let s:words = join(s:temp, "\\|") +exec "syn match rakuType display \"\\%(". s:words . "\\)\\%([A-Za-z_\\xC0-\\xFF0-9]\\|[-'][A-Za-z_\\xC0-\\xFF]\\)\\@!\" contained" +unlet s:group s:words_list s:keywords s:types s:words_space s:temp s:words + +syn match rakuPreDeclare display "[.^]\@1<!\<\%(multi\|proto\|only\)\>" nextgroup=rakuDeclare,rakuIdentifier skipwhite skipempty +syn match rakuDeclare display "[.^]\@1<!\<\%(macro\|sub\|submethod\|method\|module\|class\|role\|package\|enum\|grammar\|slang\|subset\)\>" nextgroup=rakuIdentifier skipwhite skipempty +syn match rakuDeclareRegex display "[.^]\@1<!\<\%(regex\|rule\|token\)\>" nextgroup=rakuRegexName skipwhite skipempty + +syn match rakuTypeConstraint display "\%([.^]\|^\s*\)\@<!\a\@=\%(does\|as\|but\|trusts\|of\|returns\|handles\|where\|augment\|supersede\)\>" +syn match rakuTypeConstraint display "\%([.^]\|^\s*\)\@<![A-Za-z_\xC0-\xFF0-9]\@1<!\%([A-Za-z_\xC0-\xFF][-']\)\@2<!is\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\)\@!" skipwhite skipempty nextgroup=rakuProperty +syn match rakuProperty display "\a\@=\%(signature\|context\|also\|shape\|prec\|irs\|ofs\|ors\|export\|deep\|binary\|unary\|reparsed\|rw\|parsed\|cached\|readonly\|defequiv\|will\|ref\|copy\|inline\|tighter\|looser\|equiv\|assoc\|required\|DEPRECATED\|raw\|repr\|dynamic\|hidden-from-backtrace\|nodal\|pure\)" contained + +" packages, must come after all the keywords +syn match rakuIdentifier display "\%(::\)\@2<=\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)*" +syn match rakuIdentifier display "\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(::\)\@=" + +" The sigil in ::*Package +syn match rakuPackageTwigil display "\%(::\)\@2<=\*" + +" some standard packages +syn match rakuType display "\%(::\)\@2<!\%(SeekType\%(::SeekFromBeginning\|::SeekFromCurrent\|::SeekFromEnd\)\|Order\%(::Same\|::More\|::Less\)\?\|Bool\%(::True\|::False\)\?\)\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\)\@!" + +" Don't put a "\+" at the end of the character class. That makes it so +" greedy that the "%" " in "+%foo" won't be allowed to match as a sigil, +" among other things +syn match rakuOperator display "[-+/*~?|=^!%&,<>».;\\∈∉∋∌∩∪≼≽⊂⊃⊄⊅⊆⊇⊈⊉⊍⊎⊖∅∘]" +syn match rakuOperator display "\%(:\@1<!::\@2!\|::=\|\.::\)" +" these require whitespace on the left side +syn match rakuOperator display "\%(\s\|^\)\@1<=\%(xx=\)" +" index overloading +syn match rakuOperator display "\%(&\.(\@=\|@\.\[\@=\|%\.{\@=\)" + +" Reduce metaoperators like [+] +syn match rakuReduceOp display "\%(^\|\s\|(\)\@1<=!*\%([RSXZ\[]\)*[&RSXZ]\?\[\+(\?\%(\d\|[@%$][.?^=[:alpha:]]\)\@!\%(\.\|[^[{('".[:space:]]\)\+)\?]\+" +syn match rakuSetOp display "R\?(\%([-^.+|&]\|[<>][=+]\?\|cont\|elem\))" + +" Reverse, cross, and zip metaoperators +exec "syn match rakuRSXZOp display \"[RSXZ]:\\@!\\%(\\a\\@=\\%(". s:alpha_metaops_or . "\\)\\>\\|[[:alnum:]]\\@!\\%([.,]\\|[^[,.[:alnum:][:space:]]\\)\\+\\|\\s\\@=\\|$\\)\"" + +syn match rakuBlockLabel display "^\s*\zs\h\w*\s*::\@!\_s\@=" + +syn match rakuNumber display "[A-Za-z_\xC0-\xFF0-9]\@1<!\%(\%(\%(\_^\|\s\|[^*\a]\)\@1<=[-+]\)\?Inf\|NaN\)" +syn match rakuNumber display "[A-Za-z_\xC0-\xFF0-9]\@1<!\%(\%(\_^\|\s\|[^*\a]\)\@1<=[-+]\)\?\%(\%(\d\|__\@!\)*[._]\@1<!\.\)\?_\@!\%(\d\|_\)\+_\@1<!\%([eE]-\?_\@!\%(\d\|_\)\+\)\?i\?" +syn match rakuNumber display "[A-Za-z_\xC0-\xFF0-9]\@1<!\%(\%(\_^\|\s\|[^*\a]\)\@1<=[-+]\)\?0[obxd]\@=" nextgroup=rakuOctBase,rakuBinBase,rakuHexBase,rakuDecBase +syn match rakuOctBase display "o" contained nextgroup=rakuOctNumber +syn match rakuBinBase display "b" contained nextgroup=rakuBinNumber +syn match rakuHexBase display "x" contained nextgroup=rakuHexNumber +syn match rakuDecBase display "d" contained nextgroup=rakuDecNumber +syn match rakuOctNumber display "[0-7][0-7_]*" contained +syn match rakuBinNumber display "[01][01_]*" contained +syn match rakuHexNumber display "\x[[:xdigit:]_]*" contained +syn match rakuDecNumber display "\d[[:digit:]_]*" contained + +syn match rakuVersion display "\<v\d\+\%(\.\%(\*\|\d\+\)\)*+\?" + +" Contextualizers +syn match rakuContext display "\<\%(item\|list\|slice\|hash\)\>" +syn match rakuContext display "\%(\$\|@\|%\|&\)(\@=" + +" Quoting + +" one cluster for every quote adverb +syn cluster rakuInterp_scalar + \ add=rakuInterpScalar + +syn cluster rakuInterp_array + \ add=rakuInterpArray + +syn cluster rakuInterp_hash + \ add=rakuInterpHash + +syn cluster rakuInterp_function + \ add=rakuInterpFunction + +syn cluster rakuInterp_closure + \ add=rakuInterpClosure + +syn cluster rakuInterp_q + \ add=rakuEscQQ + \ add=rakuEscBackSlash + +syn cluster rakuInterp_backslash + \ add=@rakuInterp_q + \ add=rakuEscape + \ add=rakuEscOpenCurly + \ add=rakuEscCodePoint + \ add=rakuEscHex + \ add=rakuEscOct + \ add=rakuEscOctOld + \ add=rakuEscNull + +syn cluster rakuInterp_qq + \ add=@rakuInterp_scalar + \ add=@rakuInterp_array + \ add=@rakuInterp_hash + \ add=@rakuInterp_function + \ add=@rakuInterp_closure + \ add=@rakuInterp_backslash + \ add=rakuMatchVarSigil + +syn region rakuInterpScalar + \ start="\ze\z(\$\%(\%(\%(\d\+\|!\|/\|¢\)\|\%(\%(\%([.^*?=!~]\|:\@1<!::\@!\)[A-Za-z_\xC0-\xFF]\@=\)\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\)\%(\.\^\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\|\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)*\)\.\?\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)\)" + \ start="\ze\z(\$\%(\%(\%(\%([.^*?=!~]\|:\@1<!::\@!\)[A-Za-z_\xC0-\xFF]\@=\)\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\)\|\%(\d\+\|!\|/\|¢\)\)\)" + \ end="\z1\zs" + \ contained keepend + \ contains=TOP + +syn region rakuInterpScalar + \ matchgroup=rakuContext + \ start="\$\ze()\@!" + \ skip="([^)]*)" + \ end=")\zs" + \ contained + \ contains=TOP + +syn region rakuInterpArray + \ start="\ze\z(@\$*\%(\%(\%(!\|/\|¢\)\|\%(\%(\%([.^*?=!~]\|:\@1<!::\@!\)[A-Za-z_\xC0-\xFF]\@=\)\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\)\%(\.\^\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\|\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)*\)\.\?\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)\)" + \ end="\z1\zs" + \ contained keepend + \ contains=TOP + +syn region rakuInterpArray + \ matchgroup=rakuContext + \ start="@\ze()\@!" + \ skip="([^)]*)" + \ end=")\zs" + \ contained + \ contains=TOP + +syn region rakuInterpHash + \ start="\ze\z(%\$*\%(\%(\%(!\|/\|¢\)\|\%(\%(\%([.^*?=!~]\|:\@1<!::\@!\)[A-Za-z_\xC0-\xFF]\@=\)\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\)\%(\.\^\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\|\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)*\)\.\?\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)\)" + \ end="\z1\zs" + \ contained keepend + \ contains=TOP + +syn region rakuInterpHash + \ matchgroup=rakuContext + \ start="%\ze()\@!" + \ skip="([^)]*)" + \ end=")\zs" + \ contained + \ contains=TOP + +syn region rakuInterpFunction + \ start="\ze\z(&\%(\%(!\|/\|¢\)\|\%(\%(\%([.^*?=!~]\|:\@1<!::\@!\)[A-Za-z_\xC0-\xFF]\@=\)\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(\.\^\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\|\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)*\)\.\?\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\)\)" + \ end="\z1\zs" + \ contained keepend + \ contains=TOP + +syn region rakuInterpFunction + \ matchgroup=rakuContext + \ start="&\ze()\@!" + \ skip="([^)]*)" + \ end=")\zs" + \ contained + \ contains=TOP + +syn region rakuInterpClosure + \ start="\\\@1<!{}\@!" + \ skip="{[^}]*}" + \ end="}" + \ contained keepend + \ contains=TOP + +" generic escape +syn match rakuEscape display "\\\S" contained + +" escaped closing delimiters +syn match rakuEscQuote display "\\'" contained +syn match rakuEscDoubleQuote display "\\\"" contained +syn match rakuEscCloseAngle display "\\>" contained +syn match rakuEscCloseFrench display "\\»" contained +syn match rakuEscBackTick display "\\`" contained +syn match rakuEscForwardSlash display "\\/" contained +syn match rakuEscVerticalBar display "\\|" contained +syn match rakuEscExclamation display "\\!" contained +syn match rakuEscComma display "\\," contained +syn match rakuEscDollar display "\\\$" contained +syn match rakuEscCloseCurly display "\\}" contained +syn match rakuEscCloseBracket display "\\\]" contained + +" matches :key, :!key, :$var, :key<var>, etc +" Since we don't know in advance how the adverb ends, we use a trick. +" Consume nothing with the start pattern (\ze at the beginning), +" while capturing the whole adverb into \z1 and then putting it before +" the match start (\zs) of the end pattern. +syn region rakuAdverb + \ start="\ze\z(:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\|\[[^\]]*]\|<[^>]*>\|«[^»]*»\|{[^}]*}\)\?\)" + \ start="\ze\z(:!\?[@$%]\$*\%(::\|\%(\$\@1<=\d\+\|!\|/\|¢\)\|\%(\%([.^*?=!~]\|:\@1<!::\@!\)[A-Za-z_\xC0-\xFF]\)\|\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\)\)" + \ end="\z1\zs" + \ contained keepend + \ contains=TOP + +" <words> +" Distinguishing this from the "less than" operator is tricky. For now, +" it matches if any of the following is true: +" +" * There is whitespace missing on either side of the "<", since +" people tend to put spaces around "less than". We make an exception +" for " = < ... >" assignments though. +" * It comes after "enum", "for", "any", "all", or "none" +" * It's the first or last thing on a line (ignoring whitespace) +" * It's preceded by "(\s*" or "=\s\+" +" * It's empty and terminated on the same line (e.g. <> and < >) +" +" It never matches when: +" +" * Preceded by [<+~=!] (e.g. <<foo>>, =<$foo>, * !< 3) +" * Followed by [-=] (e.g. <--, <=, <==, <->) +syn region rakuStringAngle + \ matchgroup=rakuQuote + \ start="\%(\<\%(enum\|for\|any\|all\|none\)\>\s*(\?\s*\)\@<=<\%(<\|=>\|\%([=-]\{1,2}>\|[=-]\{2}\)\)\@!" + \ start="\%(\s\|[<+~=!]\)\@<!<\%(<\|=>\|\%([=-]\{1,2}>\|[=-]\{2}\)\)\@!" + \ start="[<+~=!]\@1<!<\%(\s\|<\|=>\|\%([=-]\{1,2}>\|[=-]\{1,2}\)\)\@!" + \ start="\%(^\s*\)\@<=<\%(<\|=>\|\%([=-]\{1,2}>\|[=-]\{2}\)\)\@!" + \ start="[<+~=!]\@1<!<\%(\s*$\)\@=" + \ start="\%((\s*\|=\s\+\)\@<=<\%(<\|=>\|\%([=-]\{1,2}>\|[=-]\{2}\)\)\@!" + \ start="<\%(\s*>\)\@=" + \ skip="\\\@1<!\\>" + \ end=">" + \ contains=rakuInnerAnglesOne,rakuEscBackSlash,rakuEscCloseAngle + +syn region rakuStringAngleFixed + \ matchgroup=rakuQuote + \ start="<" + \ skip="\\\@1<!\\>" + \ end=">" + \ contains=rakuInnerAnglesOne,rakuEscBackSlash,rakuEscCloseAngle + \ contained + +syn region rakuInnerAnglesOne + \ matchgroup=rakuStringAngle + \ start="\\\@1<!<" + \ skip="\\\@1<!\\>" + \ end=">" + \ transparent contained + \ contains=rakuInnerAnglesOne + +" <<words>> +syn region rakuStringAngles + \ matchgroup=rakuQuote + \ start="<<=\@!" + \ skip="\\\@1<!\\>" + \ end=">>" + \ contains=rakuInnerAnglesTwo,@rakuInterp_qq,rakuComment,rakuBracketComment,rakuEscHash,rakuEscCloseAngle,rakuAdverb,rakuStringSQ,rakuStringDQ + +syn region rakuInnerAnglesTwo + \ matchgroup=rakuStringAngles + \ start="<<" + \ skip="\\\@1<!\\>" + \ end=">>" + \ transparent contained + \ contains=rakuInnerAnglesTwo + +" «words» +syn region rakuStringFrench + \ matchgroup=rakuQuote + \ start="«" + \ skip="\\\@1<!\\»" + \ end="»" + \ contains=rakuInnerFrench,@rakuInterp_qq,rakuComment,rakuBracketComment,rakuEscHash,rakuEscCloseFrench,rakuAdverb,rakuStringSQ,rakuStringDQ + +syn region rakuInnerFrench + \ matchgroup=rakuStringFrench + \ start="\\\@1<!«" + \ skip="\\\@1<!\\»" + \ end="»" + \ transparent contained + \ contains=rakuInnerFrench + +" Hyperops. They need to come after "<>" and "«»" strings in order to override +" them, but before other types of strings, to avoid matching those delimiters +" as parts of hyperops. +syn match rakuHyperOp display #[^[:digit:][{('",:[:space:]][^[{('",:[:space:]]*\%(«\|<<\)# +syn match rakuHyperOp display "«\%(\d\|[@%$][.?^=[:alpha:]]\)\@!\%(\.\|[^[{('".[:space:]]\)\+[«»]" +syn match rakuHyperOp display "»\%(\d\|[@%$][.?^=[:alpha:]]\)\@!\%(\.\|[^[{('".[:space:]]\)\+\%(«\|»\?\)" +syn match rakuHyperOp display "<<\%(\d\|[@%$][.?^=[:alpha:]]\)\@!\%(\.\|[^[{('".[:space:]]\)\+\%(<<\|>>\)" +syn match rakuHyperOp display ">>\%(\d\|[@%$][.?^=[:alpha:]]\)\@!\%(\.\|[^[{('".[:space:]]\)\+\%(<<\|\%(>>\)\?\)" + +" 'string' +syn region rakuStringSQ + \ matchgroup=rakuQuote + \ start="'" + \ skip="\\\@1<!\\'" + \ end="'" + \ contains=@rakuInterp_q,rakuEscQuote + \ keepend extend + +" "string" +syn region rakuStringDQ + \ matchgroup=rakuQuote + \ start=+"+ + \ skip=+\\\@1<!\\"+ + \ end=+"+ + \ contains=@rakuInterp_qq,rakuEscDoubleQuote + \ keepend extend + +" Q// and friends + +syn match rakuQuoteQStart display "\%(:\|\%(sub\|role\)\s\)\@5<![Qq]\@=" nextgroup=rakuQuoteQ,rakuQuoteQ_q,rakuQuoteQ_qww,rakuQuoteQ_qq,rakuQuoteQ_to,rakuQuoteQ_qto,rakuQuoteQ_qqto,rakuIdentifier +syn match rakuQuoteQ display "Q\%(qq\|ww\|[abcfhpsqvwx]\)\?[A-Za-z(]\@!" nextgroup=rakuPairsQ skipwhite skipempty contained +syn match rakuQuoteQ_q display "q[abcfhpsvwx]\?[A-Za-z(]\@!" nextgroup=rakuPairsQ_q skipwhite skipempty contained +syn match rakuQuoteQ_qww display "qww[A-Za-z(]\@!" nextgroup=rakuPairsQ_qww skipwhite skipempty contained +syn match rakuQuoteQ_qq display "qq\%([pwx]\|ww\)\?[A-Za-z(]\@!" nextgroup=rakuPairsQ_qq skipwhite skipempty contained +syn match rakuQuoteQ_to display "Qto[A-Za-z(]\@!" nextgroup=rakuStringQ_to skipwhite skipempty contained +syn match rakuQuoteQ_qto display "qto[A-Za-z(]\@!" nextgroup=rakuStringQ_qto skipwhite skipempty contained +syn match rakuQuoteQ_qqto display "qqto[A-Za-z(]\@!" nextgroup=rakuStringQ_qqto skipwhite skipempty contained +syn match rakuQuoteQ_qto display "q\_s*\%(\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*:\%(to\|heredoc\)\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*(\@!\)\@=" nextgroup=rakuPairsQ_qto skipwhite skipempty contained +syn match rakuQuoteQ_qqto display "qq\_s*\%(\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*:\%(to\|heredoc\)\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*(\@!\)\@=" nextgroup=rakuPairsQ_qqto skipwhite skipempty contained +syn match rakuPairsQ "\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*" contained transparent skipwhite skipempty nextgroup=rakuStringQ +syn match rakuPairsQ_q "\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*" contained transparent skipwhite skipempty nextgroup=rakuStringQ_q +syn match rakuPairsQ_qww "\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*" contained transparent skipwhite skipempty nextgroup=rakuStringQ_qww +syn match rakuPairsQ_qq "\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*" contained transparent skipwhite skipempty nextgroup=rakuStringQ_qq +syn match rakuPairsQ_qto "\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*" contained transparent skipwhite skipempty nextgroup=rakuStringQ_qto +syn match rakuPairsQ_qqto "\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*" contained transparent skipwhite skipempty nextgroup=rakuStringQ_qqto + + +if exists("raku_embedded_pir") || exists("raku_extended_all") + syn include @rakuPIR syntax/pir.vim + syn match rakuQuote_QPIR display "Q[A-Za-z(]\@!\%(\_s*:PIR\)\@=" nextgroup=rakuPairsQ_PIR skipwhite skipempty + syn match rakuPairs_QPIR contained "\_s*:PIR" transparent skipwhite skipempty nextgroup=rakuStringQ_PIR +endif + +" hardcoded set of delimiters +let s:plain_delims = [ + \ ["DQ", "\\\"", "\\\"", "rakuEscDoubleQuote", "\\\\\\@1<!\\\\\\\""], + \ ["SQ", "'", "'", "rakuEscQuote", "\\\\\\@1<!\\\\'"], + \ ["Slash", "/", "/", "rakuEscForwardSlash", "\\\\\\@1<!\\\\/"], + \ ["BackTick", "`", "`", "rakuEscBackTick", "\\\\\\@1<!\\\\`"], + \ ["Bar", "|", "|", "rakuEscVerticalBar", "\\\\\\@1<!\\\\|"], + \ ["Exclamation", "!", "!", "rakuEscExclamation", "\\\\\\@1<!\\\\!"], + \ ["Comma", ",", ",", "rakuEscComma", "\\\\\\@1<!\\\\,"], + \ ["Dollar", "\\$", "\\$", "rakuEscDollar", "\\\\\\@1<!\\\\\\$"], +\ ] +let s:bracketing_delims = [ + \ ["Curly", "{", "}", "rakuEscCloseCurly", "\\%(\\\\\\@1<!\\\\}\\|{[^}]*}\\)"], + \ ["Angle", "<", ">", "rakuEscCloseAngle", "\\%(\\\\\\@1<!\\\\>\\|<[^>]*>\\)"], + \ ["French", "«", "»", "rakuEscCloseFrench", "\\%(\\\\\\@1<!\\\\»\\|«[^»]*»\\)"], + \ ["Bracket", "\\\[", "]", "rakuEscCloseBracket", "\\%(\\\\\\@1<!\\\\]\\|\\[^\\]]*]\\)"], + \ ["Paren", "\\s\\@1<=(", ")", "rakuEscCloseParen", "\\%(\\\\\\@1<!\\\\)\\|([^)]*)\\)"], +\ ] +let s:all_delims = s:plain_delims + s:bracketing_delims + +for [s:name, s:start_delim, s:end_delim, s:end_group, s:skip] in s:all_delims + exec "syn region rakuStringQ matchgroup=rakuQuote start=\"".s:start_delim."\" end=\"".s:end_delim."\" contained" + exec "syn region rakuStringQ_q matchgroup=rakuQuote start=\"".s:start_delim."\" skip=\"".s:skip."\" end=\"".s:end_delim."\" contains=@rakuInterp_q,".s:end_group." contained" + exec "syn region rakuStringQ_qww matchgroup=rakuQuote start=\"".s:start_delim."\" skip=\"".s:skip."\" end=\"".s:end_delim."\" contains=@rakuInterp_q,rakuStringSQ,rakuStringDQ".s:end_group." contained" + exec "syn region rakuStringQ_qq matchgroup=rakuQuote start=\"".s:start_delim."\" skip=\"".s:skip."\" end=\"".s:end_delim."\" contains=@rakuInterp_qq,".s:end_group." contained" + exec "syn region rakuStringQ_to matchgroup=rakuQuote start=\"".s:start_delim."\\z([^".s:end_delim."]\\+\\)".s:end_delim."\" end=\"^\\s*\\z1$\" contained" + exec "syn region rakuStringQ_qto matchgroup=rakuQuote start=\"".s:start_delim."\\z([^".s:end_delim."]\\+\\)".s:end_delim."\" skip=\"".s:skip."\" end=\"^\\s*\\z1$\" contains=@rakuInterp_q,".s:end_group." contained" + exec "syn region rakuStringQ_qqto matchgroup=rakuQuote start=\"".s:start_delim."\\z(\[^".s:end_delim."]\\+\\)".s:end_delim."\" skip=\"".s:skip."\" end=\"^\\s*\\z1$\" contains=@rakuInterp_qq,".s:end_group." contained" + + if exists("raku_embedded_pir") || exists("raku_extended_all") + exec "syn region rakuStringQ_PIR matchgroup=rakuQuote start=\"".s:start_delim."\" skip=\"".s:skip."\" end=\"".s:end_delim."\" contains=@rakuPIR,".s:end_group." contained" + endif +endfor +unlet s:name s:start_delim s:end_delim s:end_group s:skip s:plain_delims s:all_delims + +" :key +syn match rakuOperator display ":\@1<!::\@!!\?" nextgroup=rakuKey,rakuStringAngleFixed,rakuStringAngles,rakuStringFrench +syn match rakuKey display "\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" contained nextgroup=rakuStringAngleFixed,rakuStringAngles,rakuStringFrench + +" Regexes and grammars + +syn match rakuRegexName display "\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\?" nextgroup=rakuRegexBlockCrap skipwhite skipempty contained +syn match rakuRegexBlockCrap "[^{]*" nextgroup=rakuRegexBlock skipwhite skipempty transparent contained + +syn region rakuRegexBlock + \ matchgroup=rakuNormal + \ start="{" + \ end="}" + \ contained + \ contains=@rakuRegexen,@rakuVariables + +" Perl 6 regex bits + +syn cluster rakuRegexen + \ add=rakuRxMeta + \ add=rakuRxEscape + \ add=rakuEscCodePoint + \ add=rakuEscHex + \ add=rakuEscOct + \ add=rakuEscNull + \ add=rakuRxAnchor + \ add=rakuRxCapture + \ add=rakuRxGroup + \ add=rakuRxAlternation + \ add=rakuRxBoundary + \ add=rakuRxAdverb + \ add=rakuRxAdverbArg + \ add=rakuRxStorage + \ add=rakuRxAssertion + \ add=rakuRxAssertGroup + \ add=rakuRxQuoteWords + \ add=rakuRxClosure + \ add=rakuRxStringSQ + \ add=rakuRxStringDQ + \ add=rakuComment + \ add=rakuBracketComment + \ add=rakuMatchVarSigil + +syn match rakuRxMeta display contained ".\%([A-Za-z_\xC0-\xFF0-9]\|\s\)\@1<!" +syn match rakuRxAnchor display contained "[$^]" +syn match rakuRxEscape display contained "\\\S" +syn match rakuRxCapture display contained "[()]" +syn match rakuRxAlternation display contained "|" +syn match rakuRxRange display contained "\.\." + +" misc escapes +syn match rakuEscOctOld display "\\[1-9]\d\{1,2}" contained +syn match rakuEscNull display "\\0\d\@!" contained +syn match rakuEscCodePoint display "\\[cC]" contained nextgroup=rakuCodePoint +syn match rakuEscHex display "\\[xX]" contained nextgroup=rakuHexSequence +syn match rakuEscOct display "\\o" contained nextgroup=rakuOctSequence +syn match rakuEscQQ display "\\qq" contained nextgroup=rakuQQSequence +syn match rakuEscOpenCurly display "\\{" contained +syn match rakuEscHash display "\\#" contained +syn match rakuEscBackSlash display "\\\\" contained + +syn region rakuQQSequence + \ matchgroup=rakuEscape + \ start="\[" + \ skip="\[[^\]]*]" + \ end="]" + \ contained transparent + \ contains=@rakuInterp_qq + +syn match rakuCodePoint display "\%(\d\+\|\S\)" contained +syn region rakuCodePoint + \ matchgroup=rakuEscape + \ start="\[" + \ end="]" + \ contained + +syn match rakuHexSequence display "\x\+" contained +syn region rakuHexSequence + \ matchgroup=rakuEscape + \ start="\[" + \ end="]" + \ contained + +syn match rakuOctSequence display "\o\+" contained +syn region rakuOctSequence + \ matchgroup=rakuEscape + \ start="\[" + \ end="]" + \ contained + +" $<match>, @<match> +syn region rakuMatchVarSigil + \ matchgroup=rakuVariable + \ start="[$@]\%(<<\@!\)\@=" + \ end=">\@1<=" + \ contains=rakuMatchVar + +syn region rakuMatchVar + \ matchgroup=rakuTwigil + \ start="<" + \ end=">" + \ contained + +syn region rakuRxClosure + \ matchgroup=rakuNormal + \ start="{" + \ end="}" + \ contained + \ containedin=rakuRxClosure + \ contains=TOP +syn region rakuRxGroup + \ matchgroup=rakuStringSpecial2 + \ start="\[" + \ end="]" + \ contained + \ contains=@rakuRegexen,@rakuVariables,rakuMatchVarSigil +syn region rakuRxAssertion + \ matchgroup=rakuStringSpecial2 + \ start="<\%(?\?\%(before\|after\)\|\%(\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)=\)\|[+?*]\)\?" + \ end=">" + \ contained + \ contains=@rakuRegexen,rakuIdentifier,@rakuVariables,rakuRxCharClass,rakuRxAssertCall +syn region rakuRxAssertGroup + \ matchgroup=rakuStringSpecial2 + \ start="<\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)=\[" + \ skip="\\\@1<!\\]" + \ end="]" + \ contained +syn match rakuRxAssertCall display "\%(::\|\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\)" contained nextgroup=rakuRxAssertArgs +syn region rakuRxAssertArgs + \ start="(" + \ end=")" + \ contained keepend + \ contains=TOP +syn region rakuRxAssertArgs + \ start=":" + \ end="\ze>" + \ contained keepend + \ contains=TOP +syn match rakuRxBoundary display contained "\%([«»]\|<<\|>>\)" +syn region rakuRxCharClass + \ matchgroup=rakuStringSpecial2 + \ start="\%(<[-!+?]\?\)\@2<=\[" + \ skip="\\]" + \ end="]" + \ contained + \ contains=rakuRxRange,rakuRxEscape,rakuEscHex,rakuEscOct,rakuEscCodePoint,rakuEscNull +syn region rakuRxQuoteWords + \ matchgroup=rakuStringSpecial2 + \ start="<\s" + \ end="\s\?>" + \ contained +syn region rakuRxAdverb + \ start="\ze\z(:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\)" + \ end="\z1\zs" + \ contained keepend + \ contains=TOP +syn region rakuRxAdverbArg + \ start="\%(:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\)\@<=(" + \ skip="([^)]\{-})" + \ end=")" + \ contained + \ keepend + \ contains=TOP +syn region rakuRxStorage + \ matchgroup=rakuOperator + \ start="\%(^\s*\)\@<=:\%(my\>\|temp\>\)\@=" + \ end="$" + \ contains=TOP + \ contained + \ keepend + +" 'string' inside a regex +syn region rakuRxStringSQ + \ matchgroup=rakuQuote + \ start="'" + \ skip="\\\@1<!\\'" + \ end="'" + \ contained + \ contains=rakuEscQuote,rakuEscBackSlash + +" "string" inside a regex +syn region rakuRxStringDQ + \ matchgroup=rakuQuote + \ start=+"+ + \ skip=+\\\@1<!\\"+ + \ end=+"+ + \ contained + \ contains=rakuEscDoubleQuote,rakuEscBackSlash,@rakuInterp_qq + +" $!, $var, $!var, $::var, $package::var $*::package::var, etc +" Thus must come after the matches for the "$" regex anchor, but before +" the match for the $ regex delimiter +syn cluster rakuVariables + \ add=rakuVarSlash + \ add=rakuVarExclam + \ add=rakuVarMatch + \ add=rakuVarNum + \ add=rakuVariable + +syn match rakuBareSigil display "[@$%&]\%(\s*\%([,)}=]\|where\>\)\)\@=" +syn match rakuVarSlash display "\$/" +syn match rakuVarExclam display "\$!" +syn match rakuVarMatch display "\$¢" +syn match rakuVarNum display "\$\d\+" +syn match rakuVariable display "self" +syn match rakuVariable display "[@$%&]\?[@&$%]\$*\%(::\|\%(\%([.^*?=!~]\|:\@1<!::\@!\)[A-Za-z_\xC0-\xFF]\)\|[A-Za-z_\xC0-\xFF]\)\@=" nextgroup=rakuTwigil,rakuVarName,rakuPackageScope +syn match rakuVarName display "\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" nextgroup=rakuPostHyperOp contained +syn match rakuClose display "[\])]" transparent nextgroup=rakuPostHyperOp +syn match rakuPostHyperOp display "\%(»\|>>\)" contained +syn match rakuTwigil display "\%([.^*?=!~]\|:\@1<!::\@!\)[A-Za-z_\xC0-\xFF]\@=" nextgroup=rakuPackageScope,rakuVarName contained +syn match rakuPackageScope display "\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\?::" nextgroup=rakuPackageScope,rakuVarName contained + +" Perl 6 regex regions + +syn match rakuMatchStart_m display "\.\@1<!\<\%(mm\?\|rx\)\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\)\@!" skipwhite skipempty nextgroup=rakuMatchAdverbs_m +syn match rakuMatchStart_s display "\.\@1<!\<[sS]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\)\@!" skipwhite skipempty nextgroup=rakuMatchAdverbs_s +syn match rakuMatchStart_tr display "\.\@1<!\<tr\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\)\@!" skipwhite skipempty nextgroup=rakuMatchAdverbs_tr +syn match rakuMatchAdverbs_m "\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*" contained transparent skipwhite skipempty nextgroup=rakuMatch +syn match rakuMatchAdverbs_s "\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*" contained transparent skipwhite skipempty nextgroup=rakuSubstitution +syn match rakuMatchAdverbs_tr "\%(\_s*:!\?\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\%(([^)]*)\)\?\)*" contained transparent skipwhite skipempty nextgroup=rakuTransliteration + +" /foo/ +syn region rakuMatchBare + \ matchgroup=rakuQuote + \ start="/\@1<!\%(\%(\_^\|[!\[,=~|&/:({]\|\^\?fff\?\^\?\|=>\|\<\%(if\|unless\|while\|when\|where\|so\)\)\s*\)\@<=/[/=]\@!" + \ skip="\\/" + \ end="/" + \ contains=@rakuRegexen,rakuVariable,rakuVarExclam,rakuVarMatch,rakuVarNum + +" m/foo/, m$foo$, m!foo!, etc +syn region rakuMatch + \ matchgroup=rakuQuote + \ start=+\z([/!$,|`"]\)+ + \ skip="\\\z1" + \ end="\z1" + \ contained + \ contains=@rakuRegexen,rakuVariable,rakuVarNum + +" m<foo>, m«foo», m{foo}, etc +for [s:name, s:start_delim, s:end_delim, s:end_group, s:skip] in s:bracketing_delims + exec "syn region rakuMatch matchgroup=rakuQuote start=\"".s:start_delim."\" skip=\"".s:skip."\" end=\"".s:end_delim."\" contained keepend contains=@rakuRegexen,@rakuVariables" +endfor +unlet s:name s:start_delim s:end_delim s:end_group s:skip + +" Substitutions + +" s/foo//, s$foo$$, s!foo!!, etc +syn region rakuSubstitution + \ matchgroup=rakuQuote + \ start=+\z([/!$,|`"]\)+ + \ skip="\\\z1" + \ end="\z1"me=e-1 + \ contained + \ contains=@rakuRegexen,rakuVariable,rakuVarNum + \ nextgroup=rakuReplacement + +syn region rakuReplacement + \ matchgroup=rakuQuote + \ start="\z(.\)" + \ skip="\\\z1" + \ end="\z1" + \ contained + \ contains=@rakuInterp_qq + +" s<foo><bar>, s«foo»«bar», s{foo}{bar}, etc +for [s:name, s:start_delim, s:end_delim, s:end_group, s:skip] in s:bracketing_delims + exec "syn region rakuSubstitution matchgroup=rakuQuote start=\"".s:start_delim."\" skip=\"".s:skip."\" end=\"".s:end_delim."\" contained keepend contains=@rakuRegexen,@rakuVariables nextgroup=rakuRepl".s:name + exec "syn region rakuRepl".s:name." matchgroup=rakuQuote start=\"".s:start_delim."\" skip=\"".s:skip."\" end=\"".s:end_delim."\" contained keepend contains=@rakuInterp_qq" +endfor +unlet s:name s:start_delim s:end_delim s:end_group s:skip + +" Transliteration + +" tr/foo/bar/, tr|foo|bar, etc +syn region rakuTransliteration + \ matchgroup=rakuQuote + \ start=+\z([/!$,|`"]\)+ + \ skip="\\\z1" + \ end="\z1"me=e-1 + \ contained + \ contains=rakuRxRange + \ nextgroup=rakuTransRepl + +syn region rakuTransRepl + \ matchgroup=rakuQuote + \ start="\z(.\)" + \ skip="\\\z1" + \ end="\z1" + \ contained + \ contains=@rakuInterp_qq,rakuRxRange + +" tr<foo><bar>, tr«foo»«bar», tr{foo}{bar}, etc +for [s:name, s:start_delim, s:end_delim, s:end_group, s:skip] in s:bracketing_delims + exec "syn region rakuTransliteration matchgroup=rakuQuote start=\"".s:start_delim."\" skip=\"".s:skip."\" end=\"".s:end_delim."\" contained keepend contains=rakuRxRange nextgroup=rakuTransRepl".s:name + exec "syn region rakuTransRepl".s:name." matchgroup=rakuQuote start=\"".s:start_delim."\" skip=\"".s:skip."\" end=\"".s:end_delim."\" contained keepend contains=@rakuInterp_qq,rakuRxRange" +endfor +unlet s:name s:start_delim s:end_delim s:end_group s:skip s:bracketing_delims + +if exists("raku_perl5_regexes") || exists("raku_extended_all") + +" Perl 5 regex regions + +syn cluster rakuRegexP5Base + \ add=rakuRxP5Escape + \ add=rakuRxP5Oct + \ add=rakuRxP5Hex + \ add=rakuRxP5EscMeta + \ add=rakuRxP5CodePoint + \ add=rakuRxP5Prop + +" normal regex stuff +syn cluster rakuRegexP5 + \ add=@rakuRegexP5Base + \ add=rakuRxP5Quantifier + \ add=rakuRxP5Meta + \ add=rakuRxP5QuoteMeta + \ add=rakuRxP5ParenMod + \ add=rakuRxP5Verb + \ add=rakuRxP5Count + \ add=rakuRxP5Named + \ add=rakuRxP5ReadRef + \ add=rakuRxP5WriteRef + \ add=rakuRxP5CharClass + \ add=rakuRxP5Anchor + +" inside character classes +syn cluster rakuRegexP5Class + \ add=@rakuRegexP5Base + \ add=rakuRxP5Posix + \ add=rakuRxP5Range + +syn match rakuRxP5Escape display contained "\\\S" +syn match rakuRxP5CodePoint display contained "\\c\S\@=" nextgroup=rakuRxP5CPId +syn match rakuRxP5CPId display contained "\S" +syn match rakuRxP5Oct display contained "\\\%(\o\{1,3}\)\@=" nextgroup=rakuRxP5OctSeq +syn match rakuRxP5OctSeq display contained "\o\{1,3}" +syn match rakuRxP5Anchor display contained "[\^$]" +syn match rakuRxP5Hex display contained "\\x\%({\x\+}\|\x\{1,2}\)\@=" nextgroup=rakuRxP5HexSeq +syn match rakuRxP5HexSeq display contained "\x\{1,2}" +syn region rakuRxP5HexSeq + \ matchgroup=rakuRxP5Escape + \ start="{" + \ end="}" + \ contained +syn region rakuRxP5Named + \ matchgroup=rakuRxP5Escape + \ start="\%(\\N\)\@2<={" + \ end="}" + \ contained +syn match rakuRxP5Quantifier display contained "\%([+*]\|(\@1<!?\)" +syn match rakuRxP5ReadRef display contained "\\[1-9]\d\@!" +syn match rakuRxP5ReadRef display contained "\[A-Za-z_\xC0-\xFF0-9]<\@=" nextgroup=rakuRxP5ReadRefId +syn region rakuRxP5ReadRefId + \ matchgroup=rakuRxP5Escape + \ start="<" + \ end=">" + \ contained +syn match rakuRxP5WriteRef display contained "\\g\%(\d\|{\)\@=" nextgroup=rakuRxP5WriteRefId +syn match rakuRxP5WriteRefId display contained "\d\+" +syn region rakuRxP5WriteRefId + \ matchgroup=rakuRxP5Escape + \ start="{" + \ end="}" + \ contained +syn match rakuRxP5Prop display contained "\\[pP]\%(\a\|{\)\@=" nextgroup=rakuRxP5PropId +syn match rakuRxP5PropId display contained "\a" +syn region rakuRxP5PropId + \ matchgroup=rakuRxP5Escape + \ start="{" + \ end="}" + \ contained +syn match rakuRxP5Meta display contained "[(|).]" +syn match rakuRxP5ParenMod display contained "(\@1<=?\@=" nextgroup=rakuRxP5Mod,rakuRxP5ModName,rakuRxP5Code +syn match rakuRxP5Mod display contained "?\%(<\?=\|<\?!\|[#:|]\)" +syn match rakuRxP5Mod display contained "?-\?[impsx]\+" +syn match rakuRxP5Mod display contained "?\%([-+]\?\d\+\|R\)" +syn match rakuRxP5Mod display contained "?(DEFINE)" +syn match rakuRxP5Mod display contained "?\%(&\|P[>=]\)" nextgroup=rakuRxP5ModDef +syn match rakuRxP5ModDef display contained "\h\w*" +syn region rakuRxP5ModName + \ matchgroup=rakuStringSpecial + \ start="?'" + \ end="'" + \ contained +syn region rakuRxP5ModName + \ matchgroup=rakuStringSpecial + \ start="?P\?<" + \ end=">" + \ contained +syn region rakuRxP5Code + \ matchgroup=rakuStringSpecial + \ start="??\?{" + \ end="})\@=" + \ contained + \ contains=TOP +syn match rakuRxP5EscMeta display contained "\\[?*.{}()[\]|\^$]" +syn match rakuRxP5Count display contained "\%({\d\+\%(,\%(\d\+\)\?\)\?}\)\@=" nextgroup=rakuRxP5CountId +syn region rakuRxP5CountId + \ matchgroup=rakuRxP5Escape + \ start="{" + \ end="}" + \ contained +syn match rakuRxP5Verb display contained "(\@1<=\*\%(\%(PRUNE\|SKIP\|THEN\)\%(:[^)]*\)\?\|\%(MARK\|\):[^)]*\|COMMIT\|F\%(AIL\)\?\|ACCEPT\)" +syn region rakuRxP5QuoteMeta + \ matchgroup=rakuRxP5Escape + \ start="\\Q" + \ end="\\E" + \ contained + \ contains=@rakuVariables,rakuEscBackSlash +syn region rakuRxP5CharClass + \ matchgroup=rakuStringSpecial + \ start="\[\^\?" + \ skip="\\]" + \ end="]" + \ contained + \ contains=@rakuRegexP5Class +syn region rakuRxP5Posix + \ matchgroup=rakuRxP5Escape + \ start="\[:" + \ end=":]" + \ contained +syn match rakuRxP5Range display contained "-" + +" m:P5// +syn region rakuMatch + \ matchgroup=rakuQuote + \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@2<!\<m\s*:P\%(erl\)\?5\s*\)\@<=/" + \ skip="\\/" + \ end="/" + \ contains=@rakuRegexP5,rakuVariable,rakuVarExclam,rakuVarMatch,rakuVarNum + +" m:P5!! +syn region rakuMatch + \ matchgroup=rakuQuote + \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@2<!\<m\s*:P\%(erl\)\?5\s*\)\@<=!" + \ skip="\\!" + \ end="!" + \ contains=@rakuRegexP5,rakuVariable,rakuVarSlash,rakuVarMatch,rakuVarNum + +" m:P5$$, m:P5||, etc +syn region rakuMatch + \ matchgroup=rakuQuote + \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@2<!\<m\s*:P\%(erl\)\?5\s*\)\@<=\z([\"'`|,$]\)" + \ skip="\\\z1" + \ end="\z1" + \ contains=@rakuRegexP5,@rakuVariables + +" m:P5 () +syn region rakuMatch + \ matchgroup=rakuQuote + \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@2<!\<m\s*:P\%(erl\)\?5\s\+\)\@<=()\@!" + \ skip="\\)" + \ end=")" + \ contains=@rakuRegexP5,@rakuVariables + +" m:P5[] +syn region rakuMatch + \ matchgroup=rakuQuote + \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@2<!\<m\s*:P\%(erl\)\?5\s*\)\@<=[]\@!" + \ skip="\\]" + \ end="]" + \ contains=@rakuRegexP5,@rakuVariables + +" m:P5{} +syn region rakuMatch + \ matchgroup=rakuQuote + \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@2<!\<m\s*:P\%(erl\)\?5\s*\)\@<={}\@!" + \ skip="\\}" + \ end="}" + \ contains=@rakuRegexP5,rakuVariables + +" m:P5<> +syn region rakuMatch + \ matchgroup=rakuQuote + \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@2<!\<m\s*:P\%(erl\)\?5\s*\)\@<=<>\@!" + \ skip="\\>" + \ end=">" + \ contains=@rakuRegexP5,rakuVariables + +" m:P5«» +syn region rakuMatch + \ matchgroup=rakuQuote + \ start="\%(\%(::\|[$@%&][.!^:*?]\?\|\.\)\@2<!\<m\s*:P\%(erl\)\?5\s*\)\@<=«»\@!" + \ skip="\\»" + \ end="»" + \ contains=@rakuRegexP5,rakuVariables + +endif + +" Comments + +syn match rakuAttention display "\<\%(ACHTUNG\|ATTN\|ATTENTION\|FIXME\|NB\|TODO\|TBD\|WTF\|XXX\|NOTE\)" contained + +" normal end-of-line comment +syn match rakuComment display "#.*" contains=rakuAttention + +" Multiline comments. Arbitrary numbers of opening brackets are allowed, +" but we only define regions for 1 to 3 +syn region rakuBracketComment + \ start="#[`|=](" + \ skip="([^)]*)" + \ end=")" + \ contains=rakuAttention,rakuBracketComment +syn region rakuBracketComment + \ start="#[`|=]\[" + \ skip="\[[^\]]*]" + \ end="]" + \ contains=rakuAttention,rakuBracketComment +syn region rakuBracketComment + \ start="#[`|=]{" + \ skip="{[^}]*}" + \ end="}" + \ contains=rakuAttention,rakuBracketComment +syn region rakuBracketComment + \ start="#[`|=]<" + \ skip="<[^>]*>" + \ end=">" + \ contains=rakuAttention,rakuBracketComment +syn region rakuBracketComment + \ start="#[`|=]«" + \ skip="«[^»]*»" + \ end="»" + \ contains=rakuAttention,rakuBracketComment + +" Comments with double and triple delimiters +syn region rakuBracketComment + \ matchgroup=rakuBracketComment + \ start="#[`|=]((" + \ skip="((\%([^)\|))\@!]\)*))" + \ end="))" + \ contains=rakuAttention,rakuBracketComment +syn region rakuBracketComment + \ matchgroup=rakuBracketComment + \ start="#[`|=](((" + \ skip="(((\%([^)]\|)\%())\)\@!\)*)))" + \ end=")))" + \ contains=rakuAttention,rakuBracketComment + +syn region rakuBracketComment + \ matchgroup=rakuBracketComment + \ start="#[`|=]\[\[" + \ skip="\[\[\%([^\]]\|]]\@!\)*]]" + \ end="]]" + \ contains=rakuAttention,rakuBracketComment +syn region rakuBracketComment + \ matchgroup=rakuBracketComment + \ start="#[`|=]\[\[\[" + \ skip="\[\[\[\%([^\]]\|]\%(]]\)\@!\)*]]]" + \ end="]]]" + \ contains=rakuAttention,rakuBracketComment + +syn region rakuBracketComment + \ matchgroup=rakuBracketComment + \ start="#[`|=]{{" + \ skip="{{\%([^}]\|}}\@!\)*}}" + \ end="}}" + \ contains=rakuAttention,rakuBracketComment +syn region rakuBracketComment + \ matchgroup=rakuBracketComment + \ start="#[`|=]{{{" + \ skip="{{{\%([^}]\|}\%(}}\)\@!\)*}}}" + \ end="}}}" + \ contains=rakuAttention,rakuBracketComment + +syn region rakuBracketComment + \ matchgroup=rakuBracketComment + \ start="#[`|=]<<" + \ skip="<<\%([^>]\|>>\@!\)*>>" + \ end=">>" + \ contains=rakuAttention,rakuBracketComment +syn region rakuBracketComment + \ matchgroup=rakuBracketComment + \ start="#[`|=]<<<" + \ skip="<<<\%([^>]\|>\%(>>\)\@!\)*>>>" + \ end=">>>" + \ contains=rakuAttention,rakuBracketComment + +syn region rakuBracketComment + \ matchgroup=rakuBracketComment + \ start="#[`|=]««" + \ skip="««\%([^»]\|»»\@!\)*»»" + \ end="»»" + \ contains=rakuAttention,rakuBracketComment +syn region rakuBracketComment + \ matchgroup=rakuBracketComment + \ start="#[`|=]«««" + \ skip="«««\%([^»]\|»\%(»»\)\@!\)*»»»" + \ end="»»»" + \ contains=rakuAttention,rakuBracketComment + +syn match rakuShebang display "\%^#!.*" + +" => autoquoting +syn match rakuStringAuto display "\.\@1<!\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\ze\%(p5\)\@2<![RSXZ]\@1<!=>" +syn match rakuStringAuto display "\.\@1<!\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\ze\s\+=>" +syn match rakuStringAuto display "\.\@1<!\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)p5\ze=>" + +" Pod + +" Abbreviated blocks (implicit code forbidden) +syn region rakuPodAbbrRegion + \ matchgroup=rakuPodPrefix + \ start="^\s*\zs=\ze\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contains=rakuPodAbbrNoCodeType + \ keepend + +syn region rakuPodAbbrNoCodeType + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + \ contains=rakuPodName,rakuPodAbbrNoCode + +syn match rakuPodName contained ".\+" contains=@rakuPodFormat +syn match rakuPodComment contained ".\+" + +syn region rakuPodAbbrNoCode + \ start="^" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + \ contains=@rakuPodFormat + +" Abbreviated blocks (everything is code) +syn region rakuPodAbbrRegion + \ matchgroup=rakuPodPrefix + \ start="^\s*\zs=\zecode\>" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contains=rakuPodAbbrCodeType + \ keepend + +syn region rakuPodAbbrCodeType + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + \ contains=rakuPodName,rakuPodAbbrCode + +syn region rakuPodAbbrCode + \ start="^" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + +" Abbreviated blocks (everything is a comment) +syn region rakuPodAbbrRegion + \ matchgroup=rakuPodPrefix + \ start="^=\zecomment\>" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contains=rakuPodAbbrCommentType + \ keepend + +syn region rakuPodAbbrCommentType + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + \ contains=rakuPodComment,rakuPodAbbrNoCode + +" Abbreviated blocks (implicit code allowed) +syn region rakuPodAbbrRegion + \ matchgroup=rakuPodPrefix + \ start="^=\ze\%(pod\|item\|nested\|\u\+\)\>" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contains=rakuPodAbbrType + \ keepend + +syn region rakuPodAbbrType + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + \ contains=rakuPodName,rakuPodAbbr + +syn region rakuPodAbbr + \ start="^" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + \ contains=@rakuPodFormat,rakuPodImplicitCode + +" Abbreviated block to end-of-file +syn region rakuPodAbbrRegion + \ matchgroup=rakuPodPrefix + \ start="^=\zeEND\>" + \ end="\%$" + \ contains=rakuPodAbbrEOFType + \ keepend + +syn region rakuPodAbbrEOFType + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="\%$" + \ contained + \ contains=rakuPodName,rakuPodAbbrEOF + +syn region rakuPodAbbrEOF + \ start="^" + \ end="\%$" + \ contained + \ contains=@rakuPodNestedBlocks,@rakuPodFormat,rakuPodImplicitCode + +" Directives +syn region rakuPodDirectRegion + \ matchgroup=rakuPodPrefix + \ start="^=\%(config\|use\)\>" + \ end="^\ze\%([^=]\|=[A-Za-z_\xC0-\xFF]\|\s*$\)" + \ contains=rakuPodDirectArgRegion + \ keepend + +syn region rakuPodDirectArgRegion + \ matchgroup=rakuPodType + \ start="\S\+" + \ end="^\ze\%([^=]\|=[A-Za-z_\xC0-\xFF]\|\s*$\)" + \ contained + \ contains=rakuPodDirectConfigRegion + +syn region rakuPodDirectConfigRegion + \ start="" + \ end="^\ze\%([^=]\|=[A-Za-z_\xC0-\xFF]\|\s*$\)" + \ contained + \ contains=@rakuPodConfig + +" =encoding is a special directive +syn region rakuPodDirectRegion + \ matchgroup=rakuPodPrefix + \ start="^=encoding\>" + \ end="^\ze\%([^=]\|=[A-Za-z_\xC0-\xFF]\|\s*$\)" + \ contains=rakuPodEncodingArgRegion + \ keepend + +syn region rakuPodEncodingArgRegion + \ matchgroup=rakuPodName + \ start="\S\+" + \ end="^\ze\%([^=]\|=[A-Za-z_\xC0-\xFF]\|\s*$\)" + \ contained + +" Paragraph blocks (implicit code forbidden) +syn region rakuPodParaRegion + \ matchgroup=rakuPodPrefix + \ start="^\s*\zs=for\>" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contains=rakuPodParaNoCodeTypeRegion + \ keepend extend + +syn region rakuPodParaNoCodeTypeRegion + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="^\s*\zs\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + \ contains=rakuPodParaNoCode,rakuPodParaConfigRegion + +syn region rakuPodParaConfigRegion + \ start="" + \ end="^\ze\%([^=]\|=[A-Za-z_\xC0-\xFF]\@1<!\)" + \ contained + \ contains=@rakuPodConfig + +syn region rakuPodParaNoCode + \ start="^[^=]" + \ end="^\s*\zs\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + \ contains=@rakuPodFormat + +" Paragraph blocks (everything is code) +syn region rakuPodParaRegion + \ matchgroup=rakuPodPrefix + \ start="^\s*\zs=for\>\ze\s*code\>" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contains=rakuPodParaCodeTypeRegion + \ keepend extend + +syn region rakuPodParaCodeTypeRegion + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="^\s*\zs\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + \ contains=rakuPodParaCode,rakuPodParaConfigRegion + +syn region rakuPodParaCode + \ start="^[^=]" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + +" Paragraph blocks (implicit code allowed) +syn region rakuPodParaRegion + \ matchgroup=rakuPodPrefix + \ start="^\s*\zs=for\>\ze\s*\%(pod\|item\|nested\|\u\+\)\>" + \ end="^\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contains=rakuPodParaTypeRegion + \ keepend extend + +syn region rakuPodParaTypeRegion + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="^\s*\zs\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + \ contains=rakuPodPara,rakuPodParaConfigRegion + +syn region rakuPodPara + \ start="^[^=]" + \ end="^\s*\zs\ze\%(\s*$\|=[A-Za-z_\xC0-\xFF]\)" + \ contained + \ contains=@rakuPodFormat,rakuPodImplicitCode + +" Paragraph block to end-of-file +syn region rakuPodParaRegion + \ matchgroup=rakuPodPrefix + \ start="^=for\>\ze\s\+END\>" + \ end="\%$" + \ contains=rakuPodParaEOFTypeRegion + \ keepend extend + +syn region rakuPodParaEOFTypeRegion + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="\%$" + \ contained + \ contains=rakuPodParaEOF,rakuPodParaConfigRegion + +syn region rakuPodParaEOF + \ start="^[^=]" + \ end="\%$" + \ contained + \ contains=@rakuPodNestedBlocks,@rakuPodFormat,rakuPodImplicitCode + +" Delimited blocks (implicit code forbidden) +syn region rakuPodDelimRegion + \ matchgroup=rakuPodPrefix + \ start="^\z(\s*\)\zs=begin\>" + \ end="^\z1\zs=end\>" + \ contains=rakuPodDelimNoCodeTypeRegion + \ keepend extend skipwhite + \ nextgroup=rakuPodType + +syn region rakuPodDelimNoCodeTypeRegion + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="^\s*\zs\ze=end\>" + \ contained + \ contains=rakuPodDelimNoCode,rakuPodDelimConfigRegion + +syn region rakuPodDelimConfigRegion + \ start="" + \ end="^\s*\zs\ze\%([^=]\|=[A-Za-z_\xC0-\xFF]\|\s*$\)" + \ contained + \ contains=@rakuPodConfig + +syn region rakuPodDelimNoCode + \ start="^" + \ end="^\s*\zs\ze=end\>" + \ contained + \ contains=@rakuPodNestedBlocks,@rakuPodFormat + +" Delimited blocks (everything is code) +syn region rakuPodDelimRegion + \ matchgroup=rakuPodPrefix + \ start="^\z(\s*\)\zs=begin\>\ze\s*code\>" + \ end="^\z1\zs=end\>" + \ contains=rakuPodDelimCodeTypeRegion + \ keepend extend skipwhite + \ nextgroup=rakuPodType + +syn region rakuPodDelimCodeTypeRegion + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="^\s*\zs\ze=end\>" + \ contained + \ contains=rakuPodDelimCode,rakuPodDelimConfigRegion + +syn region rakuPodDelimCode + \ start="^" + \ end="^\s*\zs\ze=end\>" + \ contained + \ contains=@rakuPodNestedBlocks + +" Delimited blocks (implicit code allowed) +syn region rakuPodDelimRegion + \ matchgroup=rakuPodPrefix + \ start="^\z(\s*\)\zs=begin\>\ze\s*\%(pod\|item\|nested\|\u\+\)\>" + \ end="^\z1\zs=end\>" + \ contains=rakuPodDelimTypeRegion + \ keepend extend skipwhite + \ nextgroup=rakuPodType + +syn region rakuPodDelimTypeRegion + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="^\s*\zs\ze=end\>" + \ contained + \ contains=rakuPodDelim,rakuPodDelimConfigRegion + +syn region rakuPodDelim + \ start="^" + \ end="^\s*\zs\ze=end\>" + \ contained + \ contains=@rakuPodNestedBlocks,@rakuPodFormat,rakuPodImplicitCode + +" Delimited block to end-of-file +syn region rakuPodDelimRegion + \ matchgroup=rakuPodPrefix + \ start="^=begin\>\ze\s\+END\>" + \ end="\%$" + \ extend + \ contains=rakuPodDelimEOFTypeRegion + +syn region rakuPodDelimEOFTypeRegion + \ matchgroup=rakuPodType + \ start="\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + \ end="\%$" + \ contained + \ contains=rakuPodDelimEOF,rakuPodDelimConfigRegion + +syn region rakuPodDelimEOF + \ start="^" + \ end="\%$" + \ contained + \ contains=@rakuPodNestedBlocks,@rakuPodFormat,rakuPodImplicitCode + +syn cluster rakuPodConfig + \ add=rakuPodConfigOperator + \ add=rakuPodExtraConfig + \ add=rakuStringAuto + \ add=rakuPodAutoQuote + \ add=rakuStringSQ + +syn region rakuPodParens + \ start="(" + \ end=")" + \ contained + \ contains=rakuNumber,rakuStringSQ + +syn match rakuPodAutoQuote display contained "=>" +syn match rakuPodConfigOperator display contained ":!\?" nextgroup=rakuPodConfigOption +syn match rakuPodConfigOption display contained "[^[:space:](<]\+" nextgroup=rakuPodParens,rakuStringAngle +syn match rakuPodExtraConfig display contained "^=" +syn match rakuPodVerticalBar display contained "|" +syn match rakuPodColon display contained ":" +syn match rakuPodSemicolon display contained ";" +syn match rakuPodComma display contained "," +syn match rakuPodImplicitCode display contained "^\s.*" +syn match rakuPodType display contained "\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)" + +" These may appear inside delimited blocks +syn cluster rakuPodNestedBlocks + \ add=rakuPodAbbrRegion + \ add=rakuPodDirectRegion + \ add=rakuPodParaRegion + \ add=rakuPodDelimRegion + +" Pod formatting codes + +syn cluster rakuPodFormat + \ add=rakuPodFormatOne + \ add=rakuPodFormatTwo + \ add=rakuPodFormatThree + \ add=rakuPodFormatFrench + +" Balanced angles found inside formatting codes. Ensures proper nesting. + +syn region rakuPodFormatAnglesOne + \ matchgroup=rakuPodFormat + \ start="<" + \ skip="<[^>]*>" + \ end=">" + \ transparent contained + \ contains=rakuPodFormatAnglesFrench,rakuPodFormatAnglesOne + +syn region rakuPodFormatAnglesTwo + \ matchgroup=rakuPodFormat + \ start="<<" + \ skip="<<[^>]*>>" + \ end=">>" + \ transparent contained + \ contains=rakuPodFormatAnglesFrench,rakuPodFormatAnglesOne,rakuPodFormatAnglesTwo + +syn region rakuPodFormatAnglesThree + \ matchgroup=rakuPodFormat + \ start="<<<" + \ skip="<<<[^>]*>>>" + \ end=">>>" + \ transparent contained + \ contains=rakuPodFormatAnglesFrench,rakuPodFormatAnglesOne,rakuPodFormatAnglesTwo,rakuPodFormatAnglesThree + +syn region rakuPodFormatAnglesFrench + \ matchgroup=rakuPodFormat + \ start="«" + \ skip="«[^»]*»" + \ end="»" + \ transparent contained + \ contains=rakuPodFormatAnglesFrench,rakuPodFormatAnglesOne,rakuPodFormatAnglesTwo,rakuPodFormatAnglesThree + +" All formatting codes + +syn region rakuPodFormatOne + \ matchgroup=rakuPodFormatCode + \ start="\u<" + \ skip="<[^>]*>" + \ end=">" + \ contained + \ contains=rakuPodFormatAnglesOne,rakuPodFormatFrench,rakuPodFormatOne + +syn region rakuPodFormatTwo + \ matchgroup=rakuPodFormatCode + \ start="\u<<" + \ skip="<<[^>]*>>" + \ end=">>" + \ contained + \ contains=rakuPodFormatAnglesTwo,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo + +syn region rakuPodFormatThree + \ matchgroup=rakuPodFormatCode + \ start="\u<<<" + \ skip="<<<[^>]*>>>" + \ end=">>>" + \ contained + \ contains=rakuPodFormatAnglesThree,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree + +syn region rakuPodFormatFrench + \ matchgroup=rakuPodFormatCode + \ start="\u«" + \ skip="«[^»]*»" + \ end="»" + \ contained + \ contains=rakuPodFormatAnglesFrench,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree + +" C<> and V<> don't allow nested formatting formatting codes + +syn region rakuPodFormatOne + \ matchgroup=rakuPodFormatCode + \ start="[CV]<" + \ skip="<[^>]*>" + \ end=">" + \ contained + \ contains=rakuPodFormatAnglesOne + +syn region rakuPodFormatTwo + \ matchgroup=rakuPodFormatCode + \ start="[CV]<<" + \ skip="<<[^>]*>>" + \ end=">>" + \ contained + \ contains=rakuPodFormatAnglesTwo + +syn region rakuPodFormatThree + \ matchgroup=rakuPodFormatCode + \ start="[CV]<<<" + \ skip="<<<[^>]*>>>" + \ end=">>>" + \ contained + \ contains=rakuPodFormatAnglesThree + +syn region rakuPodFormatFrench + \ matchgroup=rakuPodFormatCode + \ start="[CV]«" + \ skip="«[^»]*»" + \ end="»" + \ contained + \ contains=rakuPodFormatAnglesFrench + +" L<> can have a "|" separator + +syn region rakuPodFormatOne + \ matchgroup=rakuPodFormatCode + \ start="L<" + \ skip="<[^>]*>" + \ end=">" + \ contained + \ contains=rakuPodFormatAnglesOne,rakuPodFormatFrench,rakuPodFormatOne,rakuPodVerticalBar + +syn region rakuPodFormatTwo + \ matchgroup=rakuPodFormatCode + \ start="L<<" + \ skip="<<[^>]*>>" + \ end=">>" + \ contained + \ contains=rakuPodFormatAnglesTwo,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodVerticalBar + +syn region rakuPodFormatThree + \ matchgroup=rakuPodFormatCode + \ start="L<<<" + \ skip="<<<[^>]*>>>" + \ end=">>>" + \ contained + \ contains=rakuPodFormatAnglesThree,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree,rakuPodVerticalBar + +syn region rakuPodFormatFrench + \ matchgroup=rakuPodFormatCode + \ start="L«" + \ skip="«[^»]*»" + \ end="»" + \ contained + \ contains=rakuPodFormatAnglesFrench,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree,rakuPodVerticalBar + +" E<> can have a ";" separator + +syn region rakuPodFormatOne + \ matchgroup=rakuPodFormatCode + \ start="E<" + \ skip="<[^>]*>" + \ end=">" + \ contained + \ contains=rakuPodFormatAnglesOne,rakuPodFormatFrench,rakuPodFormatOne,rakuPodSemiColon + +syn region rakuPodFormatTwo + \ matchgroup=rakuPodFormatCode + \ start="E<<" + \ skip="<<[^>]*>>" + \ end=">>" + \ contained + \ contains=rakuPodFormatAnglesTwo,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodSemiColon + +syn region rakuPodFormatThree + \ matchgroup=rakuPodFormatCode + \ start="E<<<" + \ skip="<<<[^>]*>>>" + \ end=">>>" + \ contained + \ contains=rakuPodFormatAnglesThree,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree,rakuPodSemiColon + +syn region rakuPodFormatFrench + \ matchgroup=rakuPodFormatCode + \ start="E«" + \ skip="«[^»]*»" + \ end="»" + \ contained + \ contains=rakuPodFormatAnglesFrench,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree,rakuPodSemiColon + +" M<> can have a ":" separator + +syn region rakuPodFormatOne + \ matchgroup=rakuPodFormatCode + \ start="M<" + \ skip="<[^>]*>" + \ end=">" + \ contained + \ contains=rakuPodFormatAnglesOne,rakuPodFormatFrench,rakuPodFormatOne,rakuPodColon + +syn region rakuPodFormatTwo + \ matchgroup=rakuPodFormatCode + \ start="M<<" + \ skip="<<[^>]*>>" + \ end=">>" + \ contained + \ contains=rakuPodFormatAnglesTwo,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodColon + +syn region rakuPodFormatThree + \ matchgroup=rakuPodFormatCode + \ start="M<<<" + \ skip="<<<[^>]*>>>" + \ end=">>>" + \ contained + \ contains=rakuPodFormatAnglesThree,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree,rakuPodColon + +syn region rakuPodFormatFrench + \ matchgroup=rakuPodFormatCode + \ start="M«" + \ skip="«[^»]*»" + \ end="»" + \ contained + \ contains=rakuPodFormatAnglesFrench,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree,rakuPodColon + +" D<> can have "|" and ";" separators + +syn region rakuPodFormatOne + \ matchgroup=rakuPodFormatCode + \ start="D<" + \ skip="<[^>]*>" + \ end=">" + \ contained + \ contains=rakuPodFormatAnglesOne,rakuPodFormatFrench,rakuPodFormatOne,rakuPodVerticalBar,rakuPodSemiColon + +syn region rakuPodFormatTwo + \ matchgroup=rakuPodFormatCode + \ start="D<<" + \ skip="<<[^>]*>>" + \ end=">>" + \ contained + \ contains=rakuPodFormatAngleTwo,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodVerticalBar,rakuPodSemiColon + +syn region rakuPodFormatThree + \ matchgroup=rakuPodFormatCode + \ start="D<<<" + \ skip="<<<[^>]*>>>" + \ end=">>>" + \ contained + \ contains=rakuPodFormatAnglesThree,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree,rakuPodVerticalBar,rakuPodSemiColon + +syn region rakuPodFormatFrench + \ matchgroup=rakuPodFormatCode + \ start="D«" + \ skip="«[^»]*»" + \ end="»" + \ contained + \ contains=rakuPodFormatAnglesFrench,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree,rakuPodVerticalBar,rakuPodSemiColon + +" X<> can have "|", "," and ";" separators + +syn region rakuPodFormatOne + \ matchgroup=rakuPodFormatCode + \ start="X<" + \ skip="<[^>]*>" + \ end=">" + \ contained + \ contains=rakuPodFormatAnglesOne,rakuPodFormatFrench,rakuPodFormatOne,rakuPodVerticalBar,rakuPodSemiColon,rakuPodComma + +syn region rakuPodFormatTwo + \ matchgroup=rakuPodFormatCode + \ start="X<<" + \ skip="<<[^>]*>>" + \ end=">>" + \ contained + \ contains=rakuPodFormatAnglesTwo,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodVerticalBar,rakuPodSemiColon,rakuPodComma + +syn region rakuPodFormatThree + \ matchgroup=rakuPodFormatCode + \ start="X<<<" + \ skip="<<<[^>]*>>>" + \ end=">>>" + \ contained + \ contains=rakuPodFormatAnglesThree,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree,rakuPodVerticalBar,rakuPodSemiColon,rakuPodComma + +syn region rakuPodFormatFrench + \ matchgroup=rakuPodFormatCode + \ start="X«" + \ skip="«[^»]*»" + \ end="»" + \ contained + \ contains=rakuPodFormatAnglesFrench,rakuPodFormatFrench,rakuPodFormatOne,rakuPodFormatTwo,rakuPodFormatThree,rakuPodVerticalBar,rakuPodSemiColon,rakuPodComma + +" Define the default highlighting. +" For version 5.7 and earlier: only when not done already +" For version 5.8 and later: only when an item doesn't have highlighting yet +if version >= 508 || !exists("did_raku_syntax_inits") + if version < 508 + let did_raku_syntax_inits = 1 + command -nargs=+ HiLink hi link <args> + else + command -nargs=+ HiLink hi def link <args> + endif + + HiLink rakuEscOctOld rakuError + HiLink rakuPackageTwigil rakuTwigil + HiLink rakuStringAngle rakuString + HiLink rakuStringAngleFixed rakuString + HiLink rakuStringFrench rakuString + HiLink rakuStringAngles rakuString + HiLink rakuStringSQ rakuString + HiLink rakuStringDQ rakuString + HiLink rakuStringQ rakuString + HiLink rakuStringQ_q rakuString + HiLink rakuStringQ_qww rakuString + HiLink rakuStringQ_qq rakuString + HiLink rakuStringQ_to rakuString + HiLink rakuStringQ_qto rakuString + HiLink rakuStringQ_qqto rakuString + HiLink rakuRxStringSQ rakuString + HiLink rakuRxStringDQ rakuString + HiLink rakuReplacement rakuString + HiLink rakuReplCurly rakuString + HiLink rakuReplAngle rakuString + HiLink rakuReplFrench rakuString + HiLink rakuReplBracket rakuString + HiLink rakuReplParen rakuString + HiLink rakuTransliteration rakuString + HiLink rakuTransRepl rakuString + HiLink rakuTransReplCurly rakuString + HiLink rakuTransReplAngle rakuString + HiLink rakuTransReplFrench rakuString + HiLink rakuTransReplBracket rakuString + HiLink rakuTransReplParen rakuString + HiLink rakuStringAuto rakuString + HiLink rakuKey rakuString + HiLink rakuMatch rakuString + HiLink rakuSubstitution rakuString + HiLink rakuMatchBare rakuString + HiLink rakuRegexBlock rakuString + HiLink rakuRxP5CharClass rakuString + HiLink rakuRxP5QuoteMeta rakuString + HiLink rakuRxCharClass rakuString + HiLink rakuRxQuoteWords rakuString + HiLink rakuReduceOp rakuOperator + HiLink rakuSetOp rakuOperator + HiLink rakuRSXZOp rakuOperator + HiLink rakuHyperOp rakuOperator + HiLink rakuPostHyperOp rakuOperator + HiLink rakuQuoteQ rakuQuote + HiLink rakuQuoteQ_q rakuQuote + HiLink rakuQuoteQ_qww rakuQuote + HiLink rakuQuoteQ_qq rakuQuote + HiLink rakuQuoteQ_to rakuQuote + HiLink rakuQuoteQ_qto rakuQuote + HiLink rakuQuoteQ_qqto rakuQuote + HiLink rakuQuoteQ_PIR rakuQuote + HiLink rakuMatchStart_m rakuQuote + HiLink rakuMatchStart_s rakuQuote + HiLink rakuMatchStart_tr rakuQuote + HiLink rakuBareSigil rakuVariable + HiLink rakuRxRange rakuStringSpecial + HiLink rakuRxAnchor rakuStringSpecial + HiLink rakuRxBoundary rakuStringSpecial + HiLink rakuRxP5Anchor rakuStringSpecial + HiLink rakuCodePoint rakuStringSpecial + HiLink rakuRxMeta rakuStringSpecial + HiLink rakuRxP5Range rakuStringSpecial + HiLink rakuRxP5CPId rakuStringSpecial + HiLink rakuRxP5Posix rakuStringSpecial + HiLink rakuRxP5Mod rakuStringSpecial + HiLink rakuRxP5HexSeq rakuStringSpecial + HiLink rakuRxP5OctSeq rakuStringSpecial + HiLink rakuRxP5WriteRefId rakuStringSpecial + HiLink rakuHexSequence rakuStringSpecial + HiLink rakuOctSequence rakuStringSpecial + HiLink rakuRxP5Named rakuStringSpecial + HiLink rakuRxP5PropId rakuStringSpecial + HiLink rakuRxP5Quantifier rakuStringSpecial + HiLink rakuRxP5CountId rakuStringSpecial + HiLink rakuRxP5Verb rakuStringSpecial + HiLink rakuRxAssertGroup rakuStringSpecial2 + HiLink rakuEscape rakuStringSpecial2 + HiLink rakuEscNull rakuStringSpecial2 + HiLink rakuEscHash rakuStringSpecial2 + HiLink rakuEscQQ rakuStringSpecial2 + HiLink rakuEscQuote rakuStringSpecial2 + HiLink rakuEscDoubleQuote rakuStringSpecial2 + HiLink rakuEscBackTick rakuStringSpecial2 + HiLink rakuEscForwardSlash rakuStringSpecial2 + HiLink rakuEscVerticalBar rakuStringSpecial2 + HiLink rakuEscExclamation rakuStringSpecial2 + HiLink rakuEscDollar rakuStringSpecial2 + HiLink rakuEscOpenCurly rakuStringSpecial2 + HiLink rakuEscCloseCurly rakuStringSpecial2 + HiLink rakuEscCloseBracket rakuStringSpecial2 + HiLink rakuEscCloseAngle rakuStringSpecial2 + HiLink rakuEscCloseFrench rakuStringSpecial2 + HiLink rakuEscBackSlash rakuStringSpecial2 + HiLink rakuEscCodePoint rakuStringSpecial2 + HiLink rakuEscOct rakuStringSpecial2 + HiLink rakuEscHex rakuStringSpecial2 + HiLink rakuRxEscape rakuStringSpecial2 + HiLink rakuRxCapture rakuStringSpecial2 + HiLink rakuRxAlternation rakuStringSpecial2 + HiLink rakuRxP5 rakuStringSpecial2 + HiLink rakuRxP5ReadRef rakuStringSpecial2 + HiLink rakuRxP5Oct rakuStringSpecial2 + HiLink rakuRxP5Hex rakuStringSpecial2 + HiLink rakuRxP5EscMeta rakuStringSpecial2 + HiLink rakuRxP5Meta rakuStringSpecial2 + HiLink rakuRxP5Escape rakuStringSpecial2 + HiLink rakuRxP5CodePoint rakuStringSpecial2 + HiLink rakuRxP5WriteRef rakuStringSpecial2 + HiLink rakuRxP5Prop rakuStringSpecial2 + + HiLink rakuProperty Tag + HiLink rakuAttention Todo + HiLink rakuType Type + HiLink rakuError Error + HiLink rakuBlockLabel Label + HiLink rakuNormal Normal + HiLink rakuIdentifier Normal + HiLink rakuPackage Normal + HiLink rakuPackageScope Normal + HiLink rakuNumber Number + HiLink rakuOctNumber Number + HiLink rakuBinNumber Number + HiLink rakuHexNumber Number + HiLink rakuDecNumber Number + HiLink rakuString String + HiLink rakuRepeat Repeat + HiLink rakuPragma Keyword + HiLink rakuPreDeclare Keyword + HiLink rakuDeclare Keyword + HiLink rakuDeclareRegex Keyword + HiLink rakuVarStorage Special + HiLink rakuFlowControl Special + HiLink rakuOctBase Special + HiLink rakuBinBase Special + HiLink rakuHexBase Special + HiLink rakuDecBase Special + HiLink rakuTwigil Special + HiLink rakuStringSpecial2 Special + HiLink rakuVersion Special + HiLink rakuComment Comment + HiLink rakuBracketComment Comment + HiLink rakuInclude Include + HiLink rakuShebang PreProc + HiLink rakuClosureTrait PreProc + HiLink rakuOperator Operator + HiLink rakuContext Operator + HiLink rakuQuote Delimiter + HiLink rakuTypeConstraint PreCondit + HiLink rakuException Exception + HiLink rakuVariable Identifier + HiLink rakuVarSlash Identifier + HiLink rakuVarNum Identifier + HiLink rakuVarExclam Identifier + HiLink rakuVarMatch Identifier + HiLink rakuVarName Identifier + HiLink rakuMatchVar Identifier + HiLink rakuRxP5ReadRefId Identifier + HiLink rakuRxP5ModDef Identifier + HiLink rakuRxP5ModName Identifier + HiLink rakuConditional Conditional + HiLink rakuStringSpecial SpecialChar + + HiLink rakuPodAbbr rakuPod + HiLink rakuPodAbbrEOF rakuPod + HiLink rakuPodAbbrNoCode rakuPod + HiLink rakuPodAbbrCode rakuPodCode + HiLink rakuPodPara rakuPod + HiLink rakuPodParaEOF rakuPod + HiLink rakuPodParaNoCode rakuPod + HiLink rakuPodParaCode rakuPodCode + HiLink rakuPodDelim rakuPod + HiLink rakuPodDelimEOF rakuPod + HiLink rakuPodDelimNoCode rakuPod + HiLink rakuPodDelimCode rakuPodCode + HiLink rakuPodImplicitCode rakuPodCode + HiLink rakuPodExtraConfig rakuPodPrefix + HiLink rakuPodVerticalBar rakuPodFormatCode + HiLink rakuPodColon rakuPodFormatCode + HiLink rakuPodSemicolon rakuPodFormatCode + HiLink rakuPodComma rakuPodFormatCode + HiLink rakuPodFormatOne rakuPodFormat + HiLink rakuPodFormatTwo rakuPodFormat + HiLink rakuPodFormatThree rakuPodFormat + HiLink rakuPodFormatFrench rakuPodFormat + + HiLink rakuPodType Type + HiLink rakuPodConfigOption String + HiLink rakuPodCode PreProc + HiLink rakuPod Comment + HiLink rakuPodComment Comment + HiLink rakuPodAutoQuote Operator + HiLink rakuPodConfigOperator Operator + HiLink rakuPodPrefix Statement + HiLink rakuPodName Identifier + HiLink rakuPodFormatCode SpecialChar + HiLink rakuPodFormat SpecialComment + + delcommand HiLink +endif + +if exists("raku_fold") || exists("raku_extended_all") + setl foldmethod=syntax + syn region rakuBlockFold + \ start="^\z(\s*\)\%(my\|our\|augment\|multi\|proto\|only\)\?\s*\%(\%([A-Za-z_\xC0-\xFF]\%([A-Za-z_\xC0-\xFF0-9]\|[-'][A-Za-z_\xC0-\xFF]\@=\)*\)\s\+\)\?\<\%(CATCH\|try\|ENTER\|LEAVE\|CHECK\|INIT\|BEGIN\|END\|KEEP\|UNDO\|PRE\|POST\|module\|package\|enum\|subset\|class\|sub\%(method\)\?\|multi\|method\|slang\|grammar\|regex\|token\|rule\)\>[^{]\+\%({\s*\%(#.*\)\?\)\?$" + \ end="^\z1}" + \ transparent fold keepend extend +endif + +let b:current_syntax = "raku" + +let &cpo = s:keepcpo +unlet s:keepcpo + +" vim:ts=8:sts=4:sw=4:expandtab:ft=vim diff --git a/runtime/syntax/rmd.vim b/runtime/syntax/rmd.vim index d852d225bc..cccd4110f5 100644 --- a/runtime/syntax/rmd.vim +++ b/runtime/syntax/rmd.vim @@ -1,7 +1,7 @@ " markdown Text with R statements " Language: markdown with R code chunks " Homepage: https://github.com/jalvesaq/R-Vim-runtime -" Last Change: Thu Apr 18, 2019 09:17PM +" Last Change: Wed Apr 21, 2021 09:55AM " " For highlighting pandoc extensions to markdown like citations and TeX and " many other advanced features like folding of markdown sections, it is @@ -13,27 +13,45 @@ if exists("b:current_syntax") finish endif -" Configuration if not using pandoc syntax: -" Add syntax highlighting of YAML header -let g:rmd_syn_hl_yaml = get(g:, 'rmd_syn_hl_yaml', 1) -" Add syntax highlighting of citation keys -let g:rmd_syn_hl_citations = get(g:, 'rmd_syn_hl_citations', 1) -" Highlight the header of the chunk of R code -let g:rmd_syn_hl_chunk = get(g:, 'g:rmd_syn_hl_chunk', 0) +" Highlight the header of the chunks as R code +let g:rmd_syn_hl_chunk = get(g:, 'rmd_syn_hl_chunk', 0) " Pandoc-syntax has more features, but it is slower. " https://github.com/vim-pandoc/vim-pandoc-syntax let g:pandoc#syntax#codeblocks#embeds#langs = get(g:, 'pandoc#syntax#codeblocks#embeds#langs', ['r']) runtime syntax/pandoc.vim if exists("b:current_syntax") - " Fix recognition of R code - syn region pandocDelimitedCodeBlock_r start=/^```{r\>.*}$/ end=/^```$/ contained containedin=pandocDelimitedCodeBlock contains=@R + " Recognize inline R code syn region rmdrInline matchgroup=rmdInlineDelim start="`r " end="`" contains=@R containedin=pandocLaTeXRegion,yamlFlowString keepend hi def link rmdInlineDelim Delimiter + + " Fix recognition of language chunks (code adapted from pandoc, 2021-03-28) + " Knitr requires braces in the block's header + for s:lng in g:pandoc#syntax#codeblocks#embeds#langs + let s:nm = matchstr(s:lng, '^[^=]*') + exe 'syn clear pandocDelimitedCodeBlock_'.s:nm + exe 'syn clear pandocDelimitedCodeBlockinBlockQuote_'.s:nm + if g:rmd_syn_hl_chunk + exe 'syn region rmd'.s:nm.'ChunkDelim matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>" matchgroup=rmdCodeDelim end="}$" keepend containedin=rmd'.s:nm.'Chunk contains=@R' + exe 'syn region rmd'.s:nm.'Chunk start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=rmd'.s:nm.'ChunkDelim,@'.toupper(s:nm) + else + exe 'syn region rmd'.s:nm.'Chunk matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=@'.toupper(s:nm) + endif + endfor + unlet s:lng + unlet s:nm + hi def link rmdInlineDelim Delimiter + hi def link rmdCodeDelim Delimiter let b:current_syntax = "rmd" finish endif +" Configuration if not using pandoc syntax: +" Add syntax highlighting of YAML header +let g:rmd_syn_hl_yaml = get(g:, 'rmd_syn_hl_yaml', 1) +" Add syntax highlighting of citation keys +let g:rmd_syn_hl_citations = get(g:, 'rmd_syn_hl_citations', 1) + let s:cpo_save = &cpo set cpo&vim @@ -63,15 +81,17 @@ for s:type in g:rmd_fenced_languages unlet! b:current_syntax exe 'syn include @Rmd'.s:nm.' syntax/'.s:ft.'.vim' if g:rmd_syn_hl_chunk - exe 'syn region rmd'.s:nm.'ChunkDelim matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>" matchgroup=rmdCodeDelim end="}$" keepend containedin=rmd'.s:nm.'Chunk contains=@Rmd'.s:nm + exe 'syn region rmd'.s:nm.'ChunkDelim matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>" matchgroup=rmdCodeDelim end="}$" keepend containedin=rmd'.s:nm.'Chunk contains=@Rmdr' exe 'syn region rmd'.s:nm.'Chunk start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=rmd'.s:nm.'ChunkDelim,@Rmd'.s:nm else exe 'syn region rmd'.s:nm.'Chunk matchgroup=rmdCodeDelim start="^\s*```\s*{\s*'.s:nm.'\>.*$" matchgroup=rmdCodeDelim end="^\s*```\ze\s*$" keepend contains=@Rmd'.s:nm endif - exe 'syn region rmd'.s:nm.'Inline matchgroup=rmdInlineDelim start="`'.s:nm.' " end="`" contains=@Rmd'.s:nm.' keepend' endfor unlet! s:type +" Recognize inline R code +syn region rmdrInline matchgroup=rmdInlineDelim start="`r " end="`" contains=@Rmdr keepend + hi def link rmdInlineDelim Delimiter hi def link rmdCodeDelim Delimiter diff --git a/runtime/syntax/rnoweb.vim b/runtime/syntax/rnoweb.vim index b2ba17d68d..749860a3fe 100644 --- a/runtime/syntax/rnoweb.vim +++ b/runtime/syntax/rnoweb.vim @@ -33,8 +33,8 @@ syn cluster texParaGroup add=@rnoweb " Highlighting of R code using an existing r.vim syntax file if available {{{1 syn include @rnowebR syntax/r.vim -syn region rnowebChunk matchgroup=rnowebDelimiter start="^<<.*>>=" matchgroup=rnowebDelimiter end="^@" contains=@rnowebR,rnowebChunkReference,rnowebChunk fold keepend -syn match rnowebChunkReference "^<<.*>>$" contained +syn region rnowebChunk matchgroup=rnowebDelimiter start="^\s*<<.*>>=" matchgroup=rnowebDelimiter end="^@" contains=@rnowebR,rnowebChunkReference,rnowebChunk fold keepend +syn match rnowebChunkReference "^\s*<<.*>>$" contained syn region rnowebSexpr matchgroup=Delimiter start="\\Sexpr{" matchgroup=Delimiter end="}" contains=@rnowebR contained " Sweave options command {{{1 |