Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rescript-lang/rescript-sublime
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.0.8
Choose a base ref
...
head repository: rescript-lang/rescript-sublime
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Oct 14, 2020

  1. Update for 8.3.0

    chenglou committed Oct 14, 2020
    Copy the full SHA
    83b8fc8 View commit details

Commits on Nov 1, 2020

  1. Copy the full SHA
    1e5cdd8 View commit details

Commits on Nov 22, 2020

  1. Merge pull request #2 from Dracyr/fix-null-tilde-in-syntax

    Fix tilde character interpreted as null in syntax
    IwanKaramazow authored Nov 22, 2020
    Copy the full SHA
    c14ee3c View commit details

Commits on Dec 5, 2020

  1. Copy the full SHA
    ac181a1 View commit details
  2. Copy the full SHA
    25203d9 View commit details
  3. Highlight poly variant

    chenglou committed Dec 5, 2020
    Copy the full SHA
    ce20f7c View commit details
  4. Update snippets

    chenglou committed Dec 5, 2020
    Copy the full SHA
    291053c View commit details

Commits on Jan 20, 2021

  1. Nested multiline comment

    chenglou committed Jan 20, 2021
    Copy the full SHA
    26c20f5 View commit details

Commits on Jan 26, 2021

  1. Fix = scope for module

    chenglou committed Jan 26, 2021
    Copy the full SHA
    8458527 View commit details
  2. Fix module vs variant highlighting in some cases

    See tests
    chenglou committed Jan 26, 2021
    Copy the full SHA
    623d7cd View commit details

Commits on Feb 5, 2021

  1. Clean up syntax tests

    chenglou committed Feb 5, 2021
    Copy the full SHA
    186a16d View commit details
  2. Copy the full SHA
    0fbc5d4 View commit details
  3. Tiny cleanup

    chenglou committed Feb 5, 2021
    Copy the full SHA
    1327adc View commit details

Commits on Feb 6, 2021

  1. Small cleanup

    chenglou committed Feb 6, 2021
    Copy the full SHA
    b49adb4 View commit details
  2. Add deprecated highlighting

    chenglou committed Feb 6, 2021
    Copy the full SHA
    4bd3e82 View commit details

Commits on Feb 7, 2021

  1. Copy the full SHA
    9848d2a View commit details

Commits on Feb 8, 2021

  1. Fix typo in 9848d2a

    chenglou committed Feb 8, 2021
    Copy the full SHA
    b37379e View commit details

Commits on Feb 28, 2021

  1. Copy the full SHA
    3aab2ac View commit details
  2. Update version requirement

    chenglou committed Feb 28, 2021
    Copy the full SHA
    5f86d5c View commit details

Commits on Mar 13, 2021

  1. Copy the full SHA
    748534e View commit details

Commits on Mar 28, 2021

  1. Copy the full SHA
    5262fa9 View commit details

Commits on Mar 31, 2021

  1. Highlight type param

    This is one of the few remaining unambiguous things in our syntax (uuugh), so let's at least highlight this first.
    chenglou committed Mar 31, 2021
    Copy the full SHA
    ebc26cd View commit details

Commits on May 16, 2021

  1. Higligh poly variant better

    chenglou committed May 16, 2021
    Copy the full SHA
    db3055f View commit details
  2. Beef up interpolation

    chenglou committed May 16, 2021
    Copy the full SHA
    8714fab View commit details
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@ The official Sublime Text plugin for ReScript.

## Prerequisite

`bs-platform 8.2.0` installed locally in your project.
- `>=0.0.9` requires `bs-platform >=8.3.0` installed locally in your project.
- `0.0.8` requires `bs-platform 8.2.0` installed locally in your project.

## Install

@@ -16,6 +17,9 @@ Get it from https://packagecontrol.io/packages/ReScript
- Formatting: Command Palette (`cmd-shift-p`) -> ReScript: Format File. caveats:
- Currently requires the file to be part of a ReScript project, i.e. with a `bsconfig.json`.
- Cannot be a temporary file.
- Snippets to ease a few syntaxes:
- `external` features such as `@bs.module` and `@bs.val`
- `try`, `for`, etc.

## Upcoming Features

82 changes: 41 additions & 41 deletions ReScript.sublime-syntax
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ variables:

# slightly different than reason-highlightjs
RE_KEYWORDS:
\b(and|as|assert|begin|class|constraint|done|downto|exception|external|fun|functor|inherit|lazy|let|pub|mutable|new|nonrec|object|of|or|pri|rec|then|to|val|virtual|try|catch|finally|do|else|for|if|switch|while|import|library|export|module|in|raise|private)\b
\b(and|as|assert|constraint|downto|else|exception|external|false|for|if|in|include|lazy|let|module|mutable|of|open|rec|switch|to|true|try|type|when|while|with)\b
RE_LITERAL: \b(true|false)\b

