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

ENH: infer language driving the kernel and update syntax #16

Open
sglyon opened this issue Nov 21, 2013 · 1 comment
Open

ENH: infer language driving the kernel and update syntax #16

sglyon opened this issue Nov 21, 2013 · 1 comment

Comments

@sglyon
Copy link

sglyon commented Nov 21, 2013

Disclaimer: this might be unfeasible because it might involve dynamic changes to tmLanguage files.

Now that there are more and more languages implementing ipython kernels (Julia, Go, Haskell, ...), it might make sense to expand the syntax highlighting (and by extension all the snipets/completions, ect. provided by sublime) for code cells. This would involve changing this line of SublimeIPythonNotebook.tmLanguage to be updated dynamically based on the metadata given at the top of the .ipynb JSON file.

For example, when using IJulia (ipython with julia backend), the first few lines of the .ipynb are

{
 "metadata": {
  "language": "Julia",
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [

whereas with a normal python based notebook we have

{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [

Actually changing the line would be easy, but the question we need to ask is whether or not we would be worried about corrupting the tmLanguage source or introducing a security issue by allowing this file to be dynamically updated.

I guess another option would be to have different tmLanguage files for each type of backend (they would be copy/paste of one another with minor changes) and we would somehow instruct sublime on which one to use based on the backend.

@maximsch2
Copy link
Owner

Instructing sublime to use different tmLanguage files is easy: look for this line
view.set_syntax_file("Packages/IPython Notebook/SublimeIPythonNotebook.tmLanguage")
and change it to the syntax you want. Generating syntax files on the fly might be doable, but having them pre-made will probably not be that bad - it's not like there is new language added to IPython Notebook every day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants