Giter Club home page Giter Club logo

jupytext.nvim's Introduction

Jupytext.nvim

Seamlessly open Jupyter Notebooks as there associated plain text alternatives. Powered by jupytext.

jupytext.nvim is a lua port of the original jupytext.vim with some additional features and a simpler configuration.

Installation

lazy.nvim example:

return {
  "GCBallesteros/jupytext.nvim",
  config = true,
  -- Depending on your nvim distro or config you may need to make the loading not lazy
  -- lazy=false,
}

For jupytext.nvim to run correctly you will also need to make sure that you have the jupytext CLI installed (pip install jupytext).

If jupytext is available and yet when you open a notebook you still see a wall of inscrutable JSON then it may be that jupytext.nvim wasn't available due to lazy loading. The easiest fix is to not lazy load this plugin. For example if using lazy.nvim just set lazy=false. This plugin is tiny and will be a rounding error on your startup time.

Configuration

The simplest configuration only requires you to decide what plain text representation you want jupytext to output. The default configuration is:

{
  style = "hydrogen",
  output_extension = "auto",  -- Default extension. Don't change unless you know what you are doing
  force_ft = nil,  -- Default filetype. Don't change unless you know what you are doing
  custom_language_formatting = {},
}

By default, the extension of the plain text file is automatically selected by jupytext. This can be modified by changing the extension from auto to any other file extension supported by Jupytext. This is most useful to those using Quarto or Markdown. Analogously, we can provide a default filetype that will be given to the new buffer by using force_ft. Again, this is only really useful to users of Quarto.

Important

Some combinations of style and extensions are incompatible and Jupytext will fail if you attempt them, e.g. the md extension with the quarto style. You will see this as an error from the read_ipynb function.

If you need something different pass your own configuration to require("jupytext").setup, e.g.

require("jupytext").setup({ style = "light" })

Tip

Quarto and markdown format users keep on reading!

By default we use the auto mode of jupytext. This will create a script with the correct extension for each language. However, this can be overridden in a per language basis if you want to. For this add to the configuration options a field named custom_language_formatting which contains a series of per language fields. For example, to convert python files to quarto markdown:

custom_language_formatting = {
  python = {
    extension = "qmd",
    style = "quarto",
    force_ft = "quarto", -- you can set whatever filetype you want here
  },
}

Or, for regular markdown:

custom_language_formatting = {
  python = {
    extension = "md",
    style = "markdown",
    force_ft = "markdown", -- you can set whatever filetype you want here
  },
}

Setting force_ft is important to get other plugins like otter.nvim working correctly.

Acknowledgements

This plugin is a lua port of goerz/jupytext.vim and it wouldn't have existed without it.

jupytext.nvim's People

Contributors

benlubas avatar dacid44 avatar gcballesteros avatar rchhong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.