mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 16:39:00 +02:00
plugins/julia-cell: init + test
This commit is contained in:
parent
5b225c1b70
commit
e638f71f9e
3 changed files with 140 additions and 0 deletions
114
plugins/languages/julia/julia-cell.nix
Normal file
114
plugins/languages/julia/julia-cell.nix
Normal file
|
@ -0,0 +1,114 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
cfg = config.plugins.julia-cell;
|
||||
helpers = import ../../helpers.nix {inherit lib;};
|
||||
|
||||
# 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.
|
||||
mappings = {
|
||||
executeCell = {
|
||||
cmd = "ExecuteCell";
|
||||
desc = "executing the current code cell";
|
||||
};
|
||||
executeCellJump = {
|
||||
cmd = "ExecuteCellJump";
|
||||
desc = "executing the current code cell and jumping to the next cell";
|
||||
};
|
||||
run = {
|
||||
cmd = "Run";
|
||||
desc = "running the entire file";
|
||||
};
|
||||
clear = {
|
||||
cmd = "Clear";
|
||||
desc = "clearing the REPL";
|
||||
};
|
||||
prevCell = {
|
||||
cmd = "PrevCell";
|
||||
desc = "jumping to the previous cell header";
|
||||
};
|
||||
nextCell = {
|
||||
cmd = "NextCell";
|
||||
desc = "jumping to the next cell header";
|
||||
};
|
||||
};
|
||||
in
|
||||
with lib; {
|
||||
options.plugins.julia-cell = {
|
||||
enable = mkEnableOption "julia-cell";
|
||||
|
||||
package = helpers.mkPackageOption "julia-cell" pkgs.vimPlugins.vim-julia-cell;
|
||||
|
||||
delimitCellsBy = 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;
|
||||
};
|
||||
'';
|
||||
};
|
||||
|
||||
keymaps =
|
||||
{
|
||||
silent = mkOption {
|
||||
type = types.bool;
|
||||
description = "Whether julia-cell keymaps should be silent";
|
||||
default = false;
|
||||
};
|
||||
}
|
||||
// (
|
||||
mapAttrs
|
||||
(
|
||||
name: value:
|
||||
helpers.mkNullOrOption types.str "Keymap for ${value.desc}."
|
||||
)
|
||||
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
|
||||
);
|
||||
|
||||
maps.normal = mkMerge (
|
||||
mapAttrsToList
|
||||
(
|
||||
name: value: let
|
||||
key = cfg.keymaps.${name};
|
||||
in
|
||||
if key == null
|
||||
then {}
|
||||
else {
|
||||
${key} = {
|
||||
action = ":JuliaCell${value.cmd}<CR>";
|
||||
inherit (cfg.keymaps) silent;
|
||||
};
|
||||
}
|
||||
)
|
||||
mappings
|
||||
);
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue