mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +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
|
@ -29,6 +29,7 @@
|
||||||
./git/neogit.nix
|
./git/neogit.nix
|
||||||
|
|
||||||
./languages/clangd-extensions.nix
|
./languages/clangd-extensions.nix
|
||||||
|
./languages/julia/julia-cell.nix
|
||||||
./languages/ledger.nix
|
./languages/ledger.nix
|
||||||
./languages/markdown-preview.nix
|
./languages/markdown-preview.nix
|
||||||
./languages/nix.nix
|
./languages/nix.nix
|
||||||
|
|
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
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
25
tests/test-sources/plugins/languages/julia/julia-cell.nix
Normal file
25
tests/test-sources/plugins/languages/julia/julia-cell.nix
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
{
|
||||||
|
empty = {
|
||||||
|
plugins.julia-cell.enable = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
example = {
|
||||||
|
plugins.julia-cell = {
|
||||||
|
enable = true;
|
||||||
|
|
||||||
|
delimitCellsBy = "marks";
|
||||||
|
tag = "##";
|
||||||
|
|
||||||
|
keymaps = {
|
||||||
|
silent = true;
|
||||||
|
|
||||||
|
executeCell = "a";
|
||||||
|
executeCellJump = "b";
|
||||||
|
run = "c";
|
||||||
|
clear = "d";
|
||||||
|
prevCell = "e";
|
||||||
|
nextCell = "f";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue