plugins/julia-cell: switch to mkVimPlugin

This commit is contained in:
Gaetan Lepage 2024-02-14 08:56:38 +01:00 committed by Gaétan Lepage
parent e76acb65b3
commit 9d30e87455
2 changed files with 58 additions and 70 deletions

View file

@ -1,12 +1,10 @@
{ {
lib, lib,
helpers, helpers,
pkgs,
config, config,
pkgs,
... ...
}: let }: let
cfg = config.plugins.julia-cell;
# The keys are the option name in nixvim (under plugins.julia-cell.keymaps) # The keys are the option name in nixvim (under plugins.julia-cell.keymaps)
# cmd: Such that the mapping action is ':JuliaCell${cmd}<CR>' # cmd: Such that the mapping action is ':JuliaCell${cmd}<CR>'
# desc: The description of the option. # desc: The description of the option.
@ -37,30 +35,31 @@
}; };
}; };
in in
with lib; { with lib;
options.plugins.julia-cell = { helpers.vim-plugin.mkVimPlugin config {
enable = mkEnableOption "julia-cell"; name = "julia-cell";
originalName = "vim-julia-cell";
defaultPackage = pkgs.vimPlugins.vim-julia-cell;
globalPrefix = "julia_cell_";
package = helpers.mkPackageOption "julia-cell" pkgs.vimPlugins.vim-julia-cell; maintainers = [maintainers.GaetanLepage];
delimitCellsBy = helpers.defaultNullOpts.mkEnumFirstDefault ["marks" "tags"] '' # TODO introduced 2024-02-19: remove 2024-04-19
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"delimitCellsBy"
"tag"
];
settingsOptions = {
delimit_cells_by = helpers.defaultNullOpts.mkEnumFirstDefault ["marks" "tags"] ''
Specifies if cells are delimited by 'marks' or 'tags'. Specifies if cells are delimited by 'marks' or 'tags'.
''; '';
tag = helpers.defaultNullOpts.mkStr "##" "Specifies the tag format."; tag = helpers.defaultNullOpts.mkStr "##" "Specifies the tag format.";
extraConfig = mkOption {
type = types.attrs;
default = {};
description = ''
The configuration options for julia-cell without the 'julia_cell_' prefix.
Example: To set 'julia_cell_foobar' to 1, write
extraConfig = {
foobar = true;
};
'';
}; };
extraOptions = {
keymaps = keymaps =
{ {
silent = mkOption { silent = mkOption {
@ -79,20 +78,7 @@ in
); );
}; };
config = mkIf cfg.enable { extraConfig = cfg: {
extraPlugins = [cfg.package];
globals =
mapAttrs'
(name: nameValuePair ("julia_cell_" + name))
(
{
delimit_cells_by = cfg.delimitCellsBy;
inherit (cfg) tag;
}
// cfg.extraConfig
);
keymaps = flatten ( keymaps = flatten (
mapAttrsToList mapAttrsToList
( (

View file

@ -7,8 +7,10 @@
plugins.julia-cell = { plugins.julia-cell = {
enable = true; enable = true;
delimitCellsBy = "marks"; settings = {
delimit_cells_by = "marks";
tag = "##"; tag = "##";
};
keymaps = { keymaps = {
silent = true; silent = true;