Fix rust character highlight

This commit is contained in:
Ivan Tham 2020-06-09 14:02:51 +08:00
parent 7bd459f774
commit 21c38f37cd
5 changed files with 16 additions and 1 deletions

View File

@ -67,7 +67,6 @@ add-highlighter shared/rust/macro_attributes/ default-region fill meta
add-highlighter shared/rust/macro_attributes/string region %{(?<!')"} (?<!\\)(\\\\)*" fill string add-highlighter shared/rust/macro_attributes/string region %{(?<!')"} (?<!\\)(\\\\)*" fill string
add-highlighter shared/rust/macro_attributes/raw_string region -match-capture %{(?<!')r(#*)"} %{"(#*)} fill string add-highlighter shared/rust/macro_attributes/raw_string region -match-capture %{(?<!')r(#*)"} %{"(#*)} fill string
add-highlighter shared/rust/code/byte_literal regex "'\\\\?.'" 0:value
add-highlighter shared/rust/code/long_quoted regex "('\w+)[^']" 1:meta add-highlighter shared/rust/code/long_quoted regex "('\w+)[^']" 1:meta
add-highlighter shared/rust/code/field_or_parameter regex (_?\w+)(?::)(?!:) 1:variable add-highlighter shared/rust/code/field_or_parameter regex (_?\w+)(?::)(?!:) 1:variable
add-highlighter shared/rust/code/namespace regex [a-zA-Z](\w+)?(\h+)?(?=::) 0:module add-highlighter shared/rust/code/namespace regex [a-zA-Z](\w+)?(\h+)?(?=::) 0:module
@ -84,6 +83,9 @@ add-highlighter shared/rust/code/attributes regex \b(?:trait|struct|enum|union|t
# the language keywords are defined here, but many of them are reserved and unused yet: # the language keywords are defined here, but many of them are reserved and unused yet:
# https://doc.rust-lang.org/reference/keywords.html # https://doc.rust-lang.org/reference/keywords.html
add-highlighter shared/rust/code/keywords regex \b(?:let|as|fn|return|match|if|else|loop|for|in|while|break|continue|move|box|where|impl|dyn|pub|unsafe|async|await|mod|crate|use|extern)\b 0:keyword add-highlighter shared/rust/code/keywords regex \b(?:let|as|fn|return|match|if|else|loop|for|in|while|break|continue|move|box|where|impl|dyn|pub|unsafe|async|await|mod|crate|use|extern)\b 0:keyword
add-highlighter shared/rust/code/char_character regex "'([^\\]|\\(.|x[0-9a-fA-F]{2}|u\{[0-9a-fA-F]{1,6}\}))'" 0:green
# TODO highlight error for unicode or single escape byte character
add-highlighter shared/rust/code/byte_character regex b'([\x00-\x5B\x5D-\x7F]|\\(.|x[0-9a-fA-F]{2}))' 0:yellow
add-highlighter shared/rust/code/builtin_types regex \b(?:u8|u16|u32|u64|u128|usize|i8|i16|i32|i64|i128|isize|f32|f64|bool|char|str|Self)\b 0:type add-highlighter shared/rust/code/builtin_types regex \b(?:u8|u16|u32|u64|u128|usize|i8|i16|i32|i64|i128|isize|f32|f64|bool|char|str|Self)\b 0:type
add-highlighter shared/rust/code/return regex \breturn\b 0:meta add-highlighter shared/rust/code/return regex \breturn\b 0:meta

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,2 @@
b'\' b'\x00' b'0' b'a' b' ' b'!' b'\n' b'一' b'\u{12}'
'\x00' '0' 'a' ' ' '!' '\n' '\u{12}' '一'

View File

@ -0,0 +1,3 @@
source "%val{runtime}/colors/default.kak"
source "%val{runtime}/rc/filetype/rust.kak"
set buffer filetype rust

View File

@ -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": "b" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "'\\' " }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": "b'\\x00'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": "b'0'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": "b'a'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": "b' '" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": "b'!'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": "b'\\n'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " b" }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "'一'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " b" }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "'\\u{12}'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }], [{ "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "'\\x00'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "'0'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "'a'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "' '" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "'!'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "'\\n'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "'\\u{12}'" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "'一'" }, { "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] }'