diff options
author | Giorbo | 2022-09-07 18:13:06 +0000 |
---|---|---|
committer | GitHub | 2022-09-07 18:13:06 +0000 |
commit | 5b1113766d5363c2e434ab596fcca64a1c707a55 (patch) | |
tree | 157a31d133fdc722de81c873672e581be3b9c56f | |
parent | e14b48af2ebeb84868334e3b3281844353a9371d (diff) |
Add syntax highlighting for SML (#3692)
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
-rw-r--r-- | book/src/generated/lang-support.md | 1 | ||||
-rw-r--r-- | languages.toml | 12 | ||||
-rw-r--r-- | runtime/queries/sml/highlights.scm | 91 |
3 files changed, 104 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 4e10ffc1..a66fae21 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -95,6 +95,7 @@ | scheme | ✓ | | | | | scss | ✓ | | | `vscode-css-language-server` | | slint | ✓ | | ✓ | `slint-lsp` | +| sml | ✓ | | | | | solidity | ✓ | | | `solc` | | sql | ✓ | | | | | sshclientconfig | ✓ | | | | diff --git a/languages.toml b/languages.toml index d3051377..38d9cb55 100644 --- a/languages.toml +++ b/languages.toml @@ -1712,3 +1712,15 @@ language-server = { command = "pasls", args = [] } [[grammar]] name = "pascal" source = { git = "https://github.com/Isopod/tree-sitter-pascal", rev = "2fd40f477d3e2794af152618ccfac8d92eb72a66" } + +[[language]] +name = "sml" +scope = "source.sml" +injection-regex = "sml" +file-types = ["sml"] +comment-token = "(*" +roots = [] + +[[grammar]] +name = "sml" +source = { git = "https://github.com/Giorbo/tree-sitter-sml", rev = "bd4055d5554614520d4a0706b34dc0c317c6b608" } diff --git a/runtime/queries/sml/highlights.scm b/runtime/queries/sml/highlights.scm new file mode 100644 index 00000000..dfbf5caf --- /dev/null +++ b/runtime/queries/sml/highlights.scm @@ -0,0 +1,91 @@ +; Highlights queries from Matthew Fluet (https://github.com/MatthewFluet/tree-sitter-sml) +; +; MIT License +; +; Copyright (c) 2022 Matthew Fluet +; +; Permission is hereby granted, free of charge, to any person obtaining a copy +; of this software and associated documentation files (the "Software"), to deal +; in the Software without restriction, including without limitation the rights +; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +; copies of the Software, and to permit persons to whom the Software is +; furnished to do so, subject to the following conditions: +; +; The above copyright notice and this permission notice shall be included in all +; copies or substantial portions of the Software. +; +; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +; SOFTWARE. + +;; ******************************************************************* +;; Comments +;; ******************************************************************* + +[(block_comment) (line_comment)] @comment + +;; ******************************************************************* +;; Keywords +;; ******************************************************************* + +[ + ;; Reserved Words Core + "abstype" "and" "andalso" "as" "case" "datatype" "do" "else" "end" + "exception" "fn" "fun" "handle" "if" "in" "infix" "infixr" "let" + "local" "nonfix" "of" "op" "open" "orelse" "raise" "rec" "then" + "type" "val" "with" "withtype" "while" + ;; Reserved Words Modules + "eqtype" "functor" "include" "sharing" "sig" "signature" "struct" + "structure" "where" +] @keyword + +;; ******************************************************************* +;; Constants +;; ******************************************************************* + +(integer_scon) @constant.numeric.integer +(real_scon) @constant.numeric.float +(word_scon) @constant.numeric +(string_scon) @string +(char_scon) @constant.character + +;; ******************************************************************* +;; Types +;; ******************************************************************* + +(fn_ty "->" @type) +(tuple_ty "*" @type) +(paren_ty ["(" ")"] @type) +(tyvar_ty (tyvar) @type) +(record_ty + ["{" "," "}"] @type + (tyrow [(lab) ":"] @type)? + (ellipsis_tyrow ["..." ":"] @type)?) +(tycon_ty + (tyseq ["(" "," ")"] @type)? + (longtycon) @type) + +;; ******************************************************************* +;; Constructors +;; ******************************************************************* + +;; Assume value identifiers starting with capital letter are constructors +((vid) @constructor + (#match? @constructor "^[A-Z].*")) + +((vid) @constant.builtin (#eq? @constant.builtin "nil")) +((vid) @constant.builtin.boolean + (#match? @constant.builtin.boolean "^(true|false)$")) +((vid) @operator (#eq? @operator "::")) +((vid) @keyword.storage.modifier (#eq? @keyword.storage.modifier "ref")) + +;; ******************************************************************* +;; Punctuation +;; ******************************************************************* + +["(" ")" "[" "]" "{" "}"] @punctuation.bracket +["." "," ":" ";" "|" "=>" ":>"] @punctuation.delimiter |