From a25ef2bd6de5d5688dd99a231719193f798755c1 Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Sat, 1 May 2021 00:35:56 -0400 Subject: [PATCH] fix rust pub highlight --- rc/filetype/rust.kak | 3 ++- test/highlight/rust/pub/cmd | 1 + test/highlight/rust/pub/in | 17 +++++++++++++++++ test/highlight/rust/pub/rc | 3 +++ test/highlight/rust/pub/script | 7 +++++++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 test/highlight/rust/pub/cmd create mode 100644 test/highlight/rust/pub/in create mode 100644 test/highlight/rust/pub/rc create mode 100644 test/highlight/rust/pub/script diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index 5b0c0261..a388f8de 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -82,8 +82,9 @@ add-highlighter shared/rust/code/question_mark regex \? 0:meta add-highlighter shared/rust/code/function_call regex _?[a-zA-Z]\w*\s*(?=\() 0:function add-highlighter shared/rust/code/generic_function_call regex _?[a-zA-Z]\w*\s*(?=::<) 0:function add-highlighter shared/rust/code/function_declaration regex (?:fn\h+)(_?\w+)(?:<[^>]+?>)?\( 1:function -add-highlighter shared/rust/code/keywords regex \b(?:let|as|fn|return|match|if|else|loop|for|in|while|break|continue|box|where|impl|dyn|unsafe|async|await|mod|crate|use|extern|trait|struct|enum|union|type|default)\b 0:keyword +add-highlighter shared/rust/code/keywords regex \b(?:as|break|continue|crate|else|enum|extern|false|fn|for|if|impl|in|let|loop|match|mod|pub|return|self|Self|struct|super|trait|true|type|unsafe|use|where|while|async|await|dyn|abstract|become|box|do|try)\b 0:keyword add-highlighter shared/rust/code/storage regex \b(move|mut|ref|static|const)\b 0:type +add-highlighter shared/rust/code/pub_with_scope regex \b(pub)\h*(\()\h*(crate|super|self|in\h+[\w:]+)\h*(\)) 1:keyword 2:meta 4:meta # after let can be an arbitrary pattern match add-highlighter shared/rust/code/macro regex \b\w+! 0:meta # the number literals syntax is defined here: diff --git a/test/highlight/rust/pub/cmd b/test/highlight/rust/pub/cmd new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/highlight/rust/pub/cmd @@ -0,0 +1 @@ + diff --git a/test/highlight/rust/pub/in b/test/highlight/rust/pub/in new file mode 100644 index 00000000..6eb12235 --- /dev/null +++ b/test/highlight/rust/pub/in @@ -0,0 +1,17 @@ +// bare +pub + +// with scope +pub(crate) +pub (crate) +pub(super) +pub(self) +pub(in ::foo) +pub(in foo) +pub(in foo::bar) +pub(in foo::bar::baz) + +// not valid pub expression, parens not colored +pub(crat) +pub(in) +spub(crate) diff --git a/test/highlight/rust/pub/rc b/test/highlight/rust/pub/rc new file mode 100644 index 00000000..64064c25 --- /dev/null +++ b/test/highlight/rust/pub/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/rust.kak" +set buffer filetype rust diff --git a/test/highlight/rust/pub/script b/test/highlight/rust/pub/script new file mode 100644 index 00000000..c29604d0 --- /dev/null +++ b/test/highlight/rust/pub/script @@ -0,0 +1,7 @@ +ui_out '{ "jsonrpc": "2.0", "method": "set_ui_options", "params": [{}] }' +ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "attributes": ["final_fg","final_bg"] }, "contents": "/" }, { "face": { "fg": "cyan", "bg": "default", "attributes": [] }, "contents": "/ bare" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "pub" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "cyan", "bg": "default", "attributes": [] }, "contents": "// with scope" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "pub" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "(" }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "crate" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": ")" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "pub" }, { "face": { "fg": "cyan", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "(" }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "crate" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": ")" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "pub" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "(" }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "super" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": ")" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "pub" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "(" }, { "face": { "fg": "red", "bg": "default", "attributes": [] }, "contents": "self" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": ")" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "pub" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "(" }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "in" }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "::" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "foo" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": ")" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "pub" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "(" }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "in" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " foo" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": ")" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "pub" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "(" }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "in" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "foo" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "::" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "bar" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": ")" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "pub" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "(" }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "in" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "foo" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "::" }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "bar" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": "::" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "baz" }, { "face": { "fg": "magenta", "bg": "default", "attributes": [] }, "contents": ")" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "cyan", "bg": "default", "attributes": [] }, "contents": "// not valid pub expression, parens not colored" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "pub" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "(crat)\u000a" }], [{ "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "pub" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "(" }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "in" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": ")\u000a" }], [{ "face": { "fg": "cyan", "bg": "default", "attributes": [] }, "contents": "spub" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "(" }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "crate" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": ")\u000a" }]], { "fg": "default", "bg": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "attributes": [] }] }' +ui_out '{ "jsonrpc": "2.0", "method": "menu_hide", "params": [] }' +ui_out '{ "jsonrpc": "2.0", "method": "info_hide", "params": [] }' +ui_out '{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "out 1:1 " }, { "face": { "fg": "black", "bg": "yellow", "attributes": [] }, "contents": "" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " - client0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "attributes": [] }] }' +ui_out '{ "jsonrpc": "2.0", "method": "set_cursor", "params": ["buffer", { "line": 0, "column": 0 }] }' +ui_out '{ "jsonrpc": "2.0", "method": "refresh", "params": [true] }'