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"; originalName = "molten-nvim";
defaultPackage = pkgs.vimPlugins.molten-nvim; defaultPackage = pkgs.vimPlugins.molten-nvim;
globalPrefix = "molten_"; globalPrefix = "molten_";
# TODO introduced 2024-03-01: remove 2024-05-01
deprecateExtraConfig = true; deprecateExtraConfig = true;
optionsRenamedToSettings = [
"autoOpenOutput"
"copyOutput"
"enterOutputBehavior"
"imageProvider"
"outputCropBorder"
"outputShowMore"
"outputVirtLines"
"outputWinBorder"
"outputWinCoverGutter"
"outputWinHideOnLeave"
"outputWinMaxHeight"
"outputWinMaxWidth"
"outputWinStyle"
"savePath"
"useBorderHighlights"
"virtLinesOffBy1"
"wrapOutput"
"showMimetypeDebug"
];
options = { settingsOptions = {
autoOpenOutput = mkDefaultOpt { auto_image_popup = helpers.defaultNullOpts.mkBool false ''
global = "auto_open_output"; When true, cells that produce an image output will open the image output automatically with
description = '' python's `Image.show()`.
Automatically open the output window when your cursor moves over a cell.
Default: `true`
''; '';
type = types.bool;
example = false;
};
copyOutput = mkDefaultOpt { auto_init_behavior = helpers.defaultNullOpts.mkStr "init" ''
global = "copy_output"; When set to "raise" commands which would otherwise ask for a kernel when they're run without
description = '' a running kernel will instead raise an exception.
Copy evaluation output to clipboard automatically (requires pyperclip). Useful for other plugins that want to use `pcall` and do their own error handling.
Default: `false`
''; '';
type = types.bool;
example = true;
};
enterOutputBehavior = mkDefaultOpt { auto_open_html_in_browser = helpers.defaultNullOpts.mkBool false ''
global = "enter_output_behavior"; Automatically open HTML outputs in a browser. related: `open_cmd`.
description = ''
The behavior of MoltenEnterOutput.
Default: `"open_then_enter"`
''; '';
type = types.enum ["open_then_enter" "open_and_enter" "no_open"];
};
imageProvider = mkDefaultOpt { auto_open_output = helpers.defaultNullOpts.mkBool true ''
global = "image_provider"; Automatically open the floating output window when your cursor moves into a cell.
description = '' '';
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. How images are displayed.
Default: `"none"`
''; '';
type = types.enum ["none" "image.nvim"];
};
outputCropBorder = mkDefaultOpt { open_cmd = helpers.mkNullOrOption types.str ''
global = "output_crop_border"; Defaults to `xdg-open` on Linux, `open` on Darwin, and `start` on Windows.
description = '' 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 'crops' the bottom border of the output window when it would otherwise just sit at the
bottom of the screen. bottom of the screen.
Default: `true`
''; '';
type = types.bool;
};
outputShowMore = mkDefaultOpt { output_show_more = helpers.defaultNullOpts.mkBool false ''
global = "output_show_more"; When the window can't display the entire contents of the output buffer, shows the number of
description = '' extra lines in the window footer (requires nvim 10.0+ and a window border).
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`
''; '';
type = types.bool;
};
outputVirtLines = mkDefaultOpt { output_virt_lines = helpers.defaultNullOpts.mkBool false ''
global = "output_virt_lines"; Pad the main buffer with virtual lines so the floating window doesn't cover anything while
description = '' it's open.
Pad the main buffer with virtual lines so the output doesn't cover anything while it's
open.
Default: `false`
''; '';
type = types.bool;
};
outputWinBorder = mkDefaultOpt { output_win_border = helpers.defaultNullOpts.mkBorder ''["" "" "" ""]'' "output window" "";
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()`.
Default: `["" "" "" ""]` output_win_cover_gutter = helpers.defaultNullOpts.mkBool true ''
'';
type = helpers.nixvimTypes.border;
};
outputWinCoverGutter = mkDefaultOpt {
global = "output_win_cover_gutter";
description = ''
Should the output window cover the gutter (numbers and sign col), or not. Should the output window cover the gutter (numbers and sign col), or not.
If you change this, you probably also want to change `outputWinStyle`. If you change this, you probably also want to change `output_win_style`.
Default: `true`
''; '';
type = types.bool;
};
outputWinHideOnLeave = mkDefaultOpt { output_win_hide_on_leave = helpers.defaultNullOpts.mkBool true ''
global = "output_win_hide_on_leave";
description = ''
After leaving the output window (via `:q` or switching windows), do not attempt to redraw After leaving the output window (via `:q` or switching windows), do not attempt to redraw
the output window. the output window.
Default: `true`
''; '';
type = types.bool;
};
outputWinMaxHeight = mkDefaultOpt { output_win_max_height = helpers.defaultNullOpts.mkUnsignedInt 999999 ''
global = "output_win_max_height";
description = ''
Max height of the output window. Max height of the output window.
Default: `999999`
''; '';
type = types.ints.unsigned;
};
outputWinMaxWidth = mkDefaultOpt { output_win_max_width = helpers.defaultNullOpts.mkUnsignedInt 999999 ''
global = "output_win_max_width";
description = ''
Max width of the output window. Max width of the output window.
Default: `999999`
''; '';
type = types.ints.unsigned;
};
outputWinStyle = mkDefaultOpt { output_win_style = helpers.defaultNullOpts.mkEnum [false "minimal"] "false" ''
global = "output_win_style"; Value passed to the style option in `:h nvim_open_win()`.
description = ''
Value passed to the `style` option in `:h nvim_open_win()`
Default: `false`
''; '';
type = types.enum [false "minimal"];
};
savePath = mkDefaultOpt { save_path =
global = "save_path"; helpers.defaultNullOpts.mkStr
description = '' ''{__raw = "vim.fn.stdpath('data')..'/molten'";}''
Where to save/load data with `:MoltenSave` and `:MoltenLoad`. "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 { use_border_highlights = helpers.defaultNullOpts.mkBool false ''
global = "use_border_highlights";
description = ''
When true, uses different highlights for output border depending on the state of the cell When true, uses different highlights for output border depending on the state of the cell
(running, done, error). (running, done, error).
See [highlights](https://github.com/benlubas/molten-nvim#highlights).
Default: `false`
''; '';
type = types.bool;
};
virtLinesOffBy1 = mkDefaultOpt { limit_output_chars = helpers.defaultNullOpts.mkUnsignedInt 1000000 ''
global = "virt_lines_off_by_1"; Limit on the number of chars in an output.
description = '' If you're lagging your editor with too much output text, decrease it.
_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`
''; '';
type = types.bool;
};
wrapOutput = mkDefaultOpt { virt_lines_off_by_1 = helpers.defaultNullOpts.mkBool false ''
global = "wrap_output"; Allows the output window to cover exactly one line of the regular buffer when
description = '' `output_virt_lines` is `true`, also effects where `virt_text_output` is displayed.
Wrap text in output windows. (useful for running code in a markdown file where that covered line will just be ```).
Default: `false`
''; '';
type = types.bool;
};
# Debug virt_text_output = helpers.defaultNullOpts.mkBool false ''
showMimetypeDebug = mkDefaultOpt { When true, show output as virtual text below the cell, virtual text stays after leaving the
global = "show_mimetype_debug"; cell.
description = '' 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. Before any non-iostream output chunk, the mime-type for that output chunk is shown.
Meant for debugging/plugin devlopment. 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 = { plugins.molten = {
enable = true; enable = true;
autoOpenOutput = true; settings = {
copyOutput = false; auto_image_popup = false;
enterOutputBehavior = "open_then_enter"; auto_init_behavior = "init";
imageProvider = "none"; auto_open_html_in_browser = false;
outputCropBorder = true; auto_open_output = true;
outputShowMore = false; cover_empty_lines = false;
outputVirtLines = false; cover_lines_starting_with = [];
outputWinBorder = ["" "" "" ""]; copy_output = false;
outputWinCoverGutter = true; enter_output_behavior = "open_then_enter";
outputWinHideOnLeave = true; image_provider = "none";
outputWinMaxHeight = 999999; open_cmd = null;
outputWinMaxWidth = 999999; output_crop_border = true;
outputWinStyle = false; output_show_more = false;
savePath.__raw = "vim.fn.stdpath('data')..'/molten'"; output_virt_lines = false;
useBorderHighlights = false; output_win_border = ["" "" "" ""];
virtLinesOffBy1 = false; output_win_cover_gutter = true;
wrapOutput = false; output_win_hide_on_leave = true;
showMimetypeDebug = false; 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;
};
}; };
}; };
} }