-
-
Notifications
You must be signed in to change notification settings - Fork 230
utility/jupynvim: init #1787
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
Open
jack-thesparrow
wants to merge
10
commits into
NotAShelf:main
Choose a base branch
from
jack-thesparrow:feat/jupynvim
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
utility/jupynvim: init #1787
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
543d0df
jupynvim: init
jack-thesparrow a315777
Merge branch 'main' into feat/jupynvim
jack-thesparrow 845f282
pkgs/jupynvim: build jupynvim-core as its own by-name package
jack-thesparrow 6e03f0d
concatenated "delete current cell" keybind to pass typo-check
jack-thesparrow a182bf3
Merge branch 'main' into feat/jupynvim
jack-thesparrow 831f153
jupynvim: address review feedback
jack-thesparrow 86ee0e0
Merge branch 'main' into feat/jupynvim
jack-thesparrow db9060c
jupynvim: address review feedback
jack-thesparrow e0b2074
Merge branch 'main' into feat/jupynvim
jack-thesparrow 31c1bf2
Merge branch 'main' into feat/jupynvim
jack-thesparrow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| { | ||
| lib, | ||
| pins, | ||
| rustPlatform, | ||
| stdenv, | ||
| pkgs, | ||
| ... | ||
| }: let | ||
| # From npins | ||
| pin = pins.jupynvim; | ||
|
|
||
| version = pin.revision; | ||
| src = pkgs.fetchFromGitHub { | ||
| inherit (pin.repository) owner repo; | ||
| rev = pin.revision; | ||
| sha256 = pin.hash; | ||
| }; | ||
| in | ||
| rustPlatform.buildRustPackage (finalAttrs: { | ||
| pname = "jupynvim-core"; | ||
| inherit version src; | ||
|
|
||
| sourceRoot = "${finalAttrs.src.name}/core"; | ||
|
|
||
| cargoHash = "sha256-cZKHYCFtzU1ULNp7TY/4/l6SrzGF3ghnBF5y5nvxuWw="; | ||
|
|
||
| doCheck = false; | ||
|
|
||
| env.RUSTFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-C link-arg=-undefined -C link-arg=dynamic_lookup"; | ||
|
|
||
| meta = { | ||
| description = "Native backend for jupynvim, a Jupyter notebook interface for Neovim"; | ||
| homepage = "https://github.com/sheng-tse/jupynvim"; | ||
| license = lib.licenses.mit; | ||
| mainProgram = "jupynvim-core"; | ||
| }; | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| { | ||
| lib, | ||
| callPackage, | ||
| pins, | ||
| pkgs, | ||
| vimUtils, | ||
| ... | ||
| }: let | ||
| # From npins | ||
| pin = pins.jupynvim; | ||
|
|
||
| version = pin.revision; | ||
| src = pkgs.fetchFromGitHub { | ||
| inherit (pin.repository) owner repo; | ||
| rev = pin.revision; | ||
| sha256 = pin.hash; | ||
| }; | ||
|
|
||
| jupynvim-core = callPackage ../jupynvim-core/package.nix {}; | ||
| in | ||
| vimUtils.buildVimPlugin { | ||
| pname = "jupynvim"; | ||
| inherit version src; | ||
|
|
||
| doCheck = false; | ||
|
|
||
| postInstall = '' | ||
| install -Dm755 ${jupynvim-core}/bin/jupynvim-core $out/core/target/release/jupynvim-core | ||
| ''; | ||
|
|
||
| meta = { | ||
| description = "Jupyter notebooks in Neovim with a native Rust backend"; | ||
| homepage = "https://github.com/sheng-tse/jupynvim"; | ||
| license = lib.licenses.mit; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |
| ./icon-picker | ||
| ./images | ||
| ./grug-far-nvim | ||
| ./jupynvim | ||
| ./leetcode-nvim | ||
| ./mkdir | ||
| ./motion | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| { | ||
| config, | ||
| lib, | ||
| ... | ||
| }: let | ||
| inherit (lib.attrsets) recursiveUpdate; | ||
| inherit (lib.modules) mkIf; | ||
|
|
||
| cfg = config.vim.utility.jupynvim; | ||
| in { | ||
| config = mkIf cfg.enable { | ||
| vim = { | ||
| lazy.plugins.jupynvim = { | ||
| package = "jupynvim"; | ||
| setupModule = "jupynvim"; | ||
| event = [ | ||
| { | ||
| event = "BufReadCmd"; | ||
| pattern = "*.ipynb"; | ||
| } | ||
| { | ||
| event = "BufNewFile"; | ||
| pattern = "*.ipynb"; | ||
| } | ||
| ]; | ||
| setupOpts = | ||
| recursiveUpdate | ||
| { | ||
| keymaps = { | ||
| run_advance = cfg.mappings.runAdvance; | ||
| run_stay = cfg.mappings.runStay; | ||
| run_advance_alt = cfg.mappings.runAdvanceAlt; | ||
| run_all = cfg.mappings.runAll; | ||
| run_above = cfg.mappings.runAbove; | ||
| run_below = cfg.mappings.runBelow; | ||
| add_above = cfg.mappings.addAbove; | ||
| add_below = cfg.mappings.addBelow; | ||
| delete_cell = cfg.mappings.deleteCell; | ||
| move_up = cfg.mappings.moveUp; | ||
| move_down = cfg.mappings.moveDown; | ||
| to_markdown = cfg.mappings.toMarkdown; | ||
| to_code = cfg.mappings.toCode; | ||
| pick_kernel = cfg.mappings.pickKernel; | ||
| start_kernel = cfg.mappings.startKernel; | ||
| stop_kernel = cfg.mappings.stopKernel; | ||
| interrupt_kernel = cfg.mappings.interruptKernel; | ||
| restart_kernel = cfg.mappings.restartKernel; | ||
| clear_output = cfg.mappings.clearOutput; | ||
| clear_all = cfg.mappings.clearAll; | ||
| next_cell = cfg.mappings.nextCell; | ||
| prev_cell = cfg.mappings.prevCell; | ||
| next_image = cfg.mappings.nextImage; | ||
| prev_image = cfg.mappings.prevImage; | ||
| enter_output_dn = cfg.mappings.enterOutputDn; | ||
| enter_output_up = cfg.mappings.enterOutputUp; | ||
| save_image = cfg.mappings.saveImage; | ||
| delete_image = cfg.mappings.deleteImage; | ||
| refresh = cfg.mappings.refresh; | ||
| open_link = cfg.mappings.openLink; | ||
| }; | ||
| } | ||
| cfg.setupOpts; | ||
| }; | ||
| }; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| imports = [ | ||
| ./jupynvim.nix | ||
| ./config.nix | ||
| ]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,124 @@ | ||
| { | ||
| config, | ||
| lib, | ||
| ... | ||
| }: let | ||
| inherit (lib.options) mkEnableOption mkOption; | ||
| inherit (lib.types) nullOr str bool enum ints listOf; | ||
| inherit (lib.nvim.types) mkPluginSetupOption; | ||
| inherit (config.vim.lib) mkMappingOption; | ||
| in { | ||
| options.vim.utility.jupynvim = { | ||
| enable = mkEnableOption '' | ||
| jupynvim, a Jupyter notebook interface for Neovim with a native Rust backend. | ||
| See <https://github.com/sheng-tse/jupynvim#configuration> for all configuration options. | ||
| ''; | ||
|
|
||
| setupOpts = mkPluginSetupOption "jupynvim" { | ||
| log_level = mkOption { | ||
| type = enum ["trace" "debug" "info" "warn" "error"]; | ||
| default = "info"; | ||
| description = "Verbosity for both the Rust backend and the Lua frontend."; | ||
| }; | ||
|
|
||
| image_renderer = mkOption { | ||
| type = enum ["placeholder" "kitty" "chafa"]; | ||
| default = "placeholder"; | ||
| description = '' | ||
| How code-cell outputs and embedded markdown images are rendered. | ||
|
|
||
| * `placeholder` - uses the Kitty Unicode placeholder protocol. The image is | ||
| anchored to buffer text and stays put when scrolling. Required for animated | ||
| GIFs. | ||
| * `kitty` - uses direct kitty placement. Lives at fixed screen coordinates and | ||
| does not follow scroll. | ||
| * `chafa` - an ASCII-art fallback for terminals without graphics support. | ||
| ''; | ||
| }; | ||
|
|
||
| image_rows = mkOption { | ||
| type = ints.u16; | ||
| default = 16; | ||
| description = "Inline image grid size in terminal cells (rows)."; | ||
| }; | ||
|
|
||
| image_cols = mkOption { | ||
| type = ints.u16; | ||
| default = 48; | ||
| description = "Inline image grid size in terminal cells (cols)."; | ||
| }; | ||
|
|
||
| core_path = mkOption { | ||
| type = nullOr str; | ||
| default = null; | ||
| description = '' | ||
| Override the path to the `jupynvim-core` binary. Auto-detected from the | ||
| plugin directory if unset. | ||
| ''; | ||
| }; | ||
|
|
||
| disable_default_keymaps = mkOption { | ||
| type = bool; | ||
| default = false; | ||
| description = "Skip the entire default keymap set if you want to bind everything yourself."; | ||
| }; | ||
|
|
||
| auto_venv = mkOption { | ||
| type = bool; | ||
| default = true; | ||
| description = '' | ||
| Walk up from the notebook's directory to find a `.venv` and use its interpreter | ||
| as the kernel when `ipykernel` is installed there. | ||
| ''; | ||
| }; | ||
|
|
||
| lsp_blocklist = mkOption { | ||
| type = listOf str; | ||
| default = []; | ||
| description = '' | ||
| LSP servers to skip on jupynvim buffers. Useful for servers that misbehave on | ||
| `.ipynb` URIs without advertising notebook capability. | ||
| ''; | ||
| }; | ||
|
|
||
| smooth_scroll = mkOption { | ||
| type = bool; | ||
| default = false; | ||
| description = "Restore animated (smooth) scrolling inside notebook buffers."; | ||
| }; | ||
| }; | ||
|
|
||
| mappings = { | ||
| runAdvance = mkMappingOption "Run the current cell and advance to the next one" "<S-CR>"; | ||
| runStay = mkMappingOption "Run the current cell and stay on it" "<C-CR>"; | ||
| runAdvanceAlt = mkMappingOption "Run the current cell and advance (alternative binding)" "<leader>nr"; | ||
| runAll = mkMappingOption "Run all cells" "<leader>nR"; | ||
| runAbove = mkMappingOption "Run all cells above the cursor" "<leader>nA"; | ||
| runBelow = mkMappingOption "Run all cells below the cursor" "<leader>nB"; | ||
| addAbove = mkMappingOption "Add a cell above the cursor" "<leader>na"; | ||
| addBelow = mkMappingOption "Add a cell below the cursor" "<leader>nb"; | ||
| deleteCell = mkMappingOption "Delete the current cell" ("<leader>n" + "d"); | ||
| moveUp = mkMappingOption "Move the current cell up" "<leader>nk"; | ||
| moveDown = mkMappingOption "Move the current cell down" "<leader>nj"; | ||
| toMarkdown = mkMappingOption "Convert the current cell to markdown" "<leader>nm"; | ||
| toCode = mkMappingOption "Convert the current cell to code" "<leader>ny"; | ||
| pickKernel = mkMappingOption "Pick a kernel for the notebook" "<leader>nK"; | ||
| startKernel = mkMappingOption "Start the notebook kernel" "<leader>ns"; | ||
| stopKernel = mkMappingOption "Stop the notebook kernel" "<leader>nS"; | ||
| interruptKernel = mkMappingOption "Interrupt the kernel" "<leader>ni"; | ||
| restartKernel = mkMappingOption "Restart the kernel" "<leader>nx"; | ||
| clearOutput = mkMappingOption "Clear the current cell's output" "<leader>nc"; | ||
| clearAll = mkMappingOption "Clear all cell outputs" "<leader>nC"; | ||
| nextCell = mkMappingOption "Jump to the next cell" "]c"; | ||
| prevCell = mkMappingOption "Jump to the previous cell" "[c"; | ||
| nextImage = mkMappingOption "Jump to the next image cell" "]i"; | ||
| prevImage = mkMappingOption "Jump to the previous image cell" "[i"; | ||
| enterOutputDn = mkMappingOption "Enter the output below the cursor" "<C-j>"; | ||
| enterOutputUp = mkMappingOption "Enter the output above the cursor" "<C-k>"; | ||
| saveImage = mkMappingOption "Save the cell image" "<leader>nI"; | ||
| deleteImage = mkMappingOption "Delete the cell image" "<leader>nD"; | ||
| refresh = mkMappingOption "Refresh the notebook display" "<leader>nL"; | ||
| openLink = mkMappingOption "Open the link under the cursor" "gx"; | ||
| }; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.