Skip to content

WolframResearch/Sublime-WolframLanguage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wolfram System Integration with Sublime Text

Official Sublime Text package for Wolfram Language

Developing Wolfram Language Code in Other Editors and IDEs with LSP from WTC 2021: Watch Video (youtube)

Download and install the free Wolfram Engine

Forked from https://github.com/ViktorQvarfordt/Sublime-WolframLanguage

Thanks Viktor!

Features

  • Syntax Highlighting
  • Goto Definition
  • Auto complete
  • Diagnostics and suggestions for fixes
  • Formatting files and selections
  • Expand and shrink selection
  • Color swatches
  • Symbol references
  • Documentation on hover
  • New menu items (Open in System Editor)

Syntax Highlighting

Support for the entire Wolfram Language syntax and all built-in functions.

highlighting

Setup

Compatible with Sublime Text 3 and Sublime Text 4.

If the LSP package (https://github.com/sublimelsp/LSP) is installed, then additional features will be available.

LSP functionality uses a Wolfram kernel to run as a language server.

This requires Wolfram System 12.1 or higher.

You can use either Mathematica or the free Wolfram Engine.

If you do not have the Wolfram System installed, then download and install the free Wolfram Engine.

  1. Install Package Control
  2. Open Tools > Command Palette...
  3. Select Package Control: Install Package
  4. Install LSP
  5. Install WolframLanguage

The package must be installed from Wolfram Research.

The WolframLanguage package depends on LSPServer paclet to provide LSP functionality.

Install LSPServer paclet and its dependencies by running this Wolfram Language code:

PacletInstall["CodeParser"]
PacletInstall["CodeInspector"]
PacletInstall["CodeFormatter"]
PacletInstall["LSPServer"]

If properly setup, you should have syntax highlighting and linting of Wolfram Language .wl files.

Test this by typing this into a new .wl file and saving it:

Which[a, b, a, b]

You should see warnings about duplicate clauses.

Settings

If you have Wolfram System installed in the default location on your system, you may not have to change any settings.

If Wolfram System is not in the default location, then specify the actual location:

Go to the menu item: Package Settings > Wolfram Language > Settings

Add a kernel setting:

{
  …

  "kernel": "/Applications/Mathematica.app/Contents/MacOS/WolframKernel"
  …
}

The default location for Wolfram Engine on Linux is:

/usr/local/Wolfram/WolframEngine/13.1/Executables/WolframKernel

The default location for Wolfram Engine on Windows is:

C:\Program Files\Wolfram Research\Wolfram Engine\13.1\WolframKernel.exe

The default location for Wolfram Engine on macOS is:

/Applications/Mathematica.app/Contents/MacOS/WolframKernel

Other Settings

You may use a special Light color scheme that emulates the syntax coloring of the notebook editor:

{
  …
  "color_scheme": "WolframLanguage.sublime-color-scheme"
  …
}

Experimental Settings

You can enable experimental settings. These are not supported.

implicitTokens controls the display of implicit tokens.

{
  …

  "implicitTokens": ["*", ",", ";;", "?"]
  …
}
  • "*": display implicit Times character ×
  • ",": display Null around stray commas
  • ;;: display 1 and All around ;;
  • ;: display Null after ;
  • ?: display in place of missing arguments

Troubleshooting

Troubleshooting LSP for Sublime Text

Make sure that LSPServer paclet and its dependencies are up-to-date and can be found on your system:

PacletInstall["CodeParser"]
PacletInstall["CodeInspector"]
PacletInstall["CodeFormatter"]
PacletInstall["LSPServer"]

Needs["LSPServer`"]

If the kernel cannot start, then follow the instructions in the dialog that pops up after 15 seconds for more information.

Server settings

Check WolframLanguage.sublime-settings for errors.

Turn on debug logging from the kernel by giving a string argument to StartServer[].

This is a directory that kernel logs will be written to.

Needs["LSPServer`"];LSPServer`StartServer["/path/to/log/directory/"]