pylance-release icon indicating copy to clipboard operation
pylance-release copied to clipboard

Support language features for other languages when using cell magics

Open DonJayamanne opened this issue 2 years ago • 5 comments

When using cell magics such as %%html, %%sql, %%js, %%kql, etc and other such magics, Pylance does not recognize the contents after the text. Text after such magics are treated a Python code, thats incorrect. Pylance can instead utilize language request forwarding to allow VS Code to provide the language features for languages embedded via cell magics https://code.visualstudio.com/api/language-extensions/embedded-languages#request-forwarding

The question now is who manages the list of these cell magics

  • It can be hardcoded
  • a configuration to map cell magics to langauges woudl also be useful.

E.g. mapping %%kql to kusto language is something the user can add

DonJayamanne avatar Oct 17 '23 02:10 DonJayamanne

I swear we already had this issue? Yeah this is a dupe of this discussion item here: https://github.com/microsoft/pylance-release/discussions/3851

rchiodo avatar Oct 17 '23 16:10 rchiodo

Maybe it's not exactly a dupe. Reopening.

rchiodo avatar Oct 17 '23 16:10 rchiodo

Triage: next step - investigation of cost.

judej avatar Oct 18 '23 18:10 judej

Instead of expecting Pylance to automagically handle every scenario, including those involving multiple languages, maybe we start with a fairly simple configuration option. This would allow users/devs to set up mappings for Pylance.. A simple configuration, similar to a gitignore file, could be implemented. For example:

  • If the scenario is "%%time+simple", ignore only that part.
  • If it's "%%sql+block", ignore the entire section as it's not Python.
  • All other %% - default to ignoring

I use Jupyter with Python in VSCode and would be happy to assist with testing.

bgupta avatar Jul 01 '24 20:07 bgupta

this would be awesome. Please allow specifying any supported language using vscode's identifier for that language. Not just common ones like SQL. For example I would like to create my own cell magic %%cypher for the cypher graph query language.

Perhaps there could be a mapping between cell magic name and the vscode identifier in settings?

na-wapf avatar Aug 20 '24 08:08 na-wapf

I'd love this! I think there's a very valid usecase for custom languages with cell magic and more integrated support would be awesome

mayurankv avatar Oct 17 '25 09:10 mayurankv