Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion extension.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/zed-extensions/haskell"

[language_servers.hls]
name = "Haskell Language Server"
languages = ["Haskell", "Cabal"]
languages = ["Haskell", "Cabal", "Literate Haskell"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure this is a good idea? Did a quick check and https://discourse.haskell.org/t/hls-visual-studio-code-whats-so-great-about-it/4181/16 would suggest otherwise, but that is a bit older, so perhaps I am missing context?


[grammars.haskell]
repository = "https://github.com/tree-sitter/tree-sitter-haskell"
Expand All @@ -20,3 +20,7 @@ commit = "8a99848fc734f9c4ea523b3f2a07df133cbbcec2"
[grammars.cabal]
repository = "https://gitlab.com/zweimach/tree-sitter-cabal/"
commit = "6f00f6d4883eb2eb650eea7cc1e95bd25e48419c"

[grammars.haskell_literate]
repository = "https://github.com/LaurentRDC/tree-sitter-haskell-literate"
commit = "8ad7bd1b1595f4cc1a4ccc775d4a3c460f43a596"
14 changes: 14 additions & 0 deletions languages/literate-haskell/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name = "Literate Haskell"
grammar = "haskell_literate"
path_suffixes = ["lhs"]
line_comments = ["-- "]
block_comment = ["{- ", " -}"]
autoclose_before = ",=)}]"
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 },
]
16 changes: 16 additions & 0 deletions languages/literate-haskell/highlights.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
; Bird track marker
(bird_line ">" @punctuation.special)

; LaTeX delimiters
(latex_begin) @keyword.directive
(latex_end) @keyword.directive

; Highlight LaTeX comments like comments
(latex_comment) @comment

; Markdown delimiters
(markdown_begin) @keyword.directive
(markdown_end) @keyword.directive

; Normal prose is not highlighted. Haskell code will be
; highlighted by the injected Haskell grammar
14 changes: 14 additions & 0 deletions languages/literate-haskell/injections.scm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to have injections for LaTeX / Mardown as well? Or would that not work/break other things?

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
; Inject Haskell parser into bird-style code lines
((bird_line
(haskell_code) @injection.content)
(#set! injection.language "haskell"))

; Inject Haskell parser into LaTeX code blocks
((latex_code_line
(haskell_code) @injection.content)
(#set! injection.language "haskell"))

; Inject Haskell parser into Markdown code blocks
((markdown_code_line
(haskell_code) @injection.content)
(#set! injection.language "haskell"))