plugins/molten: switch to settings option

This commit is contained in:
Gaetan Lepage 2024-03-01 21:26:23 +01:00 committed by Gaétan Lepage
parent 0c1c11049c
commit d8432ef9c1
2 changed files with 201 additions and 184 deletions

View file

@ -12,201 +12,181 @@ with helpers.vim-plugin;
originalName = "molten-nvim";
defaultPackage = pkgs.vimPlugins.molten-nvim;
globalPrefix = "molten_";
# 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"
];
options = {
autoOpenOutput = mkDefaultOpt {
global = "auto_open_output";
description = ''
Automatically open the output window when your cursor moves over a cell.
Default: `true`
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()`.
'';
type = types.bool;
example = false;
};
copyOutput = mkDefaultOpt {
global = "copy_output";
description = ''
Copy evaluation output to clipboard automatically (requires pyperclip).
Default: `false`
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.
'';
type = types.bool;
example = true;
};
enterOutputBehavior = mkDefaultOpt {
global = "enter_output_behavior";
description = ''
The behavior of MoltenEnterOutput.
Default: `"open_then_enter"`
auto_open_html_in_browser = helpers.defaultNullOpts.mkBool false ''
Automatically open HTML outputs in a browser. related: `open_cmd`.
'';
type = types.enum ["open_then_enter" "open_and_enter" "no_open"];
};
imageProvider = mkDefaultOpt {
global = "image_provider";
description = ''
auto_open_output = helpers.defaultNullOpts.mkBool true ''
Automatically open the floating output window when your cursor moves into a cell.
'';
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.
'';
cover_lines_starting_with = helpers.defaultNullOpts.mkListOf types.str "[]" ''
When `cover_empty_lines` is `true`, also covers lines starting with these strings.
'';
copy_output = helpers.defaultNullOpts.mkBool false ''
Copy evaluation output to clipboard automatically (requires `pyperclip`).
'';
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).";
image_provider = helpers.defaultNullOpts.mkEnumFirstDefault ["none" "image.nvim"] ''
How images are displayed.
Default: `"none"`
'';
type = types.enum ["none" "image.nvim"];
};
outputCropBorder = mkDefaultOpt {
global = "output_crop_border";
description = ''
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])`
'';
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.
Default: `true`
'';
type = types.bool;
};
outputShowMore = mkDefaultOpt {
global = "output_show_more";
description = ''
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).
Default: `false`
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).
'';
type = types.bool;
};
outputVirtLines = mkDefaultOpt {
global = "output_virt_lines";
description = ''
Pad the main buffer with virtual lines so the output doesn't cover anything while it's
open.
Default: `false`
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.
'';
type = types.bool;
};
outputWinBorder = mkDefaultOpt {
global = "output_win_border";
description = ''
Some border features will not work if you don't specify your border as a table.
See border option of `:h nvim_open_win()`.
output_win_border = helpers.defaultNullOpts.mkBorder ''["" "" "" ""]'' "output window" "";
Default: `["" "" "" ""]`
'';
type = helpers.nixvimTypes.border;
};
outputWinCoverGutter = mkDefaultOpt {
global = "output_win_cover_gutter";
description = ''
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 `outputWinStyle`.
Default: `true`
If you change this, you probably also want to change `output_win_style`.
'';
type = types.bool;
};
outputWinHideOnLeave = mkDefaultOpt {
global = "output_win_hide_on_leave";
description = ''
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.
Default: `true`
'';
type = types.bool;
};
outputWinMaxHeight = mkDefaultOpt {
global = "output_win_max_height";
description = ''
output_win_max_height = helpers.defaultNullOpts.mkUnsignedInt 999999 ''
Max height of the output window.
Default: `999999`
'';
type = types.ints.unsigned;
};
outputWinMaxWidth = mkDefaultOpt {
global = "output_win_max_width";
description = ''
output_win_max_width = helpers.defaultNullOpts.mkUnsignedInt 999999 ''
Max width of the output window.
Default: `999999`
'';
type = types.ints.unsigned;
};
outputWinStyle = mkDefaultOpt {
global = "output_win_style";
description = ''
Value passed to the `style` option in `:h nvim_open_win()`
Default: `false`
output_win_style = helpers.defaultNullOpts.mkEnum [false "minimal"] "false" ''
Value passed to the style option in `:h nvim_open_win()`.
'';
type = types.enum [false "minimal"];
};
savePath = mkDefaultOpt {
global = "save_path";
description = ''
Where to save/load data with `:MoltenSave` and `:MoltenLoad`.
save_path =
helpers.defaultNullOpts.mkStr
''{__raw = "vim.fn.stdpath('data')..'/molten'";}''
"Where to save/load data with `:MoltenSave` and `:MoltenLoad`.";
Default: `{__raw = "vim.fn.stdpath('data')..'/molten'";}`
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.
'';
type = with helpers.nixvimTypes; either str rawLua;
};
useBorderHighlights = mkDefaultOpt {
global = "use_border_highlights";
description = ''
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).
See [highlights](https://github.com/benlubas/molten-nvim#highlights).
Default: `false`
'';
type = types.bool;
};
virtLinesOffBy1 = mkDefaultOpt {
global = "virt_lines_off_by_1";
description = ''
_Only has effect when `outputVirtLines` is true._
Allows the output window to cover exactly one line of the regular buffer.
(useful for running code in a markdown file where that covered line will just be ```)
Default: `false`
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.
'';
type = types.bool;
};
wrapOutput = mkDefaultOpt {
global = "wrap_output";
description = ''
Wrap text in output windows.
Default: `false`
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 ```).
'';
type = types.bool;
};
# Debug
showMimetypeDebug = mkDefaultOpt {
global = "show_mimetype_debug";
description = ''
virt_text_output = helpers.defaultNullOpts.mkBool false ''
When true, show output as virtual text below the cell, virtual text stays after leaving the
cell.
When true, output window doesn't open automatically on run.
Effected by `virt_lines_off_by_1`.
'';
virt_text_max_lines = helpers.defaultNullOpts.mkUnsignedInt 12 ''
Max height of the virtual text.
'';
wrap_output = helpers.defaultNullOpts.mkBool false ''
Wrap output text.
'';
show_mimetype_debug = helpers.defaultNullOpts.mkBool false ''
Before any non-iostream output chunk, the mime-type for that output chunk is shown.
Meant for debugging/plugin devlopment.
Default: `false`
'';
type = types.bool;
};
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 = ["" "" "" ""];
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;
};
}

