Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support language features for other languages when using cell magics #4588

Closed
DonJayamanne opened this issue Feb 1, 2021 · 12 comments
Closed
Assignees
Labels
feature-request Request for new features or functionality language-any Area covering general issues geared to supporting any language (not just Python) notebook-intellisense Intellisense & other language features in notebook cells for any language notebook-serialization Applies to conversion of ipynb file to JSON & vice versa partner upstream-pylance Blocked on upstream Pylance
Milestone

Comments

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Feb 1, 2021

I would like to run bash scripts in a cell.
I use cell magics for this.
I would like the langauge of the cell to be automatically set to bash

Similarly when using %html, %%svg, etc...
%%script julia
%%html
%%kql

Provides intellisense, syntax highlighting & the like (ie. use VS Code features to improving cell editing experience for non-python & non-markdown cells)

Additionally we should make sure all of the languages supported by magics. This includes things like:

@DonJayamanne DonJayamanne added bug Issue identified by VS Code Team member as probable bug enhancement and removed bug Issue identified by VS Code Team member as probable bug labels Feb 1, 2021
@greazer greazer added this to the October 2021 milestone Oct 10, 2021
@rchiodo rchiodo added the notebook-intellisense Intellisense & other language features in notebook cells for any language label Oct 27, 2021
@rchiodo rchiodo modified the milestones: October 2021, November 2021 Oct 27, 2021
@rchiodo rchiodo modified the milestones: November 2021, January 2022 Dec 6, 2021
@rchiodo rchiodo self-assigned this Jan 19, 2022
@greazer greazer removed this from the January 2022 milestone Jan 20, 2022
@greazer greazer added language-any Area covering general issues geared to supporting any language (not just Python) papercut 🩸 Something affecting the productivity of the team and removed needs-triage labels Jan 20, 2022
@greazer
Copy link
Member

greazer commented Jan 20, 2022

Related to microsoft/vscode#140147.

@ahmed2m
Copy link

ahmed2m commented Jan 25, 2022

I hope you're planning for sql too, it's so annoying as of the current state, yesterday I changed every cell. When I opened the same notebook today all the types are reset to Python!

@Photonico
Copy link

I expect this feature will be realized soon. :)
Could you tell me any progress?

@rchiodo
Copy link
Contributor

rchiodo commented Mar 16, 2022

Sorry this isn't on our radar at the moment.

@Photonico
Copy link

Photonico commented Mar 16, 2022

Sorry this isn't on our radar at the moment.

Hi,

Do you have a plan to fix this problem?

For example, I use both Python and Julia in one Jupyter notebook. I found that clicking the lower right button of the cell can demonstrate the menu which controls the syntax highlighting. I guess that If Julia option would be added to the menu, the problem gets solved.

pic

However, I prefer the feature that allows multiple kernels on one notebook can be native of Jupyter extension.

@rchiodo
Copy link
Contributor

rchiodo commented Mar 16, 2022

This issue is about autodetecting cell magics that change the language. The plan is to make the language change automatically as you type a cell magic. It's not a high priority at the moment but will likely be addressed eventually.

What you're describing is more of a polyglot kernel. The jupyter extension has no plans for a polyglot kernel. However .NET interactive does. A polyglot kernel would likely support ALL languages in that dropdown. @DonJayamanne also mentioned another polyglot kernel in your discussion of this topic.

The IPython kernel supports only a subset of languages based on known cell magics that can change the language from python to something else. It seems julia is possible in that list though with the julia.magic extension:
https://stackoverflow.com/questions/24091373/best-way-to-run-julia-code-in-an-ipython-notebook-or-python-code-in-an-ijulia-n. So when we implement this feature, we should add julia to the list.

@Photonico
Copy link

Photonico commented Mar 16, 2022

This issue is about autodetecting cell magics that change the language. The plan is to make the language change automatically as you type a cell magic. It's not a high priority at the moment but will likely be addressed eventually.

What you're describing is more of a polyglot kernel. The jupyter extension has no plans for a polyglot kernel. However .NET interactive does. A polyglot kernel would likely support ALL languages in that dropdown. @DonJayamanne also mentioned another polyglot kernel in your discussion of this topic.

The IPython kernel supports only a subset of languages based on known cell magics that can change the language from python to something else. It seems julia is possible in that list though with the julia.magic extension: https://stackoverflow.com/questions/24091373/best-way-to-run-julia-code-in-an-ipython-notebook-or-python-code-in-an-ijulia-n. So when we implement this feature, we should add julia to the list.

Thanks a lot for your reply!!!

Julia language should be added to the menu. However, I still need to change the cell language every time I open the notebook.
It is better that the cell can identify the language of the cell automatically according to the statement: %%script julia, and change the syntax highlights.

I wish that Julia code can be demonstrated perfectly in Python kernel Jupyter notebook.
Other language support like C/C++, Go, Rust, etc is also great!

Sincerely
Lu

@greazer greazer added feature-request Request for new features or functionality and removed enhancement labels May 4, 2022
@RafalSkolasinski
Copy link

One more use case that seems not mentioned,

If there would be for example

%%writefile myfile.yaml
some: field
other: field

it'd be nice if it could be detected that this is yaml syntax.

@nicocanali
Copy link

This issue is about autodetecting cell magics that change the language

Instead of autodetecting, which might be tricky, would it be possible to allow a custom mapping? For example, I have a Kusto syntax highlighting extension that would be great to autoswitch when %%kql appears in a cell. Similarly, there may be non-standard names (like %%bigquery) that would nicely map to SQL, but might be tricky to do it automatically...so letting the user map it through a setting could work...? WDYT?

@DonJayamanne DonJayamanne removed the papercut 🩸 Something affecting the productivity of the team label Dec 28, 2022
@leifwalsh
Copy link

I also think this would be useful, whether it's done automatically or at least exposed in the api such that a motivated extension author could make it happen

@DonJayamanne
Copy link
Contributor Author

Created an upstream issue microsoft/pylance-release#4969
That would be a better solution, as pylance natively supports notebooks

@DonJayamanne DonJayamanne added the upstream-pylance Blocked on upstream Pylance label Dec 1, 2023
@DonJayamanne DonJayamanne changed the title Automatically change cell language based on cell magics Support language features for other languages when using cell magics Dec 1, 2023
@DonJayamanne DonJayamanne added this to the Backlog milestone Dec 4, 2023
@DonJayamanne
Copy link
Contributor Author

Closing in favour of upstream issue microsoft/pylance-release#4969

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality language-any Area covering general issues geared to supporting any language (not just Python) notebook-intellisense Intellisense & other language features in notebook cells for any language notebook-serialization Applies to conversion of ipynb file to JSON & vice versa partner upstream-pylance Blocked on upstream Pylance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants