Language mapping in Hydrogen


#1

Hi,

How can I map one Jupyter kernel to several Atom languages when using Hydrogen? Specifically I’d like to map both rmarkdown (I’m using “GitHub Markdown” here) and “R” to the Jupyter R kernel. Thanks!

Cheers,
Rasmus


#2

It looks like kernels are entirely determined by the grammar you have active. So you’d have to change the grammar.


#3

I’ve just started using Hydrogen, and it seems to have this language mapping ability built in now. I guess it didn’t have it a year ago.

I’m having difficulty setting up a mapping. Could someone explain what I’m meant to put into the Language Mappings setting box? What is the “kernel language name” and what is the “Atom’s grammar name”?

I’m trying to use Hydrogen with Fortran using the language-fortran package for Atom and the jupyter_fortran_kernel package for Jupyter.

The grammar I’m using is called “Fortran - Free Form” and the scope says source.fortran.free.

The JSON spec for the kernel is:

"fortran_spec": {
      "resource_dir": "C:\\ProgramData\\jupyter\\kernels\\fortran_spec",
      "spec": {
        "argv": [
          "python3",
          "-m",
          "jupyter_fortran_kernel",
          "-f",
          "{connection_file}"
        ],
        "env": {},
        "display_name": "Fortran",
        "language": "Fortran"
      }
    }

I’ve tried all the combinations I can think of for “kernel language name” and “Atom’s grammar name” but I can’t get Hydrogen to recognise that my file is a Fortran file. :confused:

Should it be something like this:

{ "Fortran": "Fortran - Free Form" }

or maybe:

{ "fortran_spec": "source.fortran.free" }

Neither of those seem to work for me.


#4

I thought it might help to add some screenshots:

This is the grammar I’m using:
grammar

This is the list of Jupyter kernels found by Hydrogen:
kernels

This is what I’ve tried in the language mapping box:

And this is the error I get:
kernelnotfound


#5

The string that most resembles a kernel name to me would be "jupyter_fortran_kernel", so I would suggest you try { "jupyter_fortran_kernel": "source.fortran.free" }.


#6

It turns out the problem was due to case changes—the code only looks for lower case matches for some reason.

This didn’t work:

{ “Fortran": "Fortran - Free Form" }

This did work:

{ “fortran”: "fortran - free form" }