Sublime Text 3: Worth a look!

Just a minor UI feature you may know from some point, but useful here with the split windows:
The ‘Super’ key (Windows Key) coupled with L/R/U/D arrows resizes a window to fill left half, right half, upper or lower half of a screen (keep going and will push to another monitor if you have one).
This is VERY useful for getting two windows lined up side by side quickly!

Sorry for the delay, here is a code with a good example of PrettyTables.jl HTML back-end:

using PrettyTables

t = 0:1:20;
data = hcat(t, ones(length(t))*1, 1*t, 0.5.*t.^2);
header = ["Time" "Acceleration" "Velocity" "Distance";
               "[s]"       "[m/s²]"    "[m/s]"      "[m]"];

hl_v = HTMLHighlighter( (data,i,j)->(j == 3) && data[i,3] > 9, HTMLDecoration(color = "blue", font_weight = "bold"));
hl_p = HTMLHighlighter( (data,i,j)->(j == 4) && data[i,4] > 10, HTMLDecoration(color = "red"));
hl_e = HTMLHighlighter( (data,i,j)->data[i,1] == 10, HTMLDecoration(background = "gray", color = "white"));

pretty_table(data, header, backend = :html, highlighters = (hl_e, hl_p, hl_v, hl_e))

No worries, this is great, thanks!! Ok, how can this be saved as .html file? Anything special to get formatting correct?
From there, think this workflow would be complete (using a local hot-loaded static html server feeding a browser window).

If you want to save to a HTML file, then just do this:

open("index.html", "w") do f
pretty_table(f, data, header, backend = :html, highlighters = (hl_e, hl_p, hl_v, hl_e))
1 Like

Hi @dawbarton, nice you joined the fray here, thanks for all your replies to get things working for folks!

That’s perfect @Ronis_BR, saving to html file was the last piece needed for the workflow. Ok, thanks to @xiaodai for prompting desire to see output in a browser, and after reading up on live-loading and hot-loading of static servers, have a real simple solution working that is quite dynamic using an open-source MIT licensed app and requires zero browser plugins. Node is a dependency.

There are a ton of static servers out there that can serve a local page. Willurd on github put together a list of “one-liners”, and then someone took that and all the comments and created comprehensive list, see: Used a few criteria wading through the options, such as no browser plugin (eliminating livereloadx and others), be dynamic without requiring clicks, Open Source with permissive license, etc. . Should be extensible for other scenarios where Julia produces html output. This should work cross-platform, a windows user will need to validate as have switched to linux now :smiling_face_with_three_hearts:
App selected is simply called reload (reload - npm):

The code is commented, so won’t retype. Set view in ST3 to slip top-bottom with REPL shrunk down on bottom, hid tabs and sidebar, and then used the Super(Win)-Left key to put ST3 on left 1/2 of monitor. Just used Super(Win)-Right key to quickly place the browser launched by reload app on the right side of monitor (can just go to another monitor). Here is a screenshot:

And the commented code as provided by Ronis, who is the real hero here! :clap: Note, changed exponent to ^4, altering and resending the html output automatically reloads the browser - and it’s snappy!

## PrettyTables to Browser with ST3 - Workflow

# ref: 
# The '-g' option in the npm install command installs the app globally
# $ sudo npm install -g reload                                          [1]
# /usr/bin/reload -> /usr/lib/node_modules/reload/bin/reload
# + reload@3.0.3
# added 50 packages from 53 contributors in 8.159s
# pwd()
# "/home/e/Documents/eds2020_xps15/julia/workflow/html-st3"
# This is where HTML file will be saved by PrettyTables, alter as needed.
# Send the 3 line-output command to write the index.html file.
# Once file is present in directory, navigate to directory in a terminal shell.
# Enter following command to run 'reload' app and launch a browser with '-b'
# $ reload -b
# This is what it will look like when running, with a new line for each time index.html changes:
# ~/.../workflow/html-st3 >>> reload -b                                                                
# Reload web server:
# listening on port 8080
# monitoring dir /home/e/Documents/eds2020_xps15/julia/workflow/html-st3
# Server restarted  at 12:52:16
# Server restarted  at 12:52:48

using PrettyTables

t = 0:1:20;
data = hcat(t, ones(length(t))*1, 1*t, 0.5.*t.^4);
header = ["Time" "Acceleration" "Velocity" "Distance";
               "[s]"       "[m/s²]"    "[m/s]"      "[m]"];

hl_v = HTMLHighlighter( (data,i,j)->(j == 3) && data[i,3] > 9, HTMLDecoration(color = "blue", font_weight = "bold"));
hl_p = HTMLHighlighter( (data,i,j)->(j == 4) && data[i,4] > 10, HTMLDecoration(color = "red"));
hl_e = HTMLHighlighter( (data,i,j)->data[i,1] == 10, HTMLDecoration(background = "gray", color = "white"));

