Zulip Chat Archive

Stream: general

Topic: Manual syntax highlighting in VS Code


Ioannis Konstantoulas (Jul 06 2023 at 13:59):

The Lean 4 manual (https://leanprover.github.io/lean4/doc/faq.html) has excellent syntax highlighting for Lean; but the standard color scheme in VS Code (light modern) does not include as many variations as the text in the manual; how can I get the color scheme and highlighting details the manual uses into VS Code?

Thank you for your time!

Patrick Massot (Jul 06 2023 at 17:52):

It probably means you need to enable semantic syntax highlighting.

Patrick Massot (Jul 06 2023 at 17:52):

Open VSCode settings and search for semantic syntax highlighting.

Scott Morrison (Jul 06 2023 at 23:59):

More specifically, it sounds like something is wrong with your system, and the default installation instructions result in VS Code correctly syntax highlighting Lean code.

Perhaps you could show us a screen shot of your VS Code window, and/or tell us which installation instructions you used?

Ioannis Konstantoulas (Jul 07 2023 at 10:52):

vs_code_colors.png

Here is what my editor looks like.

Ioannis Konstantoulas (Jul 07 2023 at 10:53):

I do not see any settings for semantic syntax highlighting :( Searching produces no results in the editor.

Julian Berman (Jul 07 2023 at 10:55):

What version of VSCode are you using?

Ioannis Konstantoulas (Jul 07 2023 at 10:58):

Version: 1.79.2
Commit: 695af097c7bd098fbf017ce3ac85e09bbc5dda06
Date: 2023-06-17T15:54:35.168Z
Electron: 22.3.15
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Linux x64 6.4.1-arch2-1

Patrick Massot (Jul 07 2023 at 12:12):

semantic.gif

Max Nowak 🐉 (Jul 07 2023 at 13:34):

You might have to customize the semantic token colors in your settings.json

Max Nowak 🐉 (Jul 07 2023 at 13:39):

There’s a vscode command to show (semantic and syntactic) token types and what colors they cause. Then position your cursor over some text and you’ll see which (if any) semantic token kinda you have. For example, variables (let, params) the “variable” semantic token modifier. It should show up.

Eric Wieser (Jul 07 2023 at 14:49):

Does the lean manual really use semantic highlighting? If so, how does that work? I assume it's not just pygments or highlight.js?

Sebastian Ullrich (Jul 07 2023 at 15:16):

The Examples section uses LeanInk

Ioannis Konstantoulas (Jul 07 2023 at 21:15):

Is LeanInk a vs code color theme I can download?

Ioannis Konstantoulas (Jul 07 2023 at 21:16):

Also, I do have semantic highlighting on, it does not make a difference as to the colors being shown.

Mac Malone (Jul 08 2023 at 01:04):

@Ioannis Konstantoulas The screenshot you gave looks like proper syntax highlighting for the VS Code light theme (at least in my experience). What do you think it is missing?

Ioannis Konstantoulas (Jul 08 2023 at 07:11):

What I want is the color scheme that the Lean manual (and especially the book Functional Programming in Lean) uses. Is this not available for VS Code? My eyesight is quite bad, so I may be wrong, but it seemed to me the light theme highlights fewer groups than the color scheme in that book.

Mac Malone (Jul 08 2023 at 07:58):

Ioannis Konstantoulas said:

but it seemed to me the light theme highlights fewer groups than the color scheme in that book.

This is true. The the default VS Code light scheme is not very colorful. The book color scheme is much more vibrant. However, I am not sure if the book color scheme is available as a VS Code theme. This could be a good question for Sebastian.

@Sebastian Ullrich: do you happen to know if there is VS Code theme that parallels the book's color scheme or what modifications could be to approximate it?

Sebastian Ullrich (Jul 08 2023 at 08:35):

I don't know, it's just the standard mdBook highlighting outside of the LeanInk part

Max Nowak 🐉 (Jul 08 2023 at 11:04):

You can customize the token colors in your vscode settings and pick a more vibrant color

Ioannis Konstantoulas (Jul 08 2023 at 11:12):

Thank you all!

Sebastian Ullrich (Jul 08 2023 at 11:27):

There is no lack of VS Code themes online, though it is not readily apparent what semantic tokens they support out of the box. Perhaps we do need our own, blessed Lean theme especially in consideration of lean4#2305


Last updated: Dec 20 2023 at 11:08 UTC