Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jul 06 17:01
    palango closed #95
  • Jan 08 2019 17:20
    mmagnuski closed #219
  • Oct 12 2018 13:40
    gdkrmr closed #218
  • May 19 2018 02:07
    yehielliv commented #223
  • May 19 2018 02:03
    yehielliv opened #223
  • Feb 10 2018 11:08
    currymj closed #171
  • Jul 25 2016 19:04
    jingpengwu commented #203
  • May 24 2016 12:19
    JonWel closed #183
  • May 24 2016 12:19
    JonWel commented #183
  • Apr 12 2016 11:11
    MikeInnes closed #185
  • Apr 12 2016 11:11
    MikeInnes closed #166
  • Apr 12 2016 11:11
    MikeInnes closed #163
  • Apr 12 2016 11:11
    MikeInnes closed #101
  • Apr 12 2016 11:11
    MikeInnes closed #82
  • Apr 12 2016 11:11
    MikeInnes closed #73
  • Apr 12 2016 11:11
    MikeInnes closed #68
  • Apr 12 2016 11:11
    MikeInnes closed #69
  • Apr 12 2016 11:11
    MikeInnes closed #61
  • Apr 12 2016 11:10
    MikeInnes closed #59
  • Apr 12 2016 11:10
    MikeInnes closed #57
