-
Notifications
You must be signed in to change notification settings - Fork 585
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
[Lisp] Highlighting seems very gone #1968
Comments
(define (square x)
(* x x))
(define (square-tree tree)
(map (lambda (sub-tree)
(if (pair? sub-tree)
(square-tree sub-tree)
(square sub-tree)))
tree) Lisp (mostly) still has a "highlight the keywords" structure to its syntax definition file, rather than the stack of contexts that most of the recent language rewrites have used. On the plus side, Lisp's elegance probably makes it relatively easy to rewrite. |
I've noticed this issue as well, and especially the dashes-are-operators-even-in-identifiers problem is extremely annoying. I'm not a Sublime user, but the Rust ecosystem syntax highlighting support is based on Sublime's syntax definitions, via the @michaelblyons Could you give some guidance on what "modern" syntax definitions to base a Scheme/CL syntax definition on? I'd be interested at giving it a go, probably focusing on Scheme first. |
I don't know what syntax definition might be closest to Lisp/Scheme, mostly because I don't use any languages that look like them. 😉 In my opinion, Javascript is the syntax definition that is most meticulously maintained. Perl had a fairly recent rewrite. There's an overhaul of Haskell in PR #2225. The Sublime Text Discord is happy to help with questions, and the pointers in #757 may help you out. (I believe someone specifically mentions |
I'd also recommend taking a look at the Lua syntax definition, which has a similar structure to the JavaScript definition but is much simpler. The Lisp definition should be easy to rewrite because Lisp's syntax is so simple. You could probably write a no-frills highlighter in an hour. A complication is that basic features like control flow and function definitions are implemented as (essentially) library functions, and they vary from dialect to dialect. I'm not sure whether the existing Lisp definition was written for Scheme, Common Lisp, both, or neither, or to what extent a single definition could cover a variety of Lisp dialects. |
@michaelblyons Thanks for the pointers -- I was looking for some maintained/modern syntax definition, not something I could directly base a Scheme one on, so answer is indeed quite helpful. @Thom1729 So it seems Lua would be my go-to place when I get stuck. Thanks for the hint. I agree that a basic syntax definition should be pretty easy, but at least for Scheme, I'll go for covering a superset of R6RS, with some common non-conflicting extensions. While this is probably very simple as far as languages go, I suspect it's not trivial, if you want to cover all the syntax that can be reasonably reflected in a Sublime syntax definition. Regarding "keywords": they indeed do not exist in Scheme: there are just identifiers, some of which happen to be bound to syntax (aka macros), and they can be imported under different names, so the highlighting is necessarily an approximation. However, that's good enough™, and I think even die-hard Scheme programmers will not expect more -- even Emacs, a major Lisp IDE, relies on an approximate approach for highlighting. Regarding sharing syntax definitions between Common Lisp (CL) and Scheme, I'm pretty sure the existing "Lisp" definition is for CL, and it would be a bad fit for Scheme, even if ignoring the obvious flaws that apply to both dialects. The names and semantics of available syntax ("keywords" in the above Sublime sense) vary wildly between them, and that's not the only difference. Some basic stuff is totally common, e.g. round brackets for structure, and the use of the semicolon for comments, but, just off the top of my head (and note that I know CL only from hearsay):
This list is for sure not exhaustive. So, it would be helpful for me, and the next person to come along, who, like me, may have zero experience with Sublime syntax definitions, to give some hints how to structure the support for the Lisp family, and if it seems sensible to share code (YAML, code is data yadayada 😉) between the definitions at all, and if so, how. Thinking about it, I will probably aim for the following in a first shot:
How does that sound? |
I think @jrappen was linking Discord, which I failed to do when I mentioned it. The same people also frequent a Discourse-based forum if that's your preference. Your plan sounds good to me. If there are matches or contexts shared between Lisp dialects that are self-contained (or do not need to Also, if Thom contradicts anything I've said, go with Thom. 😉 |
Ah yes, it's clear in retrospect, sorry for knee-jerking. Thanks for pointing out the forum, the existence of discourse as an alternative is indeed much appreciated. |
See also dandavison/delta#1580 |
Feel free to fork #2387. I don't know when I'll be able to return to it. |
The highlighting on Scheme dialect of Lisp seems very dead.
1: Minus symbols as variable names are highlighted inconsistently
2: Some internal functions like map are highlighted, whereas others like pair are not (maybe this depends what Lisp dialect is in use)
3: define isn't highlighted
Another note I just found:
null?
highlights thenull
section purple but the qmark remains grey/white+:
rest
is highlighted as a function likemap
The text was updated successfully, but these errors were encountered: