Extract Haskell support into an extension (#9814)
This PR extracts Haskell support into an extension and removes the built-in Haskell support from Zed. I tested out the extension locally in a Nix shell using `nix-shell -p ghc haskell-language-server` to confirm the language server still operated as expected: <img width="341" alt="Screenshot 2024-03-26 at 11 26 26 AM" src="https://github.com/zed-industries/zed/assets/1486634/df16fd38-4046-4a45-ac9f-c2b85bffe5c0"> Release Notes: - Removed built-in support for Haskell, in favor of making it available as an extension. The Haskell extension will be suggested for download when you open a `.hs` file.
This commit is contained in:
parent
9d4c6c60fb
commit
1d6792b17d
15 changed files with 72 additions and 67 deletions
|
@ -1,52 +0,0 @@
|
|||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use language::{LanguageServerName, LspAdapter, LspAdapterDelegate};
|
||||
use lsp::LanguageServerBinary;
|
||||
use std::{any::Any, path::PathBuf};
|
||||
|
||||
pub struct HaskellLanguageServer;
|
||||
|
||||
#[async_trait(?Send)]
|
||||
impl LspAdapter for HaskellLanguageServer {
|
||||
fn name(&self) -> LanguageServerName {
|
||||
LanguageServerName("hls".into())
|
||||
}
|
||||
|
||||
async fn fetch_latest_server_version(
|
||||
&self,
|
||||
_: &dyn LspAdapterDelegate,
|
||||
) -> Result<Box<dyn 'static + Any + Send>> {
|
||||
Ok(Box::new(()))
|
||||
}
|
||||
|
||||
async fn fetch_server_binary(
|
||||
&self,
|
||||
_version: Box<dyn 'static + Send + Any>,
|
||||
_container_dir: PathBuf,
|
||||
_: &dyn LspAdapterDelegate,
|
||||
) -> Result<LanguageServerBinary> {
|
||||
Err(anyhow!(
|
||||
"hls (haskell language server) must be installed via ghcup"
|
||||
))
|
||||
}
|
||||
|
||||
async fn cached_server_binary(
|
||||
&self,
|
||||
_: PathBuf,
|
||||
_: &dyn LspAdapterDelegate,
|
||||
) -> Option<LanguageServerBinary> {
|
||||
Some(LanguageServerBinary {
|
||||
path: "haskell-language-server-wrapper".into(),
|
||||
env: None,
|
||||
arguments: vec!["lsp".into()],
|
||||
})
|
||||
}
|
||||
|
||||
fn can_be_reinstalled(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
async fn installation_test_binary(&self, _: PathBuf) -> Option<LanguageServerBinary> {
|
||||
None
|
||||
}
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
("(" @open ")" @close)
|
||||
("[" @open "]" @close)
|
||||
("{" @open "}" @close)
|
|
@ -1,14 +0,0 @@
|
|||
name = "Haskell"
|
||||
grammar = "haskell"
|
||||
path_suffixes = ["hs"]
|
||||
autoclose_before = ",=)}]"
|
||||
line_comments = ["-- "]
|
||||
block_comment = ["{- ", " -}"]
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true },
|
||||
{ start = "\"", end = "\"", close = true, newline = false },
|
||||
{ start = "'", end = "'", close = true, newline = false },
|
||||
{ start = "`", end = "`", close = true, newline = false },
|
||||
]
|
|
@ -1,156 +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.
|
||||
|
||||
;; ----------------------------------------------------------------------------
|
||||
;; 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"
|
||||
"∀"
|
||||
] @keyword
|
||||
|
||||
(pragma) @constant
|
||||
|
||||
[
|
||||
"if"
|
||||
"then"
|
||||
"else"
|
||||
"case"
|
||||
"of"
|
||||
] @keyword
|
||||
|
||||
(exp_lambda_cases "\\" ("cases" @variant))
|
||||
|
||||
[
|
||||
"import"
|
||||
"qualified"
|
||||
"module"
|
||||
] @keyword
|
||||
|
||||
[
|
||||
(operator)
|
||||
(constructor_operator)
|
||||
(type_operator)
|
||||
(tycon_arrow)
|
||||
(qualified_module) ; grabs the `.` (dot), ex: import System.IO
|
||||
(all_names)
|
||||
(wildcard)
|
||||
"="
|
||||
"|"
|
||||
"::"
|
||||
"=>"
|
||||
"->"
|
||||
"<-"
|
||||
"\\"
|
||||
"`"
|
||||
"@"
|
||||
] @operator
|
||||
|
||||
(module) @title
|
||||
|
||||
[
|
||||
(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
|
|
@ -1,3 +0,0 @@
|
|||
(_ "[" "]" @end) @indent
|
||||
(_ "{" "}" @end) @indent
|
||||
(_ "(" ")" @end) @indent
|
|
@ -1,26 +0,0 @@
|
|||
(adt
|
||||
"data" @context
|
||||
name: (type) @name) @item
|
||||
|
||||
(type_alias
|
||||
"type" @context
|
||||
name: (type) @name) @item
|
||||
|
||||
(newtype
|
||||
"newtype" @context
|
||||
name: (type) @name) @item
|
||||
|
||||
(signature
|
||||
name: (variable) @name) @item
|
||||
|
||||
(class
|
||||
"class" @context
|
||||
(class_head) @name) @item
|
||||
|
||||
(instance
|
||||
"instance" @context
|
||||
(instance_head) @name) @item
|
||||
|
||||
(foreign_import
|
||||
"foreign" @context
|
||||
(impent) @name) @item
|
|
@ -23,7 +23,6 @@ mod elixir;
|
|||
mod elm;
|
||||
mod erlang;
|
||||
mod go;
|
||||
mod haskell;
|
||||
mod html;
|
||||
mod json;
|
||||
mod lua;
|
||||
|
@ -85,7 +84,6 @@ pub fn init(
|
|||
("go", tree_sitter_go::language()),
|
||||
("gomod", tree_sitter_gomod::language()),
|
||||
("gowork", tree_sitter_gowork::language()),
|
||||
("haskell", tree_sitter_haskell::language()),
|
||||
("hcl", tree_sitter_hcl::language()),
|
||||
("heex", tree_sitter_heex::language()),
|
||||
("html", tree_sitter_html::language()),
|
||||
|
@ -316,7 +314,6 @@ pub fn init(
|
|||
}
|
||||
}
|
||||
|
||||
language!("haskell", vec![Arc::new(haskell::HaskellLanguageServer {})]);
|
||||
language!(
|
||||
"html",
|
||||
vec![
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue