haskell: Extract to zed-extensions/haskell repository (#26306)
This PR extracts the Haskell extension to the [zed-extensions/haskell](https://github.com/zed-extensions/haskell) repository. Release Notes: - N/A
This commit is contained in:
parent
f57dece2d5
commit
4f6682c7fe
13 changed files with 1 additions and 325 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -17072,13 +17072,6 @@ dependencies = [
|
||||||
"zed_extension_api 0.1.0",
|
"zed_extension_api 0.1.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "zed_haskell"
|
|
||||||
version = "0.1.3"
|
|
||||||
dependencies = [
|
|
||||||
"zed_extension_api 0.1.0",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zed_html"
|
name = "zed_html"
|
||||||
version = "0.1.6"
|
version = "0.1.6"
|
||||||
|
|
|
@ -171,7 +171,6 @@ members = [
|
||||||
|
|
||||||
"extensions/emmet",
|
"extensions/emmet",
|
||||||
"extensions/glsl",
|
"extensions/glsl",
|
||||||
"extensions/haskell",
|
|
||||||
"extensions/html",
|
"extensions/html",
|
||||||
"extensions/perplexity",
|
"extensions/perplexity",
|
||||||
"extensions/proto",
|
"extensions/proto",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Haskell
|
# Haskell
|
||||||
|
|
||||||
Haskell support is available through the [Haskell extension](https://github.com/zed-industries/zed/tree/main/extensions/haskell).
|
Haskell support is available through the [Haskell extension](https://github.com/zed-extensions/haskell).
|
||||||
|
|
||||||
- Tree-sitter: [tree-sitter-haskell](https://github.com/tree-sitter/tree-sitter-haskell)
|
- Tree-sitter: [tree-sitter-haskell](https://github.com/tree-sitter/tree-sitter-haskell)
|
||||||
- Language Server: [haskell-language-server](https://github.com/haskell/haskell-language-server)
|
- Language Server: [haskell-language-server](https://github.com/haskell/haskell-language-server)
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
[package]
|
|
||||||
name = "zed_haskell"
|
|
||||||
version = "0.1.3"
|
|
||||||
edition.workspace = true
|
|
||||||
publish.workspace = true
|
|
||||||
license = "Apache-2.0"
|
|
||||||
|
|
||||||
[lints]
|
|
||||||
workspace = true
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
path = "src/haskell.rs"
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
zed_extension_api = "0.1.0"
|
|
|
@ -1 +0,0 @@
|
||||||
../../LICENSE-APACHE
|
|
|
@ -1,18 +0,0 @@
|
||||||
id = "haskell"
|
|
||||||
name = "Haskell"
|
|
||||||
description = "Haskell support."
|
|
||||||
version = "0.1.3"
|
|
||||||
schema_version = 1
|
|
||||||
authors = [
|
|
||||||
"Pocæus <github@pocaeus.com>",
|
|
||||||
"Lei <45155667+leifu1128@users.noreply.github.com>"
|
|
||||||
]
|
|
||||||
repository = "https://github.com/zed-industries/zed"
|
|
||||||
|
|
||||||
[language_servers.hls]
|
|
||||||
name = "Haskell Language Server"
|
|
||||||
language = "Haskell"
|
|
||||||
|
|
||||||
[grammars.haskell]
|
|
||||||
repository = "https://github.com/tree-sitter/tree-sitter-haskell"
|
|
||||||
commit = "8a99848fc734f9c4ea523b3f2a07df133cbbcec2"
|
|
|
@ -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) @string
|
|
||||||
(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
|
|
|
@ -1,12 +0,0 @@
|
||||||
(comment)+ @comment.around
|
|
||||||
|
|
||||||
[
|
|
||||||
(adt)
|
|
||||||
(type_alias)
|
|
||||||
(newtype)
|
|
||||||
] @class.around
|
|
||||||
|
|
||||||
(record_fields "{" (_)* @class.inside "}")
|
|
||||||
|
|
||||||
((signature)? (function)+) @function.around
|
|
||||||
(function rhs:(_) @function.inside)
|
|
|
@ -1,67 +0,0 @@
|
||||||
use zed::lsp::{Symbol, SymbolKind};
|
|
||||||
use zed::{CodeLabel, CodeLabelSpan};
|
|
||||||
use zed_extension_api::{self as zed, Result};
|
|
||||||
|
|
||||||
struct HaskellExtension;
|
|
||||||
|
|
||||||
impl zed::Extension for HaskellExtension {
|
|
||||||
fn new() -> Self {
|
|
||||||
Self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn language_server_command(
|
|
||||||
&mut self,
|
|
||||||
_language_server_id: &zed::LanguageServerId,
|
|
||||||
worktree: &zed::Worktree,
|
|
||||||
) -> Result<zed::Command> {
|
|
||||||
let path = worktree
|
|
||||||
.which("haskell-language-server-wrapper")
|
|
||||||
.ok_or_else(|| "hls must be installed via ghcup".to_string())?;
|
|
||||||
|
|
||||||
Ok(zed::Command {
|
|
||||||
command: path,
|
|
||||||
args: vec!["lsp".to_string()],
|
|
||||||
env: worktree.shell_env(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fn label_for_symbol(
|
|
||||||
&self,
|
|
||||||
_language_server_id: &zed::LanguageServerId,
|
|
||||||
symbol: Symbol,
|
|
||||||
) -> Option<CodeLabel> {
|
|
||||||
let name = &symbol.name;
|
|
||||||
|
|
||||||
let (code, display_range, filter_range) = match symbol.kind {
|
|
||||||
SymbolKind::Struct => {
|
|
||||||
let data_decl = "data ";
|
|
||||||
let code = format!("{data_decl}{name} = A");
|
|
||||||
let display_range = 0..data_decl.len() + name.len();
|
|
||||||
let filter_range = data_decl.len()..display_range.end;
|
|
||||||
(code, display_range, filter_range)
|
|
||||||
}
|
|
||||||
SymbolKind::Constructor => {
|
|
||||||
let data_decl = "data A = ";
|
|
||||||
let code = format!("{data_decl}{name}");
|
|
||||||
let display_range = data_decl.len()..data_decl.len() + name.len();
|
|
||||||
let filter_range = 0..name.len();
|
|
||||||
(code, display_range, filter_range)
|
|
||||||
}
|
|
||||||
SymbolKind::Variable => {
|
|
||||||
let code = format!("{name} :: T");
|
|
||||||
let display_range = 0..name.len();
|
|
||||||
let filter_range = 0..name.len();
|
|
||||||
(code, display_range, filter_range)
|
|
||||||
}
|
|
||||||
_ => return None,
|
|
||||||
};
|
|
||||||
|
|
||||||
Some(CodeLabel {
|
|
||||||
spans: vec![CodeLabelSpan::code_range(display_range)],
|
|
||||||
filter_range: filter_range.into(),
|
|
||||||
code,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
zed::register_extension!(HaskellExtension);
|
|
Loading…
Add table
Add a link
Reference in a new issue