Git Product home page Git Product logo

vscode-wolfram's Introduction

Wolfram System Integration with Visual Studio Code

Official Visual Studio Code extension 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

Features

  • Syntax Highlighting
  • Diagnostics and suggestions for fixes
  • Formatting files and selections
  • Semantic highlighting
  • Expand and shrink selection
  • Outline
  • 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

Install the Wolfram Language extension from the Visual Studio Code Marketplace.

The extension must be installed from Wolfram Research.

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.

The Wolfram Language extension 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 (either Mathematica or Wolfram Engine) 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:

Open the Command Palette

Enter the command: Preferences: Configure Language Specific Settings...

Enter @ext:wolframresearch.wolfram

A UI file is now open.

settings

And change the Wolfram: Kernel setting to the location of the WolframKernel executable to use.

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

It is convenient to remove $ from word separators, which is a letterlike character in WL.

It is also convenient to add _ from word separators, which is NOT a letterlike character in WL.

"editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?_"

A color theme that focuses on WL syntax is available.

"workbench.colorTheme": "BrentonWL"

Experimental Settings

You can enable experimental settings. These are not supported.

Wolfram: Implicit Tokens controls the display of implicit tokens:

["*", ",", ";;", "?"]
  • "*": display implicit Times character Γ—
  • ",": display Null around stray commas
  • ;;: display 1 and All around ;;
  • ;: display Null after ;
  • ?: display β–‘ in place of missing arguments

Wolfram: Semantic Tokens controls semantic highlighting such as Module variables.

To use semantic tokens, a theme that has semantic highlighting enabled must be used, such as BrentonWL.

Troubleshooting

Make sure that the paclets can be found on your system:

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

Needs["LSPServer`"]

If the kernel cannot start, then check Output view and open the Wolfram Language Error Report output channel for more information.

error report

vscode-wolfram's People

Contributors

lumakernel avatar padinadrian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-wolfram's Issues

Formatting and Commenting shortcuts

I followed the link from the extension page (in VS Code), but that sent me to the Sublime Text repo. Here's what I posted there. Please feel free to delete the irrelevant post:

I love the new plugin. What's stopping me from moving from IntelliJ to VS Code is some of the formatting shortcuts. The two shortcuts that would be really helpful are:

Formatting (add spaces) like cmnd+opt+L in IntelliJ
Wrap selection in (* *) and also unwrap it like cmnd+opt+/ in IntelliJ
Also, navigation to function definitions is easier in IntelliJ. Using shfit+shift and typing my function name is very helpful. In VS Code, cmnd+P only gets me to file names.

Extra points if you can get this to work within other expressions. For Example, I might have a function that caches my user name like this:
With[{user = $Username}, myFunction[string_] := user <> string ]
But in IntelliJ, myFunction isn't found because it's within another expression.

Couldn't start client Wolfram Language

Hello, Thank you for this nice extension.

I used it regularly for package management on a laptop with Linux running on endeavouros but after moving to fedora I received the error in the title. I am using version 13.2 of Mathematica and Version: 1.74.3 of VScode. The paclets seemed to be installed

'Go to Definition' Support across project

Is this plugin somehow responsible for finding definitions via VSCode's 'Go to Definition'? It seems to work fine within a file, but across a project (especially a project with a wild file structure like mine) it doesn't seem to work. I'm wondering if I can contribute something to either make it work or understand the structure it is expecting currently. Any pointers appreciated.

Setting up vscode-wolfram on Mac M1

Hi all,

I'm setting up my VS Code environment to prepare for the Wolfram Summer School '23 coming up. My goal is to use VS Code as my Wolfram IDE.

Here's my system specs:
Model Name: MacBook Pro Model Identifier: MacBookPro18,1 Chip: Apple M1 Pro Total Number of Cores: 10 (8 performance and 2 efficiency) Memory: 32 GB

Setup algorithm:

  1. Download and installed version 13.2
  2. Installed VS Code Plugin Install version 1.7.0
  3. Use this to setup help
  4. In my workspace.code-workspace I added:
{
	"folders": [
		{
			"path": "."
		}
	],

	"wolfram.kernel": "/Applications/Wolfram Engine.app/Contents/MacOS/WolframKernel",

	"settings": {
		"wolfram.kernel": "/Applications/Wolfram Engine.app/Contents/MacOS/WolframKernel",
		"wolfram.installationDirectory": "/Applications/Wolfram Engine.app/Contents/MacOS/WolframKernel",
		"editor.fontLigatures": false,
		"wolfram.command": [
			"`kernel`",
			"-noinit",
			"-noprompt",
			"-nopaclet",
			"-noicon",
			"-nostartuppaclets",
			"-run",
			"Needs[\"LSPServer`\"];LSPServer`StartServer[]"
		],
		"editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|:'\",.<>/?",
		"workbench.colorTheme": "BrentonWL",
		"editor.fontVariations": false,
	}

	
}

Facts and notes:

  1. Wasn't sure where wolfram.kernel needed to be which is why it's two places in the json above.
  2. Confirmed kernel install by successfully running wolframscript from command line
  3. When I open a test.wl with Which[a, b, a, b] I do see Duplicate clauses in Which. error in problems tab. However,
  4. In the Output tab > Wolfram Language I get this error:
12:40:39.126 $CommandLine: {/Applications/Wolfram Engine.app/Contents/MacOS/WolframKernel, -noinit, -noprompt, -nopaclet, -noicon, -nostartuppaclets, -run, Needs["LSPServer`"];LSPServer`StartServer[]}
12:40:39.128 

12:40:39.128 $commProcess: StdIO
12:40:39.128 

12:40:39.128 $ProcessID: 24696
12:40:39.128 

12:40:39.128 $ParentProcessID: 24563
12:40:39.129 

12:40:39.129 Directory[]: /private/var/folders/ll/ncs54ns51dvc_v__m6s7brh40000gn/T/Wolfram-LSPServer
12:40:39.129 

12:40:39.129 Starting server... (If this is the last line you see, then StartServer[] may have been called in an unexpected way and the server is hanging.)
12:40:39.129 
  1. I've disabled other extensions to see if that's the issue.
  2. In the Output > Extension Host I get this warning too:
    [warning] TextEditor is closed/disposed [info] ExtensionService#_doActivateExtension WolframResearch.wolfram, startup: false, activationEvent: 'onLanguage:wolfram'
  3. I've wondered if the "/Applications/Wolfram Engine.app/Contents/MacOS/WolframKernel" needs an escape in "Wolfram Engine"

So I haven't been able to write/run Wolfram code in VS Code yet.

Thanks in advance for the help!

Blank should be a wordseparator as well

The Readme file suggests setting up the following characters as word separators:

"editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?",

Shouldn't _ be one as well? It's really annoying when you can't select myVar in myVar_String easily.

Crash while trying to select code in a saved file

Server is crashing while trying to select trivial code with Cmd+Shift+Up in a saved file.

Make a file test.m, with only a simple line f[x_] := x, put a cursor between x and _, and press Cmd+Shift+Up:

Screen.Recording.2022-10-13.at.14.39.31.mov

Part::pspec1: Part specification Key[CodeParser`Source] is not applicable.

Part::partd: Part specification (-1 + {CodeParser`CallNode[{CodeParser`LeafNode[Symbol, f, <|CodeParser`Source -> {{1, 1}, {1, 2}}|>]}, CodeParser`GroupNode[CodeParser`GroupSquare, {CodeParser`LeafNode[Token`OpenSquare, [, <|CodeParser`Source -> {{1, 2}, {1, 3}}|>], CodeParser`CompoundNode[CodeParser`PatternBlank, {CodeParser`LeafNode[Symbol, x, <|CodeParser`Source -> {{1, 3}, {1, 4}}|>], CodeParser`LeafNode[Token`Under, _, <|CodeParser`Source -> {{1, 4}, {1, 5}}|>]}, <|CodeParser`Source -> {{1, 3}, {1, 5}}|>], CodeParser`LeafNode[Token`CloseSquare, ], <|CodeParser`Source -> {{1, 5}, {1, 6}}|>]}, <|CodeParser`Source -> {{1, 2}, {1, 6}}|>], <|CodeParser`Source -> {{1, 1}, {1, 6}}|>], CodeParser`LeafNode[Whitespace,  , <|CodeParser`Source -> {{1, 6}, {1, 7}}|>], CodeParser`LeafNode[Token`ColonEqual, :=, <|CodeParser`Source -> {{1, 7}, {1, 9}}|>], CodeParser`LeafNode[Whitespace,  , <|CodeParser`Source -> {{1, 9}, {1, 10}}|>], CodeParser`LeafNode[Symbol, x, <|CodeParser`Source -> {{1, 10}, {1, 11}}|>]}[[3,Key[CodeParser`Source]]])[[1,1]] is longer than depth of object.

Part::partd: Part specification (-1 + {CodeParser`CallNode[{CodeParser`LeafNode[Symbol, f, <|CodeParser`Source -> {{1, 1}, {1, 2}}|>]}, CodeParser`GroupNode[CodeParser`GroupSquare, {CodeParser`LeafNode[Token`OpenSquare, [, <|CodeParser`Source -> {{1, 2}, {1, 3}}|>], CodeParser`CompoundNode[CodeParser`PatternBlank, {CodeParser`LeafNode[Symbol, x, <|CodeParser`Source -> {{1, 3}, {1, 4}}|>], CodeParser`LeafNode[Token`Under, _, <|CodeParser`Source -> {{1, 4}, {1, 5}}|>]}, <|CodeParser`Source -> {{1, 3}, {1, 5}}|>], CodeParser`LeafNode[Token`CloseSquare, ], <|CodeParser`Source -> {{1, 5}, {1, 6}}|>]}, <|CodeParser`Source -> {{1, 2}, {1, 6}}|>], <|CodeParser`Source -> {{1, 1}, {1, 6}}|>], CodeParser`LeafNode[Whitespace,  , <|CodeParser`Source -> {{1, 6}, {1, 7}}|>], CodeParser`LeafNode[Token`ColonEqual, :=, <|CodeParser`Source -> {{1, 7}, {1, 9}}|>], CodeParser`LeafNode[Whitespace,  , <|CodeParser`Source -> {{1, 9}, {1, 10}}|>], CodeParser`LeafNode[Symbol, x, <|CodeParser`Source -> {{1, 10}, {1, 11}}|>]}[[3,Key[CodeParser`Source]]])[[1,2]] is longer than depth of object.

Developer`WriteRawJSONString::jsonstrictencoding: Expression Part cannot be exported as JSON.
14:40:22.045 


14:40:22.046 Could not convert to JSON: <|jsonrpc -> 2.0, id -> 8, result -> {<|range -> <|start -> <|line -> 0, character -> 2|>, end -> <|line -> 0, character -> 3|>|>, parent -> <|range -> <|start -> <|line -> 0, character -> 2|>, end -> <|line -> 0, character -> 4|>|>, parent -> <|range -> <|start -> <|line -> 0, character -> 1|>, end -> <|line -> 0, character -> 5|>|>, parent -> <|range -> <|start -> <|line -> (-1 + {CallNode[{LeafNode[Symbol, f, <|Source -> {{1, 1}, {1, 2}}|>]}, GroupNode[GroupSquare, {LeafNode[Token`OpenSquare, [, <|Source -> {{1, 2}, {1, 3}}|>], CompoundNode[PatternBlank, {LeafNode[Symbol, x, <|Source -> {{1, 3}, {1, 4}}|>], LeafNode[Token`Under, _, <|Source -> {{1, 4}, {1, 5}}|>]}, <|Source -> {{1, 3}, {1, 5}}|>], LeafNode[Token`CloseSquare, ], <|Source -> {{1, 5}, {1, 6}}|>]}, <|Source -> {{1, 2}, {1, 6}}|>], <|Source -> {{1, 1}, {1, 6}}|>], LeafNode[Whitespace,  , <|Source -> {{1, 6}, {1, 7}}|>], LeafNode[Token`ColonEqual, :=, <|Source -> {{1, 7}, {1, 9}}|>], LeafNode[Whitespace,  , <|Source -> {{1, 9}, {1, 10}}|>], LeafNode[Symbol, x, <|Source -> {{1, 10}, {1, 11}}|>]}[[3,Key[Source]]])[[1,1]], character -> (-1 + {CallNode[{LeafNode[Symbol, f, <|Source -> {{1, 1}, {1, 2}}|>]}, GroupNode[GroupSquare, {LeafNode[Token`OpenSquare, [, <|Source -> {{1, 2}, {1, 3}}|>], CompoundNode[PatternBlank, {LeafNode[Symbol, x, <|Source -> {{1, 3}, {1, 4}}|>], LeafNode[Token`Under, _, <|Source -> {{1, 4}, {1, 5}}|>]}, <|Source -> {{1, 3}, {1, 5}}|>], LeafNode[Token`CloseSquare, ], <|Source -> {{1, 5}, {1, 6}}|>]}, <|Source -> {{1, 2}, {1, 6}}|>], <|Source -> {{1, 1}, {1, 6}}|>], LeafNode[Whitespace,  , <|Source -> {{1, 6}, {1, 7}}|>], LeafNode[Token`ColonEqual, :=, <|Source -> {{1, 7}, {1, 9}}|>], LeafNode[Whitespace,  , <|Source -> {{1, 9}, {1, 10}}|>], LeafNode[Symbol, x, <|Source -> {{1, 10}, {1, 11}}|>]}[[3,Key[Source]]])[[1,2]]|>, end -> <|line -> {CallNode[{LeafNode[Symbol, f, <|Source -> {{1, 1}, {1, 2}}|>]}, GroupNode[GroupSquare, {LeafNode[Token`OpenSquare, [, <|Source -> {{1, 2}, {1, 3}}|>], CompoundNode[PatternBlank, {LeafNode[Symbol, x, <|Source -> {{1, 3}, {1, 4}}|>], LeafNode[Token`Under, _, <|Source -> {{1, 4}, {1, 5}}|>]}, <|Source -> {{1, 3}, {1, 5}}|>], LeafNode[Token`CloseSquare, ], <|Source -> {{1, 5}, {1, 6}}|>]}, <|Source -> {{1, 2}, {1, 6}}|>], <|Source -> {{1, 1}, {1, 6}}|>], LeafNode[Whitespace,  , <|Source -> {{1, 6}, {1, 7}}|>], LeafNode[Token`ColonEqual, :=, <|Source -> {{1, 7}, {1, 9}}|>], LeafNode[Whitespace,  , <|Source -> {{1, 9}, {1, 10}}|>], LeafNode[Symbol, x, <|Source -> {{1, 10}, {1, 11}}|>]}, character -> 3|>|>|>|>|>|>}|>
14:40:22.047 


14:40:22.047 Language Server kernel did not shutdown properly.
14:40:22.047 
14:40:22.047 This is the command that was used:
14:40:22.047 {/Applications/Mathematica.app/Contents/MacOS/WolframKernel, -noinit, -noprompt, -nopaclet, -noicon, -nostartuppaclets, -run, Needs["LSPServer`"];LSPServer`StartServer[]}
14:40:22.048 
14:40:22.048 To help diagnose the problem, run this in a notebook:
             Needs["LSPServer`"]
             LSPServer`RunServerDiagnostic[{"/Applications/Mathematica.app/Contents/MacOS/WolframKernel", "-noinit", "-noprompt", "-nopaclet", "-noicon", "-nostartuppaclets", "-run", "Needs[\"LSPServer`\"];LSPServer`StartServer[]"}]
14:40:22.048 
14:40:22.048 Fix any problems then restart and try again.
14:40:22.048 


14:40:22.048 KERNEL IS EXITING HARD
14:40:22.048 


[Info  - 2:40:23 PM] Connection to server got closed. Server will restart.
[Error - 2:40:23 PM] Request textDocument/selectionRange failed.
Error: Connection got disposed.
    at Object.connectionOptions [as dispose] (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-jsonrpc/lib/common/connection.js:1045:52)
    at Object._clientOptions [as dispose] (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-languageclient/lib/common/client.js:2414:123)
    at w.fillInitializeParams (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-languageclient/lib/common/client.js:2432:27)
    at w.this [as handleConnectionClosed] (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-languageclient/lib/node/main.js:158:15)
    at isEmpty (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-languageclient/lib/common/client.js:2413:45)
    at i._callbacks [as invoke] (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-jsonrpc/lib/common/events.js:64:5)
    at o.timer [as fire] (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-jsonrpc/lib/common/events.js:122:18)
    at isEmpty (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-jsonrpc/lib/common/connection.js:274:33)
    at i._callbacks [as invoke] (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-jsonrpc/lib/common/events.js:64:5)
    at o.partialMessageEmitter [as fire] (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-jsonrpc/lib/common/events.js:122:18)
    at m.fireClose (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-jsonrpc/lib/common/messageReader.js:43:21)
    at Socket.<anonymous> (/Users/swish/.vscode/extensions/wolframresearch.wolfram-1.7.0/node_modules/vscode-jsonrpc/lib/common/messageReader.js:131:45)
    at Socket.emit (node:events:538:35)
    at Pipe.<anonymous> (node:net:687:12)
14:40:25.098 $CommandLine: {/Applications/Mathematica.app/Contents/MacOS/WolframKernel, -noinit, -noprompt, -nopaclet, -noicon, -nostartuppaclets, -run, Needs["LSPServer`"];LSPServer`StartServer[]}
14:40:25.100 


14:40:25.100 $commProcess: StdIO
14:40:25.100 


14:40:25.100 $ProcessID: 90329
14:40:25.101 


14:40:25.101 $ParentProcessID: 90158
14:40:25.101 


14:40:25.101 Directory[]: /private/var/folders/ll/y9p6f70j7bxddkx_3l8rr8fh0000gn/T/Wolfram-LSPServer
14:40:25.101 


14:40:25.101 Starting server... (If this is the last line you see, then StartServer[] may have been called in an unexpected way and the server is hanging.)
14:40:25.101 



When I use the newest versions of both CodeFormatter and LSPServer, the extension gives warning "LSPServer and CodeFormatter are of different versions".

Mathematica: 13.0
Operating System: Windows 11
CodeFormatter: 1.5.2
LSPServer: 1.5.0

Because both versions are the newest, I am confused why it warns about them being of different versions. I am further confused by the fact that, if I try to install CodeFormatter using command PacletInstall["CodeFormatter"->"1.5.0"], Wolfram gives error "No paclet ... is available is available for download from any currently enabled paclet sites." This leads me to believe that I should, indeed, be using the newest versions of every paclet repectively, instead of keeping their version numbers the same.

However, not wanting to risk it, I downloaded CodeFormatter 1.5.0's source code to build it. Then, the extension gives warning "CodeFormatter and LSPServer are built too far apart".

These warnings contradict each other. I am confused what versions the extension is trying to tell me to use.

Cannot start Wolfram Language server

I installed this extension in VS code and installed the LSPServer in the wolframscript.exe of Wolfram Engine. It didn't function well: "No usage message" for all functions and no "Syntax highlighting".

Environments

OS: Windows_NT x64 10.0.19042
VS code Version: 1.60.2
Wolfram Engine Version :12.3.1 for Microsoft Windows (64-bit) (June 24, 2021)

Details

When I open a file.m file, it first pops a warning

LSPServer BuildDate cannot be parsed: DateObject[{Tue 24 Aug 2021 15:00:00, {DayName,  , Day,  , MonthName,  , Year,  , Hour, :, Minute, :, Second}}]

then an error

Cannot start Wolfram Language server. Check Wolfram Language Error Report output channel for more information.

The error report reads

Language Server kernel did not initialize properly after 10 seconds.

This is the command that was used:
C:\Program Files\Wolfram Research\Wolfram Engine\12.3\WolframKernel,-noinit,-noprompt,-nopaclet,-noicon,-nostartuppaclets,-run,Needs["LSPServer`"];LSPServer`StartServer[]

To help diagnose the problem, run this in a notebook:

Needs["LSPServer`"]
LSPServer`RunServerDiagnostic[{"C:\Program Files\Wolfram Research\Wolfram Engine\12.3\WolframKernel", "-noinit", "-noprompt", "-nopaclet", "-noicon", "-nostartuppaclets", "-run", "Needs[\"LSPServer`\"];LSPServer`StartServer[]"}]

Fix any problems then restart and try again.

So I run the code given above in the wolframscript.exe of Wolfram Engine, it gives

Running Language Server diagnostic...

WARNING: There are unrecognized arguments to Language Server kernel: {-nostartuppaclets}

Starting Language Server kernel with command: {C:\Program Files\Wolfram Research\Wolfram Engine\12.3\WolframKernel.exe,-noinit,-noprompt,-nopaclet,-noicon,-nostartuppaclets,-run,Needs["LSPServer`"];LSPServer`StartServer[]}



If any messages are printed below, they must be fixed.



Writing initialize...

and nothing else.

The above problem just behaves the same when I use Mathematica(version 12.2) instead of Wolfram Engine. (Path setting in VS code had been changed right; LSPServer was installed in Mathematica; diagnose code was run in the notebook of Mathematica)

Here are some screenshots. (At some moment when I was trying to find the problem and running the LSPServer in the wolframscript, the usages of functions were shown but no syntax highlighting. However, I can't repeat that.)
image
image

Starting client failed

I'm having problems using this extension.

System is Windows 10 Enterprise.
Wolfram Engine Installed on default folder
C:\Program Files\Wolfram Research\Wolfram Engine\13.1

The kernel works fine by itself.

image

Output tab shows:

[Error - 13:53:16] Starting client failed
Launching server using command "C:\Program Files\Wolfram Research\Wolfram Engine\13.1\WolframKernel.exe" failed.

My settings.json files is like this:

{
    "telemetry.enableCrashReporter": true,
    "telemetry.enableTelemetry": true,
    "code-runner.enableAppInsights": false,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "python.languageServer": "Default",
    "terminal.integrated.detectLocale": "on",
    "cSpell.userWords": [
    ],
    "cSpell.language": "en-GB",
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
    "terminal.integrated.shellArgs.windows": null,
    "workbench.colorTheme": "BrentonWL",
    "wolfram.semanticTokens": true,
    "wolfram.command": [
        "`kernel`",
        "-noinit",
        "-noprompt",
        "-nopaclet",
        "-noicon",
        "-nostartuppaclets",
        "-run",
        "Needs[\"LSPServer`\"];LSPServer`StartServer[]"
    ],
    "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:'\",.<>/?_",
    "[wolfram]": {
        "wolfram.kernel": "C:\\Program Files\\Wolfram Research\\Wolfram Engine\\13.1\\WolframKernel.exe",
        "wolfram.command": [
            "`kernel`",
            "-noinit",
            "-noprompt",
            "-nopaclet",
            "-noicon",
            "-nostartuppaclets",
            "-run",
            "Needs[\"LSPServer`\"];LSPServer`StartServer[]"
        ]
    },
    "wolfram.kernel": "C:\\Program Files\\Wolfram Research\\Wolfram Engine\\13.1\\WolframKernel.exe"
}

image

Syntax highlighting: symbols

Hi, I decided to give it a try. Is there any documentation about customizing styles used for WL files? Especially to enable highlighting without affecting the whole vs-code colors with the BrentonWL theme?

That was the side note, the main issue is here:

