Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Get basic syntax highlighting for Haskell working
Pseudomata02ab16037c91
diff --git a/Cargo.lock b/Cargo.lockindex 04b3dee49c6..b02087080a9 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -8477,6 +8477,15 @@ dependencies = ["tree-sitter",]+[[package]]+name = "tree-sitter-haskell"+version = "0.14.0"+source = "git+https://github.com/tree-sitter/tree-sitter-haskell?rev=dd924b8df1eb76261f009e149fc6f3291c5081c2#dd924b8df1eb76261f009e149fc6f3291c5081c2"+dependencies = [+ "cc",+ "tree-sitter",+]+[[package]]name = "tree-sitter-heex"version = "0.0.1"@@ -9740,6 +9749,7 @@ dependencies = ["tree-sitter-embedded-template","tree-sitter-glsl","tree-sitter-go",+ "tree-sitter-haskell","tree-sitter-heex","tree-sitter-html","tree-sitter-json 0.20.0",diff --git a/Cargo.toml b/Cargo.tomlindex 7acc460af86..11e426a2eaa 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -150,6 +150,7 @@ tree-sitter-python = "0.20.2"tree-sitter-toml = { git = "https://github.com/tree-sitter/tree-sitter-toml", rev = "342d9be207c2dba869b9967124c679b5e6fd0ebe" }tree-sitter-typescript = { git = "https://github.com/tree-sitter/tree-sitter-typescript", rev = "5d20856f34315b068c41edaee2ac8a100081d259" }tree-sitter-ruby = "0.20.0"+tree-sitter-haskell = { git = "https://github.com/tree-sitter/tree-sitter-haskell", rev = "dd924b8df1eb76261f009e149fc6f3291c5081c2" }tree-sitter-html = "0.19.0"tree-sitter-scheme = { git = "https://github.com/6cdh/tree-sitter-scheme", rev = "af0fd1fa452cb2562dc7b5c8a8c55551c39273b9"}tree-sitter-svelte = { git = "https://github.com/Himujjal/tree-sitter-svelte", rev = "697bb515471871e85ff799ea57a76298a71a9cca"}diff --git a/crates/zed/Cargo.toml b/crates/zed/Cargo.tomlindex 683a7c6fed7..813f3e70758 100644--- a/crates/zed/Cargo.toml+++ b/crates/zed/Cargo.toml@@ -130,6 +130,7 @@ tree-sitter-python.workspace = truetree-sitter-toml.workspace = truetree-sitter-typescript.workspace = truetree-sitter-ruby.workspace = true+tree-sitter-haskell.workspace = truetree-sitter-html.workspace = truetree-sitter-php.workspace = truetree-sitter-scheme.workspace = truediff --git a/crates/zed/src/languages.rs b/crates/zed/src/languages.rsindex 3fdcad46fe1..474fce456ab 100644--- a/crates/zed/src/languages.rs+++ b/crates/zed/src/languages.rs@@ -13,6 +13,7 @@ mod c;mod css;mod elixir;mod go;+mod haskell;mod html;mod json;#[cfg(feature = "plugin_runtime")]@@ -160,6 +161,7 @@ pub fn init(Arc::new(tailwind::TailwindLspAdapter::new(node_runtime.clone())),],);+ language("haskell", tree_sitter_haskell::language(), vec![]);language("html",tree_sitter_html::language(),diff --git a/crates/zed/src/languages/haskell.rs b/crates/zed/src/languages/haskell.rsnew file mode 100644index 00000000000..8b137891791--- /dev/null+++ b/crates/zed/src/languages/haskell.rs@@ -0,0 +1 @@+diff --git a/crates/zed/src/languages/haskell/brackets.scm b/crates/zed/src/languages/haskell/brackets.scmnew file mode 100644index 00000000000..191fd9c084a--- /dev/null+++ b/crates/zed/src/languages/haskell/brackets.scm@@ -0,0 +1,3 @@+("(" @open ")" @close)+("[" @open "]" @close)+("{" @open "}" @close)diff --git a/crates/zed/src/languages/haskell/config.toml b/crates/zed/src/languages/haskell/config.tomlnew file mode 100644index 00000000000..15fdd7b78e2--- /dev/null+++ b/crates/zed/src/languages/haskell/config.toml@@ -0,0 +1,12 @@+name = "Haskell"+path_suffixes = ["hs"]+autoclose_before = ",=)}]"+line_comment = "-- "+block_comment = ["{- ", " -}"]+brackets = [+ { start = "{", end = "}", close = true, newline = true },+ { start = "[", end = "]", close = true, newline = true },+ { start = "(", end = ")", close = true, newline = true },+ { start = "\"", end = "\"", close = false, newline = false },+ { start = "'", end = "'", close = false, newline = false },+]diff --git a/crates/zed/src/languages/haskell/highlights.scm b/crates/zed/src/languages/haskell/highlights.scmnew file mode 100644index 00000000000..3ab843e8337--- /dev/null+++ b/crates/zed/src/languages/haskell/highlights.scm@@ -0,0 +1,156 @@+;; Copyright 2022 nvim-treesitter+;;+;; Licensed under the Apache License, Version 2.0 (the "License");+;; you may not use this file except in compliance with the License.+;; You may obtain a copy of the License at+;;+;; http://www.apache.org/licenses/LICENSE-2.0+;;+;; Unless required by applicable law or agreed to in writing, software+;; distributed under the License is distributed on an "AS IS" BASIS,+;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+;; See the License for the specific language governing permissions and+;; limitations under the License.++;; ----------------------------------------------------------------------------+;; Literals and comments++(integer) @number+(exp_negation) @number+(exp_literal (float)) @float+(char) @character+(string) @string++(con_unit) @symbol ; unit, as in ()++(comment) @comment+++;; ----------------------------------------------------------------------------+;; Punctuation++[+ "("+ ")"+ "{"+ "}"+ "["+ "]"+] @punctuation.bracket++[+ (comma)+ ";"+] @punctuation.delimiter+++;; ----------------------------------------------------------------------------+;; Keywords, operators, includes++[+ "forall"+ "∀"+] @repeat++(pragma) @constant.macro++[+ "if"+ "then"+ "else"+ "case"+ "of"+] @conditional++(exp_lambda_cases "\\" ("cases" @conditional))++[+ "import"+ "qualified"+ "module"+] @include++[+ (operator)+ (constructor_operator)+ (type_operator)+ (tycon_arrow)+ (qualified_module) ; grabs the `.` (dot), ex: import System.IO+ (all_names)+ (wildcard)+ "="+ "|"+ "::"+ "=>"+ "->"+ "<-"+ "\\"+ "`"+ "@"+] @operator++(module) @namespace++[+ (where)+ "let"+ "in"+ "class"+ "instance"+ "data"+ "newtype"+ "family"+ "type"+ "as"+ "hiding"+ "deriving"+ "via"+ "stock"+ "anyclass"+ "do"+ "mdo"+ "rec"+ "infix"+ "infixl"+ "infixr"+] @keyword+++;; ----------------------------------------------------------------------------+;; Functions and variables++(variable) @variable+(pat_wildcard) @variable++(signature name: (variable) @type)+(function+ name: (variable) @function+ patterns: (patterns))+((signature (fun)) . (function (variable) @function))+((signature (context (fun))) . (function (variable) @function))+((signature (forall (context (fun)))) . (function (variable) @function))++(exp_infix (variable) @operator) ; consider infix functions as operators++(exp_infix (exp_name) @function (#set! "priority" 101))+(exp_apply . (exp_name (variable) @function))+(exp_apply . (exp_name (qualified_variable (variable) @function)))+++;; ----------------------------------------------------------------------------+;; Types++(type) @type+(type_variable) @type++(constructor) @constructor++; True or False+((constructor) @_bool (#match? @_bool "(True|False)")) @boolean+++;; ----------------------------------------------------------------------------+;; Quasi-quotes++(quoter) @function+; Highlighting of quasiquote_body is handled by injections.scmdiff --git a/crates/zed/src/languages/haskell/indents.scm b/crates/zed/src/languages/haskell/indents.scmnew file mode 100644index 00000000000..112b414aa45--- /dev/null+++ b/crates/zed/src/languages/haskell/indents.scm@@ -0,0 +1,3 @@+(_ "[" "]" @end) @indent+(_ "{" "}" @end) @indent+(_ "(" ")" @end) @indent