kenkangxgwe / lsp-wl Goto Github PK
View Code? Open in Web Editor NEWA Wolfram Language Server
License: MIT License
A Wolfram Language Server
License: MIT License
Just cloned lsp-wl to my Arch Linux system and, after following the paclet instructions, tried to run it.
With Mathematica 12.0 installed, I ran
wolfram -script init.wls
and got the following output:
[INFO 2021-02-01T21:09:06] Initializing Wolfram Language Server
[INFO 2021-02-01T21:09:07] Language server is connecting the client through
socket.
SocketConnect::zmqexception:
A ZeroMQLink exception was thrown - Connection refused (code 111)
[ERROR 2021-02-01T21:09:07] Cannot connect to client via socket.
On Ubuntu 20.04, I try to use lsp-wl
in the self compiled git master version of Emacs using the following settings in ~/.emacs.d/init.el
according to the notes here:
(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"
"~/Public/repo/github.com/kenkangxgwe/lsp-wl.git/init.wls"
,(concat
"--socket="
(number-to-string port)
))))
:major-modes '(wolfram-mode)
:server-id 'lsp-wl
))
But when I start Emacs, I noticed the following info:
Warning (initialization): An error occurred while loading ‘/home/werner/.emacs.d/init.el’:
Symbol's value as variable is void: lsp-language-id-configuration
Any hints for fixing this problem?
Regards,
HY
During initialisation of the server from 'development' branch (MMA 12.2/12.3 pre/macOS/ VSCode extension)
[INFO 2021-03-30T12:51:10] Initializing Wolfram Language Server
LogDebug::shdw:
Symbol LogDebug appears in multiple contexts
{ZeroMQLink`Logging`, WolframLanguageServer`Logger`}
; definitions in context ZeroMQLink`Logging`
may shadow or be shadowed by other definitions.
LogInfo::shdw: Symbol LogInfo appears in multiple contexts
{ZeroMQLink`Logging`, WolframLanguageServer`Logger`}
; definitions in context ZeroMQLink`Logging`
may shadow or be shadowed by other definitions.
LogWarn::shdw: Symbol LogWarn appears in multiple contexts
{ZeroMQLink`Logging`, WolframLanguageServer`Logger`}
; definitions in context ZeroMQLink`Logging`
may shadow or be shadowed by other definitions.
LogError::shdw:
Symbol LogError appears in multiple contexts
{ZeroMQLink`Logging`, WolframLanguageServer`Logger`}
; definitions in context ZeroMQLink`Logging`
may shadow or be shadowed by other definitions.
This extension is very good but it needs a debugger to be completed.
On Ubuntu 20.04, I use the latest stable vscode
and the git master version of lsp-wl
. I noticed the following strange problem: after login into the system, the first time running of the "Start Debugging F5" with the lsp-wl
will fail with the following error:
The easy and quick way to fix this problem is running the math
or mathematica
commands once. Other workarounds, based on my observation, including, but may not be limited to, the following way: Click on the "Cancel", and then re-run the "Start Debugging F5" for several times, the problem will finally disappear.
Afterwards, if I close the vscode
, then restart it, the problem doesn't appear again. More specifically, the problem occurs only when F5
is called from vscode
for the first time after logging into the system.
Regards,
HY
This issue keeps track of the symbols that are not shown correctly in the symbol usage messages (such as hover and completion).
Some symbols are defined in the Private Use Area of Mathematica fonts, thus we are looking for Unicode symbols to replace them.
For example:
\[LeftAssociation]
-> <|
\[TwoWayRule]
-> <->
TODO:
I installed it several days ago, met several problems. Finally I overcome them, and hope this article can help others.Besides, it is awesome!
I use this code. And into debug mode.
fib[1]=1;
fib[2]=1;
fib[3]=2;
fib[4]=3;
fib[5]=5;
fib[x_]:=fib[x]=fib[x-1]+fib[x-2];
Print[fib[30]]
In git bash, I get these.
fib[2]=1;
fib[3]=2;
fib[4]=3;
fib[5]=5;
fib[x_]:=fib[x]=fib[x-1]+fib[x-2];
Print[fib[30]
]
[ERROR 2021-01-26T18:14:59] <|type -> event, event -> stopped, body -> <|reason
-> pause, description -> Cell Evaluated Successfully, threadId ->
Key[id][KernelObject[1, local]]|>|>
Hi @Gravifer , did you open a remote file with a local VSCode. If so, can you open a local file with the server running correctly?
Yes, the server is working smoothly on local files.
In the former comment, I was actually trying to link the server with a WolframEngine kernel on the remote machine, by modifying the remote:SSH settings.json
, specifying the path of wolfram
on the remote machine, as well as the path to the clone of this repo on the remote machine. There are several possible combinations:
kernel | language server | file | current status | |
1 | local | local | local | neato ditto |
2 | remote | remote | remote | ZMQ exception |
3 | local | remote | remote | to try |
4 | remote | local | remote | to try |
5 | remote | local | remote | to try |
I'll update my testing results here ASAP.
P.S.: At this point it seems that support for remoting could actually be a separate feature request, and may not really fit in the thread of this issue. Feel free to move this discussion to a new open issue if needed.
Originally posted by @Gravifer in #36 (comment)
Hello, I've just started using lsp-wl, and I've discovered that the WolframKernel process is using 100% of one core as soon as VSCode is launched, and pegs it there. I'm running Mathematica 11.3, and the latest pull of lsp-wl.
我Mathematica升级到12.3后我就无法使用lsp的补全功能了,看起来是没有连接到wolfram内核上去
设置都是没问题的,内核我也都确认了没有问题
Recently I find this https://tieba.baidu.com/p/6566049919 8th floor.
And I try it in wls.
<<JavaGraphics`
Plot[x,{x,0,5}]
The picture flash by. So I wonder there maybe some ways to hold it?
PS, if I run it line by line, this is the effect.
PPS, recently I use matlab, and matlab can plot.
this is its code in Code Runner.
"matlab": "cd $dir && matlab -nosplash -nodesktop -r $fileNameWithoutExt"
I tried to use it on mma's setting.
"wolframscript -file"
But failed.
I'm trying this server with coc-lsp-wl but I'm only getting "Connection to server got closed. Server will restart." in :CocInfo
.
Output: https://gist.github.com/oblitum/4e8489a0205ec49650046a005c9f9c7f
I follow the steps in the installation section but found there was no syntax highlighting? Currently, I am using this plugin for syntax highlighting.
Hi,
I played with this language server protocol yesterday and following instructions, I ran PacletInstall["CodeParser"]
PacletInstall["CodeInspector"] in my Mathematica 12.1 notebook.
However, my MMA stopped working today. It freezes at the initializing process when I try to open it.
Any advice on undo the language server protocol and these 2 installed paclets, so I can make MMA work again?
First of all, awesome project, thank you!
I have done everything in the docs, but I still don't get syntax highlighting. I have verified that the language server is running. What am I missing?
The language server does not seem to start in my VS Code. It keeps notifying me to install the right AST and Lint version AST-0.15 and Lint-0.15. Running {PacletInstall["AST", "UpdateSites" -> True], PacletInstall["Lint", "UpdateSites" -> True]}
returns
{PacletObject[
Association[
"Name" -> "AST", "Version" -> "0.16", "WolframVersion" -> "11.0+",
"Creator" -> "Brenton Bostick <[email protected]>",
"Extensions" -> {{
"Kernel", "Root" -> "Kernel", "Context" -> "AST`"}, {
"Documentation", "Language" -> "English"}, {"LibraryLink"}},
"Location" -> "C:\\Users\\407\\AppData\\Roaming\\Mathematica\\\
Paclets\\Repository\\AST-0.16"]], PacletObject[
Association[
"Name" -> "Lint", "Version" -> "0.16", "WolframVersion" -> "11.0+",
"Creator" -> "Brenton Bostick <[email protected]>",
"Extensions" -> {{
"Kernel", "Root" -> "Kernel", "Context" -> "Lint`"}, {
"Documentation", "Language" -> "English"}, {"FrontEnd"}},
"Location" -> "C:\\Users\\407\\AppData\\Roaming\\Mathematica\\\
Paclets\\Repository\\Lint-0.16"]]}
Am I doing anything wrong here?
Basically, FoldWhile is a new System-context symbol in Mathematica version 12.2 and higher:
So there is a name clash with the function defined in Server.wl. As far as I can tell, the LSP function and the System-context context function do the same thing, but the LSP function should be renamed to fix the issue.
[INFO 2021-01-14T11:09:14] Initializing Wolfram Language Server
SetDelayed::write:
Tag FoldWhile in FoldWhile[f_, x_, list_List, test_] is Protected.
SetDelayed::write:
Tag FoldWhile in FoldWhile[f_, list_List, test_] is Protected.
as the title said.
On Ubuntu 20.04, I try to use lsp-wl
in the self compiled git master version of Emacs using the following settings in ~/.emacs.d/init.el
according to the notes here:
(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"
"~/Public/repo/github.com/kenkangxgwe/lsp-wl.git/init.wls"
,(concat
"--socket="
(number-to-string port)
))))
:major-modes '(wolfram-mode)
:server-id 'lsp-wl
))
After Emacs has been started, I still don't know how to trigger/activate the corresponding functions supplied by lsp-wl
, just as seen in vscode
shown in the following screenshot:
Any hints will be highly appreciated.
Regards,
HY
macOS/MMA 12.2/12.3pre, VSCode. 'development' branch.
This behaviour persist even when VSCode is not visible and nothing happens.
Any hints on how to diagnose this further are welcome.
To reproduce, use vim-surround and add two brackets around a word
Do not wait until completionResolve
to reveal the item.kind
Upon running init.wls I get:
[INFO 2020-01-25T11:16:51] Initializing Wolfram Language Server
FileExistsQ::badfile:
The specified argument AST`Library`Private`CompiledLibrary[/Users/ddyok/Lib
rary/WolframEngine/Paclets/Repository/AST-0.15/LibraryResources/MacOSX-x
86-64/expr.dylib] should be a valid string or File.
[INFO 2020-01-25T11:16:53] Language server is connecting the client through
socket.
SocketConnect::zmqexception:
A ZeroMQLink exception was thrown - Connection refused (code 61)
[ERROR 2020-01-25T11:16:53] Cannot connect to client via socket.
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
Is this on my end?
I'm new to VS Code and this extension. I tried to install it and run the test with wolframscript /path/to/lsp-wl/init.wls --test, -t
. It returns the following error:
Running tests for all.
FileExistsQ::badfile: The specified argument AST`Library`Private`CompiledLibrary[/Users/User/Library/Mathematica/Paclets/Repository/AST-0.15/LibraryResources/MacOSX-x86-64/expr.dylib] should be a valid string or File.
Column[{Column[{TableForm[{{Test: , WolframLanguageServer`Test`TextDocumentTest`}, {Test passed: , {{3, /, 3}}}, {Time Elapsed: , Quantity[0.0008230000000000001`2.588793578324601, Seconds]}}], Column[{}]}]}]
The extension also does not seem to be started in my VS Code. I have already install the AST and Lint Paclet with {PacletInstall["AST", "UpdateSites" -> True], PacletInstall["Lint", "UpdateSites" -> True]}
in Mathematica and it returns {Paclet[AST, 0.15, <>], Paclet[Lint, 0.15, <>]}
, which means that the 2 paclets seem to be rightly installed.
Am I doing something wrong here?
This code can make the logo in the center.
<p align="center">
<img alt="WolframLanguageServerLogo" src="images/wolfram-language-server-logo-clipped.png" >
</p>
It will be helpful to implement a stdio channel,
so that the Mathematica earlier than 11.2 will also be supported,but it is really hard to expose the stdin channel. Hope this will be dicussed in future release of Wolfram kernel.
This has been a well-known ( to people that know it) problem with Mathematica for years and is unlikely to change anytime soon. I wrote MathLine specifically to deal with this problem. It may be of help to you.
lots of messages like this are generated during textDocument/publishDiagnostics:
StringDrop::seqs:
Sequence specification (+n, -n, {+n}, {-n}, {m, n}, or {m, n, s}) expected
at position 2 in StringDrop[pollSockets[timeout_Integer] ,
WolframLanguageServer`TextDocument`Private`startCharacter].
lsp-wl-master>wolfram -script init.wls --log=debug
[DEBUG 2019-10-24T19:27:45] Logging level: DEBUG
[INFO 2019-10-24T19:27:45] Initializing Wolfram Language Server
[DEBUG 2019-10-24T19:27:48] Cache: D:\Setup\Plugin\Mathematica
Package\Bridge\lsp-wl-master\wlServerCache
[INFO 2019-10-24T19:27:48] Language server is connecting the client through
socket.
FromCharacterCode::notunicode:
A character code, which should be a non-negative integer less than 65536,
is expected at position 1 in
{-45, -55, -45, -38, -60, -65, -79, -22, -68, -58, -53, -29, -69, -6,
-69, -3, -68, -85, -66, -36, -66, -8, -93, -84, -50, -34, -73, -88, -63,
-84, -67, -45, -95, -93, 13, 10}.
SocketConnect::zmqexception:
A ZeroMQLink exception was thrown -
FromCharacterCode[{-45, -55, -45, -38, -60, -65, -79, -22, -68, -58, -53,
-29, -69, -6, -69, -3, -68, -85, -66, -36, -66, <<5>>, -73, -88, -63,
-84, -67, -45, -95, -93, 13, 10}, UTF-8] (code 10061)
[ERROR 2019-10-24T19:27:49] Cannot connect to client via socket.
lsp-wl-master>wolfram -script init.wls -v
Wolfram Language Server 0.1.1 running on
Wolfram Language 11.2.0 for Microsoft Windows (64-bit) (October 2, 2017)
I'm using AST 0.13 & Lint 0.13 as there seems to be no lower versions provided anymore. Are they essential?
If course, I'll provide any infomation if you need.
I got following error:
Get::noopen: Cannot open GitLink`.
Needs::nocont: Context GitLink` was not created when Needs was evaluated.
This error has resolved by installing GitLink.
This dependency should be written in README.md
, I think.
Hi, I am trying to implement a lsp-wl client in emacs (lsp-mode). However, the editor gives an error on completion because the lsp client expects the triggerCharacter to be a String[] instead of String.
I am not a developer, just trying to implement the lsp-client which the lsp-mode author made quite easy to do. However I contacted him about this 'bug' and he mentioned this in his reply (see image below)
On Ubuntu 20.04, I use lsp-wl with the latest stable version of vscode. I find a strange completion behaviour as described below:
Firstly, we type \
and some character, say, f
, as shown below:
Then, we click on Backspace
to delete the f
, and re-type f
. This time, the pop-up window of the completion entries will look like below:
As you can see, they are different. Any hints for this problem?
Regards,
HY
for example:
When I type Plot
,it will show this.
after that,I want to type, for example : Plot[x,{x,0,5}]
but after I type []
, I have to type the format by memory.
Can it show the hint like this? (though C++ is huge different from mma)
After I type something and a comma , it will change the highlight.
The current implementation supports document structure based on MMA cell structures (like (* ::Title:: *)
). To my knowledge the official version is a pure front-end feature, and it is of much convenience to have it handled for code editors.
However, the kernel features - namespaces (contexts and packages) and scoping constructs like Module
Block
- are not resolved. Therefore, developers will have to go through the scripts manually to tell which context a symbol is in.
As most authors use namespaces concurrently along with cell structures, the current features are actually sufficient, and this issue may not be a necessity; if this is the case, this thread could be used to discuss the best practice for concurrent use of namespaces and cell structures.
There're lots of messages in the form:
ParentDirectory::dirnex:
Directory Users/ppavel/Projects/wolfram-engine-app-server/paclet/Kernel/App
Server does not exist.
ParentDirectory::nums:
Argument ParentDirectory[Users/ppavel/Projects/wolfram-engine-app-server/pa
clet/Kernel/AppServer] should be a positive machine-size integer, a
nonempty string, or a File specification.
ParentDirectory::nums:
Argument ParentDirectory[ParentDirectory[Users/ppavel/Projects/wolfram-engi
ne-app-server/paclet/Kernel/AppServer]] should be a positive
machine-size integer, a nonempty string, or a File specification.
ParentDirectory::nums:
Argument ParentDirectory[ParentDirectory[ParentDirectory[Users/ppavel/Proje
cts/wolfram-engine-app-server/paclet/Kernel/AppServer]]] should be a
positive machine-size integer, a nonempty string, or a File
specification.
General::stop: Further output of ParentDirectory::nums
will be suppressed during this calculation.
as the image shows, it will warning. But it did can run in .wls
.
\[Alpha]=1
Print[\[Alpha]]
besides, I have tested that this can't run.
α=1;Print[α]
in .nb , α
will be translated into \[Alpha]
,then do the following calculation.(But shown as α).
So here are some advice.
\[Alpha]
as α,but run it as itself.(But it's confusing that how to deal with the widith of this character)α
.But if use //CopyToClipboard//UsingFrontEnd
,it's also hard to deal with.(Or maybe just ignore it?)α
into vscode, change it into \[Alpha]
(but shown as α
)Maybe there can be a switch to open/close the "translate"? If some users really want to see \[Alpha]
.
This issue is to collect different formatting styles of Wolfram Language. The current state of the language server is not capable to do complicate formatting (not even simple ones, because I haven't implemented any lol). I know that Brenton (@bostick the author of AST and Lint) is working on a code formatter (see the end of the video, and I definitely admire his ambition to do notebook manipulation 🤣 but I haven't known whether his formatter will let users define their own styles.
Since people have different appetites this issue welcomes ALL possible styles that we can format the wolfram language into. YES, all possible styles. I didn't say I would accept or implement all of them, just for the aesthetic purpose.
A code block or screenshot to illustrate the style is recommended.
Here are some features we can start thinking from:
If[condition,
true,
false
]
F@a
vs F @ a
same for (//
)a ~Join~ b
vs a ~ Join ~ b
i++
vs i ++
same for other unary operators"str"<>"ing"
vs "str" <> "ing"
(same for ~~
).wl
/.wls
file in Mathematica. Thus it is recommended to split up different(* ::Section:: *)
(*section name*)
Function1 := functionDefinition1
Attributes[Function] = {Protect}
(* overloads *)
Function2[a_String] := (functionDefinition2)
Function2[a_] := (functionDefinition3)
Function[aVeryLongParameterThatSomeHowYouWantToWrapTheLine1,
aVeryLongParameterThatSomeHowYouWantToWrapTheLine2]
Function[
aVeryLongParameterThatSomeHowYouWantToWrapTheLine1,
aVeryLongParameterThatSomeHowYouWantToWrapTheLine2]
ThisFunctionHasALongName[ThisFunctionHasALongNameToo[
ThisParameterHasLongNameToo]]
ThisFunctionHasALongName[
ThisFunctionHasALongNameToo[ThisParameterHasLongNameToo]
]
]
at the end of the line
Function[aVeryLongParameterThatSomeHowYouWantToWrapTheLine1,
aVeryLongParameterThatSomeHowYouWantToWrapTheLine2]
]
at the begining of the line
(*dynamic indentation*)
Function[
aVeryLongParameterThatSomeHowYouWantToWrapTheLine1,
aVeryLongParameterThatSomeHowYouWantToWrapTheLine2
]
{
, (
, <|
at the end of the line
list = {
aVeryLongListElement1,
aVeryLongListElement2,
aVeryLongListElement3
}
list =
{
aVeryLongListElement1,
aVeryLongListElement2,
aVeryLongListElement3
}
MatchQ[form1 |
form2 |
form3]
MatchQ[form1
| form2
| form3]
&&
, ||
, <>
, ~~
, etcCompoundExpression
)Using it with coc-lsp-wl, when I close Vim, the WolframKernel instance started by the editor is left dangling when the editor is closed. Does the plugin have to do something in particular to close it? The WolframKernel instances keep accumulating and the fix I know of is to killall -9
.
As far as I know. MMA doesn't have a commonly used code formater.
I searched on mse, find this https://github.com/lshifr/CodeFormatter . But it seems a bit hard to use.
So where can I find the code formater?(Since there are only 3 mma-about plugins in VS Code plugin market)
Meanwhile, format it by hand is not pleased.
Good day!
I'v got lots of messages like this (the character is a Cyrillic unicode character as encoded by MMA in notebooks AND .wl files created using frontend).
P.S.:
I'm willing to participate in development of the project. Frankly I tried it several times with VSCode but it never even started wolfram kernel. This issue should be broken in parts probably so please consider is as an initial contact.
Currently the server starts but the only thing that works is getting document outline from the server (no syntax highlighting, no hover info etc). This behaviour persists in both master (that seems to be "more broken") and development branches.
I get both 12.2 and 12.3 prerelease versions installed under macOS and I also use Linux so I can try different combinations.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.