Diego A. Casas

Disable NonASCIICharacter warnings for Wolfram Language in Visual Studio Code

I recently started learning the Wolfram language, the language that powers Mathematica and WolframAlpha. Wolfram is a language that focuses on symbolic and functional programming. It has thousands of built-in functions and a very regular functional syntax.

I installed Wolfram Engine Community Edition that comes with a free license for pre-production. Although it does not include the Wolfram Notebook as in Mathematica, there is a Visual Studio Code extension developed by Wolfram Research. The extension is enough for me. I am learning Wolfram Language by solving the programming puzzles in Advent of Code.

Wolfram Language supports Unicode in names and operators like the Julia language. However, the VS Code extension shows warnings when defining variables or functions with non-ASCII characters in their names. The warnings are NonASCIICharacter and UnexpectedLetterlikeCharacter. These warnings were annoying, so I looked for a way to fix them.

I found that in February 2023 someone had the same issue while using Chinese characters for variable names. A user proposed changing the wolfram.command setting in VS Code adding options to ignore the NonASCIICharacter and UnexpectedLetterlikeCharacter warnings. This did not work for me since in my version of the extension, the mentioned setting does not even exist.

Several changes were made to the extension since February 2023. The setting is now named wolfram.advanced.lsp.command. Additionally, I went through the code and found that the extension has hard-coded default paths and arguments for the Wolfram kernel. I copied the path and arguments from the code and added the options suggested in the issue.

I finally arrived at the following setting. It can be appended to the user settings JSON file in VS Code.

"wolfram.advanced.lsp.command": [
	"C:\\Program Files\\Wolfram Research\\Wolfram Engine\\14.1\\WolframKernel.exe",
	"-noinit",
	"-noprompt",
	"-nopaclet",
	"-noicon",
	"-nostartuppaclets",
	"-run",
	"Needs[\"LSPServer`\"];SetOptions[CodeInspector`CodeInspectCST, \"TagExclusions\" -> {\"UnexpectedLetterlikeCharacter\", \"NonASCIICharacter\"}];LSPServer`StartServer[]"
]