image

  • UpdateTarget has two colors
  • System symbols like Attributes and HoldAll have different coloring
  • Square brackets have orange, pink and blue coloring, is it correct? Maybe there's logic behind it but I'd prefer a single color anyway
  • notice bin[root, key] = {} line, the bin is pale blue like a full name symbols e.g. FrontEnd\UpdateDynamicObjects`

I guess most of the I could fix with custom theme but maybe they manifest something that requires fixing so I decided to post it.

Thanks for your work on code tools.
Best

Selection expansion not working?

Hi,

I just tried giving this a go, but I can't figure out how the selection expansion is supposed to work. As far as I can tell, selection just expands in the same way as in any other text editor (letter -> word -> line -> everything). Another user I spoke to also mentioned this problem. Is there a special shortcut or something for it?

Selection expansion is extremely important to me; I basically won't consider any plugin that doesn't do it correctly, which is one of the main reasons I'm still on the Eclipse plugin even though it has a number of other issues.

Best,
Sjoerd

Request of implementation of devcontainer

Hi, it's been a while since I used Wolfram product and looking into the docker container got here. This project looks promising and seems a perfect match to create a vscode-dev-container which will make the setup of a development environment to test things out very trivial.

Not sure if this is the right place to post the request, let me know if there is a better place.

Thanks,

Cannot run wl files in VSCode

Hi,
I will appreciate your help for running wl code from VS Code. I do the following sequence:

1- I verified that I can run the Wolfram Engine from the Wolframscript.
2- I installed this package from the VS Code market place
3- I had to change the VS code kernel directory (that still points to 13.1) to be 13.2.
4-I created a one line wl file containing the code:
Range[3]
Note that the wl file gets interactive syntax Wolfram language highlighting, syntax checking, and documentation.
5- Run the file without debugging (Ctrl+F5) and I get a Visual Studio Code dialog box with the message:
"You don't have an extension for debugging Wolfram. Should we find a Wolfram extension in the Marketplace?"
With a button: "Find Wolfram extension"
6- Clicking on the button generates a: "@category:debuggers Wolfram" which results in "No extension found"

Note: Because I cannot execute Wolfram code I don't know how/where to execute
LSPServer placelet you mention in the setup documentation. If I run those installation lines of code in Wolframscript they execute ok but I still get the same error inside VSCode.
Could you please guide me. What am I doing wrong?

Another question: Not sure if the functionality in this repository is supposed to allow the execution of notebooks in VS code.

Thanks,
Petrarca

$MaxLicenseProcesses with Infinity crashes LSPServer

I've run the LSPServer`RunServerDiagnosticBasically, the problem boils down to this error:
Developer`WriteRawJSONString::jsonstrictencoding: Expression DirectedInfinity cannot be exported as JSON.

Could not convert to JSON: <|jsonrpc -> 2.0, id -> 2, result -> <|kernelVersion -> 13.0, commandLine -> {/Applications/Wolfram Desktop 13.1.app/Contents/MacOS/WolframKernel, -noinit, -noprompt, -nopaclet, -noicon, -nostartuppaclets, -run, Needs[LSPServer`];LSPServer`StartServer[]}, directory -> /Users/swish, maxLicenseProcesses -> Infinity, lspServerVersion -> 1.7, codeParserVersion -> 1.7, codeInspectorVersion -> 1.7, codeFormatterVersion -> 1.7, lspServerBuildDate -> Wed 29 Jun 2022 18:12:08, codeParserBuildDate -> Fri 01 Jul 2022 11:50:30, codeInspectorBuildDate -> Fri 01 Jul 2022 11:58:38, codeFormatterBuildDate -> Fri 01 Jul 2022 13:03:52|>|>

Problem building vsix package

πŸ‘‹ Hello! I tried following the instructions in HowToBuild.md but ran into a problem. I'm running on linux and using the WolframEngine instead of Mathematica. Here are the commands I ran:

npm install -g vsce
mkdir build
cd build
cmake -DWOLFRAMKERNEL=/usr/local/Wolfram/WolframEngine/12.3/Executables/WolframKernel ..
cmake --build .

And got the following error message:

...
[88] external "net" 42 bytes {0} [built]
    + 121 hidden modules
 ERROR  Couldn't detect the repository where this extension is published. The image 'docs/highlighting.png' will be broken in README.md. GitHub/GitLab repositories will be automatically detected. Otherwise, please provide the repository URL in package.json or use the --baseContentUrl and --baseImagesUrl options.
make[2]: *** [CMakeFiles/vsix.dir/build.make:71: wolfram-1.4.0.vsix] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/vsix.dir/all] Error 2
make: *** [Makefile:118: all] Error 2

Any idea what I might have forgotten to do?

Can not start Wolfram language server

After following the instructions on the homepage of the repository I do get the code highlights and issues on the test example as well as the real project files, however, I still get the error message:
"Cannot start Wolfram language server. Check Output view and open the Wolfram Language Error Report output channel for more information. "

There is nothing helpful in the Wolfram Language output, but Wolfram Language Error Report shows the error that the Language server kernel did not start in 10 seconds. This is what I get from running the diagnostics in the notebook:

Needs["LSPServer`"];
LSPServer`RunServerDiagnostic[{"c:\Program Files\Wolfram Research\Mathematica\12.3\WolframKernel.exe","-noinit","-noprompt","-nopaclet","-nostartuppaclets","-noicon","-run","Needs[\"LSPServer`\"];LSPServer`StartServer[]"}]
Kernel that is running RunServerDiagnostic[] ($CommandLine[[1]]): WolframKernel
Kernel that RunServerDiagnostic[] will start (RunServerDiagnostic[{kernel, ...}]): c:\Program Files\Wolfram Research\Mathematica\12.3\WolframKernel.exe
WARNING: RunServerDiagnostic[] should be run with same kernel that RunServerDiagnostic[] will start.

Starting Language Server kernel with command: {c:\Program Files\Wolfram Research\Mathematica\12.3\WolframKernel.exe,-noinit,-noprompt,-nopaclet,-nostartuppaclets,-noicon,-run,Needs["LSPServer`"];LSPServer`StartServer[]}

If any messages are printed below, they must be fixed.

Writing initialize...

ReadByteArray::InputStream[C:\Users\user\AppData\Roaming\Mathematica\ApplicationData\ProcessLink\Streams\wl-stream-stdout-15idkdmg23gkj,4] is not open

ERROR: ReadByteArray returned unevaluated; exiting hard
Process timed out after 30 seconds.
INFO: Exit code: None

Environments
OS: Windows_NT x64 10.0.19042
VS code Version: 1.63.2
Wolfram Engine Version : 12.3.0 for Microsoft Windows (64-bit) (May 10, 2021)
Wolfram Language Version: 1.4.0

Does it work with the Wolfram Player?

I distribute an application in the EnterpriseCDF format. The application uses a configuration file which is in the WL format (basically a large association full of data settings). These users don't have Mathematica or the Wolfram Engine but they all do have the Wolfram Player. Can the vs code extension be made to work in this scenario?

Documentation on hover doesn't seem to work.

The extension description mentions that it provides "Documentation on hover". However when I hover my mouse over any function, all I get back is a tooltip that says No usage message.
I'm fairly confident that I have installed the extension correctly, since most of the features including syntax highlighting and diagnostic errors are working correctly.

Unlink from the .m file

.m files are used by both MATLAB and mathematica.
When vscode installs both plugins, the MATLAB file is incorrectly marked as a mathematica file.And MATLAB cannot provide syntax checking.
I wish to unlink the .m file in vscode via settings, and I would try to report the same issue to the official MATLAB plugin.

Formatting options

Sorry if this isn't technically an issue, but I was wondering what everyone was doing for formatting. The only option in VS code for "Document Format As" is Wolfram Language, but that has the following problem:

I would like the indents to be added correctly for new lines, and for my line breaks to be left untouched. But what's going on now is code that starts like this:
image

Ends up like this after shift+opt+F
image

If there's a better place to ask this question (Stack Exchange etc.) please point me there. Thanks

LSP for wolfram language in VSCode jupyter notebook

So I have the WolframLanguageForJupyter paclet and kernel which runs fine in both Jupyter Notebook and in the Visual Studio code ipynb support.

I also installed the VSCode Wolfram extension. The syntax highlighting works fine, and the language server protocol is working fine for any files, except .ipynb. In particular, it won't give linting or documentation if I'm editing a notebook cell set to wolfram language.

How should I configure the extension to still run LSP for those cases ?

Section Folding bug

I posted this in a closed issue, so I'm referencing it to create a new issue:

@bostick, it appears something has changed in the LSPServer. Section folding has a bug now.

This code shows the "Import" section declaration and then a function, which I've folded, followed by the initialization of variable 'sheets'
image

This "Import" section goes until line 470, but when I fold it, you'll see it only folds that first function.
image

A couple things stand out.

  1. Folding functions is a new feature I believe. It seems to be interfering with the section folding.
  2. The function folding is a nice feature that would be awesome to add to other large expression constructs like With, Block, Module, etc. For example, the next bit of code is a function encapsulated within a "With" expression. I am unable to fold it because of the encapsulation. It'd be nice to be able to fold the With statement:

image

Originally posted by @hifismith in #12 (comment)

Section folding

Can sections and subsections be recognized and folded? In the screenshot I've used cmnd+K+0 to fold everything, but the sections and subsections are expanded.
image

Request: publish extension in open-vsx.org

VS Code is very popular in part for being open source. But if you try to install the vscode-wolfram extension in anything other than a Microsoft compiled VS Code you find that it is unavailable. This is because extensions published on the Microsoft Marketplace are prohibited from being used from any other products:

https://github.com/VSCodium/vscodium/blob/master/DOCS.md#extensions--marketplace

The solution is to also publish the extension in the Open VSX Registry:

https://open-vsx.org/

My understanding is the this would only require signing and an additional agreement:

https://www.eclipse.org/legal/open-vsx-registry-faq/#faq-4

Any chance of this getting done? I see that there are now 2330 extension on open-vsx.org so this seems like a good idea.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.