View file

@ -7,24 +7,61 @@
plugins.molten = {
enable = true;
autoOpenOutput = true;
copyOutput = false;
enterOutputBehavior = "open_then_enter";
imageProvider = "none";
outputCropBorder = true;
outputShowMore = false;
outputVirtLines = false;
outputWinBorder = ["" "" "" ""];
outputWinCoverGutter = true;
outputWinHideOnLeave = true;
outputWinMaxHeight = 999999;
outputWinMaxWidth = 999999;
outputWinStyle = false;
savePath.__raw = "vim.fn.stdpath('data')..'/molten'";
useBorderHighlights = false;
virtLinesOffBy1 = false;
wrapOutput = false;
showMimetypeDebug = false;
settings = {
auto_image_popup = false;
auto_init_behavior = "init";
auto_open_html_in_browser = false;
auto_open_output = true;
cover_empty_lines = false;
cover_lines_starting_with = [];
copy_output = false;
enter_output_behavior = "open_then_enter";
image_provider = "none";
open_cmd = null;
output_crop_border = true;
output_show_more = false;
output_virt_lines = false;
output_win_border = ["" "" "" ""];
output_win_cover_gutter = true;
output_win_hide_on_leave = true;
output_win_max_height = 999999;
output_win_max_width = 999999;
output_win_style = false;
save_path.__raw = "vim.fn.stdpath('data')..'/molten'";
tick_rate = 500;
use_border_highlights = false;
limit_output_chars = 1000000;
virt_lines_off_by_1 = false;
virt_text_output = false;
virt_text_max_lines = 12;
wrap_output = false;
show_mimetype_debug = false;
};
};
};
example = {
plugins.molten = {
enable = true;
settings = {
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 = ["" "" "" ""];
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;
};
};
};
}