diff options
Diffstat (limited to '')
32 files changed, 2153 insertions, 75 deletions
diff --git a/runtime/syntax/testdir/input/c.c b/runtime/syntax/testdir/input/c.c index c96fb33..595721b 100644 --- a/runtime/syntax/testdir/input/c.c +++ b/runtime/syntax/testdir/input/c.c @@ -1,4 +1,5 @@ /* vi:set ts=8 sts=4 sw=4 noet: + * VIM_TEST_SETUP let g:c_comment_strings = 1 * * VIM - Vi IMproved by Bram Moolenaar * diff --git a/runtime/syntax/testdir/input/java_comments.java b/runtime/syntax/testdir/input/java_comments.java new file mode 100644 index 0000000..be347d7 --- /dev/null +++ b/runtime/syntax/testdir/input/java_comments.java @@ -0,0 +1,25 @@ +// VIM_TEST_SETUP unlet! g:java_ignore_javadoc g:java_no_trail_space_error +// VIM_TEST_SETUP unlet! g:java_no_tab_space_error +// VIM_TEST_SETUP let [g:java_space_errors,g:java_comment_strings] = [1,1] +// VIM_TEST_SETUP setlocal spell +class CommentsTests +{ /* TRAILING BLANKS AND MESSPILLINGS ARE SIGNIFICANT! */ + /** + * The method {@code main} must be declared {@code public}, {@code + * static}, and {@code void}. It must specify a formal parameter + * whose declared type is array of {@link String}. Therefore, + * either of the following declarations is acceptable: + * {@snippet lang="java": + * // @highlight substring="main" type="italic": + * public static void main(String[] args) { } + * }<br /><pre class="snippet"> + *{@code public static void main(String... args) { }}</pre> + * + * @param args optional commande-line arguments + * @jls 12.1.4 Invoke {@code Test.main} + */ + // @start region = main + // @link substring = 'String' target = 'java.lang.String' : + public static void main(String[] args) { } + // @end +} diff --git a/runtime/syntax/testdir/input/java_escapes.java b/runtime/syntax/testdir/input/java_escapes.java new file mode 100644 index 0000000..eadaa42 --- /dev/null +++ b/runtime/syntax/testdir/input/java_escapes.java @@ -0,0 +1,123 @@ +class EscapesTests +{ // javap -constants EscapesTests.class + // static final String hello = "hello"; + \u0073\u0074\u0061\u0074\u0069\u0063 + \u0066\u0069\u006e\u0061\u006c + \u0053\u0074\u0072\u0069\u006e\u0067 + \u0068\u0065\u006c\u006c\u006f + \u003d + \u0022\u0068\u0065\u006c\u006c\u006f\u0022 + \u003b + + static { + char ee[] = { + '\b', '\s', '\t', + '\n', '\f', '\r', + '\"', '\'', '\\', + }; + + System.out.println(new String[] { + "\b", "\s", "\t", + "\n", "\f", "\r", + "\"", "\'", "\\", + }); + + char oo[] = { + '\0', '\1', '\2', '\3', '\4', '\5', '\6', '\7', + + '\00', '\01', '\02', '\03', '\04', '\05', '\06', '\07', + + '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', + + '\10', '\11', '\12', '\13', '\14', '\15', '\16', '\17', + '\20', '\21', '\22', '\23', '\24', '\25', '\26', '\27', + '\30', '\31', '\32', '\33', '\34', '\35', '\36', '\37', + '\40', '\41', '\42', '\43', '\44', '\45', '\46', '\47', + '\50', '\51', '\52', '\53', '\54', '\55', '\56', '\57', + '\60', '\61', '\62', '\63', '\64', '\65', '\66', '\67', + '\70', '\71', '\72', '\73', '\74', '\75', '\76', '\77', + + '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', + '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', + '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', + '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', + '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', + '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', + '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', + + '\100', '\101', '\102', '\103', '\104', '\105', '\106', '\107', + '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117', + '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127', + '\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137', + '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', + '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', + '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', + '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', + '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', + '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', + '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', + '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', + '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', + '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', + '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', + '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', + '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', + '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', + }; + + System.out.println(new String[] { + "\0", "\1", "\2", "\3", "\4", "\5", "\6", "\7", + + "\00", "\01", "\02", "\03", "\04", "\05", "\06", "\07", + + "\000", "\001", "\002", "\003", "\004", "\005", "\006", "\007", + + "\10", "\11", "\12", "\13", "\14", "\15", "\16", "\17", + "\20", "\21", "\22", "\23", "\24", "\25", "\26", "\27", + "\30", "\31", "\32", "\33", "\34", "\35", "\36", "\37", + "\40", "\41", "\42", "\43", "\44", "\45", "\46", "\47", + "\50", "\51", "\52", "\53", "\54", "\55", "\56", "\57", + "\60", "\61", "\62", "\63", "\64", "\65", "\66", "\67", + "\70", "\71", "\72", "\73", "\74", "\75", "\76", "\77", + + "\010", "\011", "\012", "\013", "\014", "\015", "\016", "\017", + "\020", "\021", "\022", "\023", "\024", "\025", "\026", "\027", + "\030", "\031", "\032", "\033", "\034", "\035", "\036", "\037", + "\040", "\041", "\042", "\043", "\044", "\045", "\046", "\047", + "\050", "\051", "\052", "\053", "\054", "\055", "\056", "\057", + "\060", "\061", "\062", "\063", "\064", "\065", "\066", "\067", + "\070", "\071", "\072", "\073", "\074", "\075", "\076", "\077", + + "\100", "\101", "\102", "\103", "\104", "\105", "\106", "\107", + "\110", "\111", "\112", "\113", "\114", "\115", "\116", "\117", + "\120", "\121", "\122", "\123", "\124", "\125", "\126", "\127", + "\130", "\131", "\132", "\133", "\134", "\135", "\136", "\137", + "\140", "\141", "\142", "\143", "\144", "\145", "\146", "\147", + "\150", "\151", "\152", "\153", "\154", "\155", "\156", "\157", + "\160", "\161", "\162", "\163", "\164", "\165", "\166", "\167", + "\170", "\171", "\172", "\173", "\174", "\175", "\176", "\177", + "\200", "\201", "\202", "\203", "\204", "\205", "\206", "\207", + "\210", "\211", "\212", "\213", "\214", "\215", "\216", "\217", + "\220", "\221", "\222", "\223", "\224", "\225", "\226", "\227", + "\230", "\231", "\232", "\233", "\234", "\235", "\236", "\237", + "\240", "\241", "\242", "\243", "\244", "\245", "\246", "\247", + "\250", "\251", "\252", "\253", "\254", "\255", "\256", "\257", + "\260", "\261", "\262", "\263", "\264", "\265", "\266", "\267", + "\270", "\271", "\272", "\273", "\274", "\275", "\276", "\277", + "\300", "\301", "\302", "\303", "\304", "\305", "\306", "\307", + "\310", "\311", "\312", "\313", "\314", "\315", "\316", "\317", + "\320", "\321", "\322", "\323", "\324", "\325", "\326", "\327", + "\330", "\331", "\332", "\333", "\334", "\335", "\336", "\337", + "\340", "\341", "\342", "\343", "\344", "\345", "\346", "\347", + "\350", "\351", "\352", "\353", "\354", "\355", "\356", "\357", + "\360", "\361", "\362", "\363", "\364", "\365", "\366", "\367", + "\370", "\371", "\372", "\373", "\374", "\375", "\376", "\377", + }); + } +} diff --git a/runtime/syntax/testdir/input/java_numbers.java b/runtime/syntax/testdir/input/java_numbers.java new file mode 100644 index 0000000..e926534 --- /dev/null +++ b/runtime/syntax/testdir/input/java_numbers.java @@ -0,0 +1,88 @@ +class NumbersTests +{ + static { + double[] dd = { + 0x.0p0, 0x0.p0, 0x0.0p0, 0x0P0, + 0x.0p0d, 0x0.p0d, 0x0.0p0d, 0x0P0D, + 0x.0p0f, 0x0.p0f, 0x0.0p0f, 0x0P0F, + 0x.0p0, 0x0.p0, 0x0.0p0, 0x0P0, + 0x.0p0d, 0x0.p0d, 0x0.0p0d, 0x0P0D, + 0x.0p0f, 0x0.p0f, 0x0.0p0f, 0x0P0F, + 0x.0p-0, 0x0.p-0, 0x0.0p-0, 0x0P-0, + 0x.0p-0d, 0x0.p-0d, 0x0.0p-0d, 0x0P-0D, + 0x.0p-0f, 0x0.p-0f, 0x0.0p-0f, 0x0P-0F, + 0x.0p+0, 0x0.p+0, 0x0.0p+0, 0x0P+0, + 0x.0p+0d, 0x0.p+0d, 0x0.0p+0d, 0x0P+0D, + 0x.0p+0f, 0x0.p+0f, 0x0.0p+0f, 0x0P+0F, + + 1., 1.2, 1.2e3, 1.2e3d, 1.2e3f, + 1.2e-3, 1.2e-3d, 1.2E-3F, + 1.2e+3, 1.2E+3D, 1.2e+3f, + .2, .2e3, .2e3d, .2e3f, + .2e-3, .2e-3d, .2E-3F, + .2e+3, .2E+3D, .2e+3f, + 1e3, 1e3d, 1e3f, + 1e-3, 1e-3d, 1E-3F, + 1e+3, 1E+3D, 1e+3f, + 1d, 1D, 1f, 1F, + +//// MALFORMED: :let g:java_comment_strings = 1 | doautocmd Syntax +// 0_x.0p0, 0x._0p0, 0x.0_p0, 0x.0p_0, 0x.0p0_, +// 0x0_.0p0, 0x_0.0p0, 0xp0, + }; + + int O = 0; + int OO = 00; + int OxO = 0x0; + + int x = 0x12_345_678; + int y = 0b01_01_01_01_01; + int z = 0__1__2__3__4__5__6__7; + + // String.format("%a", -1.0) + double minus_one_d = -0x1.0p0; + + double z_d = -0x.0p0; + double y_d = 0xap1__0__0; + double x_d = .0__1__2__3__4__5__6__7__8__9; + double dot_O = .0; + + // JLS, §3.10.2: + float max_dec_f = 3.4028235e38f; + float max_hex_f = 0x1.fffffeP+127f; + float min_dec_f = 1.4e-45f; + float min_hex_f_a = 0x0.000002P-126f; + float min_hex_f_b = 0x1.0P-149f; + + double max_dec_d = 1.7976931348623157e3__0__8; + double max_hex_d = 0x1.f_ffff_ffff_ffffP+1023; + double min_dec_d = 4.9e-3__2__4; + double min_hex_d_a = 0x0.0_0000_0000_0001P-1022; + double min_hex_d_b = 0x1.0P-1074; + + // JLS, §3.10.1: + int max_hex = 0x7fff_ffff; + int max_oct = 0177_7777_7777; + int max_bin = 0b0111_1111_1111_1111_1111_1111_1111_1111; + + int min_hex = 0x8000_0000; + int min_oct = 0200_0000_0000; + int min_bin = 0b1000_0000_0000_0000_0000_0000_0000_0000; + + int minus_one_hex = 0xffff_ffff; + int minus_one_oct = 0377_7777_7777; + int minus_one_bin = 0b1111_1111_1111_1111_1111_1111_1111_1111; + + long max_hex_l = 0x7fff_ffff_ffff_ffffL; + long max_oct_l = 07_7777_7777_7777_7777_7777L; + long max_bin_l = 0b0111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111L; + + long min_hex_l = 0x8000_0000_0000_0000L; + long min_oct_l = 010_0000_0000_0000_0000_0000L; + long min_bin_l = 0b1000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000_0000L; + + long minus_one_hex_l = 0xffff_ffff_ffff_ffffL; + long minus_one_oct_l = 017_7777_7777_7777_7777_7777L; + long minus_one_bin_l = 0b1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111_1111L; + } +} diff --git a/runtime/syntax/testdir/input/java_string.java b/runtime/syntax/testdir/input/java_string.java new file mode 100644 index 0000000..43a7a05 --- /dev/null +++ b/runtime/syntax/testdir/input/java_string.java @@ -0,0 +1,104 @@ +class StringTests // JDK 21+ (--enable-preview --release 21). +{ + static { + String s1 = "A quick brown fox jumps over the lazy dog"; + String s2 = "\"Woof\s!\""; + String s3 = """ + A\s\ + quick \ + brown\s\ + fox \ + jumps\s\ + over \ + the\s\ + lazy \ + dog"""; + String s4 = """ + "Woof\s!\""""; + String s5 = """ + String s3 = \""" + A\\s\\ + quick \\ + brown\\s\\ + fox \\ + jumps\\s\\ + over \\ + the\\s\\ + lazy \\ + dog\""";"""; + + // There are SPACE, FF, HT, CR, and LF after """. + String empty = """
+ """; + + System.out.println(""" + " + "" + ""\u005c" + ""\u005c"" + ""\"\u0022\u0022 + ""\"""\u005c\u0022 + ""\"""\"" + ""\"""\""\""""); + + System.out.println(STR.""" + " + \{"\"\""} + \{"\"\""}\{"\u005c\u0022"} + \{"\"\""}\{"\u005c\u0022"}" + \{"\"\""}\"\{"\u005c\u0022\u005c\u0022"} + \{"\"\""}\"\{"\"\""}\{"\u005c\u0022"} + \{"\"\""}\"\{"\"\""}\"" + \{"\"\""}\"\{"\"\""}\""\""""); // JDK 21+. + + String woof = "Woof", dog = "dog", fox = "fox"; + + String s6 = STR + ."A quick brown \{fox} jumps over the lazy \{dog}"; + String s7 = STR.process(StringTemplate.RAW + ."\"\{woof}\s!\""); + String s8 = STR.""" + A\s\ + quick \ + brown\s\ + \{fox} \ + jumps\s\ + over \ + the\s\ + lazy \ + \{dog}"""; + String s9 = STR.process(StringTemplate.RAW + . + """ + "\{woof}\s!\""""); + String s10 = java.util.FormatProcessor.FMT + . "%-14s\{"A\s" + STR . "quick" + "brown"}%s\{fox} " + + java.util.FormatProcessor.FMT + . "%-20s\{"jumps\sover the\s" + + STR . "lazy"}%s\{dog}"; + String s11 = STR.""" + \"\{ // A nested comment. + (new java.util.function.Function<String, String>() { + public String apply(String bay) { return bay; }; + }).apply(woof) + }\s!\""""; + String s12 = java.util.FormatProcessor.FMT + .""" + %-14s\{STR.""" + A\s\ + \{ "quick" } \ + brown"""}\ + %s\{ fox } \ + %-20s\{STR.""" + jumps\s\ + over \ + the\s\ + \{ "lazy" } """}\ + %s\{ dog }"""; + String s13 = STR + ."\"\{ /* A nested comment. */ + ((java.util.function.Function<String, String>) bay -> bay) + .apply(woof) + }\s!\""; + } +} diff --git a/runtime/syntax/testdir/input/java_switch.java b/runtime/syntax/testdir/input/java_switch.java new file mode 100644 index 0000000..14b2e11 --- /dev/null +++ b/runtime/syntax/testdir/input/java_switch.java @@ -0,0 +1,122 @@ +class SwitchTests // JDK 21+. +{ + static void echo(Object o) { System.out.println(o); } + + static { + interface Yieldable<T> + { + T yield(); + default Yieldable<T> default_() { return this; } + default Yieldable<T> when() { return this; } + } + + // There are 80 bytes (\@80<!) between "::" and "yield;". + Yieldable<?> y = ((Yieldable<?>) () -> 0):: + yield; + ((Yieldable<?>) () -> 0).when().default_().yield(); + + enum Letters { OTHER, ALPHA, BETA } + + Letters when = Letters.OTHER; + + switch (when) { + case ALPHA: { echo(Letters.ALPHA); break; } + case BETA: { echo(Letters.BETA); break; } + default: { echo(Letters.OTHER); } + } + + echo(switch (when) { + case ALPHA -> Letters.ALPHA; + case BETA -> Letters.BETA; + default -> { yield(Letters.OTHER); } + }); + + String yield = null; + + switch (yield) { + case "A": case "B": { echo("A or B"); break; } + case ":": { echo("Colon"); break; } + case String str when !str.equals(""): + { echo("<non-empty>"); break; } + case null: default: { echo("Other"); } + } + + echo(switch (yield) { + case "A", "B" -> { yield("A or B"); } + case "->" -> "Arrow"; + case String str when !str.equals("") + -> "<non-empty>"; + case null, default -> "Other"; + }); + + Object o = new Object(); + + switch (o) { + case null: { echo("null"); break; } + case Letters[] ll: { echo("SwitchTests$1Letters[]"); break; } + default: { echo("java.lang.Object"); break; } + }; + + echo(switch (o) { + case null -> "null"; + case Letters[] ll -> "SwitchTests$1Letters[]"; + default -> "java.lang.Object"; + }); + + char ch = 'c'; + + switch (ch) { + case 'a': { echo('a'); break; } + case 'b': { echo('b'); break; } + default: { echo('\u0000'); break; } + }; + + echo(switch (ch) { + case 'a' -> 'a'; + case 'b' -> 'b'; + default -> '\u0000'; + }); + + byte b = (byte) 2; + + switch (b) { + case ((byte) 0): { echo((byte) 0); break; } + case ((byte) 1): { echo((byte) 1); break; } + default: { echo((byte) -1); break; } + }; + + echo(switch (b) { + case ((byte) 0) -> (byte) 0; + case ((byte) 1) -> (byte) 1; + default -> (byte) -1; + }); + + short sh = (short) 2; + + switch (sh) { + case ((short) 0): { echo((short) 0); break; } + case ((short) 1): { echo((short) 1); break; } + default: { echo((short) -1); break; } + }; + + echo(switch (sh) { + case ((short) 0) -> (short) 0; + case ((short) 1) -> (short) 1; + default -> (short) -1; + }); + + int i = 2; + + switch (i) { + case 0b0__00___000: { echo(0); break; } + case 0x000___00__1: { echo(1); break; } + default: { echo(-1); break; } + }; + + echo(switch (i) { + case 0_0_0_0_0 -> 0; + case 1 -> 1; + default -> -1; + }); + } +} diff --git a/runtime/syntax/testdir/input/markdown_conceal.markdown b/runtime/syntax/testdir/input/markdown_conceal.markdown new file mode 100644 index 0000000..8049d68 --- /dev/null +++ b/runtime/syntax/testdir/input/markdown_conceal.markdown @@ -0,0 +1,15 @@ +_Italic_, *Italic*. __Bold__, **Bold**. +___Bold Italic___, ***Bold Italic***. +~~Strikethrough~~, S̶t̶r̶i̶k̶e̶t̶h̶r̶o̶u̶g̶h̶. + +~~~html +<p> +<del>Strikethrough</del>, <s>Strikethrough</s>.<br /> +~~~ + +```html +<strong><em>Bold Italic</em></strong>. +<strong><em>Bold Italic</em></strong>.<br /> +<strong>Bold</strong>, <strong>Bold</strong>. +<em>Italic</em>, <em>Italic</em>. +``` diff --git a/runtime/syntax/testdir/input/setup/markdown_conceal.vim b/runtime/syntax/testdir/input/setup/markdown_conceal.vim new file mode 100644 index 0000000..a1585b1 --- /dev/null +++ b/runtime/syntax/testdir/input/setup/markdown_conceal.vim @@ -0,0 +1,8 @@ +if has('conceal') + let g:markdown_syntax_conceal = 1 + setlocal conceallevel=3 concealcursor=n +endif + +let g:markdown_fenced_languages = ['html'] +highlight link markdownBold Todo +highlight link htmlBold Todo diff --git a/runtime/syntax/testdir/input/sh_10.sh b/runtime/syntax/testdir/input/sh_10.sh new file mode 100644 index 0000000..be463c3 --- /dev/null +++ b/runtime/syntax/testdir/input/sh_10.sh @@ -0,0 +1,49 @@ +#!/bin/ksh + +# This script is a test file for ksh93 shared-state +# command substitutions (subshares) and mksh value +# substitutions (valsubs). + +# ====== +# Below is subshare syntax supported by both ksh93 and mksh. +print ${ echo one } +print ${ echo two +} +print ${ +echo three } +print ${ echo 'four'; } +print ${ echo 'five' ;} +print ${ echo 'six' +} +print ${ echo 'seven' } +echo ${ print 'eight' } +typeset nine=${ pwd; } + +# ====== +# Value substitutions of the form ${|command} are only +# supported by mksh, not ksh93. +if ! command eval '((.sh.version >= 20070703))' 2>/dev/null; then + valsubfunc() { + REPLY=$1 + } + echo ${|valsubfunc ten} + print "${|valsubfunc eleven;}" + printf '%s' "${|valsubfunc twelve }" + unlucky=${|valsubfunc thirteen +} + typeset notafloat=${|valsubfunc notanumber } + print $unlucky $notanumber + ${|echo foo} + ${|echo bar +} +fi + +# ====== +# Shared-state command substitutions using the syntax ${<file;} +# are only supported by ksh93, not mksh. +echo ${ + printf %s str +} > /tmp/strfile +echo ${</tmp/strfile;} + +exit 0 diff --git a/runtime/syntax/testdir/input/sh_11.sh b/runtime/syntax/testdir/input/sh_11.sh new file mode 100644 index 0000000..6e192fc --- /dev/null +++ b/runtime/syntax/testdir/input/sh_11.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Issue #962 + +arr=( + 1 2 3 4 +) # ok + +if true; then + + arr=(1 2 3 4) # ok + + arr=( 1 2 3 4 ) # ok + + arr=( + 1 2 3 4 + ) # paren error! + +fi + diff --git a/runtime/syntax/testdir/input/vim_ex_abbreviate.vim b/runtime/syntax/testdir/input/vim_ex_abbreviate.vim new file mode 100644 index 0000000..7360e38 --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_abbreviate.vim @@ -0,0 +1,25 @@ +" Vim :abbreviate commands + +abbrev <buffer> foo foobar +cabbrev <buffer> cfoo cfoobar +iabbrev <buffer> ifoo cfoobar + +abbrev <expr> <buffer> foo foobar +cabbrev <expr> <buffer> cfoo cfoobar +iabbrev <expr> <buffer> ifoo cfoobar + +noreabbrev <buffer> foo foobar +cnoreabbrev <buffer> cfoo cfoobar +inoreabbrev <buffer> ifoo cfoobar + +abbrev <expr> <buffer> foo foobar +cabbrev <expr> <buffer> cfoo cfoobar +iabbrev <expr> <buffer> ifoo cfoobar + +unabbrev <buffer> foo +cunabbrev <buffer> cfoo +iunabbrev <buffer> ifoo + +abclear <buffer> +cabclear <buffer> +iabclear <buffer> diff --git a/runtime/syntax/testdir/input/vim_ex_augroup.vim b/runtime/syntax/testdir/input/vim_ex_augroup.vim new file mode 100644 index 0000000..2dae59d --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_augroup.vim @@ -0,0 +1,19 @@ +" Vim :augroup command + +augroup foo + autocmd BufRead * echomsg "Foo" +augroup END + +augroup foo | autocmd! | augroup END +augroup! foo + +augroup !@#$%^&*()_+ + autocmd BufRead * echomsg "Foo" +augroup END + +augroup !@#$%^&*()_+ | autocmd! | augroup END +augroup! !@#$%^&*()_+ + +" list groups +augroup + diff --git a/runtime/syntax/testdir/input/vim_ex_behave.vim b/runtime/syntax/testdir/input/vim_ex_behave.vim new file mode 100644 index 0000000..a1e99f0 --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_behave.vim @@ -0,0 +1,7 @@ +" Vim behave command + +behave mswin +behave xterm + +behave! mswin +behave! xterm diff --git a/runtime/syntax/testdir/input/vim_ex_command.vim b/runtime/syntax/testdir/input/vim_ex_command.vim new file mode 100644 index 0000000..9e98296 --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_command.vim @@ -0,0 +1,5 @@ +" Vim :command command + +" Issue #14135 + +com Foo call system('ls') diff --git a/runtime/syntax/testdir/input/vim_ex_commands.vim b/runtime/syntax/testdir/input/vim_ex_commands.vim index 6826967..571fd7b 100644 --- a/runtime/syntax/testdir/input/vim_ex_commands.vim +++ b/runtime/syntax/testdir/input/vim_ex_commands.vim @@ -13,6 +13,8 @@ : help : help +:2match +:3match :append text . @@ -603,6 +605,8 @@ call Foo() | help call Foo() |help call Foo()| help +call Foo() | 2match +call Foo() | 3match " FIXME call Foo() | append text diff --git a/runtime/syntax/testdir/input/vim_ex_def.vim b/runtime/syntax/testdir/input/vim_ex_def.vim new file mode 100644 index 0000000..dd4ecd1 --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_def.vim @@ -0,0 +1,125 @@ +" Vim :def command + + +" list + +def +def Foo +def /Foo.* + +def | echo "Foo" +def " comment +def Foo | echo "Foo" +def Foo " comment + + +" definition + +" empty definition +def Foo() +enddef + +# curly-brace names +def {"F"}oo() +enddef + +def F{"o"}o() +enddef + +def Fo{"o"}() +enddef + +def {"F"}o{"o"}() +enddef + +def {"F"}{"o"}{"o"}() +enddef + +def Foo(): number + return 42 +enddef + +# trailing whitespace +def Foo(): number + return 42 +enddef + +def Foo() # comment +enddef + +def Foo(): number # comment + return 42 +enddef + +def! Foo(): number + return 42 +enddef + +def g:Foo(): number + return 42 +enddef + +def s:Foo(): number + return 42 +enddef + +def <SID>Foo(): number + return 42 +enddef + +def foo#bar#Foo(): number + return 42 +enddef + +" same name as an Ex command +def s:ls() +enddef + + +" return types + +def Foo(): void +enddef + +def Foo(): void # comment +enddef + +def Foo(): list<dict<number>> +enddef + +def Foo(): func(dict<list<number>>, func, bool, func(number, list<number>)): bool +enddef + + +" :enddef trailing + +def Foo() + # trailing whitespace +enddef + +def Foo() +enddef | echo "Foo" + +def Foo() +enddef " comment + + +" parameters + +def Foo(x: bool, y = 42, z: string = "zed") +enddef + +def Foo( + x: bool, + y = 42, + z: string = "zed") +enddef + + +" comments + +def Foo() + # Vim9-script comment + "useless string" +enddef + diff --git a/runtime/syntax/testdir/input/vim_ex_def_fold.vim b/runtime/syntax/testdir/input/vim_ex_def_fold.vim new file mode 100644 index 0000000..7ab3e3f --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_def_fold.vim @@ -0,0 +1,126 @@ +" Vim :def command +" VIM_TEST_SETUP let g:vimsyn_folding = "f" | set fdm=syntax + + +" list + +def +def Foo +def /Foo.* + +def | echo "Foo" +def " comment +def Foo | echo "Foo" +def Foo " comment + + +" definition + +" empty definition +def Foo() +enddef + +# curly-brace names +def {"F"}oo() +enddef + +def F{"o"}o() +enddef + +def Fo{"o"}() +enddef + +def {"F"}o{"o"}() +enddef + +def {"F"}{"o"}{"o"}() +enddef + +def Foo(): number + return 42 +enddef + +# trailing whitespace +def Foo(): number + return 42 +enddef + +def Foo() # comment +enddef + +def Foo(): number # comment + return 42 +enddef + +def! Foo(): number + return 42 +enddef + +def g:Foo(): number + return 42 +enddef + +def s:Foo(): number + return 42 +enddef + +def <SID>Foo(): number + return 42 +enddef + +def foo#bar#Foo(): number + return 42 +enddef + +" same name as an Ex command +def s:ls() +enddef + + +" return types + +def Foo(): void +enddef + +def Foo(): void # comment +enddef + +def Foo(): list<dict<number>> +enddef + +def Foo(): func(dict<list<number>>, func, bool, func(number, list<number>)): bool +enddef + + +" :enddef trailing + +def Foo() + # trailing whitespace +enddef + +def Foo() +enddef | echo "Foo" + +def Foo() +enddef " comment + + +" parameters + +def Foo(x: bool, y = 42, z: string = "zed") +enddef + +def Foo( + x: bool, + y = 42, + z: string = "zed") +enddef + + +" comments + +def Foo() + # Vim9-script comment + "useless string" +enddef + diff --git a/runtime/syntax/testdir/input/vim_ex_echo.vim b/runtime/syntax/testdir/input/vim_ex_echo.vim new file mode 100644 index 0000000..df2bf5c --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_echo.vim @@ -0,0 +1,38 @@ +" Vim :echo commands + +echo "Answer = " 42 +echon "Answer = " 42 +echomsg "Answer = " 42 +echowindow "Answer = " 42 +echoerr "Answer = " 42 +echoconsole "Answer = " 42 + +echo "following command is :|" | | + +echohl WarningMsg | echo "Don't panic!" | echohl None + +echo "Answer = " + "\ comment + \ 42 + +echo + \ "Answer = " + "\ comment + \ 42 + +" :echo without {expr} +echo| echo "Foo" + +" trailing comment needs | +echo "foo" | " comment + + +" Issue #9987 (parenthesised argument - not a function call) + +let foo = {'end': 123} + +if 123 + echo (foo.end) +else + echo 'bar' +endif diff --git a/runtime/syntax/testdir/input/vim_ex_execute.vim b/runtime/syntax/testdir/input/vim_ex_execute.vim new file mode 100644 index 0000000..2ec507e --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_execute.vim @@ -0,0 +1,41 @@ +" Vim :execute command + +" :help :execute + +execute "buffer" nextbuf +execute "normal" count .. "w" +execute '!ls' | echo "theend" +execute "normal ixxx\<Esc>" +execute "e " .. fnameescape(filename) +execute "!ls " .. shellescape(filename, 1) +if 0 + execute 'while i > 5' + echo "test" + endwhile +endif +execute 'while i < 5 | echo i | let i = i + 1 | endwhile' + +" following command is :|" +execute "call Foo()" | | + +execute "call" + "\ comment + \ "Foo()" + +execute + \ "call" + "\ comment + \ "Foo()" + +" :execute without {expr} +execute| echo "Foo" + +" trailing comment needs | +execute "foo" | " comment + + +" Issue #9987 (parenthesised argument - not a function call) + +" FIXME: execute is ex command not builtin function +let foo = {'arg': "call Foo()"} +execute (foo.arg) diff --git a/runtime/syntax/testdir/input/vim_ex_function.vim b/runtime/syntax/testdir/input/vim_ex_function.vim new file mode 100644 index 0000000..38213b4 --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_function.vim @@ -0,0 +1,182 @@ +" Vim :function command + + +" list + +function +function Foo +function /Foo.* + +function | echo "Foo" +function " comment +function Foo | echo "Foo" +function Foo " comment + + +" definition + +" empty definition +function Foo() +endfunction + +" curly-brace names +function {"F"}oo() +endfunction + +function F{"o"}o() +endfunction + +function Fo{"o"}() +endfunction + +function {"F"}o{"o"}() +endfunction + +function {"F"}{"o"}{"o"}() +endfunction + +function Foo() + return 42 +endfunction + +" trailing whitespace +function Foo() + return 42 +endfunction + +function Foo() " comment + return 42 +endfunction + +function! Foo() + return 42 +endfunction + +function g:Foo() + return 42 +endfunction + +function s:Foo() + return 42 +endfunction + +function <SID>Foo() + return 42 +endfunction + +function foo#bar#Foo() + return 42 +endfunction + +" same name as an Ex command +function s:ls() +endfunction + + +" modifiers + +function Foo() range +endfunction + +function Foo() range " comment +endfunction + +function Foo() range + return 42 +endfunction + +function Foo() abort + return 42 +endfunction + +function Foo() dict + return 42 +endfunction + +function Foo() closure + return 42 +endfunction + +function Foo() range abort dict closure + return 42 +endfunction + +function! Foo() range + return 42 +endfunction + +function! Foo() abort + return 42 +endfunction + +function! Foo() dict + return 42 +endfunction + +function! Foo() closure + return 42 +endfunction + +function! Foo() range abort dict closure + return 42 +endfunction + + +" :endfunction trailing + +function Foo() + return 42 + " trailing whitespace +endfunction + +function Foo() + return 42 +endfunction | echo "Foo" + +function Foo() + return 42 +endfunction " comment + + +" parameters + +function Foo(x, y, z, ...) + return 42 +endfunction + +function Foo( + \ x, + \ y, + \ z, + \ ...) + return 42 +endfunction + +function Foo(x, y = 42, z = "zed") + return 42 +endfunction + +function Foo( + \ x, + \ y = 42, + \ z = "zed") + return 42 +endfunction + + +" comments + +function Foo() + " Legacy-script comment + # 42 " comment + return 42 +endfunction + + +" delete function + +delfunction Foo +delfunction foo.bar +delfunction! Foo +delfunction foo.bar + diff --git a/runtime/syntax/testdir/input/vim_ex_function_fold.vim b/runtime/syntax/testdir/input/vim_ex_function_fold.vim new file mode 100644 index 0000000..f9d9bee --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_function_fold.vim @@ -0,0 +1,183 @@ +" Vim :function command +" VIM_TEST_SETUP let g:vimsyn_folding = "f" | set fdm=syntax + + +" list + +function +function Foo +function /Foo.* + +function | echo "Foo" +function " comment +function Foo | echo "Foo" +function Foo " comment + + +" definition + +" empty definition +function Foo() +endfunction + +" curly-brace names +function {"F"}oo() +endfunction + +function F{"o"}o() +endfunction + +function Fo{"o"}() +endfunction + +function {"F"}o{"o"}() +endfunction + +function {"F"}{"o"}{"o"}() +endfunction + +function Foo() + return 42 +endfunction + +" trailing whitespace +function Foo() + return 42 +endfunction + +function Foo() " comment + return 42 +endfunction + +function! Foo() + return 42 +endfunction + +function g:Foo() + return 42 +endfunction + +function s:Foo() + return 42 +endfunction + +function <SID>Foo() + return 42 +endfunction + +function foo#bar#Foo() + return 42 +endfunction + +" same name as an Ex command +function s:ls() +endfunction + + +" modifiers + +function Foo() range +endfunction + +function Foo() range " comment +endfunction + +function Foo() range + return 42 +endfunction + +function Foo() abort + return 42 +endfunction + +function Foo() dict + return 42 +endfunction + +function Foo() closure + return 42 +endfunction + +function Foo() range abort dict closure + return 42 +endfunction + +function! Foo() range + return 42 +endfunction + +function! Foo() abort + return 42 +endfunction + +function! Foo() dict + return 42 +endfunction + +function! Foo() closure + return 42 +endfunction + +function! Foo() range abort dict closure + return 42 +endfunction + + +" :endfunction trailing + +function Foo() + return 42 + " trailing whitespace +endfunction + +function Foo() + return 42 +endfunction | echo "Foo" + +function Foo() + return 42 +endfunction " comment + + +" parameters + +function Foo(x, y, z, ...) + return 42 +endfunction + +function Foo( + \ x, + \ y, + \ z, + \ ...) + return 42 +endfunction + +function Foo(x, y = 42, z = "zed") + return 42 +endfunction + +function Foo( + \ x, + \ y = 42, + \ z = "zed") + return 42 +endfunction + + +" comments + +function Foo() + " Legacy-script comment + # 42 " comment + return 42 +endfunction + + +" delete function + +delfunction Foo +delfunction foo.bar +delfunction! Foo +delfunction foo.bar + diff --git a/runtime/syntax/testdir/input/vim_ex_highlight.vim b/runtime/syntax/testdir/input/vim_ex_highlight.vim new file mode 100644 index 0000000..e23968a --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_highlight.vim @@ -0,0 +1,55 @@ +" Vim :highlight command + +" list +highlight +highlight Comment + +" reset +highlight clear + +" disable +highlight clear Comment +highlight Comment NONE + +" add/modify +highlight Comment cterm=underline +highlight default Comment term=bold + +" link +highlight link Foo Comment +highlight! link Foo Comment +highlight link Foo NONE +highlight! link Foo NONE + +" default link +highlight default link Foo Comment +highlight! default link Foo Comment +highlight default link Foo NONE +highlight! default link Foo NONE + + +" line continuation and command separator + +hi Comment + "\ comment + \ term=bold + "\ comment + \ ctermfg=Cyan + \ guifg=#80a0ff + \ gui=bold + +hi Comment + \ term=bold + \ ctermfg=Cyan + \ guifg=#80a0ff + \ gui=bold | echo "Foo" + +hi Comment term=bold ctermfg=Cyan guifg=#80a0ff gui=bold | echo "Foo" + +hi default link + \ Foo + \ Comment + +hi default link + \ Foo + \ Comment | echo "Foo" diff --git a/runtime/syntax/testdir/input/vim_ex_map.vim b/runtime/syntax/testdir/input/vim_ex_map.vim new file mode 100644 index 0000000..95f4292 --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_map.vim @@ -0,0 +1,87 @@ +" Vim :map commands + +map! +map! lhs rhs +map +map lhs rhs + +call map(list, 'v:val') +call map (list, 'v:val') + +mapclear <buffer> +mapclear! <buffer> +nmapclear <buffer> +vmapclear <buffer> +xmapclear <buffer> +smapclear <buffer> +omapclear <buffer> +imapclear <buffer> +lmapclear <buffer> +cmapclear <buffer> +tmapclear <buffer> + + +" :help map-bar + +" <Bar> '<' is not in 'cpoptions' +map _l :!ls <Bar> more^M:echo "rhs"<CR> +" \| 'b' is not in 'cpoptions' +map _l :!ls \| more^M:echo "rhs"<CR> +" ^V| always, in Vim and Vi +map _l :!ls | more^M:echo "rhs"<CR> + +map lhs :search('foo\\|bar')<CR>:echo "rhs"<CR> + + +" multiline RHS + +map <leader>baz + \ :echo (<bar> + \ + \'bar')<cr> + "\ comment + +map lhs + "\ comment + \ echo "foo" + +map lhs + "\ comment + \ echo "foo" + +map lhs + "\ comment + \ echo "foo" + +map l hs + "\ comment + \ echo "foo" + +map l hs + "\ comment + \ echo "foo" + +map lhs rhs +map l h s rhs + +map lhs + "\ comment (matches as RHS but harmless) +echo "clear" + + +" Issue #12672 + +nnoremap <leader>foo :echo call( + "\ comment + \ {x->x}, + \ ['foo'])<cr> + +nnoremap <leader>bar :echo ( + \ + \ 'bar')<cr> + + +" Example: +" /autoload/netrw.vim + +if !hasmapto('<Plug>NetrwOpenFile') |nmap <buffer> <silent> <nowait> % <Plug>NetrwOpenFile|endif diff --git a/runtime/syntax/testdir/input/vim_ex_menu.vim b/runtime/syntax/testdir/input/vim_ex_menu.vim new file mode 100644 index 0000000..fb737c2 --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_menu.vim @@ -0,0 +1,87 @@ +" Vim :menu commands + +" :help disable menus +menu disable &File.&Open\.\.\. +amenu enable * +amenu disable &Tools.* + + +" :help menu-examples +nmenu Words.Add\ Var wb"zye:menu! Words.<C-R>z <C-R>z<CR> +nmenu Words.Remove\ Var wb"zye:unmenu! Words.<C-R>z<CR> +vmenu Words.Add\ Var "zy:menu! Words.<C-R>z <C-R>z <CR> +vmenu Words.Remove\ Var "zy:unmenu! Words.<C-R>z<CR> +imenu Words.Add\ Var <Esc>wb"zye:menu! Words.<C-R>z <C-R>z<CR>a +imenu Words.Remove\ Var <Esc>wb"zye:unmenu! Words.<C-R>z<CR>a + + +" special keys +menu <silent> &Foo\ bar :echo "Foobar"<CR> +menu <special> &Foo\ bar :echo "Foobar"<CR> +menu <script> &Foo\ bar :echo "Foobar"<CR> +menu <silent> <special> &Foo\ bar :echo "Foobar"<CR> +menu <silent> <special> <script> &Foo\ bar :echo "Foobar"<CR> + + +function Foo() + menu <silent> &Foo\ bar :echo "Foobar"<CR> +endfunction + + +" Example: runtime/menu.vim (modified) +an <silent> 10.330 &File.&Close<Tab>:close :confirm close<CR> + +an <silent> 10.330 &File.&Close<Tab>:close + \ :if winheight(2) < 0 && tabpagewinnr(2) == 0 <Bar> + \ confirm enew <Bar> + \ else <Bar> + \ confirm close <Bar> + \ endif<CR> + +an <silent> 10.330 &File.&Close<Tab>:close + "\ comment + \ :if winheight(2) < 0 && tabpagewinnr(2) == 0 <Bar> + "\ comment + \ confirm enew <Bar> + "\ comment + \ else <Bar> + "\ comment + \ confirm close <Bar> + "\ comment + \ endif<CR> + +an <silent> 10.330 &File.&Close<Tab>:close :if winheight(2) < 0 && tabpagewinnr(2) == 0 <Bar> + \ confirm enew <Bar> + \ else <Bar> + \ confirm close <Bar> + \ endif<CR> + +an <silent> 10.330 &File.&Close<Tab>:close :if winheight(2) < 0 && tabpagewinnr(2) == 0 <Bar> + "\ comment + \ confirm enew <Bar> + "\ comment + \ else <Bar> + "\ comment + \ confirm close <Bar> + "\ comment + \ endif<CR> + + +" popup menus +popup &Foo | echo "Foo" +popup! &Foo | echo "Foo" + + +" Issue #14230 + +" a menu item name cannot start with '.' + +export def HistoryJumpMenu() + popup.FilterMenu("Jump history", dir_hist, + (res, _) => { + HistoryJump(res.text) + }) +enddef + +popup\.FilterMenu<Tab>Filter()<CR> + diff --git a/runtime/syntax/testdir/input/vim_ex_menutranslate.vim b/runtime/syntax/testdir/input/vim_ex_menutranslate.vim new file mode 100644 index 0000000..5e0289d --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_menutranslate.vim @@ -0,0 +1,51 @@ +" Vim :menutranslate command + +menutranslate clear +menutranslate clear | echo "Foo" +menutranslate clear " comment + +menutranslate &Foo\ bar &FuBar | echo "Foo" + +menutranslate &Foo\ bar &FuBar " comment +menutranslate \"&Foo"\ bar \"&FuBar +menutranslate &Foo\ "bar" &FuBar + +menutranslate &Foo\ bar + \ &Fubar | echo "Foo" + +menutranslate + \ &Foo\ bar + \ &Fubar | echo "Foo" + +menutranslate + \ &Foo\ bar + \ &Fubar| echo "Foo" + +menutranslate + \ &Foo\ bar + \ &Fubar + \ | echo "Foo" + +menutranslate &Foo\ bar + "\ comment + \ &Fubar | echo "Foo" + +menutranslate + "\ comment + \ &Foo\ bar + "\ comment + \ &Fubar | echo "Foo" + +menutranslate + \ &Foo\ bar + "\ comment + \ &Fubar| echo "Foo" + "\ comment + +menutranslate + "\ comment + \ &Foo\ bar + "\ comment + \ &Fubar + \ | echo "Foo" + diff --git a/runtime/syntax/testdir/input/vim_ex_substitute.vim b/runtime/syntax/testdir/input/vim_ex_substitute.vim new file mode 100644 index 0000000..340d573 --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_substitute.vim @@ -0,0 +1,86 @@ +substitute/foo/bar/& +substitute/foo/bar/cegiInp#lr + +snomagic/foo/bar/& +snomagic/foo/bar/cegiInp#lr + +smagic/foo/bar/& +smagic/foo/bar/cegiInp#lr + +:substitute/foo/bar/& +:substitute/foo/bar/cegiInp#lr + +:snomagic/foo/bar/& +:snomagic/foo/bar/cegiInp#lr + +:smagic/foo/bar/& +:smagic/foo/bar/cegiInp#lr + +call Foo() | substitute/foo/bar/& +call Foo() | substitute/foo/bar/cegiInp#lr + +call Foo() | snomagic/foo/bar/& +call Foo() | snomagic/foo/bar/cegiInp#lr + +call Foo() | smagic/foo/bar/& +call Foo() | smagic/foo/bar/cegiInp#lr + +let foo = str->substitute(str, pat, sub, flags) + +function Foo() + substitute/foo/bar/ + let bar = str->substitute(str, pat, sub, flags) +endfunction + +def Foo() + substitute/foo/bar/ + let bar = str->substitute(str, pat, sub, flags) +enddef + +" various delimiters + +s!/!//! " comment +" s"/"//" " comment (works but disallowed) +s#/#//# " comment +s$/$//$ " comment +s%/%//% " comment +s&/&//& " comment +s'/'//' " comment +" FIXME - matches vimUserFunc +" s(/(//( " comment +s)/)//) " comment +s*/*//* " comment +s+/+//+ " comment +s,/,//, " comment +s-/-//- " comment +s././/. " comment +s/X/XX/ " comment +s:/://: " comment +s;/;//; " comment +s</<//< " comment +s=/=//= " comment +s>/>//> " comment +s?/?//? " comment +s@/@//@ " comment +s[/[//[ " comment +" s\/\//\ " comment (disallowed) +s]/]//] " comment +s^/^//^ " comment +s_/_//_ " comment +s`/`//` " comment +s{/{//{ " comment +" s|/|//| " comment (disallowed) +s}/}//} " comment +s~/~//~ " comment + + +" Issue #13883 + +str[s] +str(s) + +def Test() + str[s] + str(s) +enddef + diff --git a/runtime/syntax/testdir/input/vim_ex_syntax.vim b/runtime/syntax/testdir/input/vim_ex_syntax.vim new file mode 100644 index 0000000..79437ff --- /dev/null +++ b/runtime/syntax/testdir/input/vim_ex_syntax.vim @@ -0,0 +1,177 @@ +" Vim :syntax command + +syn match testMatch "pattern" contained " tail comment +" NOTE: comments not currently supported +syn keyword testKeyword keyword contained " tail comment +syn region testRegion start="start-pattern" skip="skip-pattern" end="end-pattern" contained " tail comment + +" Multiline commands + +syn keyword testKeyword + "\ OPTIONS + "\ conceal option + \ conceal + "\ cchar option + \ cchar=& + "\ contained option + \ contained + "\ containedin option + \ containedin=testContainer + "\ nextgroup option + \ nextgroup=testNext0,@testCluster + "\ transparent option + \ transparent + "\ skipwhite option + \ skipwhite + "\ skipempty option + \ skipempty + "\ skipnl option + \ skipnl + "\ KEYWORDS LIST + "\ keyword 1 + \ keyword1 + "\ keyword 2 + \ keyword2 + "\ keyword 3 + \ keyword3 + +syn match testMatch + "\ MATCH PATTERN + "\ pattern start + \ / + "\ part 1 description + \pat1a .* pat1b + "\ part 2 description + \pat2a .* pat2b + "\ part 3 description + \pat3a .* pat3b + "\ pattern end + \/ + "\ OPTIONS + "\ conceal option + \ conceal + "\ cchar option + \ cchar=& + "\ contained option + \ contained + "\ containedin option + \ containedin=testContainer + "\ nextgroup option + \ nextgroup=testNext0,@testCluster + "\ transparent option + \ transparent + "\ skipwhite option + \ skipwhite + "\ skipempty option + \ skipempty + "\ skipnl option + \ skipnl + "\ contains option + \ contains=testContained1,testContained2 + "\ fold option + \ fold + "\ display option + \ display + "\ extend option + \ extend + "\ excludenl option + \ excludenl + "\ keepend option + \ keepend + +syn region testRegion + "\ OPTIONS + "\ start option + \ start="start-pattern" + "\ skip option + \ skip="skip-pattern" + "\ end option + \ end="end-pattern" + "\ conceal option + \ conceal + "\ cchar option + \ cchar=& + "\ contained option + \ contained + "\ containedin option + \ containedin=testContainer + "\ nextgroup option + \ nextgroup=testNext0,@testCluster + "\ transparent option + \ transparent + "\ skipwhite option + \ skipwhite + "\ skipempty option + \ skipempty + "\ skipnl option + \ skipnl + "\ contains option + \ contains=testContained1,testContained2 + "\ oneline option + \ oneline + "\ fold option + \ fold + "\ display option + \ display + "\ extend option + \ extend + "\ concealends option + \ concealends + "\ excludenl option + \ excludenl + "\ keepend option + \ keepend + +syn cluster testCluster + "\ OPTIONS + "\ contains option + \ contains=testContained1,testContained2,testContained3 + +syn cluster testCluster + "\ OPTIONS + "\ add option + \ add=testAdd + "\ remove option + \ remove=testRemove + + +" multiline group list + +syn keyword testNext0 keyword +syn keyword testNext1 keyword +syn keyword testNext2 keyword +syn keyword testNext3 keyword +syn keyword testNext4 keyword +syn keyword testNext5 keyword +syn keyword testNext6 keyword +syn keyword testNext7 keyword +syn keyword testNext8 keyword +syn keyword testNext9 keyword + +syn keyword testKeyword + "\ nextgroup option + \ nextgroup= + "\ a comment + \ testNext0 , testNext1 , + "\ a comment + \ testNext[2-8].* , + "\ a comment + \ testNext9 , @testCluster skipwhite + "\ KEYWORDS LIST + \ keyword4 + \ keyword5 + \ keyword6 + + +" leaking contained groups + +" Example: runtime/syntax/zsh.vim +" "cluster" should not be highlighted outside of :syntax commands + +function! s:ContainedGroup() + " ... + for cluster in ['markdownHighlight_zsh', 'zsh'] + " ... + endfor + " ... +endfunction diff --git a/runtime/syntax/testdir/input/vim_expr.vim b/runtime/syntax/testdir/input/vim_expr.vim new file mode 100644 index 0000000..cf5838c --- /dev/null +++ b/runtime/syntax/testdir/input/vim_expr.vim @@ -0,0 +1,71 @@ +" String + +echo 'It''s a string' +echo 'tab: \t, new line: \n, backslash: \\' +echo "tab: \t, new line: \n, backslash: \\" + +" String escape sequences + +echo "\316 - \31 - \3 - \x1f - \xf - \X1F - \XF - \u02a4 - \U000002a4 - \b - \e - \f - \n - \r - \t - \\ - \" - \<C-W>" +echo '\316 \31 \3 \x1f \xf \X1F \XF \u02a4 \U000002a4 \b \e \f \n \r \t \\ \" \<C-W>' +echo "\3160 - \x1f0 - \X1F0 - \u02a40 - \U000002a40" + +echo $"\316 - \31 - \3 - \x1f - \xf - \X1F - \XF - \u02a4 - \U000002a4 - \b - \e - \f - \n - \r - \t - \\ - \" - \<C-W>" +echo $'\316 \31 \3 \x1f \xf \X1F \XF \u02a4 \U000002a4 \b \e \f \n \r \t \\ \" \<C-W>' +echo $"\3160 - \x1f0 - \X1F0 - \u02a40 - \U000002a40" + +echo "\<C-a>" +echo "\<*C-a>" +echo "\<C->>" +echo "\<*C->>" +echo "\<C->>>" +echo "\<*C->>>" + +" String interpolation + +echo 'Don''t highlight interpolation: {{ {1 + 2} }}' +echo "Don't highlight interpolation: {{ {1 + 2} }}" +echo $'Highlight interpolation:\t{{ { string({'foo': 'bar'}) } }}' +echo $'Highlight interpolation:\t{{ { $'nested: {{ {1 + 2} }}' } }}' +echo $"Highlight interpolation:\t{{ { string({"foo": "bar"}) } }}" +echo $"Highlight interpolation:\t{{ { $"nested: {{ {1 + 2} }}" } }}" + +" Number + +" Hexadecimal +echo 0xFF +echo 0XFF +echo -0xFF +echo -0XFF + +" Decimal +echo 255 +echo -255 + +" Octal +echo 0377 +echo 0o377 +echo 0O377 +echo -0377 +echo -0o377 +echo -0O377 + +" Binary +echo 0b11111111 +echo 0B11111111 +echo -0b11111111 +echo -0B11111111 + +" Float +123.456 ++0.0001 +55.0 +-0.123 +1.234e03 +1.0E-6 +-3.1416e+88 + +" Blob +echo 0zFF00ED015DAF +echo 0zFF00.ED01.5DAF +echo 0zFF.00.ED.01.5D.AF diff --git a/runtime/syntax/testdir/input/vim_key_notation.vim b/runtime/syntax/testdir/input/vim_key_notation.vim new file mode 100644 index 0000000..8bc128a --- /dev/null +++ b/runtime/syntax/testdir/input/vim_key_notation.vim @@ -0,0 +1,163 @@ +" Key notation + +<Space> +<Tab> +<Tab> +<NL> +<NewLine> +<LineFeed> +<LF> +<CR> +<Return> +<Enter> +<BS> +<BackSpace> +<Esc> +<CSI> +<xCSI> +<Bar> +<Bslash> +<Del> +<Delete> +<kDel> +<Up> +<Down> +<Left> +<Right> +<xUp> +<xDown> +<xLeft> +<xRight> +<PasteStart> +<PasteEnd> +<F1> +<F2> +<F3> +<F4> +<F5> +<F6> +<F7> +<F8> +<F9> +<F10> +<F11> +<F12> +<F13> +<F14> +<F15> +<F16> +<F17> +<F18> +<F19> +<F20> +<F21> +<F22> +<F23> +<F24> +<F25> +<F26> +<F27> +<F28> +<F29> +<F30> +<F31> +<F32> +<F33> +<F34> +<F35> +<F36> +<F37> +<xF1> +<xF2> +<xF3> +<xF4> +<Help> +<Undo> +<Insert> +<Ins> +<kInsert> +<Home> +<kHome> +<xHome> +<zHome> +<End> +<kEnd> +<xEnd> +<zEnd> +<PageUp> +<PageDown> +<kPageUp> +<kPageDown> +<kPlus> +<kMinus> +<kDivide> +<kMultiply> +<kEnter> +<kPoint> +<k0> +<k1> +<k2> +<k3> +<k4> +<k5> +<k6> +<k7> +<k8> +<k9> +<lt> +<Mouse> +<NetMouse> +<DecMouse> +<JsbMouse> +<PtermMouse> +<UrxvtMouse> +<SgrMouse> +<SgrMouseRelease> +<LeftMouse> +<LeftMouseNM> +<LeftDrag> +<LeftRelease> +<LeftReleaseNM> +<MouseMove> +<MiddleMouse> +<MiddleDrag> +<MiddleRelease> +<RightMouse> +<RightDrag> +<RightRelease> +<ScrollWheelUp> +<ScrollWheelDown> +<ScrollWheelRight> +<ScrollWheelLeft> +<MouseDown> +<MouseUp> +<X1Mouse> +<X1Drag> +<X1Release> +<X2Mouse> +<X2Drag> +<X2Release> +<Drop> +<Nul> +<SNR> +<Plug> +<CursorHold> +<Ignore> +<Cmd> +<ScriptCmd> +<FocusGained> +<FocusLost> + +<cword> +<cWORD> +<cexpr> +<cfile> +<afile> +<abuf> +<amatch> +<sfile> +<stack> +<script> +<slnum> +<sflnum> +<client> diff --git a/runtime/syntax/testdir/input/vim_line_continuation.vim b/runtime/syntax/testdir/input/vim_line_continuation.vim new file mode 100644 index 0000000..a32666a --- /dev/null +++ b/runtime/syntax/testdir/input/vim_line_continuation.vim @@ -0,0 +1,49 @@ +" Vim line continuations with interspersed comments + +function Foo( + "\ param a + \ a, + "\ param b + \ b, + "\ param c + \ c + \) + echomsg + "\ start string + \ $" + "\ print a + \ a = {a:a}, + "\ print b + \ b = {a:b}, + "\ print c + \ c = {a:c} + "\ end string + \" +endfunction + +call Foo( + "\ arg 1 + \ 11, + "\ arg 2 + \ 22, + "\ arg 3 + \ 33 + \) + +let dict = #{ + "\ pair 1 + \ a: 1, + "\ pair 2 + \ b: 2, + "\ pair 3 + \ c: 3 + \} + +let array = [ + "\ element 1 + \ 1, + "\ element 2 + \ 2, + "\ element 3 + \ 3 + \] diff --git a/runtime/syntax/testdir/input/vim_new.vim b/runtime/syntax/testdir/input/vim_new.vim new file mode 100644 index 0000000..985cfd3 --- /dev/null +++ b/runtime/syntax/testdir/input/vim_new.vim @@ -0,0 +1,17 @@ +vim9script + +# Vim :new command and class constructors. +class Test + def new() + enddef + def newOther() + enddef + def newyetanother() + enddef +endclass + +Test.new() +Test.newOther() +Test.newyetanother() +new +quit diff --git a/runtime/syntax/testdir/input/vim_syntax.vim b/runtime/syntax/testdir/input/vim_syntax.vim deleted file mode 100644 index e8c112c..0000000 --- a/runtime/syntax/testdir/input/vim_syntax.vim +++ /dev/null @@ -1,75 +0,0 @@ -" Vim :syntax highlighting - -syn keyword testKeyword - \ conceal - \ cchar=& - \ contained - \ containedin=testContainer - \ nextgroup=testNext,@testCluster - \ transparent - \ skipwhite - \ skipempty - \ skipnl - \ keyword1 - \ keyword2 - \ keyword3 - -syn match testMatch - \ "pattern" - \ conceal - \ cchar=& - \ contained - \ containedin=testContainer - \ nextgroup=testNext,@testCluster - \ transparent - \ skipwhite - \ skipempty - \ skipnl - \ contains=testContained1,testContained2 - \ fold - \ display - \ extend - \ excludenl - \ keepend - -syn region testRegion - \ start="start-pattern" - \ end="end-pattern" - \ skip="skip-pattern" - \ contained - \ conceal - \ cchar=& - \ contained - \ containedin=testContainer - \ nextgroup=testNext,@testCluster - \ transparent - \ skipwhite - \ skipempty - \ skipnl - \ contains=testContained1,testContained2 - \ oneline - \ fold - \ display - \ extend - \ concealends - \ excludenl - \ keepend - -syn cluster testCluster - \ contains=testContained1,testContained2,testContained3 - -syn cluster testCluster - \ add=testAdd - \ remove=testRemove - - -" check multiline group list -syn keyword testKeyword - \ nextgroup= - \ testNext , - \ testNext2 , - \ @testCluster - \ skipwhite - \ keyword4 - \ keyword5 - \ keyword6 |