nix-community.nixvim/plugins/utils/molten.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

243 lines
7.4 KiB
Nix
Raw Normal View History

2023-11-06 10:49:41 +01:00
{
lib,
config,
helpers,
2023-11-06 10:49:41 +01:00
pkgs,
...
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
name = "molten";
originalName = "molten-nvim";
defaultPackage = pkgs.vimPlugins.molten-nvim;
globalPrefix = "molten_";
2024-05-05 19:39:35 +02:00
maintainers = [ maintainers.GaetanLepage ];
2024-05-05 19:39:35 +02:00
# TODO introduced 2024-03-01: remove 2024-05-01
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"autoOpenOutput"
"copyOutput"
"enterOutputBehavior"
"imageProvider"
"outputCropBorder"
"outputShowMore"
"outputVirtLines"
"outputWinBorder"
"outputWinCoverGutter"
"outputWinHideOnLeave"
"outputWinMaxHeight"
"outputWinMaxWidth"
"outputWinStyle"
"savePath"
"useBorderHighlights"
"virtLinesOffBy1"
"wrapOutput"
"showMimetypeDebug"
2024-05-05 19:39:35 +02:00
];
settingsOptions = {
auto_image_popup = helpers.defaultNullOpts.mkBool false ''
When true, cells that produce an image output will open the image output automatically with
python's `Image.show()`.
'';
2024-05-05 19:39:35 +02:00
auto_init_behavior = helpers.defaultNullOpts.mkStr "init" ''
When set to "raise" commands which would otherwise ask for a kernel when they're run without
a running kernel will instead raise an exception.
Useful for other plugins that want to use `pcall` and do their own error handling.
'';
2024-05-05 19:39:35 +02:00
auto_open_html_in_browser = helpers.defaultNullOpts.mkBool false ''
Automatically open HTML outputs in a browser. related: `open_cmd`.
'';
2024-05-05 19:39:35 +02:00
auto_open_output = helpers.defaultNullOpts.mkBool true ''
Automatically open the floating output window when your cursor moves into a cell.
'';
2024-05-05 19:39:35 +02:00
cover_empty_lines = helpers.defaultNullOpts.mkBool false ''
The output window and virtual text will be shown just below the last line of code in the
cell.
'';
2024-05-05 19:39:35 +02:00
cover_lines_starting_with = helpers.defaultNullOpts.mkListOf types.str [ ] ''
When `cover_empty_lines` is `true`, also covers lines starting with these strings.
'';
2024-05-05 19:39:35 +02:00
copy_output = helpers.defaultNullOpts.mkBool false ''
Copy evaluation output to clipboard automatically (requires `pyperclip`).
'';
2024-05-05 19:39:35 +02:00
enter_output_behavior = helpers.defaultNullOpts.mkEnumFirstDefault [
"open_then_enter"
"open_and_enter"
"no_open"
] "The behavior of [MoltenEnterOutput](https://github.com/benlubas/molten-nvim#moltenenteroutput).";
2024-05-05 19:39:35 +02:00
image_provider =
helpers.defaultNullOpts.mkEnumFirstDefault
2024-05-05 19:39:35 +02:00
[
"none"
"image.nvim"
2024-05-05 19:39:35 +02:00
]
''
How images are displayed.
'';
open_cmd = helpers.mkNullOrOption types.str ''
Defaults to `xdg-open` on Linux, `open` on Darwin, and `start` on Windows.
But you can override it to whatever you want.
The command is called like: `subprocess.run([open_cmd, filepath])`
'';
2024-05-05 19:39:35 +02:00
output_crop_border = helpers.defaultNullOpts.mkBool true ''
'crops' the bottom border of the output window when it would otherwise just sit at the
bottom of the screen.
2024-05-05 19:39:35 +02:00
'';
output_show_more = helpers.defaultNullOpts.mkBool false ''
When the window can't display the entire contents of the output buffer, shows the number of
extra lines in the window footer (requires nvim 10.0+ and a window border).
2024-05-05 19:39:35 +02:00
'';
output_virt_lines = helpers.defaultNullOpts.mkBool false ''
Pad the main buffer with virtual lines so the floating window doesn't cover anything while
it's open.
2024-05-05 19:39:35 +02:00
'';
output_win_border = helpers.defaultNullOpts.mkBorder [
""
""
""
""
] "output window" "";
2024-05-05 19:39:35 +02:00
output_win_cover_gutter = helpers.defaultNullOpts.mkBool true ''
Should the output window cover the gutter (numbers and sign col), or not.
If you change this, you probably also want to change `output_win_style`.
2024-05-05 19:39:35 +02:00
'';
output_win_hide_on_leave = helpers.defaultNullOpts.mkBool true ''
After leaving the output window (via `:q` or switching windows), do not attempt to redraw
the output window.
2024-05-05 19:39:35 +02:00
'';
output_win_max_height = helpers.defaultNullOpts.mkUnsignedInt 999999 ''
Max height of the output window.
'';
2024-05-05 19:39:35 +02:00
output_win_max_width = helpers.defaultNullOpts.mkUnsignedInt 999999 ''
Max width of the output window.
2024-05-05 19:39:35 +02:00
'';
output_win_style =
helpers.defaultNullOpts.mkEnumFirstDefault
2024-05-05 19:39:35 +02:00
[
false
"minimal"
2024-05-05 19:39:35 +02:00
]
''
Value passed to the style option in `:h nvim_open_win()`.
'';
save_path = helpers.defaultNullOpts.mkStr {
__raw = "vim.fn.stdpath('data')..'/molten'";
} "Where to save/load data with `:MoltenSave` and `:MoltenLoad`.";
2024-05-05 19:39:35 +02:00
tick_rate = helpers.defaultNullOpts.mkUnsignedInt 500 ''
How often (in ms) we poll the kernel for updates.
Determines how quickly the ui will update, if you want a snappier experience, you can set
this to 150 or 200.
2024-05-05 19:39:35 +02:00
'';
use_border_highlights = helpers.defaultNullOpts.mkBool false ''
When true, uses different highlights for output border depending on the state of the cell
(running, done, error).
2024-05-05 19:39:35 +02:00
'';
limit_output_chars = helpers.defaultNullOpts.mkUnsignedInt 1000000 ''
Limit on the number of chars in an output.
If you're lagging your editor with too much output text, decrease it.
2024-05-05 19:39:35 +02:00
'';
virt_lines_off_by_1 = helpers.defaultNullOpts.mkBool false ''
Allows the output window to cover exactly one line of the regular buffer when
`output_virt_lines` is `true`, also effects where `virt_text_output` is displayed.
(useful for running code in a markdown file where that covered line will just be ```).
2024-05-05 19:39:35 +02:00
'';
virt_text_output = helpers.defaultNullOpts.mkBool false ''
When true, show output as virtual text below the cell, virtual text stays after leaving the
2024-05-05 19:39:35 +02:00
cell.
When true, output window doesn't open automatically on run.
Effected by `virt_lines_off_by_1`.
2024-05-05 19:39:35 +02:00
'';
virt_text_max_lines = helpers.defaultNullOpts.mkUnsignedInt 12 ''
Max height of the virtual text.
2024-05-05 19:39:35 +02:00
'';
wrap_output = helpers.defaultNullOpts.mkBool false ''
Wrap output text.
2024-05-05 19:39:35 +02:00
'';
show_mimetype_debug = helpers.defaultNullOpts.mkBool false ''
Before any non-iostream output chunk, the mime-type for that output chunk is shown.
2024-03-07 19:44:13 +01:00
Meant for debugging/plugin development.
2024-05-05 19:39:35 +02:00
'';
};
settingsExample = {
auto_open_output = true;
copy_output = false;
enter_output_behavior = "open_then_enter";
image_provider = "none";
output_crop_border = true;
output_show_more = false;
output_virt_lines = false;
output_win_border = [
2024-05-05 19:39:35 +02:00
""
""
""
""
];
output_win_cover_gutter = true;
output_win_hide_on_leave = true;
output_win_style = false;
save_path.__raw = "vim.fn.stdpath('data')..'/molten'";
use_border_highlights = false;
virt_lines_off_by1 = false;
wrap_output = false;
show_mimetype_debug = false;
2024-05-05 19:39:35 +02:00
};
extraOptions = {
python3Dependencies = mkOption {
type = with types; functionTo (listOf package);
2024-05-05 19:39:35 +02:00
default =
p: with p; [
2024-05-05 19:39:35 +02:00
pynvim
jupyter-client
cairosvg
2024-05-05 19:39:35 +02:00
ipython
nbformat
];
defaultText = literalExpression ''
p: with p; [
2024-05-05 19:39:35 +02:00
pynvim
jupyter-client
2024-05-05 19:39:35 +02:00
cairosvg
ipython
nbformat
]
'';
description = "Python packages to add to the `PYTHONPATH` of neovim.";
};
2024-05-05 19:39:35 +02:00
};
extraConfig = cfg: { extraPython3Packages = cfg.python3Dependencies; };
}