Make python code highlighting for VSCodium equal to VSCode
Asked Answered
R

3

7

Migrated from VSCode to VSCodium because "Microsoft bad". Developing python applications seems to be missing some of the code colors like the modules in turquoise or local variables in light blue in the "Dark +" theme, visible in the comparison below:

enter image description here Left: VSCodium. Right: VSCode

Is the right style of code highlighting Microsoft only or am I missing an extension? I tried Manage>Settings>tokenColorCustomizations but the available types like comments, functions or keywords are not python specific, so doing it manually probably won't do the trick.

Edit #1

I seem to have missed the same question which was posted prior to mine. So far I have not been able to make it work within this timespan (summer 2023), but I tried out suggestions and found a few things:

Suggestion #0: Forcing Pylance

Normally, Pylance is hidden from the VSCodium extensions, but you can still get it via the online VS marketplace as a .vsix download. Installing it finishes fine, but neither the advanced highlighting nor code completion/suggestions are shown (?). The output of Python Language Server is reduced to

[info] (Client) You may install and use any number of copies of the software only with Microsoft Visual Studio, Visual Studio for Mac, Visual Studio Code, Azure DevOps, Team Foundation Server, and successor Microsoft products and services (collectively, the “Visual Studio Products and Services”) to develop and test your applications [...]

which is neither an error nor a warning, but maybe the confirmation of this post, which basically says that a combination of Pylance and VSCodium is not possible. Also, adding

"editor.semanticHighlighting.enabled": true,    
"python.languageServer": "Pylance"

does not seem to work for me.

Suggestion #1: "Just use pyright"

From the docs:

For most VS Code users, we recommend using the Pylance extension rather than Pyright. Pylance incorporates the Pyright type checker but features additional capabilities such as semantic token highlighting and symbol indexing. You can install the latest-published version of the Pylance VS Code extension directly from VS Code. Simply open the extensions panel and search for “Pylance”.

As if that isn't discouraging enough, installing pyright anyway fails with this error (Vscodium 1.81.1 for Win x64):

Pyright has detected that the Pylance extension is installed. Pylance includes the functionality of Pyright, and running both of these extensions can lead to problems. Pyright will disable itself. Uninstall or disable Pyright to avoid this message.

Fair enough, as Pylance is installed and probably still configured in settings.json. However, adding "python.languageServer": "Pyright" there shows me a value error Value is not accepted. Valid values: "Default", "Jedi", "Pylance", "None".. As the docs redirect me to Pylance, I am not sure what to put in here to select Pyright. Additionally, this may not even tackle the original problem, as it only employs static typechecking and not semantic highlighting as mentioned in the comments of the related post.

Suggestion #2: "Use Jedi"

Switching to "python.languageServer": "Jedi" and reloading the window changes nothing about the highlighting, but at least enables reliable auto-completion. Where Jedi is installed or where it comes from is a mystery to me, so I assume that it is built in. While this is an acceptable solution to having basic highlighting and completion, it also does not tackle the original question.

Suggestion #3: Copy-Paste hackery

This results in all sort of version errors if the default extensions are installed in VSCode and then manually moved to VSCodium. The former installs for 1.82 and the latter for 1.81. Reverting extensions to previous versions leads me back to suggestion #1.

Further works

~~If it can't be achieved, then so be it and I'll use Jedi. However, I remember having an old laptop with VSCodium which was running Pylance fine, so it's either me messing up or it was a compatibility change over time. I will investigate this soon and add updates here.~~

Edit #2

Recent developments regarding this issue suggest that Pylance, as a proprietary product of Microsoft, is being reinforced in fending off "non-official" usage such as installing it with VSCodium. Relevant links:

This is very much in the power of Microsoft. It's their language server and nothing will change that. I have been using jedi for half a year now, it sadly is not as powerful as Pylance. However, I found a solution.

This solution is so benign and unexplainable to me, that I do not necessarily recommend depending on it, because it might just break like all the other solutions listed in the provided links. Somewhere in one of these discussions somebody posted a link to a specific Pylance version 2023.6.40 download. Installing it manually over the "install from .vsix option in VSCodium actually works (tested for Windows 10), which very much surprised me at this point.

All in all this seems like another instance of the Freeware vs. FLOSS dilemma, whereby a free product creates issues with the FLOSS community on an ethical basis because it is very purposefully free but not FLOSS. And since "free but not FLOSS" does not actually exist, you pay in telemetry data, which is exactly what drives people to FLOSS options in the first place.

Rob answered 4/2, 2023 at 13:45 Comment(12)
I think this is related to the language server. If you still have Code installed, you could check by switching python.languageServer from Pylance to Jedi. Pylance is not supported in unofficial builds.Injury
Related? How can I get VS's python syntax highlighting in VS code? There's an answer about changing the colours manually; that might help.Injury
@Injury so VSCodium is unofficial? Unofficial as in not backed by a tech giant? But thanks for the info, I'll try out Jedi.Rob
Unofficial as in, not built by Microsoft. That's the whole point of VSCodium...?Injury
What happens if you set "editor.semanticHighlighting.enabled": false in your VS Code settings? Does VS Code then appear the same as the VS Codium appearance?Holohedral
@user For me, that setting has no effect on Python syntax highlighting. (Oh yeah, I forgot to mention that before: I see the same thing as OP on Codium, and I'm using Jedi. Never used PyLance.)Injury
To be clear, I believe Pylance adds the more detailed syntax highlighting on VSCode. Some of it seems to require introspection, like knowing that os is an imported name, but on Codium, Jedi doesn't seem to provide any of that, so you're stuck with basic TextMate-powered highlighting. That is, unless you want to do the hack to allow Pylance.Injury
@Injury unofficial means it's not the official Microsoft version, it's built from the same code just with the Microsoft tracking BS left out.Stillman
@Stillman I think you tagged the wrong person. I already said that on Feb 4Injury
@Injury sorry I meant to tag wjandrea. I know that was the point you were making, I just wanted to clarify as from your response it's not too clear what how the builds differStillman
check out basedpyright - open-vsx.org/extension/detachhead/basedpyrightGlasswort
Whats the status on this issue? I use Codium and I keep missing things that would be highlighted if I was using VS Code.Sepalous
H
1

I successfully have the same syntax highlighting by installing vscode and python extension (with Pylance) and then:

rm -rf ~/.vscodium-server/extensions
cp -R ~/.vscode-server/extensions ~/.vscodium-server/extensions

You can then remove vscode :)

EDIT: I had trouble with the latest version, this resolved it https://github.com/VSCodium/vscodium/issues/1640#issue-1898772365

Hollenbeck answered 11/5, 2023 at 12:59 Comment(2)
Are you able to get updates after using that trick? Seems like a great trick but I wouldn't want to repeat it and reinstall all my extensions every time I need to update my python pluginsStillman
No problem with updates since thenHollenbeck
F
0

Pyright gives the same highlighting as Pylance in vscode and it is available in codium

Fondue answered 7/6, 2023 at 20:51 Comment(1)
Unfortunately, Semantic Highlighting is a feature of Pylance, not Pyright. github.com/microsoft/pyright/issues/1138Haily
A
0

Somehow Jedi and Pyright also were not working properly with my VSCodium, so I installed a specific pylance version .vsix as suggested, and it worked.

Download it from here:
https://www.vsixhub.com/vsix/32420/

Abeyance answered 5/7 at 6:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.