contexts:
@@ -31,12 +31,13 @@ contexts:
scope: punctuation.definition.comment.begin
push:
- meta_scope: comment.block
- include: commentBlock
- match: \*/
scope: punctuation.definition.comment.end
pop: true

punctuations:
- match: ~
- match: \~
scope: punctuation.definition.keyword
- match: ;
scope: punctuation.terminator
@@ -98,15 +99,7 @@ contexts:
# TODO: will need expression
- include: operator
- include: punctuations
- match: (\$)
captures:
1: punctuation.section.interpolation
push:
- clear_scopes: 1
- match: '{{RE_IDENT}}'
pop: true
- match: '(?=\S)'
pop: true
- include: string
- match: '`'
scope: punctuation.definition.string.end
pop: true
@@ -120,34 +113,44 @@ contexts:
- match: '''[\x00-\x7F]'''
scope: string.quoted.single

typeParameter:
- match: '''[A-Za-z][A-Za-z0-9_]*'
scope: support.type

number:
- match:
\b(0[xX][a-fA-F0-9_]+[Lln]?|0[oO][0-7_]+[Lln]?|0[bB][01_]+[Lln]?|[0-9][0-9_]*([Lln]|(\.[0-9_]+)?([eE][-+]?[0-9_]+)?)?)\b
scope: constant.numeric

operator:
- match:
'->|\|\||&&|\+\+|\*\*|\+\.|\+|-\.|-|\*\.|\*|/\.|/|\.\.\.|\.\.|\|>|===|==|\^|:=|!|>=|<='
scope: keyword.operator

assignment:
- match: '='
scope: keyword.operator.assignment
'->|\|\||&&|\+\+|\*\*|\+\.|\+|-\.|-|\*\.|\*|/\.|/|\.\.\.|\.\.|\|===|==|\^|:=|!|>=(?! *\?)|<=|='
# gotta add `keyword` to this scope. This file is synced with our vscode
# textmate grammar too, and many themes there don't highlight
# `keyword.operator`. So we'll highlight them as `keyword`
scope: keyword.operator keyword
- match: '\|>'
scope: invalid.deprecated

# doesn't contain ` unlike reason-highlightjs
constructor:
- match: '\b[A-Z][0-9a-zA-Z_]*\b'
# won't mark and highlight this for now. This often shares the same
# highlighting as entity.name.namespace (our module). We don't want
# highlighting as entity.name.namespace our module). We don't want
# variant and modules confused
# scope: entity.name.union
scope: variable.function variable.other
- match: '(#)(\.\.\.)?[a-zA-Z][0-9a-zA-Z_]*\b'
- match: '(#)(\.\.\.)?([a-zA-Z][0-9a-zA-Z_]*)\b'
captures:
1: punctuation.definition.keyword
2: punctuation.definition.keyword
# see comment above
3: variable.function variable.other
- match: '(#)'
captures:
1: punctuation.definition.keyword

array:
bracketAccess:
- match: '\['
scope: punctuation.section.brackets.begin
- match: '\]'
@@ -161,15 +164,6 @@ contexts:
- match: '\}'
scope: punctuation.section.braces.end

objectAccess:
- match: '\b{{RE_IDENT}}(\[)'
captures:
# technically this should be punctuation.accessor. But we don't wrap
# the section, so we'll just conform to list and array brackets
1: punctuation.section.brackets.begin
- match: '\]'
scope: punctuation.section.brackets.end

attribute:
- match: '@@?'
scope: storage.modifier punctuation.definition.annotation
@@ -179,13 +173,16 @@ contexts:
push: attributeContent
attributeContent:
- meta_scope: meta.annotation
# - match: '{{RE_ATTRIBUTE}} *\('
# scope: variable.annotation
# push:
# - match: \)
# pop: true
- match: '{{RE_ATTRIBUTE}}'
scope: variable.annotation
- match: 'bs\.send\.pipe'
scope: invalid.deprecated
pop: true
- match: 'splice'
scope: invalid.illegal
pop: true
- match: '(bs\.)?({{RE_ATTRIBUTE}})'
captures:
1: invalid.deprecated
2: variable.annotation
pop: true

jsx:
@@ -203,7 +200,7 @@ contexts:
push: moduleAccessEndsWithModuleThenPop

openOrIncludeModule:
- match: '\b(open|include)\s*'
- match: '\b(open|include)\s+'
scope: keyword
push: moduleAccessEndsWithModuleThenPop

@@ -234,6 +231,9 @@ contexts:
- match: \)
scope: punctuation.section.parens.end
pop: true
- match: \{
scope: punctuation.section.braces.begin
push: moduleInner
- include: moduleAccessEndsWithModule
- include: main

@@ -265,7 +265,8 @@ contexts:
captures:
1: punctuation.section.braces.begin
push: moduleInner
- match: '='
- match: '=[^\S]'
scope: keyword.operator keyword
set: moduleRHS
- match: '(?=\S)'
pop: true
@@ -283,15 +284,14 @@ contexts:
- include: commentLine
- include: commentBlock
- include: character
- include: typeParameter
- include: string
- include: attribute
- include: function
- include: list
- include: objectAccess
- include: array
- include: bracketAccess
- include: jsx
- include: operator
- include: assignment
- include: number
- include: openOrIncludeModule
- include: moduleDeclaration
4 changes: 2 additions & 2 deletions format.py
Original file line number Diff line number Diff line change
@@ -109,9 +109,9 @@ def parseBsbLogOutput(content):
# map of file path to list of diagnosis
for diagnosisLines in res:
fileAndLocation, *diagnosisMessage = diagnosisLines
lastSpace = fileAndLocation.rfind(" ")
lastSpace = fileAndLocation.find(":")
file = fileAndLocation[2:lastSpace]
location = fileAndLocation[lastSpace:]
location = fileAndLocation[lastSpace + 1:]
if not file in ret:
ret[file] = []
cleanedUpDiagnosis = "\n".join([line[2:] for line in diagnosisMessage]).strip()
9 changes: 0 additions & 9 deletions snippets/comment.sublime-snippet

This file was deleted.

11 changes: 0 additions & 11 deletions snippets/docblock.sublime-snippet

This file was deleted.

6 changes: 6 additions & 0 deletions snippets/external-global-module.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<snippet>
<content><![CDATA[
@val external ${1:setTimeout}: ${2:(unit => unit, int) => float} = "${3:setTimeout}"]]></content>
<tabTrigger>external</tabTrigger>
<scope>source.res</scope>
</snippet>
6 changes: 6 additions & 0 deletions snippets/external-global-object.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<snippet>
<content><![CDATA[
@val external ${1:setTimeout}: ${2:(unit => unit, int) => float} = "${3:setTimeout}"]]></content>
<tabTrigger>external</tabTrigger>
<scope>source.res</scope>
</snippet>
6 changes: 6 additions & 0 deletions snippets/external-js-module-default.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<snippet>
<content><![CDATA[
@module external ${1:leftPad}: ${2:(string, int) => string} = "${3:leftPad}"]]></content>
<tabTrigger>external</tabTrigger>
<scope>source.res</scope>
</snippet>
6 changes: 6 additions & 0 deletions snippets/external-js-module.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<snippet>
<content><![CDATA[
@scope("${1:Math}") @val external ${2:random}: ${3:unit => float} = "${4:random}"]]></content>
<tabTrigger>external</tabTrigger>
<scope>source.res</scope>
</snippet>
9 changes: 9 additions & 0 deletions snippets/for-loop.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<snippet>
<content><![CDATA[
for ${1:i} in ${2:startValueInclusive} to ${3:endValueInclusive} {
${4:Js.log(${1:i})}
}
]]></content>
<tabTrigger>for</tabTrigger>
<scope>source.res</scope>
</snippet>
9 changes: 9 additions & 0 deletions snippets/for-reverse.sublime-snippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<snippet>
<content><![CDATA[
for ${1:i} in ${2:startValueInclusive} downto ${3:endValueInclusive} {
${4:Js.log(${1:i})}
}
]]></content>
<tabTrigger>for</tabTrigger>
<scope>source.res</scope>
</snippet>
9 changes: 0 additions & 9 deletions snippets/inlineComment.sublime-snippet

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<snippet>
<content><![CDATA[
module ${1:Name} = {
${2:/* Module contents */}
${2:// Module contents}
}
]]></content>
<tabTrigger>mod</tabTrigger>
<tabTrigger>module</tabTrigger>
<scope>source.res</scope>
</snippet>
6 changes: 3 additions & 3 deletions snippets/switch.sublime-snippet
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<snippet>
<content><![CDATA[
switch ${1:subject} {
| ${2:option1} => ${3:expression}
${4:| ${5:option2} => ${6:expression}}
switch ${1:value} {
| ${2:pattern1} => ${3:expression}
${4:| ${5:pattern2} => ${6:expression}}
}
]]></content>
<tabTrigger>switch</tabTrigger>
7 changes: 0 additions & 7 deletions snippets/type.sublime-snippet

This file was deleted.

Loading