nickmqb / muon

Modern low-level programming language
MIT License
772 stars 25 forks source link

Editor integration / syntax highlighting #11

Closed twitchyliquid64 closed 4 years ago

twitchyliquid64 commented 5 years ago

Does anything exist ATM?

Assuming theres a formal BNF or something for the grammar, I might give this a go (I have a highlighter for ace somewhere ...)

nickmqb commented 5 years ago

I'm currently working on a language server, when that's ready it should be usable by all editors that support the language service protocol.

However, each editor will require some extra code to make everything work: a grammar to do syntax highlighting, some glue code to integrate with the language server, etc. I'm working on a VSCode extension as a proof of concept, but it would be really cool to support more editors! Did you have any particular editor in mind?

twitchyliquid64 commented 5 years ago

Not really, I was just looking at it at github and realized how nice it is to have highlighting ...

In terms of what I have experience with, ace (embeddable js code editor) is the only one i have experience writing highlighters for.

haferburg commented 5 years ago

For Sublime I used this as the basis for my language. https://gist.github.com/gingerBill/9d9816b08fc3fd1429c558fdd90e5647

desdeux commented 5 years ago

I'm started writing the vscode extension, but not finished it yet https://github.com/desdeux/vscode-muon

nickmqb commented 5 years ago

TextMate based grammar for tokenization/syntax highlighting will be a good starting point.

@desdeux, cool, I'm working on a VSCode extension myself as well (see above) but if you want to take this and run with it that would be great! I'm also working on a language server: I just filed #14 to track the progress on that. Once I've got an initial version you should be able to use it from your VSCode extension.

@haferburg Thanks for the tip. Btw, nice work on Odin! I came across it recently on the handmade network (might submit Muon there as a project as well).

ghost commented 5 years ago

I'm going to be in the passenger seat of a car for a few hours today, so I'll try to work on a grammar and syntax package for Atom between intermittent spells of motion sickness.

twitchyliquid64 commented 5 years ago

+1 for intermittent spells of motion sickness.

If we want github to support highlighting for Muon, we need to implement support in Pygments - http://pygments.org/docs/lexerdevelopment/. I'll either give that or Ace a go when I get the chance in the near future.

ghost commented 5 years ago

Jeez, looks like I practically have to rewrite the parser in a format that Atom likes; which is a problem, because I don't know a damn thing about how this parser works. Maybe commenting the code should be on the TO-DO? :)

twitchyliquid64 commented 5 years ago

I have the same concern about not know what is legal for Muon, see #17.

For Atom though, dont you just need to write a bunch of regexes and a few states for it to move between? Even without a full understanding, we should be able to do constants/string/types/functions?

If you start a repo lemme know, I'll see if I can help out.

ghost commented 5 years ago

Yeah, it might have been a bit of a hyperbole, but having to go through whole other formats and frameworks does seem like a bit of a roundabout way to do it. Necessary though I suppose.

I'll start on the Tree Sitter grammar here, don't expect to see anything on their too soon.

nickmqb commented 5 years ago

+1 for intermittent spells of motion sickness.

If we want github to support highlighting for Muon, we need to implement support in Pygments - http://pygments.org/docs/lexerdevelopment/. I'll either give that or Ace a go when I get the chance in the near future.

I might be missing something, but it looks like GitHub uses TextMate grammars for highlighting, see: https://github.com/github/linguist/blob/master/CONTRIBUTING.md ("Syntax highlighting in GitHub is performed using TextMate-compatible grammars"). For any new language, they require that the language has some usage ("In most cases we prefer that extensions be in use in hundreds of repositories before supporting them in Linguist.") which seems fair. So GitHub syntax highlighting is not possible right now, but should become possible for us further down the road.

twitchyliquid64 commented 5 years ago

Heh, my information is out of date, my bad :O

nickmqb commented 5 years ago

No worries, good to have it cleared up.

ghost commented 5 years ago

@twitchyliquid64 I did quite a bit of work on the tree-sitter-muon repo, but I have hit a roadblock. Try using the tree-sitter-cli to parse test.mu and you'll see whats up :/

nickmqb commented 4 years ago

We now have a language server (https://github.com/nickmqb/muon/tree/master/language_server) and a vscode-muon extension (https://github.com/nickmqb/vscode-muon). Feel free to open a new issue for discussing any other editor extensions.