Skip to content
康小广 edited this page Jul 23, 2021 · 22 revisions

Editor Support

Visual Studio Code

Get the Extension from Visual Studio Marketplace

GNU Emacs

Tested under Linux. Not work for Windows, because it seems that lsp-mode doesn't support socket for Windows.

(add-to-list 'lsp-language-id-configuration '(wolfram-mode . "Mathematica"))

(lsp-register-client
 (make-lsp-client :language-id 'wolfram
                  :new-connection (lsp-tcp-server-command
                                   (lambda (port)
                                     `("wolfram" ;; or "wolframscript"
                                       "-script" ;; or "-file"
                                       "path/to/lsp-wl/init.wls"
                                       ,(concat
                                         "--socket="
                                         (number-to-string port)
                                         ))))
                  :major-modes '(wolfram-mode)
                  :server-id 'lsp-wl
                  ))

(Neo)vim

Use coc.nvim together with coc-lsp-wl.

Troubleshooting

Enable Logging

To reveal the internal debug and kernel message, change info to debug at init.wls#L188 or the similar place if you check out another branch. It reads:

    loglevel = ArgumentValue["--log"|"-l", Alternatives @@ LoggingLevels]
        // Replace[_Missing -> "debug"];

You can see the logging message in the output console of the editor. You may also dump it to a file. Uncomment init.wls#L194 or the similar place in another branch, so it reads:

    logstreams = {
        OpenWrite[WolframLanguageServer`RootDirectory <> "wlserver.log"],
        First @ Streams["stderr"]
    };

It will be saved to path/to/lsp-wl/wlserver.log.

Working with Mathematica 12.3

Mathematica 12.3 shipped with a new ZeroMQLink paclet version 1.2.0 which was found to have issues with TCP connections. WRI soon updated a new version (1.2.1) through their paclet server. Unfortunately, it doesn't resolve the issue correctly and what is worse, since it is posted to the public server, all previous Mathematica versions start to auto-update themselves to this 1.2.1 version. So what I suggested you to do as a temporary workaround is:

  • Disable the auto-updated paclet, if it already exists for your version
PacletDisable["ZeroMQLink" -> "1.2.0"]
PacletDisable["ZeroMQLink" -> "1.2.1"]
PacletDisable["ZeroMQLink" -> "1.2.2"]
  • If your version is less than 12.3, then you are good to go.
    If you are on 12.3, install the old stable version for ZeroMQLink (version 1.1.22) from the official paclet server.
PacletInstall["ZeroMQLink" -> "1.1.22", ForceVersionInstall -> True]

The TCP connection issue should be resolved. I will keep updating the tips here if there's a newer working version available, so Please remember to come back occasionally.

Working with Wolfram Engine 12.3.x

Some versions of Wolfram Engine 12.3.x do not come with symbol usages. Thus all the hovering and completion documentation will be empty at the moment. As a workaround, you can copy an existing Usage.m file from Mathematica or another version of Wolfram Engine. The path is $InstallationDirectory\SystemFiles\Kernel\TextResources\$Language\Usage.m.

Cannot start w/ Mathematica 11.2

The Curry issue has been resolved in 0.2.1. If it still happens, please file an issue.

  • Currys has been replaced by lambda expressions project-widely.

    Meanwhile, I figured out that Curry is not so efficient as the lambda function, so I started to transform them back into Function.

    Mathematica 11.2 doesn't have Curry function, so far, you just need to checkout the develop branch, where I implemented my own MyCurry function.

Related Posts

中文