helix
helix copied to clipboard
Add support for janet language
Resolves : #4574
I'm sorry for the force pushes 😅 I forgot to add a few things and I didn't want to stack commits, so I rebased and pushed again.
Since Janet is a lisp and looks a lot like clojure, I wonder if we can re-use the clojure or scheme parsers and only write new queries?
Since Janet is a lisp and looks a lot like clojure, I wonder if we can re-use the clojure or scheme parsers and only write new queries?
Does "new queries" mean injections and highlights in runtime/queries
?
I'm sorry, I'm kind of new to this repo and I'll take some time to absorb and understand stuff 😅
Yep correct. To share the same parser you will need to change the languages.toml entry to remove the new [[grammar]]
sub-table and add a grammar = "clojure"
or grammar = "scheme"
entry to the new [[language]]
sub-table. Then it will need queries in runtime/queries/janet
Gotcha. Although, I do have a concern. Looking further into the syntax of all the 3 languages [ janet, clojure and scheme ], there seems to be quite a bit of difference between the 3 of them with respect to keywords and the general mechanics of the languages. Janet does sort of represent scheme and clojure in a way but I feel that it is different enough to have its own grammar (since reusing grammar may raise questionable results and/or errors in the language later?)
Having said this, I could very well be wrong and I'm happy to correct myself if I am. If you feel that the grammar of clojure or scheme can be resused, then let me know, I'll make the necessary changes and add a new commit.
@the-mikedavis [Sorry for the mention!] Any update on this PR?
Hmm yeah, we might as well pull in a new grammar for this - when compiled, this parser is only 174KB. We can work on deduplicating grammars later, maybe we'll need to write a new grammar that's general enough to be used for any lisp.
Hmm yeah, we might as well pull in a new grammar for this - when compiled, this parser is only 174KB. We can work on deduplicating grammars later, maybe we'll need to write a new grammar that's general enough to be used for any lisp.
Alright! Is there any pending work to be done on my end? (I'm really sorry for going back and forth over this PR) 😅
Yep this still needs runtime/queries/janet/highlights.scm
queries https://docs.helix-editor.com/master/guides/adding_languages.html#queries
@the-mikedavis Is it alright if I reuse https://github.com/helix-editor/helix/blob/master/runtime/queries/clojure/highlights.scm with a bit of modification for janet atm? I know I'd told against it but I'm not finding enough time to roll out a new one for janet.
Yep that would be fine as long as the syntax is close enough. You can set the grammar to use the clojure one and then inherit the highlights:
# /languages.toml
[[language]]
name = "janet"
# .. other stuff ..
grammar = "clojure"
then in runtime/queries/janet/highlights.scm
:
; inherits: clojure
to use all of the clojure highlight patterns, or just use the patterns that are needed
Thanks! Btw, How do i resolve the merge conflict? 😅 Do I just pull the latest upstream changes and commit everything again?
You can pull down the master branch from this repo and git merge
against that:
git remote add upstream https://github.com/helix-editor/helix
git fetch upstream
git merge upstream/master
(Or if you meant which side to take in the conflict: you can add both new entries so that you have
[[language]]
name = "janet"
# ...
[[grammar]]
name = "janet"
# ...
[[language]]
name = "bicep"
# ...
[[grammar]]
name = "bicep"
)
(first off, im really sorry for the delay) @the-mikedavis I tried merging the conflicts but its only gotten worse. I want to complete the changes you suggested in this PR. I get "Your local changes to the following files would be overwritten by merge". I could squash and rebase to head and redo my changes which would erase my commits and I can just make a new one while still being part of this pr. Any advice?
It sounds like you have uncommitted changes in your local branch. You should commit them first before running git merge upstream/master
Since there aren't a lot of lines changed, starting from scratch like you said might be the easiest option. You can also try committing the local changes before the merge as @Plasma-Vortex says or stashing: git stash
before merging and then git stash pop
afterwards.