Mike J Innes
@MikeInnes
I actually changed end to be a cm-qualifier – you'll notice that in June they're faded out
Don't know if there would be a better way to achieve that though
Sebastian Pfitzner
@pfitzseb
ah, okay, that's perfectly justified if you want to have ends be less cluttering
still, I've got another question: Why are functions like print, printlnetc treated as builtin? I don't quite see why Types, special values like Inf and those functions should be treated the same.
Sebastian Pfitzner
@pfitzseb
aaand another one: what's the reasoning behind the distinction in https://github.com/one-more-minute/Jewel/blob/master/codemirror/julia.js , lines 232 to 236? It leads to strange styling if a function starts on a new line
Sebastian Pfitzner
@pfitzseb
and if anyone is interested: the first iteration of my dark version of June (not that there's much of a relation) is available at https://github.com/Varanas/Jewel
Mike J Innes
@MikeInnes
So, for the record, I inherited the Julia mode – most of what I've done so far has been tweaking it, but I'm going to do a complete rewrite to get rid of some of the weird stuff. I agree about print etc. – I'll think I'll treat all types as "builtin" (even though very little is really built in to Julia)
That column check is mine though, the idea is to treat both function foo() and foo() = as definitions
When I've got time I'll definitely give your theme a go!
Sebastian Pfitzner
@pfitzseb
Okay, a rewrite sounds like a good idea! Treating types asbuiltin even if they aren't really only comes down to naming.
About that column check: I totally forgot about that way to define functions! It does make sense to style them the same as the ones defined by function, although that check is not enough. Even a function call starting in column zero will trigger the definition-style, so a check whether there's an = after the function call should probably be added. That should cover all cases, but I'm not experienced enough in Julia to be sure about that.
Sebastian Pfitzner
@pfitzseb
And should you like June-dark and want it included in Jewel I'll gladly issue a PR.
Mike J Innes
@MikeInnes
The difficulty with doing a more robust check for something like foo(...) = ... is that you have to parse everything between the brackets before you get to the =, and even then it breaks when the = is on a new line. I might make it more precise in future but for now I think overshooting is probably better than undershooting
Liking your theme so far! So far I think I'll probably split June into it's own plugin so that it's usable from other languages, so doing that with yours too is probably the best thing
Mike J Innes
@MikeInnes
I actually really like this idea – I'll probably have a go at something like that for functions/vars
Wouldn't be too hard to keep track of the n variables in the current scope and emit the style variable-n
Eric West
@edubkendo
I remember seeing Douglas Crockford suggest something like that in a talk a while back
Mike J Innes
@MikeInnes
Ok, must be worth a try then
Mike J Innes
@MikeInnes
An even better might be to "hash" each variable in some way, mod n
Mike J Innes
@MikeInnes
Just pushed this feature – any thoughts? I have to say, I like it a lot personally
@Varanas I've included the css color generator, feel free to play around with it for June Dark
Mike J Innes
@MikeInnes
(value = 1 and saturation = 0.5 works well for me)
Sebastian Pfitzner
@pfitzseb
my thoughts: a decisive hmm...
I'm not quite sure I like it... it seems to be very cluttered, although I can understand why it could be very beneficial to have that form of highlighting
Sebastian Pfitzner
@pfitzseb
should you want to go this way: It might be very beneficial to readability and create a more distinctive look if the distance in colorspace would depend on the number of used variables/functions.
furthermore, variables internal to functions could be treated as seperate which would cut down on the total number of colors needed (everything that is input or output to a function will be in global "colorspace").
Sebastian Pfitzner
@pfitzseb
Of course, implementing that would require the parser to have a pretty deep understanding of the language itself and I'm not sure if it's feasible at all. Although that kind of distinction in scope is internal to Julia, if I'm not mistaken.
Sebastian Pfitzner
@pfitzseb
To elaborate on my first reply: Syntax highlighting (at least for me) is about structuring code. That structuring does happen (in a way) with conventional highlighting, but the main difference there is between data and functions. I agree with the article you cited above in that it would be more beneficial to be able to follow the usage of certain variables throughout a document (and to a lesser extent the usage of a function) simply by having a look at the color, but for that to work the colors would have to be distinct enough to be seperable on the first glance.
Sebastian Pfitzner
@pfitzseb
Uh, sorry for the wall of text without any concrete suggestions... Here are two:
  1. Give functions not defined in the current document a second class that makes them bold.
  2. Change the scheme of assigning a color to a certain hash, so that two hashs always have the biggest possible distance to each other (without changing any previously assigned colors). For example, the first variable gets assigned variable-1, the second variable-100, then variable-50, -25, -75 and so on. Of course those colors aren't the same in different documents and there are probably additional issues, but it's all I could come up with for now.
Sebastian Pfitzner
@pfitzseb
and an example I found (the scope coloring is pretty interesting too): https://github.com/daniellmb/JavaScript-Scope-Context-Coloring
Mike J Innes
@MikeInnes
Thanks for the feedback! It's always useful to have input from people with different tastes.
Mike J Innes
@MikeInnes

I really like a lot of these ideas, but it's really a question of feasibility – at least in the short term, it's probably best to have either a very basic version of this or none at all, rather than spending weeks on something that may not work well.

I think the best thing will be to split out this functionality into a separate plugin. It should be easy to switch on and off, so that themes (including custom ones like yours) work just as well with or without it. I realise that at the moment I've stopped you from having different styles for function calls, so that will be fixed when I do this.

It's definitely a challenge to strike the balance between having distinct colours and not making the editor look like a pile of skittles, but hopefully with enough tweaking I can get something decent going. Unfortunately I don't have nearly enough time to actually do work using the editor at the moment.

Sebastian Pfitzner
@pfitzseb

I agree that most changes would definitely need a lot of time to tweak and get just right, but the two I proposed should be relatively straightforward to implement (unfortunately I don't have all that much time rght now, but I'll take a look at your js and see if I can figure out what you're doing). The second one should also address the probem with conventional styles not working, since any function call would have two classes: The one from the definition of said class and another one that marks them as a function. If the first one doesn't provide any information regarding color than the "conventional fallback" can kick in and deliver the same look as before your changes.

A plugin for LT called match-highlighter provides a nice way to visualize any occurences of an variable (much like Matlab), so that definitely helps. Actually, it highlights anything that's called the same as the word the cursor is over - that could/should probably be tweaked to only apply...

Mike J Innes
@MikeInnes

Cool, it would be great if you could have a look at doing this – here's a couple of notes:

  1. CodeMirror modes can't look forward through the source code, but with a separate plugin it should be easy to extract all .cm-def (function definition) and .cm-variable-2 (function call) nodes from outputted DOM and apply additional CSS classes as appropriate. (Like I said, I like this idea so I'll probably have a go at it if you don't – but I don't know anything about writing CodeMirror addons yet.)
  2. CodeMirror modes also can't apply multiple styles to a token, which is my main reason for wanting to write the rainbow-vars plugin separately.

match-highlighter is neat – I might have it enabled by default if it plays well with unicode.

Sebastian Pfitzner
@pfitzseb

re 2: The CodeMirror manual (see http://codemirror.net/doc/manual.html , Writing CodeMirror Modes) says it is possible.

Regarding unicode: Ah, well... Nope, match-highlighter can't deal with it - but neither can your implementation of the parser. So right now it doesn't matter ;)

Mike J Innes
@MikeInnes

Woops, you're right – well spotted! Well, it'd still be nice to have a rainbow-vars plugin at some point, but that does solve some issues.

I was actually wondering if match-highlighter uses the DOM to find tokens – if it does then it will support unicode once the parser does with no extra effort, which would be nice

Mike J Innes
@MikeInnes
Ok, I got rid of the rainbow vars in the light theme, that wasn't working – but I had a go at a more pastel-y/zenburnesque dark theme which I think works quite nicely with it.
Sebastian Pfitzner
@pfitzseb

Just one random thought I had while staring at some code:
Wouldn't it be pretty cool if some plugin not only highlights the exact same variable but also any it is assigned to? So you'd have something like a common thread running through your code, branching when necessary? I think it's pretty important to be able to immediatly see data flow...

Although that should probably be a mode in addition to conventional syntax highlighting... But still, I somehow like it. Thoughts?

Sebastian Pfitzner
@pfitzseb
While playing a bit with your css I noticed that it doesn't look half bad if function calls are a bit transparent and bold (e.g. .cm-s-june-night span.cm-variable-2 {color: #ffc; font-weight: bold; opacity: .55;}).
And btw, thanks for fixing that backwards-compatibility-thing!
Mike J Innes
@MikeInnes

Some kind of data-flow-based highlighting is an interesting idea – you could take x = f(y, z) and colour x as a mix of y and z's colours, too. It would be fairly hard to do well, I think, but it would definitely be worth a shot.

Reducing the opacity is a nice way to distinguish functions from variables without making them really pop out – I'll play around with it a bit. For the record, I do think that bold functions work nicely with your theme. Oh, and no problem!

Mike J Innes
@MikeInnes
Backtraces should be much nicer now, let me know if there's any problems with the new code. Also, the highlighter now supports splicing ($(...)), which I think is pretty neat :)
Sebastian Pfitzner
@pfitzseb

About the data-flow-highlighting: While it does sound pretty neat in theory, I'm not at all sure if it can be implemented in any reasonable fashion. Might have to look into that... I think I'll just throw together a sketch for something a bit more feasible (hopefully).

About backtraces: Sadly, there still are some cases where it's not terribly helpful yet. One case that is pretty annoying for my style of development:
There's a function defined in some file and I try to call it within that same file. But if I've made a mistake in the function definition the line numbers displayed in the error message is about the representation of that function in init.jl and the line numbers displayed aren't the ones I would want to see.

Sebastian Pfitzner
@pfitzseb
codesketch.jpg
What I had in mind was something similar to the picture above. Whenever your cursor is above some variable (and/or some key is pressed), that variable and it's "first-order-children" (or whatever those might be called) are highlighted while the rest of the code is a bit dimmed. Otherwise it looks just like the version to the left.
That seems to be a compromise between rainbow vars and conventional highlighting - which of course doesn't have to be a good thing ;).
Mike J Innes
@MikeInnes

I like that idea for highlighting matching variables. It'd probably be fairly straightforward to prototype something like that if you're interested in having a go.

Could you give me an example of the kind of backtraces you're getting? That's exactly what I had tried to fix, on my system backtraces are very to-the-point. Are you sure you have the latest Jewel.jl code (the fix isn't in a released version yet)?

Sebastian Pfitzner
@pfitzseb
Ugh, stupid me... Works like a charm! No I finally don't have to debug in the REPL because I won't get proper backtraces in LT. Thanks!
Mike J Innes
@MikeInnes
Great!
Mike J Innes
@MikeInnes
Just so everyone knows – I'm going to change Jewel's URL to one-more-minute/Jewel-LT. gitter.im doesn't handle renames AFAIK so there won't be a redirect, but the URL of the chat room will change accordingly.
Mike J Innes
@MikeInnes
0.5.0 released yesterday, with much better highlighting/indentation support, new commands to interrupt and and kill the Julia process and improved error messages
Ethan Sherbondy
@sherbondy
Loving the project so far. Is there a means for the inline evaluator to run relative to the path of the file being evaluated rather than the LightTable directory? e.g. run(pwd) yields /Applications/LightTable.app/Contents/Resources/app.nw. Is the expectation to launch a terminal client instead?