Set up Sublime Text 3 for Julia

I want to set up Sublime Text 3 for Julia, but could not find a detailed instruction. I followed this guidance:

but I am not sure how to link Julia to it.

1 Like

Pretty sure you don’t – that plugin only provides

  • Syntax highlighting
  • Unicode tab completion (like the REPL)
  • Auto-indentation
  • Snippets

so there’s no need for a connection to a local julia installation or anything like that. That also means you’re going to miss out on the integration that VSCode/Juno/the-LSP-enabled-editor-of-your-choice provides though.

1 Like

I saw it under the Editor support, so how can I use Julia in sublime next

You can’t use Julia in Sublime Text, but you can write your code in ST3 and include it (or use Revise.jl) in a separate REPL session.

There used to be a way to run a Julia REPL (Edit: I think it may have been an IJulia terminal, actually) inside Sublime, but that was a long time ago, I don’t know if that works now.

You can run a terminal next to the editor and use https://github.com/randy3k/SendCode to send the code to the REPL. In my experience, it works quite well, but that is the workflow I abandoned in favour of VS Code and Juno, without any regrets. The ST workflow is limited in comparison.

I think some very brave folks might have gotten (or at least tried) LanguageServer.jl hooked up with Sublime, which would give you some more integration. But I’m not sure whether it actually worked in the end.

1 Like

Yes, you can, I use it all the time. The instructions on how to install Sublime-Ijulia plugin for Sublime text are found on the page at Github: https://github.com/quinnj/Sublime-IJulia.

2 Likes

Right, completly forgot about that plugin. Sorry for spreading misinformation :slight_smile:

Sublime Text users could use run LanguageServer.jl vis https://github.com/randy3k/LSP-julia and LSP.

I should have put it in the README of JuliaEditorSupport/Julia-sublime

1 Like

You might want to checkout https://github.com/ngr-t/SublimeHermes for jupyter support (especially the use_jupyter_client branch)

The terminal can be run inside ST3 (I like Terminus). The package SendCode is capable of sending Julia lines, selections, etc. to the terminal running within the editor. It works very smoothly.

2 Likes

Is it possible to upload this package to package control or to the official LSP package?

Here is my favourite for the Terminus Command Palette. If there is an open (.jl) file, the this opens up Julia (in the same folder) on the right side of the screen:

[
 	{
         "caption": "Terminus: Open Julia",
         "command": "terminus_open",
         "args"   : {
             "cmd": ["d:/Julia/julia10.cmd"],
             "cwd": "${file_path:${folder}}",
             "title": "Julia 1.0",
				      "pre_window_hooks": [
               ["set_layout", {
                   "cols": [0.0, 0.6, 1.0],
                   "rows": [0.0, 1.0],
                   "cells": [[0, 0, 1, 1], [1, 0, 2, 1]]
               }],
               ["focus_group", {"group": 1}]
            ]           

         }
     },	
]

The Julia10.cmd file contains just D:\Julia\Julia-1.0.1\bin\julia.exe (maybe I could bypass that).

2 Likes

This works beautifully. I have simplified this a tiny bit by "cmd": ["julia"], as I make sure the Julia executable is in the path.

By the way, is the correct procedure for installing this command to put it in the In Default.sublime-settings in the Terminus package?

By the way, kudos and many thanks to Randy Lai (@randy3k) for the packages SendCode and Terminus. Beautifully done and eminently useful for Sublime Text 3!

2 Likes

Indeed, now I am interested in LanguageServer integration for even better Julia experience. Does LanguageServer properly work with julia 1.0 yet?

is the correct procedure for installing this command to put it in the In Default.sublime-settings in the Terminus package?

Not sure. I just did Ctrl+Shift+P and then Preferences: Terminus Command Palette

Right, that makes sense. Thanks.

Randy,

Doesn’t this require LanguageServer.jl? I believe it only works for Julia version 0.6 (@davidanthoff)…?

By the way, it isn’t quite clear to me how https://github.com/randy3k/LSP-julia interacts with the package LSP and the actual language server. If I read your python plug-in correctly, you start LanguageServer in Julia. Did this work with Julia 0.6?

To configure LSP I did

{
	"clients": {
		"julials":
		{
		  "command": ["julials"],
		  "scopes": ["source.julia"],
		  "syntaxes": ["Packages/User/Julia-sublime/Julia.sublime-syntax"],
		  "languageId": "julia"
		},
	},
	"log_debug": true,
}

Does that look about right?

The weird thing is Julia.sublime-syntax was not installed through Package Control when Julia syntax-highlighting was installed as a package. I had to find it and copy it manually into the User settings folder.

This thread is old so I’m not sure if anybody still needs this info, but it’s new to me. :slight_smile: I got Sublime Text 3 LSP working with Julia today by simply following the instructions on this page: Sublime Text Language Server Protocol Documentation - Julia

Key versions:

  • Julia 1.3.1
  • LanguageServer.jl v1.0.0
  • SymbolServer.jl v1.0.1
  • Windows 10 64-bit

There is no need to install package LSP-julia.

These features seem to work:

  • Mouse hovering to show doc string / variable definition.
  • Right click a symbol (e.g. function name), choose LSP to “Find Symbol References”, or “Go to Symbol Definition”, or “Format Document”

For unknown reason, “Rename Symbol” does not seem to work for me.

One puzzle I spent hours to figure out: LSP for Julia started working on one of my PCs but not on another, with everything at exactly the same version, and Sublime Text 3 being an exact clone of each other (I use the portable version). On the PC that’s not working, I could see the Julia process running the language server in the background, but Sublime Text 3 never showed “julials initialized” message.

It turned out to be the firewall blocking port 8080, which is the default port used by the language server! Once I opened TCP port 8080 on my Windows Firewall julials started working.

Luckily I don’t use port 8080 for anything else, otherwise I would have to set up a different port for the language server, which can easily be done on Sublime Text 3 side (just search “tcp_port” in the Sublime Text Language Server Protocol Documentation), but I have no idea how for LanguageServer.jl

2 Likes