-
Notifications
You must be signed in to change notification settings - Fork 22
Home
Get the Extension from Visual Studio Marketplace
Tested under Linux. Not working for Windows, since sockets are not supported. See 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
))
For windows, emacs does not support socket communications. We can write a small script (in whatever language that supports stdio and TCP) to bridge between stdio and socket. An example js script can be found here: https://gist.github.com/kenkangxgwe/67e7a830848650bf88bbc36f8d3e2af5.
Then the emacs config becomes:
(add-to-list 'lsp-language-id-configuration '(wolfram-mode . "Mathematica"))
(lsp-register-client
(make-lsp-client :language-id 'wolfram
:new-connection (lsp-stdio-connection
'("node"
"/path/to/lsp-wl-stdio-bridge.js"))
:activation-fn (lsp-activate-on "Mathematica")
:major-modes '(wolfram-mode)
:server-id 'lsp-wl
))
eglot
intentionally avoids pipe due to the same reason.
Tested only on Linux, but it may work on Windows.
(let ((wlserver (expand-file-name "path/to/lsp-wl/init.wls")))
(when (and (file-exists-p wlserver) (executable-find "wolframscript"))
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
`(wolfram-mode . ("wolframscript" "-f" ,wlserver
"--tcp-server" :autoport))))))
Use coc.nvim together with coc-lsp-wl.
Syntax highlight is NOT provided since it is not a feature of LSP, but there are already some good enough extensions written by Flip Phillips and by shigma.
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
.
Mathematica 12.3 & 13.0 are shipped with a new ZeroMQLink paclet version 1.2.0 which was found to have issues with TCP connections.
Please manually upgrade the ZeroMQLink paclet to version 1.2.6 or later:
PacletInstall["ZeroMQLink"]
Some versions of Wolfram Engine do not come with symbol usages. Thus all the hovering and completion documentation will be empty with that particular version.
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
.
The Curry
issue has been resolved in 0.2.1. If it still happens, please file an issue.
-
Curry
s has been replaced by lambda expressions project-widely.Meanwhile, I figured out thatCurry
is not so efficient as the lambda function, so I started to transform them back intoFunction
.Mathematica 11.2 doesn't haveCurry
function, so far, you just need to checkout thedevelop
branch, where I implemented my ownMyCurry
function.