From 8fea4467a4386c2682223e88cb539ec67aae599c Mon Sep 17 00:00:00 2001 From: Luca BRUNO Date: Sun, 20 Oct 2024 14:47:10 +0200 Subject: [PATCH] editor-plugins: add hashbang line highlighting This adds supports for highlighting an hashbang line as a comment, in vscode and in highlight.js. --- CHANGELOG.md | 3 +++ editor-plugins/highlight.js/quint.js | 1 + vscode/quint-vscode/syntaxes/quint.tmLanguage.json | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f25242d96..675c1f1bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated ### Removed ### Fixed + +- Hashbang lines are now properly highlighted as comments in vscode and in highlight.js. + ### Security ## v0.22.2 -- 2024-10-08 diff --git a/editor-plugins/highlight.js/quint.js b/editor-plugins/highlight.js/quint.js index 9a28ba8e6..9bd66dd02 100644 --- a/editor-plugins/highlight.js/quint.js +++ b/editor-plugins/highlight.js/quint.js @@ -38,6 +38,7 @@ function quintHljs(hljs) { scope: 'number', begin: '-?(0x[0-9a-fA-F]([0-9a-fA-F]|_[0-9a-fA-F])*|0|[1-9]([0-9]|_[0-9])*)', }, + hljs.SHEBANG, // file-leading hashbang hljs.C_LINE_COMMENT_MODE, // single line comments hljs.C_BLOCK_COMMENT_MODE, // multiline comments ], diff --git a/vscode/quint-vscode/syntaxes/quint.tmLanguage.json b/vscode/quint-vscode/syntaxes/quint.tmLanguage.json index b8502598d..c010eb56e 100644 --- a/vscode/quint-vscode/syntaxes/quint.tmLanguage.json +++ b/vscode/quint-vscode/syntaxes/quint.tmLanguage.json @@ -2,6 +2,9 @@ "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", "name": "Quint", "patterns": [ + { + "include": "#hashbangLine" + }, { "include": "#lineComments" }, @@ -92,6 +95,14 @@ } ] }, + "hashbangLine": { + "patterns": [ + { + "name": "comment.line.hashbang.quint", + "match": "^#!.*$" + } + ] + }, "lineComments": { "patterns": [ {