From 7c338429f845315fb276ff482f91b94b3102dbd8 Mon Sep 17 00:00:00 2001 From: Borys Lykah Date: Sun, 9 Jul 2023 11:17:01 -0600 Subject: [PATCH] Add language support for persistent library syntax (#7261) --- book/src/generated/lang-support.md | 1 + languages.toml | 12 ++++++ runtime/queries/haskell-persistent/folds.scm | 3 ++ .../queries/haskell-persistent/highlights.scm | 37 +++++++++++++++++++ runtime/queries/haskell-persistent/locals.scm | 1 + runtime/queries/haskell/injections.scm | 8 ++++ 6 files changed, 62 insertions(+) create mode 100644 runtime/queries/haskell-persistent/folds.scm create mode 100644 runtime/queries/haskell-persistent/highlights.scm create mode 100644 runtime/queries/haskell-persistent/locals.scm diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index c3eb0f96..b5391150 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -59,6 +59,7 @@ | graphql | ✓ | | | | | hare | ✓ | | | | | haskell | ✓ | ✓ | | `haskell-language-server-wrapper` | +| haskell-persistent | ✓ | | | | | hcl | ✓ | | ✓ | `terraform-ls` | | heex | ✓ | ✓ | | `elixir-ls` | | hosts | ✓ | | | | diff --git a/languages.toml b/languages.toml index 482a2511..e8f6a7a6 100644 --- a/languages.toml +++ b/languages.toml @@ -955,6 +955,18 @@ indent = { tab-width = 2, unit = " " } name = "haskell" source = { git = "https://github.com/tree-sitter/tree-sitter-haskell", rev = "98fc7f59049aeb713ab9b72a8ff25dcaaef81087" } +[[language]] +name = "haskell-persistent" +scope = "source.persistentmodels" +file-types = ["persistentmodels"] +roots = [] +comment-token = "--" +indent = { tab-width = 2, unit = " " } + +[[grammar]] +name = "haskell-persistent" +source = { git = "https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent", rev = "58a6ccfd56d9f1de8fb9f77e6c42151f8f0d0f3d" } + [[language]] name = "purescript" scope = "source.purescript" diff --git a/runtime/queries/haskell-persistent/folds.scm b/runtime/queries/haskell-persistent/folds.scm new file mode 100644 index 00000000..ac04ad4a --- /dev/null +++ b/runtime/queries/haskell-persistent/folds.scm @@ -0,0 +1,3 @@ +[ + (entity_definition) +] @fold diff --git a/runtime/queries/haskell-persistent/highlights.scm b/runtime/queries/haskell-persistent/highlights.scm new file mode 100644 index 00000000..d6358578 --- /dev/null +++ b/runtime/queries/haskell-persistent/highlights.scm @@ -0,0 +1,37 @@ +;; ---------------------------------------------------------------------------- +;; Literals and comments + +(integer) @constant.numeric.integer +(float) @constant.numeric.float +(char) @constant.character +(string) @string +(attribute_name) @attribute +(attribute_exclamation_mark) @attribute + +(con_unit) @constant.builtin ; unit, as in () + +(comment) @comment + +;; ---------------------------------------------------------------------------- +;; Keywords, operators, includes + +[ + "Id" + "Primary" + "Foreign" + "deriving" +] @keyword + +"=" @operator + +;; ---------------------------------------------------------------------------- +;; Functions and variables + +(variable) @variable + +;; ---------------------------------------------------------------------------- +;; Types + +(type) @type + +(constructor) @constructor diff --git a/runtime/queries/haskell-persistent/locals.scm b/runtime/queries/haskell-persistent/locals.scm new file mode 100644 index 00000000..3ffb01a1 --- /dev/null +++ b/runtime/queries/haskell-persistent/locals.scm @@ -0,0 +1 @@ +(fields (variable)) @local.definition diff --git a/runtime/queries/haskell/injections.scm b/runtime/queries/haskell/injections.scm index 788b8b8c..5ee3478b 100644 --- a/runtime/queries/haskell/injections.scm +++ b/runtime/queries/haskell/injections.scm @@ -1,6 +1,14 @@ ((comment) @injection.content (#set! injection.language "comment")) +(quasiquote + (quoter) @_quoter + ((quasiquote_body) @injection.content + (#match? @_quoter "(persistWith|persistLowerCase|persistUpperCase)") + (#set! injection.language "haskell-persistent") + ) +) + (quasiquote (quoter) @injection.language (quasiquote_body) @injection.content)