Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add language support for persistent library syntax #7261

Merged

Conversation

lykahb
Copy link
Contributor

@lykahb lykahb commented Jun 6, 2023

This adds support for the language used by a persistent library to define the database models. This syntax is only used by one library, so I chose to prefix the language name with "haskell-" for specificity.

The haskell injections query uses the name of the function that handles that content of the quasi-quote as the name of the language. The persistent library has three of them that I included into the injection-regex.

image

@lykahb
Copy link
Contributor Author

lykahb commented Jun 6, 2023

I also tried an alternative recognition of the injected language that moves the recognition from injection-regex into the haskell injection query. Let me know which variant you consider cleaner.

; haskell/injections.scm

((comment) @injection.content
 (#set! injection.language "comment"))

(quasiquote
 (quoter) @_quoter
 ((quasiquote_body) @injection.content
  (#match? @_quoter "(persistWith|persistLowerCase|persistUpperCase)")
  (#set! injection.language "haskell-persistent" )
 )
)

(quasiquote
 (quoter) @injection.language
 (quasiquote_body) @injection.content)
# languages.toml

[[language]]
name = "haskell-persistent"
scope = "source.persistentmodels"
injection-regex = "haskell-persistent"
file-types = ["persistentmodels"]
roots = []
comment-token = "--"
indent = { tab-width = 2, unit = "  " }

@lykahb
Copy link
Contributor Author

lykahb commented Jun 26, 2023

Moved recognition of language name into the haskell injection queries, added folds, and marked = as an operator. Now the language support is closer to the one that got merged into nvim-treesitter.

@kirawi kirawi added the A-language-support Area: Support for programming/text languages label Jun 30, 2023
@pascalkuthe pascalkuthe merged commit 7c33842 into helix-editor:master Jul 9, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-language-support Area: Support for programming/text languages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants