nealmckee / penumbra_vscode

Penumbra VSCode Theme
MIT License
24 stars 2 forks source link

Python highlighting not working without Pylance #11

Open 4oo4 opened 1 year ago

4oo4 commented 1 year ago

I noticed that the theme wasn't highlighting correctly for only Python files when used with code-server as opposed to regular VSCode, and it appears that this is due to the use of Pylance vs Jedi Python language servers.

Unfortunately Microsoft prevents Pylance from being used outside of official Microsoft VSCode builds (which includes closed source bits and telemetry), in addition to already being proprietary. It would be great to have Penumbra work without having to depend on Pylance which is installed by default with the MS Python extension.

Example:

def request(method, uri, slack_token=None, querystring=None, payload=None, headers=None):
    """ Raw requests to Slack API """
    data = {"token": slack_token}
    if payload is not None:
        data.update(payload)
    url = BASE_URL + '/' + uri
    if querystring is not None:
        #pylint: disable=invalid-name
        qs = {k: v for k, v in querystring.items() if v is not None}
        url += f"?{urlencode(qs)}"
    #logger.debug(f"Headers: {headers}, URL: {url}, data:")
    rsp = requests.request(method, url, data=data, headers=headers, timeout=300)
    #logger.success(f"Successful request to {url}")
    return rsp.status_code, rsp.content

Using Pylance language server: image (1)

Using Jedi language server: image

It appears that variables and a few other things aren't being recognized properly based on scopes like, are there different scopes that might also work for Jedi?

https://github.com/nealmckee/penumbra_vscode/blob/959f17dd8d568b2dfe8a7673e0f0549ec1f0b398/themes/penumbra-dark-color-theme.json#L38-L44

I was experimenting with something like this but not having much luck, I wasn't finding good docs on a list of available scopes and I know nothing about vscode theme development.

    {
      "name": "variable.name.python",
      "scope": "variable.name.python",
      "settings": {
        "foreground": "#ca7081"
      }
    },

EDIT: Related: https://github.com/microsoft/pylance-release/issues/319 https://github.com/microsoft/pylance-release/issues/339 https://github.com/Binaryify/OneDark-Pro/issues/439

finnlogin commented 1 year ago

[Hi! Have you made any headway in solving this problem? I've been trying to solve this problem for a few days now, but unfortunately all my attempts so far are in vain. I installed VSCodium and would like to have the same highlighting as in VSCode.

EArlF

4oo4 commented 1 year ago

I have not, for now I went back to using pylance, despite it being closed source. I would love to use Jedi as a language server instead but as I understand it Jedi support in VSC is much newer and probably doesn't play as nicely with the Microsoft Python extension (assuming that Microsoft isn't doing other things to prevent interoperability, which I also suspect).