plugins/vim-slime: switch to settings option

This commit is contained in:
Gaetan Lepage 2024-03-02 23:24:35 +01:00 committed by Gaétan Lepage
parent 740b59c1f1
commit 7e33553fc3
2 changed files with 79 additions and 86 deletions

View file

@ -11,11 +11,24 @@ with helpers.vim-plugin;
name = "vim-slime"; name = "vim-slime";
defaultPackage = pkgs.vimPlugins.vim-slime; defaultPackage = pkgs.vimPlugins.vim-slime;
globalPrefix = "slime_"; globalPrefix = "slime_";
deprecateExtraConfig = true;
options = { # TODO introduced 2024-03-02: remove 2024-05-02
target = mkDefaultOpt { deprecateExtraConfig = true;
type = types.enum [ optionsRenamedToSettings = [
"target"
"vimterminalCmd"
"noMappings"
"pasteFile"
"preserveCurpos"
"defaultConfig"
"dontAskDefault"
"bracketedPaste"
];
settingsOptions = {
target =
helpers.defaultNullOpts.mkEnum
[
"dtach" "dtach"
"kitty" "kitty"
"neovim" "neovim"
@ -26,61 +39,38 @@ with helpers.vim-plugin;
"whimrepl" "whimrepl"
"x11" "x11"
"zellij" "zellij"
]; ]
description = '' "screen"
Which backend vim-slime should use. "Which backend vim-slime should use.";
Default: "screen" vimterminal_cmd = helpers.mkNullOrStr ''
''; The vim terminal command to execute.
example = "dtach"; '';
};
vimterminalCmd = mkDefaultOpt { no_mappings = helpers.defaultNullOpts.mkBool false ''
global = "vimterminal_cmd"; Whether to disable the default mappings.
type = types.str; '';
description = "The vim terminal command to execute.";
};
noMappings = mkDefaultOpt { paste_file = helpers.defaultNullOpts.mkStr "$HOME/.slime_paste" ''
global = "no_mappings"; Required to transfer data from vim to GNU screen or tmux.
type = types.bool; Setting this explicitly can work around some occasional portability issues.
description = '' whimrepl does not require or support this setting.
Whether to disable the default mappings. '';
Default: `false` preserve_curpos = helpers.defaultNullOpts.mkBool true ''
''; Whether to preserve cursor position when sending a line or paragraph.
}; '';
pasteFile = mkDefaultOpt { default_config =
global = "paste_file"; helpers.mkNullOrOption
type = types.str; (
description = '' with helpers.nixvimTypes;
Required to transfer data from vim to GNU screen or tmux. attrsOf
Setting this explicitly can work around some occasional portability issues. (either str rawLua)
whimrepl does not require or support this setting. )
''
Default: "$HOME/.slime_paste"
'';
};
preserveCurpos = mkDefaultOpt {
global = "preserve_curpos";
type = types.bool;
description = ''
Whether to preserve cursor position when sending a line or paragraph.
Default: `true`
'';
};
defaultConfig = mkDefaultOpt {
global = "default_config";
type = with helpers.nixvimTypes; attrsOf (either str rawLua);
description = ''
Pre-filled prompt answer. Pre-filled prompt answer.
Default: `null`
Examples: Examples:
- `tmux`: - `tmux`:
```nix ```nix
@ -97,30 +87,31 @@ with helpers.vim-plugin;
} }
``` ```
''; '';
dont_ask_default = helpers.defaultNullOpts.mkBool false ''
Whether to bypass the prompt and use the specified default configuration options.
'';
bracketed_paste = helpers.defaultNullOpts.mkBool false ''
Sometimes REPL are too smart for their own good, e.g. autocompleting a bracket that should
not be autocompleted when pasting code from a file.
In this case it can be useful to rely on bracketed-paste
(https://cirw.in/blog/bracketed-paste).
Luckily, tmux knows how to handle that. See tmux's manual.
'';
};
settingsExample = {
target = "screen";
vimterminal_cmd = null;
no_mappings = false;
paste_file = "$HOME/.slime_paste";
preserve_curpos = true;
default_config = {
socket_name = "default";
target_pane = "{last}";
}; };
dont_ask_default = false;
dontAskDefault = mkDefaultOpt { bracketed_paste = false;
global = "dont_ask_default";
type = types.bool;
description = ''
Whether to bypass the prompt and use the specified default configuration options.
Default: `false`
'';
};
bracketedPaste = mkDefaultOpt {
global = "bracketed_paste";
type = with types; nullOr bool;
description = ''
Sometimes REPL are too smart for their own good, e.g. autocompleting a bracket that should
not be autocompleted when pasting code from a file.
In this case it can be useful to rely on bracketed-paste
(https://cirw.in/blog/bracketed-paste).
Luckily, tmux knows how to handle that. See tmux's manual.
Default: `false`
'';
};
}; };
} }

View file

@ -7,17 +7,19 @@
plugins.vim-slime = { plugins.vim-slime = {
enable = true; enable = true;
target = "screen"; settings = {
vimterminalCmd = null; target = "screen";
noMappings = false; vimterminal_cmd = null;
pasteFile = "$HOME/.slime_paste"; no_mappings = false;
preserveCurpos = true; paste_file = "$HOME/.slime_paste";
defaultConfig = { preserve_curpos = true;
socket_name = "default"; default_config = {
target_pane = "{last}"; socket_name = "default";
target_pane = "{last}";
};
dont_ask_default = false;
bracketed_paste = false;
}; };
dontAskDefault = false;
bracketedPaste = false;
}; };
}; };
} }