mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
plugins/julia-cell: switch to mkVimPlugin
This commit is contained in:
parent
e76acb65b3
commit
9d30e87455
2 changed files with 58 additions and 70 deletions
|
@ -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,78 +35,66 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
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
|
||||||
Specifies if cells are delimited by 'marks' or 'tags'.
|
deprecateExtraConfig = true;
|
||||||
'';
|
optionsRenamedToSettings = [
|
||||||
|
"delimitCellsBy"
|
||||||
|
"tag"
|
||||||
|
];
|
||||||
|
|
||||||
tag = helpers.defaultNullOpts.mkStr "##" "Specifies the tag format.";
|
settingsOptions = {
|
||||||
|
delimit_cells_by = helpers.defaultNullOpts.mkEnumFirstDefault ["marks" "tags"] ''
|
||||||
extraConfig = mkOption {
|
Specifies if cells are delimited by 'marks' or 'tags'.
|
||||||
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;
|
|
||||||
};
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
tag = helpers.defaultNullOpts.mkStr "##" "Specifies the tag format.";
|
||||||
};
|
};
|
||||||
|
|
||||||
keymaps =
|
extraOptions = {
|
||||||
{
|
keymaps =
|
||||||
silent = mkOption {
|
{
|
||||||
type = types.bool;
|
silent = mkOption {
|
||||||
description = "Whether julia-cell keymaps should be silent";
|
type = types.bool;
|
||||||
default = false;
|
description = "Whether julia-cell keymaps should be silent";
|
||||||
};
|
default = false;
|
||||||
}
|
};
|
||||||
// (
|
}
|
||||||
mapAttrs
|
// (
|
||||||
|
mapAttrs
|
||||||
|
(
|
||||||
|
name: value:
|
||||||
|
helpers.mkNullOrOption types.str "Keymap for ${value.desc}."
|
||||||
|
)
|
||||||
|
mappings
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
extraConfig = cfg: {
|
||||||
|
keymaps = flatten (
|
||||||
|
mapAttrsToList
|
||||||
(
|
(
|
||||||
name: value:
|
name: value: let
|
||||||
helpers.mkNullOrOption types.str "Keymap for ${value.desc}."
|
key = cfg.keymaps.${name};
|
||||||
|
in
|
||||||
|
optional
|
||||||
|
(key != null)
|
||||||
|
{
|
||||||
|
mode = "n";
|
||||||
|
inherit key;
|
||||||
|
action = ":JuliaCell${value.cmd}<CR>";
|
||||||
|
options.silent = cfg.keymaps.silent;
|
||||||
|
}
|
||||||
)
|
)
|
||||||
mappings
|
mappings
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
config = mkIf cfg.enable {
|
|
||||||
extraPlugins = [cfg.package];
|
|
||||||
|
|
||||||
globals =
|
|
||||||
mapAttrs'
|
|
||||||
(name: nameValuePair ("julia_cell_" + name))
|
|
||||||
(
|
|
||||||
{
|
|
||||||
delimit_cells_by = cfg.delimitCellsBy;
|
|
||||||
inherit (cfg) tag;
|
|
||||||
}
|
|
||||||
// cfg.extraConfig
|
|
||||||
);
|
|
||||||
|
|
||||||
keymaps = flatten (
|
|
||||||
mapAttrsToList
|
|
||||||
(
|
|
||||||
name: value: let
|
|
||||||
key = cfg.keymaps.${name};
|
|
||||||
in
|
|
||||||
optional
|
|
||||||
(key != null)
|
|
||||||
{
|
|
||||||
mode = "n";
|
|
||||||
inherit key;
|
|
||||||
action = ":JuliaCell${value.cmd}<CR>";
|
|
||||||
options.silent = cfg.keymaps.silent;
|
|
||||||
}
|
|
||||||
)
|
|
||||||
mappings
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -7,8 +7,10 @@
|
||||||
plugins.julia-cell = {
|
plugins.julia-cell = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
delimitCellsBy = "marks";
|
settings = {
|
||||||
tag = "##";
|
delimit_cells_by = "marks";
|
||||||
|
tag = "##";
|
||||||
|
};
|
||||||
|
|
||||||
keymaps = {
|
keymaps = {
|
||||||
silent = true;
|
silent = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue