vscode: Fix syntax highlighting; bump to 0.1.1.

- Don't match "set" within e.g. "set-env".

- Fix the right-hand boundary of keywords such as "except".
This commit is contained in:
Qi Xiao 2022-06-12 01:22:19 +01:00
parent ae9e6d1565
commit 14ad776bf4
3 changed files with 29 additions and 3 deletions

View File

@ -34,7 +34,7 @@
"match": "\\$[\\w\\d_:~-]+" "match": "\\$[\\w\\d_:~-]+"
}, },
{ {
"match": "(?<=^|\\{ |\\{\t|\\(|\\||\\;)\\s*(var|set|tmp|del)((\\s+[\\w\\d_:~-]+)*)", "match": "(?<=^|\\{ |\\{\t|\\(|\\||\\;)\\s*(var|set|tmp|del)((\\s+[\\w\\d_:~-]+)+)",
"captures": { "captures": {
"1": { "1": {
"name": "keyword.other.elvish" "name": "keyword.other.elvish"
@ -101,7 +101,7 @@
} }
}, },
{ {
"match": "}\\s+(elif|else|finally)\\s+([\\w\\d_:~-]+)", "match": "}\\s+(elif|else|catch|except|finally)(?=[\\s)}<>;|&])",
"captures": { "captures": {
"1": { "1": {
"name": "keyword.control.elvish" "name": "keyword.control.elvish"

View File

@ -2,7 +2,7 @@
"name": "elvish", "name": "elvish",
"displayName": "Elvish", "displayName": "Elvish",
"description": "Elvish language support for Visual Studio Code", "description": "Elvish language support for Visual Studio Code",
"version": "0.1.0", "version": "0.1.1",
"publisher": "elves", "publisher": "elves",
"license": "BSD-2-Clause", "license": "BSD-2-Clause",
"icon": "icon.png", "icon": "icon.png",

26
vscode/sample.elv Normal file
View File

@ -0,0 +1,26 @@
# A sample file to test syntax highlighting.
nop "double \n quoted" and 'single '' quoted' # comment
# Various variable contexts
nop $pid
var var-name = { var fn-name~ = {var not-var-name} }
nop (set var-name = foo | tmp var-name = bar); del var-name
for var-name [] { }
try { } catch var-name { }
# Builtin functions
!= a (nop b) | echo c
# Builtin special command
and a b # "operator"
use re # "other"
if a { } elif b { } else { }
try { } except err { } else { } finally { }
# Metacharacters
echo ** () []
# Regression tests
set-env # should highlight entire set-env
set-foo # should highlight nothing