Set up Sublime Text 4 for Julia

I found a thread about setting up Sublime Text 3 now I am struggling to setting up correctly Sublime-Text 4 for Julia.
First great thing I found was the language-sever support:
LSP-julia
And at that point I struggle already, Julia is not in the %PATH% and I do not know how and in which configuration file I should specify the full-path.

As the GitHub readme explains:

If the julia executable is not in your PATH, you need to provide the full path to the executable in the LSP-julia package settings.

So go to the command palette, type “LSP-julia settings” and you’ll see:

image

Ok, what is missing is a hint, how to install the LSP-julia package.
I tried to install via package manager:
sublime_text_package_manager
But the ``LSP-julia` package is not listed :frowning:
sublime_text_package_manager_install_package

If you face the same situation, the reason might be that LSP-julia is already present.
My error was, I had installed LSP-julia, but was not aware of it. In a previous attempt to install the package, there was no success-message, e.g. “Installation was successful!”.
I restarted Sublime Text and was not able to find a hint that the package is now present.
The entry-point for the configuration of the package is hidden:

Nothing’s hidden from the command palette:

image

1 Like

As far as I understand are there two configuration files for the package, one is read only and is part of the package itself. And user configuration should be added in a user specific configuration file.
As the backslash is special character it must be masked, in this by the same char. Spaces in the file path must be masked also be a backslash.

Another detail might be the variable: "JULIA_SSL_CA_ROOTS_PATH".
Is it helpful to define this variable via startup.jl?
See: updating-julia-packages-from-sublime-text

And now come two other questions:
Is there Julia-REPL inside sublime text 4?
How to execute a Julia-script from inside sublime text 4?
P.S.:
Meanwhile I found:
HowToUseJuliaWithSublimeText3
But this might be outdated, is there something similar to get started with sublime text 4?

1 Like

Yes, Terminus - Packages - Package Control. I also use SendCode, SendCode - Packages - Package Control to execute code in the REPL.

This is still not very clear to me which steps I need to go. E.g. what do you put here:

[
    {
        "keys": ["ctrl+shift+enter"], "command": "send_code",
        "args": {"cmd": "\n", "prog": "tmux"}
    }
]

SendCode_Prog
If I select Terminus and send e.g. one code line, I see the following error:

ERROR: syntax: extra token "201" after end of expression                                                                                                                                                                           
Stacktrace:                                                                                                                                                                                                                        
 [1] top-level scope                                                                                                                                                                                                               
   @ none:1                                                                                                                                                                                                                        

I found something:
bracketed_paste_mode
Now my personal configuration for SendCode contains:

{
	"julia":
	{
		"bracketed_paste_mode": false,
		"prog": "terminus",
	},
	"prog": "terminus",
}

The instructions for ST3 still hold. I use them with ST4 (these days also known as ST).

2 Likes

And what about this command definition:

[
    {
        "keys": ["ctrl+shift+enter"], "command": "send_code",
        "args": {"cmd": "cd(\"$file_path\")"},
        "context": [
            { "key": "selector", "operator": "equal", "operand": "source.julia" }
        ]
    },	
]

There must be something wrong, but what?
I would like to perform the command: PSP-julia: Run Code Cell and it seems as if
the keystroke combination is assigned to this command:
run_code_cell

But something goes wrong, if I send the command via LSP-julia-menu (Ctrl+Shift+p) it works as expected, but if I use the assigned keystroke the folder of the current script combined with cd() is send to Terminus, e.g.:

julia> cd("C:\\data\\julia_scripts\\examples\\strings")

Isn’t your command “ctrl+shift+enter” instead of “alt+shift+enter” ?

Yes, you are right, but where and how to configure (ctrl+shift+enter) to execute the command PSP-julia: Run Code Cell.

I see, you want an alias for “alt+shift+enter”?

Ok, I see my mistake, this is the result of copy-and-paste:

"args": {"cmd": "cd(\"$file_path\")"},

Now it is obvious, why this happens, but the question is still there,
how to bind the Run Code Cell-command to the keystroke (ctrl+shift+enter)?

@jwortmann · GitHub
informed me how to bind the Run Code Cell to a user defined keystroke:

 { 
     "keys": ["alt+shift+j"], 
     "command": "julia_run_code_cell", 
     "context": [ 
         {"key": "selector", "operand": "source.julia"}, 
         {"key": "setting.lsp_active"} 
     ] 
 }, 

And he gave me an advice, to benefit from all features from the ST LSP-julia-package, it makes sense to open the root folder of the Pkg-Julia-Environment where the environment configuration file Project.toml is located as project folder.
P.S.:
To run code inside the Terminus REPL-window, it is not necessary to install the SendCode ST package.

1 Like

I would be interested to find out how much better LSP is compared to the auto complete (if at all) .

see also related thread: