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

Add pyodide and webr extensions to qmd #210

Open
PMassicotte opened this issue Aug 13, 2024 · 4 comments
Open

Add pyodide and webr extensions to qmd #210

PMassicotte opened this issue Aug 13, 2024 · 4 comments

Comments

@PMassicotte
Copy link
Collaborator

PMassicotte commented Aug 13, 2024

webr can be used in quarto documents.

We could add

  1. .webr (https://github.com/r-wasm/quarto-live/blob/d5e88730d9807b3f1453cdcdd0f65afb39ae5ffe/docs/interactive/hybrid.qmd#L103)

  2. pyodide (https://github.com/r-wasm/quarto-live/blob/d5e88730d9807b3f1453cdcdd0f65afb39ae5ffe/docs/interactive/hybrid.qmd#L113)

As supported code chunks

function M.get_lang()

They behave exactly as normal r and python chunks.

@PMassicotte PMassicotte changed the title Add pyodide and webr extensions to rmd and qmd Add pyodide and webr extensions to ~~rmd and~~ qmd Aug 13, 2024
@PMassicotte PMassicotte changed the title Add pyodide and webr extensions to ~~rmd and~~ qmd Add pyodide and webr extensions to qmd Aug 13, 2024
@jalvesaq
Copy link
Member

This is something that I will not use, but you can add support for them if you want.

An alternative would be to add a section to the Wiki teaching users how to add a custom query to their after/queries directory to make tree-sitter-markdown recognize the blocks as R code.

@jalvesaq
Copy link
Member

Adding this to nvim-treesitter config fixes the highlighting and the ability to send code to the R Console:

    {
        "nvim-treesitter/nvim-treesitter",
        config = function ()
            vim.treesitter.language.register("r", "webr")
            vim.treesitter.language.register("python", "pyodide")
        end,
    }

But we still can't use <LocalLeader>gn to jump to webr and pyodide chunks. If this is the only missing thing in the support, we can create a config option such as:

   r_chunk_lang = { "r", "python" }

that users could define as:

   r_chunk_lang = { "r", "python", "webr", "pyodide" }

Or, even better, use tree-sitter to find R and Python code chunks. In this case, users would not have to configure anything in R.nvim and it would work with whatever new types of chunks defined as either R or Python.

@PMassicotte
Copy link
Collaborator Author

Nice finding!

For this, how would you do it?

Or, even better, use tree-sitter to find R and Python code chunks. In this case, users would not have to configure anything in R.nvim and it would work with whatever new types of chunks defined as either R or Python.

@jalvesaq
Copy link
Member

For this, how would you do it?

I don't know... But perhaps something similar to what you have done to send functions would be possible in this case.

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