All Projects → ryantam626 → Jupyterlab_black

ryantam626 / Jupyterlab_black

Licence: mit
A JupyterLab extension to apply Black formatter to code within codecell.

Programming Languages

python
139335 projects - #7 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Jupyterlab black

BlazorMonaco
Blazor component for Microsoft's Monaco Editor which powers Visual Studio Code.
Stars: ✭ 151 (+331.43%)
Mutual labels:  formatter, code
snakefmt
The uncompromising Snakemake code formatter
Stars: ✭ 78 (+122.86%)
Mutual labels:  formatter, code
Black
The uncompromising Python code formatter
Stars: ✭ 23,973 (+68394.29%)
Mutual labels:  code, formatter
Code Notes
A simple code snippet & gist manager for developers built with Electron & Vue.js 🚀
Stars: ✭ 919 (+2525.71%)
Mutual labels:  code
Vue Konami Code
VueJS Konami code plugin
Stars: ✭ 26 (-25.71%)
Mutual labels:  code
Blockchain
区块链技术
Stars: ✭ 28 (-20%)
Mutual labels:  code
Renew
Mix task to create mix projects that builds into Docker containers.
Stars: ✭ 33 (-5.71%)
Mutual labels:  code
Translatedjs
Internationalization and localization for JavaScript and Node.js
Stars: ✭ 17 (-51.43%)
Mutual labels:  formatter
Fundamentals Of Python Data Structures
《数据结构(Python语言描述)》"Fundamentals of Python:Data Structures" 电子书和配套代码
Stars: ✭ 30 (-14.29%)
Mutual labels:  code
Qpdialcodepickerview
International Dial Code Picker View for Country or Area 国家或地区国际区号选择器
Stars: ✭ 15 (-57.14%)
Mutual labels:  code
Vim Codefmt
Stars: ✭ 870 (+2385.71%)
Mutual labels:  formatter
Vim Clang Format
Vim plugin for clang-format, a formatter for C, C++, Obj-C, Java, JavaScript, TypeScript and ProtoBuf.
Stars: ✭ 837 (+2291.43%)
Mutual labels:  formatter
Eryngii
[WIP] Erlang lint and formatter
Stars: ✭ 28 (-20%)
Mutual labels:  formatter
Radicle Alpha
A peer-to-peer stack for code collaboration
Stars: ✭ 921 (+2531.43%)
Mutual labels:  code
Arcgis Python Api
Documentation and samples for ArcGIS API for Python
Stars: ✭ 954 (+2625.71%)
Mutual labels:  jupyterlab-extension
Moment.php
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Stars: ✭ 900 (+2471.43%)
Mutual labels:  formatter
Pinecoders.github.io
PineCoders Web Site
Stars: ✭ 30 (-14.29%)
Mutual labels:  code
Vim Gofmt
Formats Go source code asynchronously with multiple Go formatters.
Stars: ✭ 11 (-68.57%)
Mutual labels:  formatter
Elyra
Elyra extends JupyterLab Notebooks with an AI centric approach.
Stars: ✭ 839 (+2297.14%)
Mutual labels:  jupyterlab-extension
Gofmtrlx
(a bit) relaxed gofmt
Stars: ✭ 21 (-40%)
Mutual labels:  formatter

NOTE

If you are using Python3.6+, feel free to use my other less hacky plugin - it supports YAPF and autopep8 as well.

However if you are using Python2 or Python(<3.5), keep going.

jupyterlab_black

npm version npm downloads

A JupyterLab extension to apply Black formatter to code within codecell.

Here is a little demo. Apologies for the horrid quality, I promise to find a better converter...

Prerequisites

  • JupyterLab
  • A Python 3.6+ anywhere on your system with black installed

Installation

From your existing environment with jupyterlab installed do the following:

jupyter labextension install @ryantam626/jupyterlab_black
pip install https://github.com/ryantam626/jupyterlab_black/archive/master.zip
jupyter serverextension enable --py jupyterlab_black

Python3.6+ Kernel Notes

Install black with something like:

conda install -c conda-forge black

OR

pip install black

Find out path of your Python by which python and that would be what to put for blackPythonBin in the Usage section.

Non-Python3.6+ Kernel Notes

If you are using kernel that are not Python3.6+, create another environment with Python3.6+ and black installed, for example (with conda, my perferred environment manager):

conda create --name py36_for_jupyterlab_black -c conda-forge python=3.6 black

Then find out where this lives by:

source activate py36_for_jupyterlab_black
which python

It should be something like /home/ryan/lib/anaconda2/envs/py36_for_jupyterlab_black/bin/python, depending on your distribution of conda, that would be what to put for blackPythonBin in the Usage section.

Usage

Head over to settings editor, and key in the python interpreter path of that Python3.6+ you have with black installed for blackPythonBin.

There is literally one option in the command palette right now:

  • Apply Black Formatter

How about a keyboard shortcut?

Add an extra extry to your keyboard shortcuts settings with something like

{"jupyterlab_black:format":{
    "command": "jupyterlab_black:format",
    "keys": [
        "Ctrl K",
        "Ctrl L"
    ],
    "selector": ".jp-Notebook.jp-mod-editMode"
}}

This basically says "Under edit mode (detected through the selector), using the chord Ctrl K + Ctrl L, invoke the jupyterlab_black:format command". And there you have it 🎉

Development

For a development install (requires npm version 4 or later), do the following in the repository directory:

pip install -e .
jupyter serverextension enable --py jupyterlab_black
npm install
npm run build
jupyter labextension install . --no-build

Get npm and jupyter to watch for changes:

npm run watch  # in terminal 1
jupyter lab --watch  # in terminal 2

Making changes in the Python part of the plugin will require a rerun of jupyter lab --watch sadly.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].