mirror of
https://github.com/FuelLabs/sway.git
synced 2025-08-08 12:48:36 +00:00
Update syntax highlighting (#426)
* Update highlighted data types * Update keywords * Add highlight.js bundled file * Fix types Co-authored-by: Alexandru Matei <alexandrumatei3693@gmail.com>
This commit is contained in:
parent
e4677959f8
commit
e8f381592d
2 changed files with 333 additions and 325 deletions
|
@ -22,17 +22,21 @@ export default function(hljs) {
|
|||
const NUMBER_SUFFIX = '([u](8|16|32|64))\?';
|
||||
|
||||
const KEYWORDS = [
|
||||
"abi",
|
||||
"as",
|
||||
"asm",
|
||||
"const",
|
||||
"contract",
|
||||
"deref",
|
||||
"enum",
|
||||
"fn",
|
||||
"if",
|
||||
"impl",
|
||||
"let",
|
||||
"library",
|
||||
"match",
|
||||
"mut",
|
||||
"else",
|
||||
"predicate",
|
||||
"ref",
|
||||
"return",
|
||||
|
@ -54,20 +58,16 @@ export default function(hljs) {
|
|||
|
||||
];
|
||||
const TYPES = [
|
||||
"u8",
|
||||
"u16",
|
||||
"u32",
|
||||
"u64",
|
||||
"bool", "char", "u8", "u16", "u32", "u64", "b256", "str", "Self"
|
||||
];
|
||||
return {
|
||||
name: 'Sway',
|
||||
aliases: [ 'sw' ],
|
||||
keywords: {
|
||||
$pattern: hljs.IDENT_RE + '!?',
|
||||
type: TYPES,
|
||||
keyword: KEYWORDS,
|
||||
literal: LITERALS,
|
||||
built_in: BUILTINS
|
||||
built_in: TYPES
|
||||
},
|
||||
illegal: '</',
|
||||
contains: [
|
||||
|
@ -126,7 +126,7 @@ export default function(hljs) {
|
|||
},
|
||||
{
|
||||
begin: [
|
||||
/let/, /\s+/,
|
||||
/(let|const)/, /\s+/,
|
||||
/(?:mut\s+)?/,
|
||||
hljs.UNDERSCORE_IDENT_RE
|
||||
],
|
||||
|
@ -149,7 +149,7 @@ export default function(hljs) {
|
|||
},
|
||||
{
|
||||
begin: [
|
||||
/(?:trait|enum|struct|impl|for|library)/,
|
||||
/(?:trait|enum|struct|impl|for|library|abi)/,
|
||||
/\s+/,
|
||||
hljs.UNDERSCORE_IDENT_RE
|
||||
],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue