From 44ffd2139ef21e44e449ea9800afc7b1584f8bd4 Mon Sep 17 00:00:00 2001 From: Denis Olshin Date: Sat, 28 Oct 2023 06:21:23 +0300 Subject: [PATCH 1/2] fixed not highlighting custom hex/oct/bin literals --- syntaxes/nim.json | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/syntaxes/nim.json b/syntaxes/nim.json index f638983..6dd642b 100644 --- a/syntaxes/nim.json +++ b/syntaxes/nim.json @@ -1478,6 +1478,18 @@ }, "custom_literal": { "patterns": [ + { + "match": "-?(\\b0[xX](\\h[_\\h]*)(\\.[_\\d]+)?')(?!((([iIuU](8|16|32|64))|[uU][^a-zA-Z0-9])|([fF](32|64|128)|[fFdD][^a-zA-Z0-9])))([a-zA-Z]\\w*)", + "name": "constant.numeric.custom.lit.hexadecimal.nim" + }, + { + "match": "-?(\\b0o([0-7][_0-7]*)(\\.[_\\d]+)?')(?!((([iIuU](8|16|32|64))|[uU][^a-zA-Z0-9])|([fF](32|64|128)|[fFdD][^a-zA-Z0-9])))([a-zA-Z]\\w*)", + "name": "constant.numeric.custom.lit.octal.nim" + }, + { + "match": "-?(\\b0(b|B)([01][_01]*)(\\.[_\\d]+)?')(?!((([iIuU](8|16|32|64))|[uU][^a-zA-Z0-9])|([fF](32|64|128)|[fFdD][^a-zA-Z0-9])))([a-zA-Z]\\w*)", + "name": "constant.numeric.custom.lit.binary.nim" + }, { "match": "-?(\\b(\\d[_\\d]*)(\\.[_\\d]+)?')(?!((([iIuU](8|16|32|64))|[uU][^a-zA-Z0-9])|([fF](32|64|128)|[fFdD][^a-zA-Z0-9])))([a-zA-Z]\\w*)", "name": "constant.numeric.custom.lit.nim" From 648f670ce7eaa2853a5a7486eb0bf3ca71a5cfbf Mon Sep 17 00:00:00 2001 From: Denis Olshin Date: Sat, 28 Oct 2023 06:22:53 +0300 Subject: [PATCH 2/2] fix triple quoted strings inside fmt function https://github.com/saem/vscode-nim/issues/122 --- syntaxes/nim.json | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/syntaxes/nim.json b/syntaxes/nim.json index 6dd642b..107c967 100644 --- a/syntaxes/nim.json +++ b/syntaxes/nim.json @@ -1173,6 +1173,9 @@ { "include": "#fmt_string" }, + { + "include": "#fmt_string_call_triple" + }, { "include": "#fmt_string_call" }, @@ -1337,6 +1340,40 @@ } ] }, + "fmt_string_call_triple": { + "begin": "(fmt)\\((?=\"\"\")", + "beginCaptures": { + "1": { + "name": "support.function.any-method.nim" + } + }, + "end": "\\)", + "patterns": [ + { + "begin": "\"\"\"", + "beginCaptures": { + "0": { + "name": "punctuation.definition.string.begin.nim" + } + }, + "end": "\"\"\"(?=\\))", + "endCaptures": { + "0": { + "name": "punctuation.definition.string.end.nim" + } + }, + "name": "string.quoted.triple.nim", + "patterns": [ + { + "include": "#string_escapes" + }, + { + "include": "#fmt_interpolation" + } + ] + } + ] + }, "string_quoted_double": { "begin": "\"", "beginCaptures": {