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,
helpers,
pkgs,
config,
pkgs,
...
}: let
cfg = config.plugins.julia-cell;
# The keys are the option name in nixvim (under plugins.julia-cell.keymaps)
# cmd: Such that the mapping action is ':JuliaCell${cmd}<CR>'
# desc: The description of the option.
@ -37,30 +35,31 @@
};
};
in
with lib; {
options.plugins.julia-cell = {
enable = mkEnableOption "julia-cell";
with lib;
helpers.vim-plugin.mkVimPlugin config {
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'.
'';
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 =
{
silent = mkOption {
@ -79,20 +78,7 @@ in
);
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
globals =
mapAttrs'
(name: nameValuePair ("julia_cell_" + name))
(
{
delimit_cells_by = cfg.delimitCellsBy;
inherit (cfg) tag;
}
// cfg.extraConfig
);
extraConfig = cfg: {
keymaps = flatten (
mapAttrsToList
(

View file

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