# The below line outputs to the REPL. We skip this with the HTML output
# pretty_table(data, header, backend = :html, highlighters = (hl_e, hl_p, hl_v, hl_e))
# After updating any code, highlight below 3-lines and ctrl-enter to send to REPL. HTML will refresh
open("index.html", "w") do f
pretty_table(f, data, header, backend = :html, highlighters = (hl_e, hl_p, hl_v, hl_e))

Ok, we now we have Blink as mentioned above, and this browser method, both working for interactive output! @xiaodai, if you are up to it, perhaps compare this to the Blink approach you used, which you described as clunky, it would be nice to know if the reload solution is more or less clunky?


This looks like a really nice option, especially with the lazy loading. The above might just completely break with large tables, not sure. Thanks for bringing this up @pdeffebach

OK. Preferences. Embedding means that cool Sublime packages are available to the user.

That’s correct! My bad

Does the Julia plugin have the same ability as send code or it just send to the Julia REPL? If latter then I can’t use a remote REPL e.g. Windows connect to Ubuntu server with Julia

The SendCode plugin sends code to a particular terminal rather than the Julia REPL directly. In Windows I use ConEmu as a terminal program and so anything open in ConEmu gets the code. It could be that you have a Julia REPL open via remote SSH connection to another machine, in which case that will receive the code. (I have to admit that I’ve never tried it though.)

I imagine that the same works with the Terminus plugin for an embedded terminal.

I have already asked this elsewhere, but now realise this might be a more appropriate setting.

ST3 + LSP + julia do work well together now. However, autocompletion is not really there, and it would be great to have autocompletion of Julia functions (from Base or any loaded package), something that Atom has. How complicated would that be? TabNine works well, but does not serve this functionality.

(Not an expert at all, so apologies if the question makes little sense).

1 Like

Maybe the only inconvenient coding in ST3 is that it don’t have a plug-in for julia-autocompletion.

1 Like

Any idea how hard it would be to make such plug-in? The presence of LSP should imply it is more than feasible, so I’m sort of curious why no one has come up with it.

I use IJulia to autocomplete with ST3 under ubuntu, but the win10 can’t find the libzmq.dll no matter how i set its path.
I can’t find a document about how to config ST3 + LSP + julia.
In fact, i know a little about LSP.

I don’t know current status, but there used to be an LSP package for ST3. On another note, ST4 is expected to have a much improved indexing and autocompletion built in.

1 Like

Have they released any information about it?

There is a discord channel where details are abundant. Also downloads of ST4 builds. Documentation is at Documentation

1 Like

Autocompletion should work in Sublime Text with the LSP package and LanguageServer.jl installed.
But it seems like the path to the Julia environment must be explicitely given in its arguments when starting the language server. The bash script for Linux/macOS that is referenced in docs for the LSP package doesn’t have that path specified, so autocompletion probably wouldn’t work with it.
I use the following command in my LSP settings file to start the server (with the default environment):

"command": ["julia", "--startup-file=no", "--history-file=no", "-e", "using Pkg; using LanguageServer; using LanguageServer.SymbolServer; env_path=dirname(Pkg.Types.Context().env.project_file); server=LanguageServer.LanguageServerInstance(stdin,stdout,false,env_path,first(Base.DEPOT_PATH)); run(server)"],

Notice that the API for the language server has changed on the master branch recently, so the next realease of that package will most likely be v3.0.0 and you would have to omit the false (for debug) in the starting arguments then.

The bash script mentioned above is used to avoid orphaned language server processes when the ST window is closed without having shut down all server sessions first, but as I’m on Windows I can’t use it anyway.

The only thing I haven’t really got to work in Sublime Text yet, is the linter which is included in the language server.


Linting with LanguageServer.jl has to be configured to be enabled.

I assume sublime text provides some way of doing lsp configuration, but I’m not familiar enough to say. See the vs-code config linked in the above issue for the available options and values.

I know and I have the client configured to send the following answer to the workspace/configuration request (comments by me):

4, // 'julia.format.indent'
true, // 'julia.format.indents'
true, // 'julia.format.ops' 
true, // 'julia.format.tuples'
true, // 'julia.format.curly'
true, // 'julia.format.calls'
true, // 'julia.format.iterOps'
true, // 'julia.format.comments'
true, // ''
false, // 'julia.format.lineends'
true, // ''
true, // ''
false, // ''
true, // 'julia.lint.iter'
false, // 'julia.lint.nothingcomp'
true, // 'julia.lint.constif'
true, // 'julia.lint.lazy'
false, // 'julia.lint.datadecl'
true, // 'julia.lint.typeparam'
true, // 'julia.lint.modname'
true // 'julia.lint.pirates'

And the language server then sends a textDocument/publishDiagnostics notification with the correct linting diagnostics for each workspace file after that, however it is followed by another notification with 'diagnostics': [] after that, and all further notifications have empty diagnostics as well.