From 02ab16037c91a6d4883f91316ae7ed02b1bb3d69 Mon Sep 17 00:00:00 2001 From: Pseudomata Date: Wed, 24 Jan 2024 18:08:47 -0500 Subject: [PATCH 01/10] Get basic syntax highlighting for Haskell working --- Cargo.lock | 10 ++ Cargo.toml | 1 + crates/zed/Cargo.toml | 1 + crates/zed/src/languages.rs | 2 + crates/zed/src/languages/haskell.rs | 1 + crates/zed/src/languages/haskell/brackets.scm | 3 + crates/zed/src/languages/haskell/config.toml | 12 ++ .../zed/src/languages/haskell/highlights.scm | 156 ++++++++++++++++++ crates/zed/src/languages/haskell/indents.scm | 3 + 9 files changed, 189 insertions(+) create mode 100644 crates/zed/src/languages/haskell.rs create mode 100644 crates/zed/src/languages/haskell/brackets.scm create mode 100644 crates/zed/src/languages/haskell/config.toml create mode 100644 crates/zed/src/languages/haskell/highlights.scm create mode 100644 crates/zed/src/languages/haskell/indents.scm diff --git a/Cargo.lock b/Cargo.lock index 04b3dee49c6dd5a6f0d2c953188547b72d12d4a6..b02087080a969e445880cc0d9c4393d8ff539389 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.toml index 7acc460af862186a8218af18f613e72f15cd8cb9..11e426a2eaa939b59083a5f8c7878f1f2a92e41a 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.toml index 683a7c6fed7c656d02b45712eb4881acbbc13c79..813f3e7075850c0f2ddb6c7018c0cdf08469f5b7 100644 --- a/crates/zed/Cargo.toml +++ b/crates/zed/Cargo.toml @@ -130,6 +130,7 @@ tree-sitter-python.workspace = true tree-sitter-toml.workspace = true tree-sitter-typescript.workspace = true tree-sitter-ruby.workspace = true +tree-sitter-haskell.workspace = true tree-sitter-html.workspace = true tree-sitter-php.workspace = true tree-sitter-scheme.workspace = true diff --git a/crates/zed/src/languages.rs b/crates/zed/src/languages.rs index 3fdcad46fe1edfbe8dbb750e821d99848abac2c3..474fce456abf02b41cb6e3027411885b00b8e351 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.rs new file mode 100644 index 0000000000000000000000000000000000000000..8b137891791fe96927ad78e64b0aad7bded08bdc --- /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.scm new file mode 100644 index 0000000000000000000000000000000000000000..191fd9c084a52eced37428281971ff9e569a4932 --- /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.toml new file mode 100644 index 0000000000000000000000000000000000000000..15fdd7b78e232e4c5c8938a97a0cd407a295619b --- /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.scm new file mode 100644 index 0000000000000000000000000000000000000000..3ab843e8337d939907497ce48a8315e742cf4a36 --- /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.scm diff --git a/crates/zed/src/languages/haskell/indents.scm b/crates/zed/src/languages/haskell/indents.scm new file mode 100644 index 0000000000000000000000000000000000000000..112b414aa45f277138d0c681851129a608ee96e0 --- /dev/null +++ b/crates/zed/src/languages/haskell/indents.scm @@ -0,0 +1,3 @@ +(_ "[" "]" @end) @indent +(_ "{" "}" @end) @indent +(_ "(" ")" @end) @indent From f9a08287c73071ced43628ccf8162386366782ff Mon Sep 17 00:00:00 2001 From: Pseudomata Date: Fri, 26 Jan 2024 10:51:39 -0500 Subject: [PATCH 02/10] Update Haskell grammar Copied queries from nvim-tree-sitter, see https://github.com/nvim-treesitter/nvim-treesitter/tree/master/queries/haskell --- crates/zed/src/languages/haskell/config.toml | 5 +- crates/zed/src/languages/haskell/folds.scm | 18 + .../zed/src/languages/haskell/highlights.scm | 564 ++++++++++++++++-- .../zed/src/languages/haskell/injections.scm | 89 +++ 4 files changed, 630 insertions(+), 46 deletions(-) create mode 100644 crates/zed/src/languages/haskell/folds.scm create mode 100644 crates/zed/src/languages/haskell/injections.scm diff --git a/crates/zed/src/languages/haskell/config.toml b/crates/zed/src/languages/haskell/config.toml index 15fdd7b78e232e4c5c8938a97a0cd407a295619b..9d0c3f602ce9e2985ae831302b1aa08ae616cccd 100644 --- a/crates/zed/src/languages/haskell/config.toml +++ b/crates/zed/src/languages/haskell/config.toml @@ -7,6 +7,7 @@ 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 }, + { start = "\"", end = "\"", close = true, newline = false }, + { start = "'", end = "'", close = true, newline = false }, + { start = "`", end = "`", close = true, newline = false }, ] diff --git a/crates/zed/src/languages/haskell/folds.scm b/crates/zed/src/languages/haskell/folds.scm new file mode 100644 index 0000000000000000000000000000000000000000..e743ecf52cc9981ed55eec9eff72be829a32f147 --- /dev/null +++ b/crates/zed/src/languages/haskell/folds.scm @@ -0,0 +1,18 @@ +;; 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. +[ + (exp_apply) + (exp_do) + (function) +] @fold diff --git a/crates/zed/src/languages/haskell/highlights.scm b/crates/zed/src/languages/haskell/highlights.scm index 3ab843e8337d939907497ce48a8315e742cf4a36..a81089d419276d282c34765d47f6df1e4d75c6df 100644 --- a/crates/zed/src/languages/haskell/highlights.scm +++ b/crates/zed/src/languages/haskell/highlights.scm @@ -11,24 +11,77 @@ ;; 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. +; ---------------------------------------------------------------------------- +; Parameters and variables +; NOTE: These are at the top, so that they have low priority, +; and don't override destructured parameters +(variable) @variable + +(pat_wildcard) @variable -;; ---------------------------------------------------------------------------- -;; Literals and comments +(function + patterns: + (patterns + (_) @variable.parameter)) + +(exp_lambda + (_)+ @variable.parameter + "->") +(function + infix: + (infix + lhs: (_) @variable.parameter)) + +(function + infix: + (infix + rhs: (_) @variable.parameter)) + +; ---------------------------------------------------------------------------- +; Literals and comments (integer) @number + (exp_negation) @number -(exp_literal (float)) @float + +(exp_literal + (float)) @number.float + (char) @character + (string) @string -(con_unit) @symbol ; unit, as in () +(con_unit) @string.special.symbol ; unit, as in () (comment) @comment - -;; ---------------------------------------------------------------------------- -;; Punctuation - +; FIXME: The below documentation comment queries are inefficient +; and need to be anchored, using something like +; ((comment) @_first . (comment)+ @comment.documentation) +; once https://github.com/neovim/neovim/pull/24738 has been merged. +; +; ((comment) @comment.documentation +; (#lua-match? @comment.documentation "^-- |")) +; +; ((comment) @_first @comment.documentation +; (comment) @comment.documentation +; (#lua-match? @_first "^-- |")) +; +; ((comment) @comment.documentation +; (#lua-match? @comment.documentation "^-- %^")) +; +; ((comment) @_first @comment.documentation +; (comment) @comment.documentation +; (#lua-match? @_first "^-- %^")) +; +; ((comment) @comment.documentation +; (#lua-match? @comment.documentation "^{-")) +; +; ((comment) @_first @comment.documentation +; (comment) @comment.documentation +; (#lua-match? @_first "^{-")) +; ---------------------------------------------------------------------------- +; Punctuation [ "(" ")" @@ -43,16 +96,14 @@ ";" ] @punctuation.delimiter - -;; ---------------------------------------------------------------------------- -;; Keywords, operators, includes - +; ---------------------------------------------------------------------------- +; Keywords, operators, includes [ "forall" "∀" -] @repeat +] @keyword.repeat -(pragma) @constant.macro +(pragma) @keyword.directive [ "if" @@ -60,24 +111,26 @@ "else" "case" "of" -] @conditional - -(exp_lambda_cases "\\" ("cases" @conditional)) +] @keyword.conditional [ "import" "qualified" "module" -] @include +] @keyword.import [ (operator) (constructor_operator) (type_operator) (tycon_arrow) - (qualified_module) ; grabs the `.` (dot), ex: import System.IO + (qualified_module) ; grabs the `.` (dot), ex: import System.IO + (qualified_type) + (qualified_variable) (all_names) (wildcard) + "." + ".." "=" "|" "::" @@ -89,7 +142,26 @@ "@" ] @operator -(module) @namespace +(module) @module + +((qualified_module + (module) @constructor) + . + (module)) + +(qualified_type + (module) @module) + +(qualified_variable + (module) @module) + +(import + (module) @module) + +(import + (module) @constructor + . + (module)) [ (where) @@ -97,6 +169,7 @@ "in" "class" "instance" + "pattern" "data" "newtype" "family" @@ -115,42 +188,445 @@ "infixr" ] @keyword +; ---------------------------------------------------------------------------- +; Functions and variables +(signature + name: (variable) @function) -;; ---------------------------------------------------------------------------- -;; Functions and variables +(function + name: (variable) @function) -(variable) @variable -(pat_wildcard) @variable +(function + name: (variable) @variable + rhs: + [ + (exp_literal) + (exp_apply + (exp_name + [ + (constructor) + (variable) + (qualified_variable) + ])) + (quasiquote) + ((exp_name) + . + (operator)) + ]) -(signature name: (variable) @type) +(function + name: (variable) @variable + rhs: + (exp_infix + [ + (exp_literal) + (exp_apply + (exp_name + [ + (constructor) + (variable) + (qualified_variable) + ])) + (quasiquote) + ((exp_name) + . + (operator)) + ])) + +; Consider signatures (and accompanying functions) +; with only one value on the rhs as variables +(signature + . + (variable) @variable + . + (_) .) + +((signature + . + (variable) @_name + . + (_) .) + . + (function + name: (variable) @variable) + (#eq? @_name @variable)) + +; but consider a type that involves 'IO' a function +(signature + name: (variable) @function + . + (type_apply + (type_name) @_type) + (#eq? @_type "IO")) + +((signature + name: (variable) @_name + . + (type_apply + (type_name) @_type) + (#eq? @_type "IO")) + . + (function + name: (variable) @function) + (#eq? @_name @function)) + +; functions with parameters +; + accompanying signatures (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))) +((signature) @function + . + (function + name: (variable) @function + patterns: (patterns))) +(function + name: (variable) @function + rhs: (exp_lambda)) + +; view patterns +(pat_view + (exp_name + [ + (variable) @function.call + (qualified_variable + (variable) @function.call) + ])) + +; consider infix functions as operators +(exp_infix + [ + (variable) @operator + (qualified_variable + (variable) @operator) + ]) + +; partially applied infix functions (sections) also get highlighted as operators +(exp_section_right + [ + (variable) @operator + (qualified_variable + (variable) @operator) + ]) + +(exp_section_left + [ + (variable) @operator + (qualified_variable + (variable) @operator) + ]) + +; function calls with an infix operator +; e.g. func <$> a <*> b +(exp_infix + (exp_name + [ + (variable) @function.call + (qualified_variable + ((module) @module + (variable) @function.call)) + ]) + . + (operator)) + +; infix operators applied to variables +((exp_name + (variable) @variable) + . + (operator)) + +((operator) + . + (exp_name + [ + (variable) @variable + (qualified_variable + (variable) @variable) + ])) + +; function calls with infix operators +((exp_name + [ + (variable) @function.call + (qualified_variable + (variable) @function.call) + ]) + . + (operator) @_op + (#any-of? @_op "$" "<$>" ">>=" "=<<")) + +; right hand side of infix operator +((exp_infix + [ + (operator) + (variable) + ] ; infix or `func` + . + (exp_name + [ + (variable) @function.call + (qualified_variable + (variable) @function.call) + ])) + . + (operator) @_op + (#any-of? @_op "$" "<$>" "=<<")) + +; function composition, arrows, monadic composition (lhs) +((exp_name + [ + (variable) @function + (qualified_variable + (variable) @function) + ]) + . + (operator) @_op + (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) + +; right hand side of infix operator +((exp_infix + [ + (operator) + (variable) + ] ; infix or `func` + . + (exp_name + [ + (variable) @function + (qualified_variable + (variable) @function) + ])) + . + (operator) @_op + (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) + +; function composition, arrows, monadic composition (rhs) +((operator) @_op + . + (exp_name + [ + (variable) @function + (qualified_variable + (variable) @function) + ]) + (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) + +; function defined in terms of a function composition +(function + name: (variable) @function + rhs: + (exp_infix + (_) + . + (operator) @_op + . + (_) + (#any-of? @_op "." ">>>" "***" ">=>" "<=<"))) + +(exp_apply + (exp_name + [ + (variable) @function.call + (qualified_variable + (variable) @function.call) + ])) + +; function compositions, in parentheses, applied +; lhs +(exp_apply + . + (exp_parens + (exp_infix + (exp_name + [ + (variable) @function.call + (qualified_variable + (variable) @function.call) + ]) + . + (operator)))) + +; rhs +(exp_apply + . + (exp_parens + (exp_infix + (operator) + . + (exp_name + [ + (variable) @function.call + (qualified_variable + (variable) @function.call) + ])))) + +; variables being passed to a function call +(exp_apply + (_)+ + . + (exp_name + [ + (variable) @variable + (qualified_variable + (variable) @variable) + ])) + +; Consider functions with only one value on the rhs +; as variables, e.g. x = Rec {} or x = foo +(function + . + (variable) @variable + . + [ + (exp_record) + (exp_name + [ + (variable) + (qualified_variable) + ]) + (exp_list) + (exp_tuple) + (exp_cond) + ] .) + +; main is always a function +; (this prevents `main = undefined` from being highlighted as a variable) +(function + name: (variable) @function + (#eq? @function "main")) + +; scoped function types (func :: a -> b) +(pat_typed + pattern: + (pat_name + (variable) @function) + type: (fun)) + +; signatures that have a function type +; + functions that follow them +(signature + (variable) @function + (fun)) + +((signature + (variable) @_type + (fun)) + . + (function + (variable) @function) + (#eq? @function @_type)) + +(signature + (variable) @function + (context + (fun))) + +((signature + (variable) @_type + (context + (fun))) + . + (function + (variable) @function) + (#eq? @function @_type)) + +((signature + (variable) @function + (forall + (context + (fun)))) + . + (function + (variable))) + +((signature + (variable) @_type + (forall + (context + (fun)))) + . + (function + (variable) @function) + (#eq? @function @_type)) + +; ---------------------------------------------------------------------------- +; Types +(type) @type -;; ---------------------------------------------------------------------------- -;; Types +(type_star) @type -(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.scm +((constructor) @boolean + (#any-of? @boolean "True" "False")) + +; otherwise (= True) +((variable) @boolean + (#eq? @boolean "otherwise")) + +; ---------------------------------------------------------------------------- +; Quasi-quotes +(quoter) @function.call + +(quasiquote + [ + (quoter) @_name + (_ + (variable) @_name) + ] + (#eq? @_name "qq") + (quasiquote_body) @string) + +(quasiquote + (_ + (variable) @_name) + (#eq? @_name "qq") + (quasiquote_body) @string) + +; namespaced quasi-quoter +(quasiquote + (_ + (module) @module + . + (variable) @function.call)) + +; Highlighting of quasiquote_body for other languages is handled by injections.scm +; ---------------------------------------------------------------------------- +; Exceptions/error handling +((variable) @keyword.exception + (#any-of? @keyword.exception "error" "undefined" "try" "tryJust" "tryAny" "catch" "catches" "catchJust" "handle" "handleJust" "throw" "throwIO" "throwTo" "throwError" "ioError" "mask" "mask_" "uninterruptibleMask" "uninterruptibleMask_" "bracket" "bracket_" "bracketOnErrorSource" "finally" "fail" "onException" "expectationFailure")) + +; ---------------------------------------------------------------------------- +; Debugging +((variable) @keyword.debug + (#any-of? @keyword.debug "trace" "traceId" "traceShow" "traceShowId" "traceWith" "traceShowWith" "traceStack" "traceIO" "traceM" "traceShowM" "traceEvent" "traceEventWith" "traceEventIO" "flushEventLog" "traceMarker" "traceMarkerIO")) + +; ---------------------------------------------------------------------------- +; Fields +(field + (variable) @variable.member) + +(pat_field + (variable) @variable.member) + +(exp_projection + field: (variable) @variable.member) + +(import_item + (type) + . + (import_con_names + (variable) @variable.member)) + +(exp_field + field: + [ + (variable) @variable.member + (qualified_variable + (variable) @variable.member) + ]) diff --git a/crates/zed/src/languages/haskell/injections.scm b/crates/zed/src/languages/haskell/injections.scm new file mode 100644 index 0000000000000000000000000000000000000000..237dbfa0ee4e8247035ef6ec673c0336ea02884c --- /dev/null +++ b/crates/zed/src/languages/haskell/injections.scm @@ -0,0 +1,89 @@ +;; 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. +; ----------------------------------------------------------------------------- +; General language injection +(quasiquote + (quoter) @injection.language + (quasiquote_body) @injection.content) + +((comment) @injection.content + (#set! injection.language "comment")) + +; ----------------------------------------------------------------------------- +; shakespeare library +; NOTE: doesn't support templating +; TODO: add once CoffeeScript parser is added +; ; CoffeeScript: Text.Coffee +; (quasiquote +; (quoter) @_name +; (#eq? @_name "coffee") +; ((quasiquote_body) @injection.content +; (#set! injection.language "coffeescript"))) +; CSS: Text.Cassius, Text.Lucius +(quasiquote + (quoter) @_name + (#any-of? @_name "cassius" "lucius") + (quasiquote_body) @injection.content + (#set! injection.language "css")) + +; HTML: Text.Hamlet +(quasiquote + (quoter) @_name + (#any-of? @_name "shamlet" "xshamlet" "hamlet" "xhamlet" "ihamlet") + (quasiquote_body) @injection.content + (#set! injection.language "html")) + +; JS: Text.Julius +(quasiquote + (quoter) @_name + (#any-of? @_name "js" "julius") + (quasiquote_body) @injection.content + (#set! injection.language "javascript")) + +; TS: Text.TypeScript +(quasiquote + (quoter) @_name + (#any-of? @_name "tsc" "tscJSX") + (quasiquote_body) @injection.content + (#set! injection.language "typescript")) + +; ----------------------------------------------------------------------------- +; HSX +(quasiquote + (quoter) @_name + (#eq? @_name "hsx") + (quasiquote_body) @injection.content + (#set! injection.language "html")) + +; ----------------------------------------------------------------------------- +; Inline JSON from aeson +(quasiquote + (quoter) @_name + (#eq? @_name "aesonQQ") + (quasiquote_body) @injection.content + (#set! injection.language "json")) + +; ----------------------------------------------------------------------------- +; SQL +; postgresql-simple +(quasiquote + (quoter) @injection.language + (#eq? @injection.language "sql") + (quasiquote_body) @injection.content) + +(quasiquote + (quoter) @_name + (#any-of? @_name "persistUpperCase" "persistLowerCase" "persistWith") + (quasiquote_body) @injection.content + (#set! injection.language "haskell_persistent")) From ee750e102d346550de64293604f6dd0d1d8de9d4 Mon Sep 17 00:00:00 2001 From: Lei <45155667+leifu1128@users.noreply.github.com> Date: Sat, 27 Jan 2024 00:55:13 +0800 Subject: [PATCH 03/10] implement hls adapter --- Cargo.lock | 21 +++++ Cargo.toml | 2 +- crates/zed/src/languages.rs | 6 +- crates/zed/src/languages/haskell.rs | 134 ++++++++++++++++++++++++++++ 4 files changed, 161 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fa06b9bd745816c9aca3f8de098d1543fbcbe17b..36ca6d70920cfe0fba4c1880eac68a80b716379a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,6 +363,7 @@ dependencies = [ "futures-io", "memchr", "pin-project-lite 0.2.13", + "xz2", ] [[package]] @@ -4081,6 +4082,17 @@ dependencies = [ "url", ] +[[package]] +name = "lzma-sys" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27" +dependencies = [ + "cc", + "libc", + "pkg-config", +] + [[package]] name = "mach2" version = "0.4.1" @@ -9609,6 +9621,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" +[[package]] +name = "xz2" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2" +dependencies = [ + "lzma-sys", +] + [[package]] name = "yansi" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index e01f24f727f29605dcd30511196058458363da6b..faac957d56f3b06360f1437c01bcee0f828b4d51 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,7 +92,7 @@ resolver = "2" [workspace.dependencies] anyhow = { version = "1.0.57" } async-trait = { version = "0.1" } -async-compression = { version = "0.4", features = ["gzip", "futures-io"] } +async-compression = { version = "0.4", features = ["gzip", "xz", "futures-io"] } chrono = { version = "0.4", features = ["serde"] } ctor = "0.2.6" derive_more = { version = "0.99.17" } diff --git a/crates/zed/src/languages.rs b/crates/zed/src/languages.rs index ef0cc1b146d60663640ddd72c8e731555e972558..a78f22dfc3da6b757cef7a68ea233ad71b7930ec 100644 --- a/crates/zed/src/languages.rs +++ b/crates/zed/src/languages.rs @@ -202,7 +202,11 @@ pub fn init( ); } } - language("haskell", tree_sitter_haskell::language(), vec![]); + language( + "haskell", + tree_sitter_haskell::language(), + vec![Arc::new(haskell::HaskellLspAdapter)], + ); language( "html", tree_sitter_html::language(), diff --git a/crates/zed/src/languages/haskell.rs b/crates/zed/src/languages/haskell.rs index 8b137891791fe96927ad78e64b0aad7bded08bdc..56699f161803475ef4736193f012cc451804cc0b 100644 --- a/crates/zed/src/languages/haskell.rs +++ b/crates/zed/src/languages/haskell.rs @@ -1 +1,135 @@ +use std::env::consts::ARCH; +use std::{any::Any, path::PathBuf}; +use anyhow::{anyhow, Context, Result}; +use async_compression::futures::bufread::XzDecoder; +use async_tar::Archive; +use async_trait::async_trait; +use futures::{io::BufReader, StreamExt}; +use smol::fs; + +use language::{LanguageServerName, LspAdapter, LspAdapterDelegate}; +use lsp::LanguageServerBinary; +use util::async_maybe; +use util::github::latest_github_release; +use util::{github::GitHubLspBinaryVersion, ResultExt}; + +pub struct HaskellLspAdapter; + +#[async_trait] +impl LspAdapter for HaskellLspAdapter { + fn name(&self) -> LanguageServerName { + LanguageServerName("haskell-language-server".into()) + } + + fn short_name(&self) -> &'static str { + "hls" + } + + async fn fetch_latest_server_version( + &self, + delegate: &dyn LspAdapterDelegate, + ) -> Result> { + // TODO: Release version should be matched against GHC version + let release = latest_github_release( + "haskell/haskell-language-server", + false, + delegate.http_client(), + ) + .await?; + let asset_name = format!( + "haskell-language-server-{}-{}-apple-darwin.tar.xz", + release.name, ARCH + ); + let asset = release + .assets + .iter() + .find(|asset| asset.name == asset_name) + .ok_or_else(|| anyhow!("no asset found matching {:?}", asset_name))?; + let version = GitHubLspBinaryVersion { + name: release.name, + url: asset.browser_download_url.clone(), + }; + Ok(Box::new(version) as Box<_>) + } + + async fn fetch_server_binary( + &self, + version: Box, + container_dir: PathBuf, + delegate: &dyn LspAdapterDelegate, + ) -> Result { + let version = version.downcast::().unwrap(); + let destination_path = + container_dir.join(format!("haskell-language-server-{}", version.name)); + if fs::metadata(&destination_path).await.is_err() { + let mut response = delegate + .http_client() + .get(&version.url, Default::default(), true) + .await + .context("error downloading release")?; + let decompressed_bytes = XzDecoder::new(BufReader::new(response.body_mut())); + let archive = Archive::new(decompressed_bytes); + archive.unpack(&container_dir).await?; + } + let binary_path = destination_path.join("bin/haskell-language-server-wrapper"); + fs::set_permissions( + &binary_path, + ::from_mode(0o755), + ) + .await?; + Ok(LanguageServerBinary { + path: binary_path, + arguments: vec!["--lsp".into()], + }) + } + + async fn cached_server_binary( + &self, + container_dir: PathBuf, + _: &dyn LspAdapterDelegate, + ) -> Option { + get_cached_server_binary(container_dir).await + } + + async fn installation_test_binary( + &self, + container_dir: PathBuf, + ) -> Option { + get_cached_server_binary(container_dir) + .await + .map(|mut binary| { + binary.arguments = vec!["--help".into()]; + binary + }) + } +} + +async fn get_cached_server_binary(container_dir: PathBuf) -> Option { + async_maybe!({ + let mut last_binary_path = None; + let mut entries = fs::read_dir(&container_dir).await?; + while let Some(entry) = entries.next().await { + let entry = entry?; + if entry.file_type().await?.is_file() + && entry + .file_name() + .to_str() + .map_or(false, |name| name == "haskell-language-server-wrapper") + { + last_binary_path = Some(entry.path()); + } + } + + if let Some(path) = last_binary_path { + Ok(LanguageServerBinary { + path, + arguments: Vec::new(), + }) + } else { + Err(anyhow!("no cached binary")) + } + }) + .await + .log_err() +} From 58a9f513610826a5d5ba8b258e515e17a54e07b6 Mon Sep 17 00:00:00 2001 From: Pseudomata Date: Fri, 26 Jan 2024 12:28:52 -0500 Subject: [PATCH 04/10] Comment out haskell_persistent and sql injections - the haskell_persistent grammar has not been added, see https://github.com/nvim-treesitter/nvim-treesitter/tree/master/queries/haskell_persistent and https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent - the sql grammar has not been added either --- .../zed/src/languages/haskell/injections.scm | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/crates/zed/src/languages/haskell/injections.scm b/crates/zed/src/languages/haskell/injections.scm index 237dbfa0ee4e8247035ef6ec673c0336ea02884c..c042b8e9b57f02e0d80591cc53948e63f5cf6b54 100644 --- a/crates/zed/src/languages/haskell/injections.scm +++ b/crates/zed/src/languages/haskell/injections.scm @@ -75,15 +75,23 @@ (#set! injection.language "json")) ; ----------------------------------------------------------------------------- +; NOTE: Commented out because the "sql" grammar is not currently added to Zed. +; ; SQL ; postgresql-simple -(quasiquote - (quoter) @injection.language - (#eq? @injection.language "sql") - (quasiquote_body) @injection.content) +; +; (quasiquote +; (quoter) @injection.language +; (#eq? @injection.language "sql") +; (quasiquote_body) @injection.content) -(quasiquote - (quoter) @_name - (#any-of? @_name "persistUpperCase" "persistLowerCase" "persistWith") - (quasiquote_body) @injection.content - (#set! injection.language "haskell_persistent")) +; ----------------------------------------------------------------------------- +; NOTE: Commented out because the "haskell_persistent" grammar is not currently added to Zed. +; See: https://github.com/nvim-treesitter/nvim-treesitter/tree/master/queries/haskell_persistent +; https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent +; +; (quasiquote +; (quoter) @_name +; (#any-of? @_name "persistUpperCase" "persistLowerCase" "persistWith") +; (quasiquote_body) @injection.content +; (#set! injection.language "haskell_persistent")) From 6e25b0a71884392b1e97d5da85b1fd83fda3a2be Mon Sep 17 00:00:00 2001 From: Pseudomata Date: Fri, 26 Jan 2024 15:04:22 -0500 Subject: [PATCH 05/10] Switch to `tree-sitter-haskell` grammar --- crates/zed/src/languages/haskell/folds.scm | 18 - .../zed/src/languages/haskell/highlights.scm | 564 ++---------------- .../zed/src/languages/haskell/injections.scm | 47 +- 3 files changed, 50 insertions(+), 579 deletions(-) delete mode 100644 crates/zed/src/languages/haskell/folds.scm diff --git a/crates/zed/src/languages/haskell/folds.scm b/crates/zed/src/languages/haskell/folds.scm deleted file mode 100644 index e743ecf52cc9981ed55eec9eff72be829a32f147..0000000000000000000000000000000000000000 --- a/crates/zed/src/languages/haskell/folds.scm +++ /dev/null @@ -1,18 +0,0 @@ -;; 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. -[ - (exp_apply) - (exp_do) - (function) -] @fold diff --git a/crates/zed/src/languages/haskell/highlights.scm b/crates/zed/src/languages/haskell/highlights.scm index a81089d419276d282c34765d47f6df1e4d75c6df..aca744f5cd50d6da088f0d647e9c3020dcbbe9b7 100644 --- a/crates/zed/src/languages/haskell/highlights.scm +++ b/crates/zed/src/languages/haskell/highlights.scm @@ -11,77 +11,24 @@ ;; 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. -; ---------------------------------------------------------------------------- -; Parameters and variables -; NOTE: These are at the top, so that they have low priority, -; and don't override destructured parameters -(variable) @variable - -(pat_wildcard) @variable - -(function - patterns: - (patterns - (_) @variable.parameter)) - -(exp_lambda - (_)+ @variable.parameter - "->") -(function - infix: - (infix - lhs: (_) @variable.parameter)) - -(function - infix: - (infix - rhs: (_) @variable.parameter)) +;; ---------------------------------------------------------------------------- +;; Literals and comments -; ---------------------------------------------------------------------------- -; Literals and comments (integer) @number - (exp_negation) @number - -(exp_literal - (float)) @number.float - +(exp_literal (float)) @float (char) @character - (string) @string -(con_unit) @string.special.symbol ; unit, as in () +(con_unit) @symbol ; unit, as in () (comment) @comment -; FIXME: The below documentation comment queries are inefficient -; and need to be anchored, using something like -; ((comment) @_first . (comment)+ @comment.documentation) -; once https://github.com/neovim/neovim/pull/24738 has been merged. -; -; ((comment) @comment.documentation -; (#lua-match? @comment.documentation "^-- |")) -; -; ((comment) @_first @comment.documentation -; (comment) @comment.documentation -; (#lua-match? @_first "^-- |")) -; -; ((comment) @comment.documentation -; (#lua-match? @comment.documentation "^-- %^")) -; -; ((comment) @_first @comment.documentation -; (comment) @comment.documentation -; (#lua-match? @_first "^-- %^")) -; -; ((comment) @comment.documentation -; (#lua-match? @comment.documentation "^{-")) -; -; ((comment) @_first @comment.documentation -; (comment) @comment.documentation -; (#lua-match? @_first "^{-")) -; ---------------------------------------------------------------------------- -; Punctuation + +;; ---------------------------------------------------------------------------- +;; Punctuation + [ "(" ")" @@ -96,14 +43,16 @@ ";" ] @punctuation.delimiter -; ---------------------------------------------------------------------------- -; Keywords, operators, includes + +;; ---------------------------------------------------------------------------- +;; Keywords, operators, includes + [ "forall" "∀" -] @keyword.repeat +] @keyword -(pragma) @keyword.directive +(pragma) @constant [ "if" @@ -111,26 +60,24 @@ "else" "case" "of" -] @keyword.conditional +] @keyword + +(exp_lambda_cases "\\" ("cases" @variant)) [ "import" "qualified" "module" -] @keyword.import +] @keyword [ (operator) (constructor_operator) (type_operator) (tycon_arrow) - (qualified_module) ; grabs the `.` (dot), ex: import System.IO - (qualified_type) - (qualified_variable) + (qualified_module) ; grabs the `.` (dot), ex: import System.IO (all_names) (wildcard) - "." - ".." "=" "|" "::" @@ -142,26 +89,7 @@ "@" ] @operator -(module) @module - -((qualified_module - (module) @constructor) - . - (module)) - -(qualified_type - (module) @module) - -(qualified_variable - (module) @module) - -(import - (module) @module) - -(import - (module) @constructor - . - (module)) +(module) @title [ (where) @@ -169,7 +97,6 @@ "in" "class" "instance" - "pattern" "data" "newtype" "family" @@ -188,445 +115,42 @@ "infixr" ] @keyword -; ---------------------------------------------------------------------------- -; Functions and variables -(signature - name: (variable) @function) -(function - name: (variable) @function) +;; ---------------------------------------------------------------------------- +;; Functions and variables -(function - name: (variable) @variable - rhs: - [ - (exp_literal) - (exp_apply - (exp_name - [ - (constructor) - (variable) - (qualified_variable) - ])) - (quasiquote) - ((exp_name) - . - (operator)) - ]) +(variable) @variable +(pat_wildcard) @variable -(function - name: (variable) @variable - rhs: - (exp_infix - [ - (exp_literal) - (exp_apply - (exp_name - [ - (constructor) - (variable) - (qualified_variable) - ])) - (quasiquote) - ((exp_name) - . - (operator)) - ])) - -; Consider signatures (and accompanying functions) -; with only one value on the rhs as variables -(signature - . - (variable) @variable - . - (_) .) - -((signature - . - (variable) @_name - . - (_) .) - . - (function - name: (variable) @variable) - (#eq? @_name @variable)) - -; but consider a type that involves 'IO' a function -(signature - name: (variable) @function - . - (type_apply - (type_name) @_type) - (#eq? @_type "IO")) - -((signature - name: (variable) @_name - . - (type_apply - (type_name) @_type) - (#eq? @_type "IO")) - . - (function - name: (variable) @function) - (#eq? @_name @function)) - -; functions with parameters -; + accompanying signatures +(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)) -((signature) @function - . - (function - name: (variable) @function - patterns: (patterns))) +(exp_infix (variable) @operator) ; consider infix functions as operators -(function - name: (variable) @function - rhs: (exp_lambda)) - -; view patterns -(pat_view - (exp_name - [ - (variable) @function.call - (qualified_variable - (variable) @function.call) - ])) - -; consider infix functions as operators -(exp_infix - [ - (variable) @operator - (qualified_variable - (variable) @operator) - ]) - -; partially applied infix functions (sections) also get highlighted as operators -(exp_section_right - [ - (variable) @operator - (qualified_variable - (variable) @operator) - ]) - -(exp_section_left - [ - (variable) @operator - (qualified_variable - (variable) @operator) - ]) - -; function calls with an infix operator -; e.g. func <$> a <*> b -(exp_infix - (exp_name - [ - (variable) @function.call - (qualified_variable - ((module) @module - (variable) @function.call)) - ]) - . - (operator)) - -; infix operators applied to variables -((exp_name - (variable) @variable) - . - (operator)) - -((operator) - . - (exp_name - [ - (variable) @variable - (qualified_variable - (variable) @variable) - ])) - -; function calls with infix operators -((exp_name - [ - (variable) @function.call - (qualified_variable - (variable) @function.call) - ]) - . - (operator) @_op - (#any-of? @_op "$" "<$>" ">>=" "=<<")) - -; right hand side of infix operator -((exp_infix - [ - (operator) - (variable) - ] ; infix or `func` - . - (exp_name - [ - (variable) @function.call - (qualified_variable - (variable) @function.call) - ])) - . - (operator) @_op - (#any-of? @_op "$" "<$>" "=<<")) - -; function composition, arrows, monadic composition (lhs) -((exp_name - [ - (variable) @function - (qualified_variable - (variable) @function) - ]) - . - (operator) @_op - (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) - -; right hand side of infix operator -((exp_infix - [ - (operator) - (variable) - ] ; infix or `func` - . - (exp_name - [ - (variable) @function - (qualified_variable - (variable) @function) - ])) - . - (operator) @_op - (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) - -; function composition, arrows, monadic composition (rhs) -((operator) @_op - . - (exp_name - [ - (variable) @function - (qualified_variable - (variable) @function) - ]) - (#any-of? @_op "." ">>>" "***" ">=>" "<=<")) - -; function defined in terms of a function composition -(function - name: (variable) @function - rhs: - (exp_infix - (_) - . - (operator) @_op - . - (_) - (#any-of? @_op "." ">>>" "***" ">=>" "<=<"))) - -(exp_apply - (exp_name - [ - (variable) @function.call - (qualified_variable - (variable) @function.call) - ])) - -; function compositions, in parentheses, applied -; lhs -(exp_apply - . - (exp_parens - (exp_infix - (exp_name - [ - (variable) @function.call - (qualified_variable - (variable) @function.call) - ]) - . - (operator)))) - -; rhs -(exp_apply - . - (exp_parens - (exp_infix - (operator) - . - (exp_name - [ - (variable) @function.call - (qualified_variable - (variable) @function.call) - ])))) - -; variables being passed to a function call -(exp_apply - (_)+ - . - (exp_name - [ - (variable) @variable - (qualified_variable - (variable) @variable) - ])) - -; Consider functions with only one value on the rhs -; as variables, e.g. x = Rec {} or x = foo -(function - . - (variable) @variable - . - [ - (exp_record) - (exp_name - [ - (variable) - (qualified_variable) - ]) - (exp_list) - (exp_tuple) - (exp_cond) - ] .) - -; main is always a function -; (this prevents `main = undefined` from being highlighted as a variable) -(function - name: (variable) @function - (#eq? @function "main")) - -; scoped function types (func :: a -> b) -(pat_typed - pattern: - (pat_name - (variable) @function) - type: (fun)) - -; signatures that have a function type -; + functions that follow them -(signature - (variable) @function - (fun)) - -((signature - (variable) @_type - (fun)) - . - (function - (variable) @function) - (#eq? @function @_type)) - -(signature - (variable) @function - (context - (fun))) - -((signature - (variable) @_type - (context - (fun))) - . - (function - (variable) @function) - (#eq? @function @_type)) - -((signature - (variable) @function - (forall - (context - (fun)))) - . - (function - (variable))) - -((signature - (variable) @_type - (forall - (context - (fun)))) - . - (function - (variable) @function) - (#eq? @function @_type)) - -; ---------------------------------------------------------------------------- -; Types -(type) @type +(exp_infix (exp_name) @function (#set! "priority" 101)) +(exp_apply . (exp_name (variable) @function)) +(exp_apply . (exp_name (qualified_variable (variable) @function))) -(type_star) @type +;; ---------------------------------------------------------------------------- +;; Types + +(type) @type (type_variable) @type (constructor) @constructor ; True or False -((constructor) @boolean - (#any-of? @boolean "True" "False")) - -; otherwise (= True) -((variable) @boolean - (#eq? @boolean "otherwise")) - -; ---------------------------------------------------------------------------- -; Quasi-quotes -(quoter) @function.call - -(quasiquote - [ - (quoter) @_name - (_ - (variable) @_name) - ] - (#eq? @_name "qq") - (quasiquote_body) @string) - -(quasiquote - (_ - (variable) @_name) - (#eq? @_name "qq") - (quasiquote_body) @string) - -; namespaced quasi-quoter -(quasiquote - (_ - (module) @module - . - (variable) @function.call)) - -; Highlighting of quasiquote_body for other languages is handled by injections.scm -; ---------------------------------------------------------------------------- -; Exceptions/error handling -((variable) @keyword.exception - (#any-of? @keyword.exception "error" "undefined" "try" "tryJust" "tryAny" "catch" "catches" "catchJust" "handle" "handleJust" "throw" "throwIO" "throwTo" "throwError" "ioError" "mask" "mask_" "uninterruptibleMask" "uninterruptibleMask_" "bracket" "bracket_" "bracketOnErrorSource" "finally" "fail" "onException" "expectationFailure")) - -; ---------------------------------------------------------------------------- -; Debugging -((variable) @keyword.debug - (#any-of? @keyword.debug "trace" "traceId" "traceShow" "traceShowId" "traceWith" "traceShowWith" "traceStack" "traceIO" "traceM" "traceShowM" "traceEvent" "traceEventWith" "traceEventIO" "flushEventLog" "traceMarker" "traceMarkerIO")) - -; ---------------------------------------------------------------------------- -; Fields -(field - (variable) @variable.member) - -(pat_field - (variable) @variable.member) - -(exp_projection - field: (variable) @variable.member) - -(import_item - (type) - . - (import_con_names - (variable) @variable.member)) - -(exp_field - field: - [ - (variable) @variable.member - (qualified_variable - (variable) @variable.member) - ]) +((constructor) @_bool (#match? @_bool "(True|False)")) @boolean + + +;; ---------------------------------------------------------------------------- +;; Quasi-quotes + +(quoter) @function +; Highlighting of quasiquote_body is handled by injections.scm diff --git a/crates/zed/src/languages/haskell/injections.scm b/crates/zed/src/languages/haskell/injections.scm index c042b8e9b57f02e0d80591cc53948e63f5cf6b54..e5e70a7c0b8153ce6fe3ea20585fa55654122f46 100644 --- a/crates/zed/src/languages/haskell/injections.scm +++ b/crates/zed/src/languages/haskell/injections.scm @@ -17,46 +17,33 @@ (quoter) @injection.language (quasiquote_body) @injection.content) -((comment) @injection.content - (#set! injection.language "comment")) - -; ----------------------------------------------------------------------------- -; shakespeare library -; NOTE: doesn't support templating -; TODO: add once CoffeeScript parser is added -; ; CoffeeScript: Text.Coffee -; (quasiquote -; (quoter) @_name -; (#eq? @_name "coffee") -; ((quasiquote_body) @injection.content -; (#set! injection.language "coffeescript"))) ; CSS: Text.Cassius, Text.Lucius (quasiquote (quoter) @_name (#any-of? @_name "cassius" "lucius") (quasiquote_body) @injection.content - (#set! injection.language "css")) + (#set! "language" "css")) ; HTML: Text.Hamlet (quasiquote (quoter) @_name (#any-of? @_name "shamlet" "xshamlet" "hamlet" "xhamlet" "ihamlet") (quasiquote_body) @injection.content - (#set! injection.language "html")) + (#set! "language" "html")) ; JS: Text.Julius (quasiquote (quoter) @_name (#any-of? @_name "js" "julius") (quasiquote_body) @injection.content - (#set! injection.language "javascript")) + (#set! "language" "javascript")) ; TS: Text.TypeScript (quasiquote (quoter) @_name (#any-of? @_name "tsc" "tscJSX") (quasiquote_body) @injection.content - (#set! injection.language "typescript")) + (#set! "language" "typescript")) ; ----------------------------------------------------------------------------- ; HSX @@ -64,7 +51,7 @@ (quoter) @_name (#eq? @_name "hsx") (quasiquote_body) @injection.content - (#set! injection.language "html")) + (#set! "language" "html")) ; ----------------------------------------------------------------------------- ; Inline JSON from aeson @@ -72,26 +59,4 @@ (quoter) @_name (#eq? @_name "aesonQQ") (quasiquote_body) @injection.content - (#set! injection.language "json")) - -; ----------------------------------------------------------------------------- -; NOTE: Commented out because the "sql" grammar is not currently added to Zed. -; -; SQL -; postgresql-simple -; -; (quasiquote -; (quoter) @injection.language -; (#eq? @injection.language "sql") -; (quasiquote_body) @injection.content) - -; ----------------------------------------------------------------------------- -; NOTE: Commented out because the "haskell_persistent" grammar is not currently added to Zed. -; See: https://github.com/nvim-treesitter/nvim-treesitter/tree/master/queries/haskell_persistent -; https://github.com/MercuryTechnologies/tree-sitter-haskell-persistent -; -; (quasiquote -; (quoter) @_name -; (#any-of? @_name "persistUpperCase" "persistLowerCase" "persistWith") -; (quasiquote_body) @injection.content -; (#set! injection.language "haskell_persistent")) + (#set! "language" "json")) From 0576214be77e6f6bcfedd9a4646f0b0cd1b1b797 Mon Sep 17 00:00:00 2001 From: Pseudomata Date: Fri, 26 Jan 2024 15:35:08 -0500 Subject: [PATCH 06/10] Remove Haskell `injections.scm` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since tree-sitter-haskell does not support injections we don’t want to mix with nvim-treesitter --- .../zed/src/languages/haskell/injections.scm | 62 ------------------- 1 file changed, 62 deletions(-) delete mode 100644 crates/zed/src/languages/haskell/injections.scm diff --git a/crates/zed/src/languages/haskell/injections.scm b/crates/zed/src/languages/haskell/injections.scm deleted file mode 100644 index e5e70a7c0b8153ce6fe3ea20585fa55654122f46..0000000000000000000000000000000000000000 --- a/crates/zed/src/languages/haskell/injections.scm +++ /dev/null @@ -1,62 +0,0 @@ -;; 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. -; ----------------------------------------------------------------------------- -; General language injection -(quasiquote - (quoter) @injection.language - (quasiquote_body) @injection.content) - -; CSS: Text.Cassius, Text.Lucius -(quasiquote - (quoter) @_name - (#any-of? @_name "cassius" "lucius") - (quasiquote_body) @injection.content - (#set! "language" "css")) - -; HTML: Text.Hamlet -(quasiquote - (quoter) @_name - (#any-of? @_name "shamlet" "xshamlet" "hamlet" "xhamlet" "ihamlet") - (quasiquote_body) @injection.content - (#set! "language" "html")) - -; JS: Text.Julius -(quasiquote - (quoter) @_name - (#any-of? @_name "js" "julius") - (quasiquote_body) @injection.content - (#set! "language" "javascript")) - -; TS: Text.TypeScript -(quasiquote - (quoter) @_name - (#any-of? @_name "tsc" "tscJSX") - (quasiquote_body) @injection.content - (#set! "language" "typescript")) - -; ----------------------------------------------------------------------------- -; HSX -(quasiquote - (quoter) @_name - (#eq? @_name "hsx") - (quasiquote_body) @injection.content - (#set! "language" "html")) - -; ----------------------------------------------------------------------------- -; Inline JSON from aeson -(quasiquote - (quoter) @_name - (#eq? @_name "aesonQQ") - (quasiquote_body) @injection.content - (#set! "language" "json")) From faf77985776bed301c7b9a62bdaef3e6a67c10a3 Mon Sep 17 00:00:00 2001 From: Pseudomata Date: Fri, 26 Jan 2024 15:41:11 -0500 Subject: [PATCH 07/10] Use same arguments for LSP binary in `haskell.rs` --- crates/zed/src/languages/haskell.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/zed/src/languages/haskell.rs b/crates/zed/src/languages/haskell.rs index 56699f161803475ef4736193f012cc451804cc0b..832907e265c4c7764c4c493afca877c333d72101 100644 --- a/crates/zed/src/languages/haskell.rs +++ b/crates/zed/src/languages/haskell.rs @@ -1,4 +1,5 @@ use std::env::consts::ARCH; +use std::ffi::OsString; use std::{any::Any, path::PathBuf}; use anyhow::{anyhow, Context, Result}; @@ -14,6 +15,10 @@ use util::async_maybe; use util::github::latest_github_release; use util::{github::GitHubLspBinaryVersion, ResultExt}; +fn server_binary_arguments() -> Vec { + vec!["--lsp".into()] +} + pub struct HaskellLspAdapter; #[async_trait] @@ -80,7 +85,7 @@ impl LspAdapter for HaskellLspAdapter { .await?; Ok(LanguageServerBinary { path: binary_path, - arguments: vec!["--lsp".into()], + arguments: server_binary_arguments(), }) } @@ -124,7 +129,7 @@ async fn get_cached_server_binary(container_dir: PathBuf) -> Option Date: Fri, 26 Jan 2024 19:02:31 -0500 Subject: [PATCH 08/10] Ability to manually configure LSP for Haskell Allow users who have HLS installed using `ghcup` to manually provide the path for the Haskell language server --- assets/settings/default.json | 4 + crates/zed/src/languages.rs | 23 +++- crates/zed/src/languages/haskell.rs | 174 +++++++++++----------------- 3 files changed, 89 insertions(+), 112 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index 01165c9e312a30192cb2e9a2206bf28a622df03a..dda8b8af678662672613ed9f7fde983d8009dbbc 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -451,6 +451,10 @@ "deno": { "enable": false }, + // Settings specific to the Haskell integration + "haskell": { + "lsp": "none" + }, // Different settings for specific languages. "languages": { "Plain Text": { diff --git a/crates/zed/src/languages.rs b/crates/zed/src/languages.rs index a78f22dfc3da6b757cef7a68ea233ad71b7930ec..56f9d17f1981111212a08a927aa7debfbe3bafcb 100644 --- a/crates/zed/src/languages.rs +++ b/crates/zed/src/languages.rs @@ -7,7 +7,7 @@ use settings::Settings; use std::{borrow::Cow, str, sync::Arc}; use util::{asset_str, paths::PLUGINS_DIR}; -use self::{deno::DenoSettings, elixir::ElixirSettings}; +use self::{deno::DenoSettings, elixir::ElixirSettings, haskell::HaskellSettings}; mod c; mod css; @@ -55,6 +55,7 @@ pub fn init( ) { ElixirSettings::register(cx); DenoSettings::register(cx); + HaskellSettings::register(cx); let language = |name, grammar, adapters| { languages.register(name, load_config(name), grammar, adapters, load_queries) @@ -202,11 +203,21 @@ pub fn init( ); } } - language( - "haskell", - tree_sitter_haskell::language(), - vec![Arc::new(haskell::HaskellLspAdapter)], - ); + + match &HaskellSettings::get(None, cx).lsp { + haskell::HaskellLspSetting::None => { + language("haskell", tree_sitter_haskell::language(), vec![]) + } + haskell::HaskellLspSetting::Local { path, arguments } => language( + "haskell", + tree_sitter_haskell::language(), + vec![Arc::new(haskell::LocalLspAdapter { + path: path.clone(), + arguments: arguments.clone(), + })], + ), + } + language( "html", tree_sitter_html::language(), diff --git a/crates/zed/src/languages/haskell.rs b/crates/zed/src/languages/haskell.rs index 832907e265c4c7764c4c493afca877c333d72101..14a8ba798ebb8fc45af1aee4a291a545d2aff0e2 100644 --- a/crates/zed/src/languages/haskell.rs +++ b/crates/zed/src/languages/haskell.rs @@ -1,140 +1,102 @@ -use std::env::consts::ARCH; -use std::ffi::OsString; -use std::{any::Any, path::PathBuf}; - -use anyhow::{anyhow, Context, Result}; -use async_compression::futures::bufread::XzDecoder; -use async_tar::Archive; +use anyhow::Result; use async_trait::async_trait; -use futures::{io::BufReader, StreamExt}; -use smol::fs; - use language::{LanguageServerName, LspAdapter, LspAdapterDelegate}; use lsp::LanguageServerBinary; -use util::async_maybe; -use util::github::latest_github_release; -use util::{github::GitHubLspBinaryVersion, ResultExt}; +use schemars::JsonSchema; +use serde_derive::{Deserialize, Serialize}; +use settings::Settings; +use std::ops::Deref; +use std::{any::Any, path::PathBuf}; + +#[derive(Clone, Serialize, Deserialize, JsonSchema)] +pub struct HaskellSettings { + pub lsp: HaskellLspSetting, +} -fn server_binary_arguments() -> Vec { - vec!["--lsp".into()] +#[derive(Clone, Serialize, Deserialize, JsonSchema)] +#[serde(rename_all = "snake_case")] +pub enum HaskellLspSetting { + None, + Local { + path: String, + arguments: Vec, + }, } -pub struct HaskellLspAdapter; +#[derive(Clone, Serialize, Default, Deserialize, JsonSchema)] +pub struct HaskellSettingsContent { + lsp: Option, +} + +impl Settings for HaskellSettings { + const KEY: Option<&'static str> = Some("haskell"); + + type FileContent = HaskellSettingsContent; + + fn load( + default_value: &Self::FileContent, + user_values: &[&Self::FileContent], + _: &mut gpui::AppContext, + ) -> Result + where + Self: Sized, + { + Self::load_via_json_merge(default_value, user_values) + } +} + +pub struct LocalLspAdapter { + pub path: String, + pub arguments: Vec, +} #[async_trait] -impl LspAdapter for HaskellLspAdapter { +impl LspAdapter for LocalLspAdapter { fn name(&self) -> LanguageServerName { - LanguageServerName("haskell-language-server".into()) + LanguageServerName("local-hls".into()) } fn short_name(&self) -> &'static str { - "hls" + "local-hls" } async fn fetch_latest_server_version( &self, - delegate: &dyn LspAdapterDelegate, + _: &dyn LspAdapterDelegate, ) -> Result> { - // TODO: Release version should be matched against GHC version - let release = latest_github_release( - "haskell/haskell-language-server", - false, - delegate.http_client(), - ) - .await?; - let asset_name = format!( - "haskell-language-server-{}-{}-apple-darwin.tar.xz", - release.name, ARCH - ); - let asset = release - .assets - .iter() - .find(|asset| asset.name == asset_name) - .ok_or_else(|| anyhow!("no asset found matching {:?}", asset_name))?; - let version = GitHubLspBinaryVersion { - name: release.name, - url: asset.browser_download_url.clone(), - }; - Ok(Box::new(version) as Box<_>) + Ok(Box::new(()) as Box<_>) } async fn fetch_server_binary( &self, - version: Box, - container_dir: PathBuf, - delegate: &dyn LspAdapterDelegate, + _: Box, + _: PathBuf, + _: &dyn LspAdapterDelegate, ) -> Result { - let version = version.downcast::().unwrap(); - let destination_path = - container_dir.join(format!("haskell-language-server-{}", version.name)); - if fs::metadata(&destination_path).await.is_err() { - let mut response = delegate - .http_client() - .get(&version.url, Default::default(), true) - .await - .context("error downloading release")?; - let decompressed_bytes = XzDecoder::new(BufReader::new(response.body_mut())); - let archive = Archive::new(decompressed_bytes); - archive.unpack(&container_dir).await?; - } - let binary_path = destination_path.join("bin/haskell-language-server-wrapper"); - fs::set_permissions( - &binary_path, - ::from_mode(0o755), - ) - .await?; + let path = shellexpand::full(&self.path)?; Ok(LanguageServerBinary { - path: binary_path, - arguments: server_binary_arguments(), + path: PathBuf::from(path.deref()), + arguments: self.arguments.iter().map(|arg| arg.into()).collect(), }) } async fn cached_server_binary( &self, - container_dir: PathBuf, + _: PathBuf, _: &dyn LspAdapterDelegate, ) -> Option { - get_cached_server_binary(container_dir).await + let path = shellexpand::full(&self.path).ok()?; + Some(LanguageServerBinary { + path: PathBuf::from(path.deref()), + arguments: self.arguments.iter().map(|arg| arg.into()).collect(), + }) } - async fn installation_test_binary( - &self, - container_dir: PathBuf, - ) -> Option { - get_cached_server_binary(container_dir) - .await - .map(|mut binary| { - binary.arguments = vec!["--help".into()]; - binary - }) + async fn installation_test_binary(&self, _: PathBuf) -> Option { + let path = shellexpand::full(&self.path).ok()?; + Some(LanguageServerBinary { + path: PathBuf::from(path.deref()), + arguments: self.arguments.iter().map(|arg| arg.into()).collect(), + }) } } - -async fn get_cached_server_binary(container_dir: PathBuf) -> Option { - async_maybe!({ - let mut last_binary_path = None; - let mut entries = fs::read_dir(&container_dir).await?; - while let Some(entry) = entries.next().await { - let entry = entry?; - if entry.file_type().await?.is_file() - && entry - .file_name() - .to_str() - .map_or(false, |name| name == "haskell-language-server-wrapper") - { - last_binary_path = Some(entry.path()); - } - } - - if let Some(path) = last_binary_path { - Ok(LanguageServerBinary { - path, - arguments: server_binary_arguments(), - }) - } else { - Err(anyhow!("no cached binary")) - } - }) - .await - .log_err() -} From 030ff0acf317efb93b73e1a3928fe6fd7f7f82af Mon Sep 17 00:00:00 2001 From: Pseudomata Date: Fri, 26 Jan 2024 20:19:36 -0500 Subject: [PATCH 09/10] Simplify Haskell LSP integration This change will work without any configuration and assume the user will install the Haskell Language Server using `ghcup` --- assets/settings/default.json | 4 -- crates/zed/src/languages.rs | 22 ++------ crates/zed/src/languages/haskell.rs | 85 +++++++---------------------- 3 files changed, 25 insertions(+), 86 deletions(-) diff --git a/assets/settings/default.json b/assets/settings/default.json index dda8b8af678662672613ed9f7fde983d8009dbbc..01165c9e312a30192cb2e9a2206bf28a622df03a 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -451,10 +451,6 @@ "deno": { "enable": false }, - // Settings specific to the Haskell integration - "haskell": { - "lsp": "none" - }, // Different settings for specific languages. "languages": { "Plain Text": { diff --git a/crates/zed/src/languages.rs b/crates/zed/src/languages.rs index 56f9d17f1981111212a08a927aa7debfbe3bafcb..0e14c4ab9a6cf432f260760385b3881150ee429b 100644 --- a/crates/zed/src/languages.rs +++ b/crates/zed/src/languages.rs @@ -7,7 +7,7 @@ use settings::Settings; use std::{borrow::Cow, str, sync::Arc}; use util::{asset_str, paths::PLUGINS_DIR}; -use self::{deno::DenoSettings, elixir::ElixirSettings, haskell::HaskellSettings}; +use self::{deno::DenoSettings, elixir::ElixirSettings}; mod c; mod css; @@ -55,7 +55,6 @@ pub fn init( ) { ElixirSettings::register(cx); DenoSettings::register(cx); - HaskellSettings::register(cx); let language = |name, grammar, adapters| { languages.register(name, load_config(name), grammar, adapters, load_queries) @@ -204,20 +203,11 @@ pub fn init( } } - match &HaskellSettings::get(None, cx).lsp { - haskell::HaskellLspSetting::None => { - language("haskell", tree_sitter_haskell::language(), vec![]) - } - haskell::HaskellLspSetting::Local { path, arguments } => language( - "haskell", - tree_sitter_haskell::language(), - vec![Arc::new(haskell::LocalLspAdapter { - path: path.clone(), - arguments: arguments.clone(), - })], - ), - } - + language( + "haskell", + tree_sitter_haskell::language(), + vec![Arc::new(haskell::HaskellLanguageServer {})], + ); language( "html", tree_sitter_html::language(), diff --git a/crates/zed/src/languages/haskell.rs b/crates/zed/src/languages/haskell.rs index 14a8ba798ebb8fc45af1aee4a291a545d2aff0e2..6667267702d23239beb27b79717d3fb7db8b76ee 100644 --- a/crates/zed/src/languages/haskell.rs +++ b/crates/zed/src/languages/haskell.rs @@ -1,83 +1,37 @@ -use anyhow::Result; +use anyhow::{anyhow, Result}; use async_trait::async_trait; use language::{LanguageServerName, LspAdapter, LspAdapterDelegate}; use lsp::LanguageServerBinary; -use schemars::JsonSchema; -use serde_derive::{Deserialize, Serialize}; -use settings::Settings; -use std::ops::Deref; use std::{any::Any, path::PathBuf}; -#[derive(Clone, Serialize, Deserialize, JsonSchema)] -pub struct HaskellSettings { - pub lsp: HaskellLspSetting, -} - -#[derive(Clone, Serialize, Deserialize, JsonSchema)] -#[serde(rename_all = "snake_case")] -pub enum HaskellLspSetting { - None, - Local { - path: String, - arguments: Vec, - }, -} - -#[derive(Clone, Serialize, Default, Deserialize, JsonSchema)] -pub struct HaskellSettingsContent { - lsp: Option, -} - -impl Settings for HaskellSettings { - const KEY: Option<&'static str> = Some("haskell"); - - type FileContent = HaskellSettingsContent; - - fn load( - default_value: &Self::FileContent, - user_values: &[&Self::FileContent], - _: &mut gpui::AppContext, - ) -> Result - where - Self: Sized, - { - Self::load_via_json_merge(default_value, user_values) - } -} - -pub struct LocalLspAdapter { - pub path: String, - pub arguments: Vec, -} +pub struct HaskellLanguageServer; #[async_trait] -impl LspAdapter for LocalLspAdapter { +impl LspAdapter for HaskellLanguageServer { fn name(&self) -> LanguageServerName { - LanguageServerName("local-hls".into()) + LanguageServerName("hls".into()) } fn short_name(&self) -> &'static str { - "local-hls" + "hls" } async fn fetch_latest_server_version( &self, _: &dyn LspAdapterDelegate, - ) -> Result> { - Ok(Box::new(()) as Box<_>) + ) -> Result> { + Ok(Box::new(())) } async fn fetch_server_binary( &self, - _: Box, - _: PathBuf, + _version: Box, + _container_dir: PathBuf, _: &dyn LspAdapterDelegate, ) -> Result { - let path = shellexpand::full(&self.path)?; - Ok(LanguageServerBinary { - path: PathBuf::from(path.deref()), - arguments: self.arguments.iter().map(|arg| arg.into()).collect(), - }) + Err(anyhow!( + "hls (haskell language server) must be installed via ghcup" + )) } async fn cached_server_binary( @@ -85,18 +39,17 @@ impl LspAdapter for LocalLspAdapter { _: PathBuf, _: &dyn LspAdapterDelegate, ) -> Option { - let path = shellexpand::full(&self.path).ok()?; Some(LanguageServerBinary { - path: PathBuf::from(path.deref()), - arguments: self.arguments.iter().map(|arg| arg.into()).collect(), + path: "haskell-language-server-wrapper".into(), + arguments: vec!["lsp".into()], }) } + fn can_be_reinstalled(&self) -> bool { + false + } + async fn installation_test_binary(&self, _: PathBuf) -> Option { - let path = shellexpand::full(&self.path).ok()?; - Some(LanguageServerBinary { - path: PathBuf::from(path.deref()), - arguments: self.arguments.iter().map(|arg| arg.into()).collect(), - }) + None } } From eccfc538fe8e626b1a3ba6bd0173a0753684cd44 Mon Sep 17 00:00:00 2001 From: Pseudomata Date: Fri, 26 Jan 2024 20:22:31 -0500 Subject: [PATCH 10/10] Remove `xz` feature (no longer using it) --- Cargo.lock | 21 --------------------- Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 36ca6d70920cfe0fba4c1880eac68a80b716379a..fa06b9bd745816c9aca3f8de098d1543fbcbe17b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -363,7 +363,6 @@ dependencies = [ "futures-io", "memchr", "pin-project-lite 0.2.13", - "xz2", ] [[package]] @@ -4082,17 +4081,6 @@ dependencies = [ "url", ] -[[package]] -name = "lzma-sys" -version = "0.1.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fda04ab3764e6cde78b9974eec4f779acaba7c4e84b36eca3cf77c581b85d27" -dependencies = [ - "cc", - "libc", - "pkg-config", -] - [[package]] name = "mach2" version = "0.4.1" @@ -9621,15 +9609,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" -[[package]] -name = "xz2" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388c44dc09d76f1536602ead6d325eb532f5c122f17782bd57fb47baeeb767e2" -dependencies = [ - "lzma-sys", -] - [[package]] name = "yansi" version = "0.5.1" diff --git a/Cargo.toml b/Cargo.toml index faac957d56f3b06360f1437c01bcee0f828b4d51..e01f24f727f29605dcd30511196058458363da6b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,7 +92,7 @@ resolver = "2" [workspace.dependencies] anyhow = { version = "1.0.57" } async-trait = { version = "0.1" } -async-compression = { version = "0.4", features = ["gzip", "xz", "futures-io"] } +async-compression = { version = "0.4", features = ["gzip", "futures-io"] } chrono = { version = "0.4", features = ["serde"] } ctor = "0.2.6" derive_more = { version = "0.99.17" }