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
n
variables in the current scope and emit the style variable-n
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.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.
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...
Cool, it would be great if you could have a look at doing this – here's a couple of notes:
.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.)match-highlighter
is neat – I might have it enabled by default if it plays well with unicode.
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 ;)
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
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?
.cm-s-june-night span.cm-variable-2 {color: #ffc; font-weight: bold; opacity: .55;}
).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!
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.
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)?
pwd
) yields /Applications/LightTable.app/Contents/Resources/app.nw. Is the expectation to launch a terminal client instead?
.CodeMirror-linebackground.error
) that isn't implemented anywhere else.
julia
from the repos, then Pkg.add("Jewel")
, finally I install the Jupiter
plugin in Light Table, but I get this error: http://bit.ly/UXFvG8
ctrl+enter
.