treewide: Reformat with nixfmt

This commit is contained in:
traxys 2024-05-05 19:39:35 +02:00
parent c6281260dc
commit 62f32bfc71
459 changed files with 28139 additions and 26377 deletions

View file

@ -5,7 +5,8 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.alpha;
sectionType = types.submodule {
@ -22,32 +23,32 @@ with lib; let
description = "Type of section";
};
val =
helpers.mkNullOrOption
(with helpers.nixvimTypes;
nullOr (oneOf [
# "button", "text"
str
# "padding"
int
(listOf (
either
val = helpers.mkNullOrOption (
with helpers.nixvimTypes;
nullOr (oneOf [
# "button", "text"
str
# "padding"
int
(listOf (
either
# "text" (list of strings)
str
# "group"
(attrsOf anything)
))
]))
"Value for section";
))
])
) "Value for section";
opts = mkOption {
type = with types; attrsOf anything;
default = {};
default = { };
description = "Additional options for the section";
};
};
};
in {
in
{
options = {
plugins.alpha = {
enable = mkEnableOption "alpha-nvim";
@ -62,10 +63,7 @@ in {
theme = mkOption {
type = with helpers.nixvimTypes; nullOr (maybeRaw str);
apply = v:
if isString v
then helpers.mkRaw "require'alpha.themes.${v}'.config"
else v;
apply = v: if isString v then helpers.mkRaw "require'alpha.themes.${v}'.config" else v;
default = null;
example = "dashboard";
description = "You can directly use a pre-defined theme.";
@ -73,7 +71,7 @@ in {
layout = mkOption {
type = types.listOf sectionType;
default = [];
default = [ ];
description = "List of sections to layout for the dashboard";
example = [
{
@ -137,16 +135,13 @@ in {
};
};
config = let
layoutDefined = cfg.layout != [];
themeDefined = cfg.theme != null;
in
config =
let
layoutDefined = cfg.layout != [ ];
themeDefined = cfg.theme != null;
in
mkIf cfg.enable {
extraPlugins =
[
cfg.package
]
++ (optional cfg.iconsEnabled pkgs.vimPlugins.nvim-web-devicons);
extraPlugins = [ cfg.package ] ++ (optional cfg.iconsEnabled pkgs.vimPlugins.nvim-web-devicons);
assertions = [
{
@ -164,19 +159,18 @@ in {
}
];
extraConfigLua = let
setupOptions =
if themeDefined
then cfg.theme
else
(with cfg; {
inherit
layout
opts
;
});
in ''
require('alpha').setup(${helpers.toLuaObject setupOptions})
'';
extraConfigLua =
let
setupOptions =
if themeDefined then
cfg.theme
else
(with cfg; {
inherit layout opts;
});
in
''
require('alpha').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -5,34 +5,33 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.auto-save;
in {
options.plugins.auto-save =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "auto-save";
in
{
options.plugins.auto-save = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "auto-save";
package = helpers.mkPackageOption "auto-save" pkgs.vimPlugins.auto-save-nvim;
package = helpers.mkPackageOption "auto-save" pkgs.vimPlugins.auto-save-nvim;
keymaps = {
silent = mkOption {
type = types.bool;
description = "Whether auto-save keymaps should be silent.";
default = false;
};
toggle = helpers.mkNullOrOption types.str "Keymap for running auto-save.";
keymaps = {
silent = mkOption {
type = types.bool;
description = "Whether auto-save keymaps should be silent.";
default = false;
};
enableAutoSave = helpers.defaultNullOpts.mkBool true ''
Whether to start auto-save when the plugin is loaded.
'';
toggle = helpers.mkNullOrOption types.str "Keymap for running auto-save.";
};
executionMessage = {
message =
helpers.defaultNullOpts.mkNullable
(with types; either str helpers.nixvimTypes.rawLua)
enableAutoSave = helpers.defaultNullOpts.mkBool true ''
Whether to start auto-save when the plugin is loaded.
'';
executionMessage = {
message =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua)
''
{
__raw = \'\'
@ -47,29 +46,26 @@ in {
This can be a lua function that returns a string.
'';
dim =
helpers.defaultNullOpts.mkNullable
(types.numbers.between 0 1)
"0.18"
"Dim the color of `message`.";
dim = helpers.defaultNullOpts.mkNullable (types.numbers.between 0
1
) "0.18" "Dim the color of `message`.";
cleaningInterval = helpers.defaultNullOpts.mkInt 1250 ''
Time (in milliseconds) to wait before automatically cleaning MsgArea after displaying
`message`.
See `:h MsgArea`.
'';
};
cleaningInterval = helpers.defaultNullOpts.mkInt 1250 ''
Time (in milliseconds) to wait before automatically cleaning MsgArea after displaying
`message`.
See `:h MsgArea`.
'';
};
triggerEvents =
helpers.defaultNullOpts.mkNullable (with types; listOf str)
''["InsertLeave" "TextChanged"]''
triggerEvents =
helpers.defaultNullOpts.mkNullable (with types; listOf str) ''["InsertLeave" "TextChanged"]''
''
Vim events that trigger auto-save.
See `:h events`.
'';
condition =
helpers.defaultNullOpts.mkLuaFn
condition =
helpers.defaultNullOpts.mkLuaFn
''
function(buf)
local fn = vim.fn
@ -88,20 +84,16 @@ in {
- return false: if it's not ok to be saved
'';
writeAllBuffers = helpers.defaultNullOpts.mkBool false ''
Write all buffers when the current one meets `condition`.
'';
writeAllBuffers = helpers.defaultNullOpts.mkBool false ''
Write all buffers when the current one meets `condition`.
'';
debounceDelay = helpers.defaultNullOpts.mkInt 135 ''
Saves the file at most every `debounce_delay` milliseconds.
'';
debounceDelay = helpers.defaultNullOpts.mkInt 135 ''
Saves the file at most every `debounce_delay` milliseconds.
'';
callbacks =
mapAttrs
(
name: desc:
helpers.mkNullOrLuaFn "The code of the function that runs ${desc}."
)
callbacks =
mapAttrs (name: desc: helpers.mkNullOrLuaFn "The code of the function that runs ${desc}.")
{
enabling = "when enabling auto-save";
disabling = "when disabling auto-save";
@ -109,11 +101,11 @@ in {
beforeSaving = "before doing the actual save";
afterSaving = "after doing the actual save";
};
};
};
config = let
options =
{
config =
let
options = {
enabled = cfg.enableAutoSave;
execution_message = with cfg.executionMessage; {
inherit message dim;
@ -129,20 +121,18 @@ in {
before_saving = beforeSaving;
after_saving = afterSaving;
};
}
// cfg.extraOptions;
in
} // cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require('auto-save').setup(${helpers.toLuaObject options})
'';
keymaps = with cfg.keymaps;
optional
(toggle != null)
{
keymaps =
with cfg.keymaps;
optional (toggle != null) {
mode = "n";
key = toggle;
action = ":ASToggle<CR>";

View file

@ -5,93 +5,91 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.auto-session;
in {
options.plugins.auto-session =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "auto-session";
in
{
options.plugins.auto-session = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "auto-session";
package = helpers.mkPackageOption "auto-session" pkgs.vimPlugins.auto-session;
package = helpers.mkPackageOption "auto-session" pkgs.vimPlugins.auto-session;
logLevel =
helpers.defaultNullOpts.mkEnum
["debug" "info" "warn" "error"]
"error"
"Sets the log level of the plugin.";
logLevel = helpers.defaultNullOpts.mkEnum [
"debug"
"info"
"warn"
"error"
] "error" "Sets the log level of the plugin.";
autoSession = {
enabled = helpers.defaultNullOpts.mkBool true ''
Enables/disables auto creating, saving and restoring.
'';
autoSession = {
enabled = helpers.defaultNullOpts.mkBool true ''
Enables/disables auto creating, saving and restoring.
'';
enableLastSession = helpers.defaultNullOpts.mkBool false ''
Whether to enable the "last session" feature.
'';
enableLastSession = helpers.defaultNullOpts.mkBool false ''
Whether to enable the "last session" feature.
'';
rootDir =
helpers.defaultNullOpts.mkNullable
(with types; either str helpers.nixvimTypes.rawLua)
rootDir =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua)
"{__raw = \"vim.fn.stdpath 'data' .. '/sessions/'\";}"
''
Root directory for session files.
Can be either a string or lua code (using `{__raw = 'foo';}`).
'';
createEnabled = helpers.mkNullOrOption types.bool ''
Whether to enable auto creating new sessions
'';
createEnabled = helpers.mkNullOrOption types.bool ''
Whether to enable auto creating new sessions
'';
suppressDirs = helpers.mkNullOrOption (with types; listOf str) ''
Suppress session create/restore if in one of the list of dirs.
'';
suppressDirs = helpers.mkNullOrOption (with types; listOf str) ''
Suppress session create/restore if in one of the list of dirs.
'';
allowedDirs = helpers.mkNullOrOption (with types; listOf str) ''
Allow session create/restore if in one of the list of dirs.
'';
allowedDirs = helpers.mkNullOrOption (with types; listOf str) ''
Allow session create/restore if in one of the list of dirs.
'';
useGitBranch = helpers.mkNullOrOption types.bool ''
Include git branch name in session name to differentiate between sessions for different
git branches.
'';
};
useGitBranch = helpers.mkNullOrOption types.bool ''
Include git branch name in session name to differentiate between sessions for different
git branches.
'';
};
autoSave = {
enabled = helpers.defaultNullOpts.mkNullable types.bool "null" ''
Whether to enable auto saving session.
'';
};
autoSave = {
enabled = helpers.defaultNullOpts.mkNullable types.bool "null" ''
Whether to enable auto saving session.
'';
};
autoRestore = {
enabled = helpers.defaultNullOpts.mkNullable types.bool "null" ''
Whether to enable auto restoring session.
'';
};
autoRestore = {
enabled = helpers.defaultNullOpts.mkNullable types.bool "null" ''
Whether to enable auto restoring session.
'';
};
cwdChangeHandling =
helpers.defaultNullOpts.mkNullable
cwdChangeHandling =
helpers.defaultNullOpts.mkNullable
(
with types;
either
(enum [false])
(submodule {
options = {
restoreUpcomingSession = helpers.defaultNullOpts.mkBool true ''
Restore session for upcoming cwd on cwd change.
'';
either (enum [ false ]) (submodule {
options = {
restoreUpcomingSession = helpers.defaultNullOpts.mkBool true ''
Restore session for upcoming cwd on cwd change.
'';
preCwdChangedHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
lua function hook.
This is called after auto_session code runs for the `DirChangedPre` autocmd.
'';
preCwdChangedHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
lua function hook.
This is called after auto_session code runs for the `DirChangedPre` autocmd.
'';
postCwdChangedHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
lua function hook.
This is called after auto_session code runs for the `DirChanged` autocmd.
'';
};
})
postCwdChangedHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
lua function hook.
This is called after auto_session code runs for the `DirChanged` autocmd.
'';
};
})
)
"false"
''
@ -99,52 +97,49 @@ in {
Set to `false` to disable the feature.
'';
bypassSessionSaveFileTypes = helpers.mkNullOrOption (with types; listOf str) ''
List of file types to bypass auto save when the only buffer open is one of the file types
listed.
bypassSessionSaveFileTypes = helpers.mkNullOrOption (with types; listOf str) ''
List of file types to bypass auto save when the only buffer open is one of the file types
listed.
'';
sessionLens = {
loadOnSetup = helpers.defaultNullOpts.mkBool true ''
If `loadOnSetup` is set to false, one needs to eventually call
`require("auto-session").setup_session_lens()` if they want to use session-lens.
'';
sessionLens = {
loadOnSetup = helpers.defaultNullOpts.mkBool true ''
If `loadOnSetup` is set to false, one needs to eventually call
`require("auto-session").setup_session_lens()` if they want to use session-lens.
'';
themeConf =
helpers.defaultNullOpts.mkNullable
types.attrs
"{winblend = 10; border = true;}"
themeConf =
helpers.defaultNullOpts.mkNullable types.attrs "{winblend = 10; border = true;}"
"Theme configuration.";
previewer = helpers.defaultNullOpts.mkBool false ''
Use default previewer config by setting the value to `null` if some sets previewer to
true in the custom config.
Passing in the boolean value errors out in the telescope code with the picker trying to
index a boolean instead of a table.
This fixes it but also allows for someone to pass in a table with the actual preview
configs if they want to.
'';
previewer = helpers.defaultNullOpts.mkBool false ''
Use default previewer config by setting the value to `null` if some sets previewer to
true in the custom config.
Passing in the boolean value errors out in the telescope code with the picker trying to
index a boolean instead of a table.
This fixes it but also allows for someone to pass in a table with the actual preview
configs if they want to.
'';
sessionControl = {
controlDir =
helpers.defaultNullOpts.mkNullable
(with types; either str helpers.nixvimTypes.rawLua)
sessionControl = {
controlDir =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua)
"\"vim.fn.stdpath 'data' .. '/auto_session/'\""
''
Auto session control dir, for control files, like alternating between two sessions
with session-lens.
'';
controlFilename = helpers.defaultNullOpts.mkStr "session_control.json" ''
File name of the session control file.
'';
};
controlFilename = helpers.defaultNullOpts.mkStr "session_control.json" ''
File name of the session control file.
'';
};
};
};
config = let
setupOptions =
{
config =
let
setupOptions = {
log_level = cfg.logLevel;
auto_session_enable_last_session = cfg.autoSession.enableLastSession;
auto_session_root_dir = cfg.autoSession.rootDir;
@ -156,14 +151,15 @@ in {
auto_session_allowed_dirs = cfg.autoSession.allowedDirs;
auto_session_use_git_branch = cfg.autoSession.useGitBranch;
cwd_change_handling =
if isAttrs cfg.cwdChangeHandling
then
with cfg.cwdChangeHandling; {
if isAttrs cfg.cwdChangeHandling then
with cfg.cwdChangeHandling;
{
restore_upcoming_session = restoreUpcomingSession;
pre_cwd_changed_hook = preCwdChangedHook;
post_cwd_changed_hook = postCwdChangedHook;
}
else cfg.cwdChangeHandling;
else
cfg.cwdChangeHandling;
bypass_session_save_file_types = cfg.bypassSessionSaveFileTypes;
session_lens = with cfg.sessionLens; {
load_on_setup = loadOnSetup;
@ -174,11 +170,10 @@ in {
control_filename = controlFilename;
};
};
}
// cfg.extraOptions;
in
} // cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require('auto-session').setup(${helpers.toLuaObject setupOptions})

View file

@ -5,10 +5,12 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.autoclose;
in {
meta.maintainers = [maintainers.GaetanLepage];
in
{
meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.autoclose = {
enable = mkEnableOption "autoclose.nvim";
@ -62,22 +64,24 @@ in {
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = let
setupOptions = with cfg; {
inherit keys;
options = with options; {
disabled_filetypes = disabledFiletypes;
disable_when_touch = disableWhenTouch;
touch_regex = touchRegex;
pair_spaces = pairSpaces;
auto_indent = autoIndent;
disable_command_mode = disableCommandMode;
extraConfigLua =
let
setupOptions = with cfg; {
inherit keys;
options = with options; {
disabled_filetypes = disabledFiletypes;
disable_when_touch = disableWhenTouch;
touch_regex = touchRegex;
pair_spaces = pairSpaces;
auto_indent = autoIndent;
disable_command_mode = disableCommandMode;
};
};
};
in ''
require('autoclose').setup(${helpers.toLuaObject setupOptions})
'';
in
''
require('autoclose').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -4,11 +4,10 @@
config,
...
}:
helpers.neovim-plugin.mkNeovimPlugin config
{
helpers.neovim-plugin.mkNeovimPlugin config {
name = "bacon";
defaultPackage = pkgs.vimPlugins.nvim-bacon;
maintainers = [helpers.maintainers.alisonjenkins];
maintainers = [ helpers.maintainers.alisonjenkins ];
settingsOptions = {
quickfix = {

View file

@ -9,7 +9,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
originalName = "baleia.nvim";
defaultPackage = pkgs.vimPlugins.baleia-nvim;
maintainers = [helpers.maintainers.alisonjenkins];
maintainers = [ helpers.maintainers.alisonjenkins ];
settingsOptions = {
async = helpers.defaultNullOpts.mkBool true ''
@ -24,9 +24,18 @@ helpers.neovim-plugin.mkNeovimPlugin config {
At which column start colorizing.
'';
log = helpers.defaultNullOpts.mkEnum ["ERROR" "WARN" "INFO" "DEBUG"] "INFO" ''
Log level, possible values are ERROR, WARN, INFO or DEBUG.
'';
log =
helpers.defaultNullOpts.mkEnum
[
"ERROR"
"WARN"
"INFO"
"DEBUG"
]
"INFO"
''
Log level, possible values are ERROR, WARN, INFO or DEBUG.
'';
name = helpers.defaultNullOpts.mkStr "BaleiaColors" ''
Prefix used to name highlight groups.

View file

@ -5,39 +5,31 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.better-escape;
in {
options.plugins.better-escape =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "better-escape.nvim";
in
{
options.plugins.better-escape = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "better-escape.nvim";
package = helpers.mkPackageOption "better-escape.nvim" pkgs.vimPlugins.better-escape-nvim;
package = helpers.mkPackageOption "better-escape.nvim" pkgs.vimPlugins.better-escape-nvim;
mapping = helpers.mkNullOrOption (with types; listOf str) ''
List of mappings to use to enter escape mode.
'';
mapping = helpers.mkNullOrOption (with types; listOf str) ''
List of mappings to use to enter escape mode.
'';
timeout =
helpers.defaultNullOpts.mkStrLuaOr types.ints.unsigned
"vim.o.timeoutlen"
''
The time in which the keys must be hit in ms.
Uses the value of `vim.o.timeoutlen` (`options.timeoutlen` in nixvim) by default.
'';
timeout = helpers.defaultNullOpts.mkStrLuaOr types.ints.unsigned "vim.o.timeoutlen" ''
The time in which the keys must be hit in ms.
Uses the value of `vim.o.timeoutlen` (`options.timeoutlen` in nixvim) by default.
'';
clearEmptyLines = helpers.defaultNullOpts.mkBool false ''
Clear line after escaping if there is only whitespace.
'';
clearEmptyLines = helpers.defaultNullOpts.mkBool false ''
Clear line after escaping if there is only whitespace.
'';
keys =
helpers.defaultNullOpts.mkNullable
(
with types;
either str helpers.nixvimTypes.rawLua
)
"<ESC>"
keys =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua) "<ESC>"
''
Keys used for escaping, if it is a function will use the result everytime.
@ -49,19 +41,21 @@ in {
end
\'\';
'';
};
};
config = let
setupOptions = with cfg;
{
inherit mapping timeout;
clear_empty_lines = clearEmptyLines;
inherit keys;
}
// cfg.extraOptions;
in
config =
let
setupOptions =
with cfg;
{
inherit mapping timeout;
clear_empty_lines = clearEmptyLines;
inherit keys;
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require('better_escape').setup(${helpers.toLuaObject setupOptions})

View file

@ -10,17 +10,26 @@ helpers.neovim-plugin.mkNeovimPlugin config {
originalName = "ccc.nvim";
defaultPackage = pkgs.vimPlugins.ccc-nvim;
maintainers = [helpers.maintainers.JanKremer];
maintainers = [ helpers.maintainers.JanKremer ];
settingsOptions = {
default_color = helpers.defaultNullOpts.mkStr "#000000" ''
The default color used when a color cannot be picked. It must be HEX format.
'';
highlight_mode = helpers.defaultNullOpts.mkEnum ["fg" "bg" "foreground" "background"] "bg" ''
Option to highlight text foreground or background. It is used to
`output_line` and `highlighter`.
'';
highlight_mode =
helpers.defaultNullOpts.mkEnum
[
"fg"
"bg"
"foreground"
"background"
]
"bg"
''
Option to highlight text foreground or background. It is used to
`output_line` and `highlighter`.
'';
lsp = helpers.defaultNullOpts.mkBool true ''
Whether to enable LSP support. The color information is updated in the
@ -50,5 +59,5 @@ helpers.neovim-plugin.mkNeovimPlugin config {
};
};
extraConfig = cfg: {opts.termguicolors = lib.mkDefault true;};
extraConfig = cfg: { opts.termguicolors = lib.mkDefault true; };
}

View file

@ -5,41 +5,39 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.clipboard-image;
pluginOptions = {
imgDir =
helpers.defaultNullOpts.mkNullable
(with helpers.nixvimTypes;
oneOf [
str
(listOf str)
rawLua
])
"img"
''
Dir name where the image will be pasted to.
(
with helpers.nixvimTypes;
oneOf [
str
(listOf str)
rawLua
]
)
"img"
''
Dir name where the image will be pasted to.
Note: If you want to create nested dir, it is better to use table since windows and unix
have different path separator.
'';
Note: If you want to create nested dir, it is better to use table since windows and unix
have different path separator.
'';
imgDirTxt =
helpers.defaultNullOpts.mkNullable
(with helpers.nixvimTypes;
oneOf [
str
(listOf str)
rawLua
])
"img"
"Dir that will be inserted into text/buffer.";
imgDirTxt = helpers.defaultNullOpts.mkNullable (
with helpers.nixvimTypes;
oneOf [
str
(listOf str)
rawLua
]
) "img" "Dir that will be inserted into text/buffer.";
imgName =
helpers.defaultNullOpts.mkStr
''{__raw = "function() return os.date('%Y-%m-%d-%H-%M-%S') end";}''
"Image's name.";
imgName = helpers.defaultNullOpts.mkStr ''{__raw = "function() return os.date('%Y-%m-%d-%H-%M-%S') end";}'' "Image's name.";
imgHandler = helpers.defaultNullOpts.mkLuaFn "function(img) end" ''
Function that will handle image after pasted.
@ -73,78 +71,79 @@ with lib; let
'';
};
processPluginOptions = opts:
with opts; {
processPluginOptions =
opts: with opts; {
img_dir = imgDir;
img_dir_txt = imgDirTxt;
img_name = imgName;
img_handler = imgHandler;
inherit affix;
};
in {
meta.maintainers = [maintainers.GaetanLepage];
in
{
meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.clipboard-image =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "clipboard-image.nvim";
options.plugins.clipboard-image = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "clipboard-image.nvim";
package = helpers.mkPackageOption "clipboard-image.nvim" pkgs.vimPlugins.clipboard-image-nvim;
package = helpers.mkPackageOption "clipboard-image.nvim" pkgs.vimPlugins.clipboard-image-nvim;
clipboardPackage = mkOption {
type = with types; nullOr package;
description = ''
Which clipboard provider to use.
clipboardPackage = mkOption {
type = with types; nullOr package;
description = ''
Which clipboard provider to use.
Recommended:
- X11: `pkgs.xclip`
- Wayland: `pkgs.wl-clipboard`
- MacOS: `pkgs.pngpaste`
'';
example = pkgs.wl-clipboard;
};
Recommended:
- X11: `pkgs.xclip`
- Wayland: `pkgs.wl-clipboard`
- MacOS: `pkgs.pngpaste`
'';
example = pkgs.wl-clipboard;
};
default = pluginOptions;
default = pluginOptions;
filetypes = mkOption {
type = with types;
attrsOf (
submodule {
options = pluginOptions;
}
);
apply = mapAttrs (_: processPluginOptions);
default = {};
description = "Override certain options for specific filetypes.";
example = {
markdown = {
imgDir = ["src" "assets" "img"];
imgDirTxt = "/assets/img";
imgHandler = ''
function(img)
local script = string.format('./image_compressor.sh "%s"', img.path)
os.execute(script)
end
'';
};
filetypes = mkOption {
type =
with types;
attrsOf (submodule {
options = pluginOptions;
});
apply = mapAttrs (_: processPluginOptions);
default = { };
description = "Override certain options for specific filetypes.";
example = {
markdown = {
imgDir = [
"src"
"assets"
"img"
];
imgDirTxt = "/assets/img";
imgHandler = ''
function(img)
local script = string.format('./image_compressor.sh "%s"', img.path)
os.execute(script)
end
'';
};
};
};
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraPackages = [cfg.clipboardPackage];
extraPackages = [ cfg.clipboardPackage ];
extraConfigLua = let
setupOptions =
{
extraConfigLua =
let
setupOptions = {
default = processPluginOptions cfg.default;
}
// cfg.filetypes
// cfg.extraOptions;
in ''
require('clipboard-image').setup(${helpers.toLuaObject setupOptions})
'';
} // cfg.filetypes // cfg.extraOptions;
in
''
require('clipboard-image').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -6,83 +6,64 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "cloak";
originalName = "cloak.nvim";
defaultPackage = pkgs.vimPlugins.cloak-nvim;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "cloak";
originalName = "cloak.nvim";
defaultPackage = pkgs.vimPlugins.cloak-nvim;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
settingsOptions = {
enabled = helpers.defaultNullOpts.mkBool true ''
Whether to enable the plugin.
'';
settingsOptions = {
enabled = helpers.defaultNullOpts.mkBool true ''
Whether to enable the plugin.
'';
cloak_character = helpers.defaultNullOpts.mkStr "*" ''
Define the cloak character.
'';
cloak_character = helpers.defaultNullOpts.mkStr "*" ''
Define the cloak character.
'';
highlight_group = helpers.defaultNullOpts.mkStr "Comment" ''
The applied highlight group (colors) on the cloaking, see `:h highlight`.
'';
highlight_group = helpers.defaultNullOpts.mkStr "Comment" ''
The applied highlight group (colors) on the cloaking, see `:h highlight`.
'';
cloak_length = helpers.mkNullOrOption types.ints.unsigned ''
Provide a number if you want to hide the true length of the value.
Applies the length of the replacement characters for all matched patterns, defaults to the
length of the matched pattern.
'';
cloak_length = helpers.mkNullOrOption types.ints.unsigned ''
Provide a number if you want to hide the true length of the value.
Applies the length of the replacement characters for all matched patterns, defaults to the
length of the matched pattern.
'';
try_all_patterns = helpers.defaultNullOpts.mkBool true ''
Whether it should try every pattern to find the best fit or stop after the first.
'';
try_all_patterns = helpers.defaultNullOpts.mkBool true ''
Whether it should try every pattern to find the best fit or stop after the first.
'';
cloak_telescope = helpers.defaultNullOpts.mkBool true ''
Set to true to cloak Telescope preview buffers.
(Required feature not in 0.1.x)
'';
cloak_telescope = helpers.defaultNullOpts.mkBool true ''
Set to true to cloak Telescope preview buffers.
(Required feature not in 0.1.x)
'';
patterns =
helpers.defaultNullOpts.mkListOf (
types.submodule {
options = {
file_pattern =
helpers.defaultNullOpts.mkNullable
(
with types;
either
str
(listOf str)
)
".env*"
''
One or several patterns to match against.
They should be valid autocommand patterns.
'';
patterns =
helpers.defaultNullOpts.mkListOf
(types.submodule {
options = {
file_pattern = helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) ".env*" ''
One or several patterns to match against.
They should be valid autocommand patterns.
'';
cloak_pattern =
helpers.defaultNullOpts.mkNullable
(
with types;
either
str
(listOf str)
)
"=.+"
''
One or several patterns to cloak.
cloak_pattern = helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) "=.+" ''
One or several patterns to cloak.
Example: `[":.+" "-.+"]` for yaml files.
'';
Example: `[":.+" "-.+"]` for yaml files.
'';
replace = helpers.mkNullOrOption types.anything ''
A function, table or string to generate the replacement.
The actual replacement will contain the `cloak_character` where it doesn't cover
the original text.
If left empty the legacy behavior of keeping the first character is retained.
'';
};
}
)
replace = helpers.mkNullOrOption types.anything ''
A function, table or string to generate the replacement.
The actual replacement will contain the `cloak_character` where it doesn't cover
the original text.
If left empty the legacy behavior of keeping the first character is retained.
'';
};
})
''
[
{
@ -96,21 +77,21 @@ with lib;
''
List of pattern configurations.
'';
};
};
settingsExample = {
enabled = true;
cloak_character = "*";
highlight_group = "Comment";
patterns = [
{
file_pattern = [
".env*"
"wrangler.toml"
".dev.vars"
];
cloak_pattern = "=.+";
}
];
};
}
settingsExample = {
enabled = true;
cloak_character = "*";
highlight_group = "Comment";
patterns = [
{
file_pattern = [
".env*"
"wrangler.toml"
".dev.vars"
];
cloak_pattern = "=.+";
}
];
};
}

View file

@ -6,100 +6,202 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "comment";
originalName = "Comment.nvim";
luaName = "Comment";
defaultPackage = pkgs.vimPlugins.comment-nvim;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "comment";
originalName = "Comment.nvim";
luaName = "Comment";
defaultPackage = pkgs.vimPlugins.comment-nvim;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-03-24: remove 2024-05-24
imports = let
oldPluginPath = ["plugins" "comment-nvim"];
newPluginPath = ["plugins" "comment"];
settingsPath = newPluginPath ++ ["settings"];
in [
(mkRenamedOptionModule (oldPluginPath ++ ["enable"]) (newPluginPath ++ ["enable"]))
(mkRenamedOptionModule (oldPluginPath ++ ["package"]) (newPluginPath ++ ["package"]))
(mkRenamedOptionModule (oldPluginPath ++ ["padding"]) (settingsPath ++ ["padding"]))
(mkRenamedOptionModule (oldPluginPath ++ ["sticky"]) (settingsPath ++ ["sticky"]))
(mkRenamedOptionModule (oldPluginPath ++ ["ignore"]) (settingsPath ++ ["ignore"]))
(mkRenamedOptionModule (oldPluginPath ++ ["toggler" "line"]) (settingsPath ++ ["toggler" "line"]))
(mkRenamedOptionModule (oldPluginPath ++ ["toggler" "block"]) (settingsPath ++ ["toggler" "block"]))
(mkRenamedOptionModule (oldPluginPath ++ ["opleader" "line"]) (settingsPath ++ ["opleader" "line"]))
(mkRenamedOptionModule (oldPluginPath ++ ["opleader" "block"]) (settingsPath ++ ["opleader" "block"]))
(mkRenamedOptionModule (oldPluginPath ++ ["mappings" "basic"]) (settingsPath ++ ["mappings" "basic"]))
(mkRenamedOptionModule (oldPluginPath ++ ["mappings" "extra"]) (settingsPath ++ ["mappings" "extra"]))
(mkRemovedOptionModule (oldPluginPath ++ ["mappings" "extended"]) "This option has been removed upstream.")
(mkRenamedOptionModule (oldPluginPath ++ ["preHook"]) (settingsPath ++ ["pre_hook"]))
(mkRenamedOptionModule (oldPluginPath ++ ["postHook"]) (settingsPath ++ ["post_hook"]))
# TODO introduced 2024-03-24: remove 2024-05-24
imports =
let
oldPluginPath = [
"plugins"
"comment-nvim"
];
newPluginPath = [
"plugins"
"comment"
];
settingsPath = newPluginPath ++ [ "settings" ];
in
[
(mkRenamedOptionModule (oldPluginPath ++ [ "enable" ]) (newPluginPath ++ [ "enable" ]))
(mkRenamedOptionModule (oldPluginPath ++ [ "package" ]) (newPluginPath ++ [ "package" ]))
(mkRenamedOptionModule (oldPluginPath ++ [ "padding" ]) (settingsPath ++ [ "padding" ]))
(mkRenamedOptionModule (oldPluginPath ++ [ "sticky" ]) (settingsPath ++ [ "sticky" ]))
(mkRenamedOptionModule (oldPluginPath ++ [ "ignore" ]) (settingsPath ++ [ "ignore" ]))
(mkRenamedOptionModule
(
oldPluginPath
++ [
"toggler"
"line"
]
)
(
settingsPath
++ [
"toggler"
"line"
]
)
)
(mkRenamedOptionModule
(
oldPluginPath
++ [
"toggler"
"block"
]
)
(
settingsPath
++ [
"toggler"
"block"
]
)
)
(mkRenamedOptionModule
(
oldPluginPath
++ [
"opleader"
"line"
]
)
(
settingsPath
++ [
"opleader"
"line"
]
)
)
(mkRenamedOptionModule
(
oldPluginPath
++ [
"opleader"
"block"
]
)
(
settingsPath
++ [
"opleader"
"block"
]
)
)
(mkRenamedOptionModule
(
oldPluginPath
++ [
"mappings"
"basic"
]
)
(
settingsPath
++ [
"mappings"
"basic"
]
)
)
(mkRenamedOptionModule
(
oldPluginPath
++ [
"mappings"
"extra"
]
)
(
settingsPath
++ [
"mappings"
"extra"
]
)
)
(mkRemovedOptionModule (
oldPluginPath
++ [
"mappings"
"extended"
]
) "This option has been removed upstream.")
(mkRenamedOptionModule (oldPluginPath ++ [ "preHook" ]) (settingsPath ++ [ "pre_hook" ]))
(mkRenamedOptionModule (oldPluginPath ++ [ "postHook" ]) (settingsPath ++ [ "post_hook" ]))
];
settingsOptions = {
padding = helpers.defaultNullOpts.mkBool true ''
Add a space b/w comment and the line.
settingsOptions = {
padding = helpers.defaultNullOpts.mkBool true ''
Add a space b/w comment and the line.
'';
sticky = helpers.defaultNullOpts.mkBool true ''
Whether the cursor should stay at its position.
'';
ignore = helpers.mkNullOrStr ''
Lines to be ignored while (un)comment.
'';
toggler = {
line = helpers.defaultNullOpts.mkStr "gcc" ''
Line-comment toggle keymap in NORMAL mode.
'';
sticky = helpers.defaultNullOpts.mkBool true ''
Whether the cursor should stay at its position.
block = helpers.defaultNullOpts.mkStr "gbc" ''
Block-comment toggle keymap in NORMAL mode.
'';
};
opleader = {
line = helpers.defaultNullOpts.mkStr "gc" ''
Line-comment operator-pending keymap in NORMAL and VISUAL mode.
'';
ignore = helpers.mkNullOrStr ''
Lines to be ignored while (un)comment.
block = helpers.defaultNullOpts.mkStr "gb" ''
Block-comment operator-pending keymap in NORMAL and VISUAL mode.
'';
};
extra = {
above = helpers.defaultNullOpts.mkStr "gcO" ''
Add comment on the line above.
'';
toggler = {
line = helpers.defaultNullOpts.mkStr "gcc" ''
Line-comment toggle keymap in NORMAL mode.
'';
below = helpers.defaultNullOpts.mkStr "gco" ''
Add comment on the line below.
'';
block = helpers.defaultNullOpts.mkStr "gbc" ''
Block-comment toggle keymap in NORMAL mode.
'';
};
eol = helpers.defaultNullOpts.mkStr "gcA" ''
Add comment at the end of line.
'';
};
opleader = {
line = helpers.defaultNullOpts.mkStr "gc" ''
Line-comment operator-pending keymap in NORMAL and VISUAL mode.
'';
block = helpers.defaultNullOpts.mkStr "gb" ''
Block-comment operator-pending keymap in NORMAL and VISUAL mode.
'';
};
extra = {
above = helpers.defaultNullOpts.mkStr "gcO" ''
Add comment on the line above.
'';
below = helpers.defaultNullOpts.mkStr "gco" ''
Add comment on the line below.
'';
eol = helpers.defaultNullOpts.mkStr "gcA" ''
Add comment at the end of line.
'';
};
mappings =
helpers.defaultNullOpts.mkNullable
mappings =
helpers.defaultNullOpts.mkNullable
(
with types;
either
(enum [false])
(submodule {
options = {
basic = helpers.defaultNullOpts.mkBool true ''
Enable operator-pending mappings (`gcc`, `gbc`, `gc[count]{motion}`, `gb[count]{motion}`).
'';
either (enum [ false ]) (submodule {
options = {
basic = helpers.defaultNullOpts.mkBool true ''
Enable operator-pending mappings (`gcc`, `gbc`, `gc[count]{motion}`, `gb[count]{motion}`).
'';
extra = helpers.defaultNullOpts.mkBool true ''
Enable extra mappings (`gco`, `gcO`, `gcA`).
'';
};
})
extra = helpers.defaultNullOpts.mkBool true ''
Enable extra mappings (`gco`, `gcO`, `gcA`).
'';
};
})
)
''
{
@ -112,34 +214,34 @@ with lib;
NOTE: If given 'false', then the plugin won't create any mappings.
'';
pre_hook = helpers.mkNullOrLuaFn ''
Lua function called before (un)comment.
'';
pre_hook = helpers.mkNullOrLuaFn ''
Lua function called before (un)comment.
'';
post_hook = helpers.mkNullOrLuaFn ''
Lua function called after (un)comment.
'';
};
post_hook = helpers.mkNullOrLuaFn ''
Lua function called after (un)comment.
'';
};
settingsExample = {
ignore = "^const(.*)=(%s?)%((.*)%)(%s?)=>";
toggler = {
line = "gcc";
block = "gbc";
};
opleader = {
line = "gc";
block = "gb";
};
pre_hook = "require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook()";
post_hook = ''
function(ctx)
if ctx.range.srow == ctx.range.erow then
-- do something with the current line
else
-- do something with lines range
end
end
'';
settingsExample = {
ignore = "^const(.*)=(%s?)%((.*)%)(%s?)=>";
toggler = {
line = "gcc";
block = "gbc";
};
}
opleader = {
line = "gc";
block = "gb";
};
pre_hook = "require('ts_context_commentstring.integrations.comment_nvim').create_pre_hook()";
post_hook = ''
function(ctx)
if ctx.range.srow == ctx.range.erow then
-- do something with the current line
else
-- do something with lines range
end
end
'';
};
}

View file

@ -5,9 +5,11 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.commentary;
in {
in
{
# TODO Add support for additional filetypes. This requires autocommands!
options = {
@ -18,7 +20,5 @@ in {
};
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
};
config = mkIf cfg.enable { extraPlugins = [ cfg.package ]; };
}

View file

@ -6,99 +6,98 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "competitest";
originalName = "competitest.nvim";
defaultPackage = pkgs.vimPlugins.competitest-nvim;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "competitest";
originalName = "competitest.nvim";
defaultPackage = pkgs.vimPlugins.competitest-nvim;
maintainers = [helpers.maintainers.svl];
maintainers = [ helpers.maintainers.svl ];
settingsOptions = {
local_config_file_name = helpers.defaultNullOpts.mkStr ".competitest.lua" ''
You can use a different configuration for every different folder.
See [local configuration](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#local-configuration).
'';
settingsOptions = {
local_config_file_name = helpers.defaultNullOpts.mkStr ".competitest.lua" ''
You can use a different configuration for every different folder.
See [local configuration](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#local-configuration).
'';
save_current_file = helpers.defaultNullOpts.mkBool true ''
If true save current file before running testcases.
'';
save_current_file = helpers.defaultNullOpts.mkBool true ''
If true save current file before running testcases.
'';
save_all_files = helpers.defaultNullOpts.mkBool false ''
If true save all the opened files before running testcases.
'';
save_all_files = helpers.defaultNullOpts.mkBool false ''
If true save all the opened files before running testcases.
'';
compile_directory = helpers.defaultNullOpts.mkStr "." ''
Execution directory of compiler, relatively to current file's path.
'';
compile_directory = helpers.defaultNullOpts.mkStr "." ''
Execution directory of compiler, relatively to current file's path.
'';
compile_command =
helpers.mkNullOrOption
compile_command =
helpers.mkNullOrOption
(
with types;
attrsOf (submodule {
options = {
exec = mkOption {
type = str;
description = "Command to execute";
};
args = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Arguments to the command.
'';
attrsOf (submodule {
options = {
exec = mkOption {
type = str;
description = "Command to execute";
};
})
args = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Arguments to the command.
'';
};
})
)
''
Configure the command used to compile code for every different language, see
[here](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#customize-compile-and-run-commands).
'';
running_directory = helpers.defaultNullOpts.mkStr "." ''
Execution directory of your solutions, relatively to current file's path.
'';
running_directory = helpers.defaultNullOpts.mkStr "." ''
Execution directory of your solutions, relatively to current file's path.
'';
run_command =
helpers.mkNullOrOption
run_command =
helpers.mkNullOrOption
(
with types;
attrsOf (submodule {
options = {
exec = mkOption {
type = str;
description = "Command to execute.";
};
args = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Arguments to the command.
'';
attrsOf (submodule {
options = {
exec = mkOption {
type = str;
description = "Command to execute.";
};
})
args = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Arguments to the command.
'';
};
})
)
''
Configure the command used to run your solutions for every different language, see
[here](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#customize-compile-and-run-commands).
'';
multiple_testing = helpers.defaultNullOpts.mkInt (-1) ''
How many testcases to run at the same time
* Set it to -1 to make the most of the amount of available parallelism.
Often the number of testcases run at the same time coincides with the number of CPUs.
* Set it to 0 if you want to run all the testcases together.
* Set it to any positive integer to run that number of testcases contemporarily.
'';
multiple_testing = helpers.defaultNullOpts.mkInt (-1) ''
How many testcases to run at the same time
* Set it to -1 to make the most of the amount of available parallelism.
Often the number of testcases run at the same time coincides with the number of CPUs.
* Set it to 0 if you want to run all the testcases together.
* Set it to any positive integer to run that number of testcases contemporarily.
'';
maximum_time = helpers.defaultNullOpts.mkInt 5000 ''
Maximum time, in milliseconds, given to processes.
If it's exceeded process will be killed.
'';
maximum_time = helpers.defaultNullOpts.mkInt 5000 ''
Maximum time, in milliseconds, given to processes.
If it's exceeded process will be killed.
'';
output_compare_method =
helpers.defaultNullOpts.mkNullable
output_compare_method =
helpers.defaultNullOpts.mkNullable
(
with types;
either (enum [
"exact"
"squish"
])
helpers.nixvimTypes.rawLua
either (enum [
"exact"
"squish"
]) helpers.nixvimTypes.rawLua
)
"squish"
''
@ -112,59 +111,59 @@ with lib;
output is acceptable, false otherwise.
'';
view_output_diff = helpers.defaultNullOpts.mkBool false ''
View diff between actual output and expected output in their respective windows.
'';
view_output_diff = helpers.defaultNullOpts.mkBool false ''
View diff between actual output and expected output in their respective windows.
'';
testcases_directory = helpers.defaultNullOpts.mkStr "." ''
Where testcases files are located, relatively to current file's path.
'';
testcases_directory = helpers.defaultNullOpts.mkStr "." ''
Where testcases files are located, relatively to current file's path.
'';
testcases_use_single_file = helpers.defaultNullOpts.mkBool false ''
If true testcases will be stored in a single file instead of using multiple text files.
If you want to change the way already existing testcases are stored see
[conversion](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#convert-testcases).
'';
testcases_use_single_file = helpers.defaultNullOpts.mkBool false ''
If true testcases will be stored in a single file instead of using multiple text files.
If you want to change the way already existing testcases are stored see
[conversion](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#convert-testcases).
'';
testcases_auto_detect_storage = helpers.defaultNullOpts.mkBool true ''
If true testcases storage method will be detected automatically.
When both text files and single file are available, testcases will be loaded according
to the preference specified in `testcases_use_single_file`.
'';
testcases_auto_detect_storage = helpers.defaultNullOpts.mkBool true ''
If true testcases storage method will be detected automatically.
When both text files and single file are available, testcases will be loaded according
to the preference specified in `testcases_use_single_file`.
'';
testcases_single_file_format = helpers.defaultNullOpts.mkStr "$(FNOEXT).testcases" ''
String representing how single testcases files should be named
(see [file-format modifiers](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#file-format-modifiers)).
'';
testcases_single_file_format = helpers.defaultNullOpts.mkStr "$(FNOEXT).testcases" ''
String representing how single testcases files should be named
(see [file-format modifiers](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#file-format-modifiers)).
'';
testcases_input_file_format = helpers.defaultNullOpts.mkStr "$(FNOEXT)_input$(TCNUM).txt" ''
String representing how testcases input files should be named
(see [file-format modifiers](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#file-format-modifiers)).
'';
testcases_input_file_format = helpers.defaultNullOpts.mkStr "$(FNOEXT)_input$(TCNUM).txt" ''
String representing how testcases input files should be named
(see [file-format modifiers](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#file-format-modifiers)).
'';
testcases_output_file_format = helpers.defaultNullOpts.mkStr "$(FNOEXT)_output$(TCNUM).txt" ''
String representing how testcases output files should be named
(see [file-format modifiers](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#file-format-modifiers)).
'';
testcases_output_file_format = helpers.defaultNullOpts.mkStr "$(FNOEXT)_output$(TCNUM).txt" ''
String representing how testcases output files should be named
(see [file-format modifiers](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#file-format-modifiers)).
'';
companion_port = helpers.defaultNullOpts.mkInt 27121 ''
Competitive companion port number.
'';
companion_port = helpers.defaultNullOpts.mkInt 27121 ''
Competitive companion port number.
'';
receive_print_message = helpers.defaultNullOpts.mkBool true ''
If true notify user that plugin is ready to receive testcases, problems and
contests or that they have just been received.
'';
receive_print_message = helpers.defaultNullOpts.mkBool true ''
If true notify user that plugin is ready to receive testcases, problems and
contests or that they have just been received.
'';
template_file =
helpers.mkNullOrOption
template_file =
helpers.mkNullOrOption
(
with types;
oneOf [
(enum [false])
str
(attrsOf str)
]
oneOf [
(enum [ false ])
str
(attrsOf str)
]
)
''
Templates to use when creating source files for received problems or contests.
@ -176,84 +175,84 @@ with lib;
* table with paths: table associating file extension to template file.
'';
evaluate_template_modifiers = helpers.defaultNullOpts.mkBool false ''
Whether to evaluate
[receive modifiers](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#receive-modifiers)
inside a template file or not.
'';
evaluate_template_modifiers = helpers.defaultNullOpts.mkBool false ''
Whether to evaluate
[receive modifiers](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#receive-modifiers)
inside a template file or not.
'';
date_format = helpers.defaultNullOpts.mkStr "%c" ''
String used to format `$(DATE)` modifier (see
[receive modifiers](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#receive-modifiers)).
The string should follow the formatting rules as per Lua's
`[os.date](https://www.lua.org/pil/22.1.html)` function.
'';
date_format = helpers.defaultNullOpts.mkStr "%c" ''
String used to format `$(DATE)` modifier (see
[receive modifiers](https://github.com/xeluxee/competitest.nvim?tab=readme-ov-file#receive-modifiers)).
The string should follow the formatting rules as per Lua's
`[os.date](https://www.lua.org/pil/22.1.html)` function.
'';
received_files_extension = helpers.defaultNullOpts.mkStr "cpp" ''
Default file extension for received problems.
'';
received_files_extension = helpers.defaultNullOpts.mkStr "cpp" ''
Default file extension for received problems.
'';
received_problems_path = helpers.defaultNullOpts.mkStr "$(CWD)/$(PROBLEM).$(FEXT)" ''
Path where received problems (not contests) are stored.
Can be one of the following:
* string with receive modifiers.
* function: function accepting two arguments, a table with task details and
a string with preferred file extension. It should return the absolute path
to store received problem.
'';
received_problems_path = helpers.defaultNullOpts.mkStr "$(CWD)/$(PROBLEM).$(FEXT)" ''
Path where received problems (not contests) are stored.
Can be one of the following:
* string with receive modifiers.
* function: function accepting two arguments, a table with task details and
a string with preferred file extension. It should return the absolute path
to store received problem.
'';
received_problems_prompt_path = helpers.defaultNullOpts.mkBool true ''
Whether to ask user confirmation about path where the received problem is stored or not.
'';
received_problems_prompt_path = helpers.defaultNullOpts.mkBool true ''
Whether to ask user confirmation about path where the received problem is stored or not.
'';
received_contests_directory = helpers.defaultNullOpts.mkStr "$(CWD)" ''
Directory where received contests are stored. It can be string or function,
exactly as `received_problems_path`.
'';
received_contests_directory = helpers.defaultNullOpts.mkStr "$(CWD)" ''
Directory where received contests are stored. It can be string or function,
exactly as `received_problems_path`.
'';
received_contests_problems_path = helpers.defaultNullOpts.mkStr "$(PROBLEM).$(FEXT)" ''
Relative path from contest root directory, each problem of a received contest
is stored following this option. It can be string or function, exactly as `received_problems_path`.
'';
received_contests_problems_path = helpers.defaultNullOpts.mkStr "$(PROBLEM).$(FEXT)" ''
Relative path from contest root directory, each problem of a received contest
is stored following this option. It can be string or function, exactly as `received_problems_path`.
'';
received_contests_prompt_directory = helpers.defaultNullOpts.mkBool true ''
Whether to ask user confirmation about the directory where received contests are stored or not.
'';
received_contests_prompt_directory = helpers.defaultNullOpts.mkBool true ''
Whether to ask user confirmation about the directory where received contests are stored or not.
'';
received_contests_prompt_extension = helpers.defaultNullOpts.mkBool true ''
Whether to ask user confirmation about what file extension to use when receiving a contest or not.
'';
received_contests_prompt_extension = helpers.defaultNullOpts.mkBool true ''
Whether to ask user confirmation about what file extension to use when receiving a contest or not.
'';
open_received_problems = helpers.defaultNullOpts.mkBool true ''
Automatically open source files when receiving a single problem.
'';
open_received_problems = helpers.defaultNullOpts.mkBool true ''
Automatically open source files when receiving a single problem.
'';
open_received_contests = helpers.defaultNullOpts.mkBool true ''
Automatically open source files when receiving a contest.
'';
open_received_contests = helpers.defaultNullOpts.mkBool true ''
Automatically open source files when receiving a contest.
'';
replace_received_testcases = helpers.defaultNullOpts.mkBool false ''
This option applies when receiving only testcases. If true replace existing
testcases with received ones, otherwise ask user what to do.
'';
};
replace_received_testcases = helpers.defaultNullOpts.mkBool false ''
This option applies when receiving only testcases. If true replace existing
testcases with received ones, otherwise ask user what to do.
'';
};
settingsExample = {
received_problems_path = "$(HOME)/cp/$(JUDGE)/$(CONTEST)/$(PROBLEM)/main.$(FEXT)";
template_file = "$(HOME)/cp/templates/template.$(FEXT)";
evaluate_template_modifiers = true;
compile_command = {
cpp = {
exec = "g++";
args = [
"-DLOCAL"
"$(FNAME)"
"-o"
"$(FNOEXT)"
"-Wall"
"-Wextra"
];
};
settingsExample = {
received_problems_path = "$(HOME)/cp/$(JUDGE)/$(CONTEST)/$(PROBLEM)/main.$(FEXT)";
template_file = "$(HOME)/cp/templates/template.$(FEXT)";
evaluate_template_modifiers = true;
compile_command = {
cpp = {
exec = "g++";
args = [
"-DLOCAL"
"$(FNAME)"
"-o"
"$(FNOEXT)"
"-Wall"
"-Wextra"
];
};
};
}
};
}

View file

@ -5,16 +5,16 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.conjure;
in {
in
{
options.plugins.conjure = {
enable = mkEnableOption "Conjure";
package = helpers.mkPackageOption "conjure" pkgs.vimPlugins.conjure;
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
};
config = mkIf cfg.enable { extraPlugins = [ cfg.package ]; };
}

View file

@ -5,7 +5,8 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.coverage;
keymapsDef = {
@ -50,123 +51,96 @@ with lib; let
description = "Displays a coverage summary report in a floating window.";
};
};
in {
options.plugins.coverage =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "nvim-coverage";
in
{
options.plugins.coverage = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "nvim-coverage";
package = helpers.mkPackageOption "nvim-coverage" pkgs.vimPlugins.nvim-coverage;
package = helpers.mkPackageOption "nvim-coverage" pkgs.vimPlugins.nvim-coverage;
keymapsSilent = mkOption {
type = types.bool;
description = "Whether nvim-coverage keymaps should be silent";
default = false;
};
keymapsSilent = mkOption {
type = types.bool;
description = "Whether nvim-coverage keymaps should be silent";
default = false;
};
keymaps =
mapAttrs
(
optionName: properties:
helpers.mkNullOrOption types.str properties.description
)
keymapsDef;
keymaps = mapAttrs (
optionName: properties: helpers.mkNullOrOption types.str properties.description
) keymapsDef;
autoReload = helpers.defaultNullOpts.mkBool false ''
If true, the `coverage_file` for a language will be watched for changes after executing
`:CoverageLoad` or `coverage.load()`.
The file watcher will be stopped after executing `:CoverageClear` or `coverage.clear()`.
'';
autoReload = helpers.defaultNullOpts.mkBool false ''
If true, the `coverage_file` for a language will be watched for changes after executing
`:CoverageLoad` or `coverage.load()`.
The file watcher will be stopped after executing `:CoverageClear` or `coverage.clear()`.
'';
autoReloadTimeoutMs = helpers.defaultNullOpts.mkInt 500 ''
The number of milliseconds to wait before auto-reloading coverage after detecting a change.
'';
autoReloadTimeoutMs = helpers.defaultNullOpts.mkInt 500 ''
The number of milliseconds to wait before auto-reloading coverage after detecting a change.
'';
commands = helpers.defaultNullOpts.mkBool true "If true, create commands.";
commands = helpers.defaultNullOpts.mkBool true "If true, create commands.";
highlights = {
covered =
helpers.defaultNullOpts.mkNullable
types.attrs
''{fg = "#B7F071";}''
highlights = {
covered =
helpers.defaultNullOpts.mkNullable types.attrs ''{fg = "#B7F071";}''
"Highlight group for covered signs.";
uncovered =
helpers.defaultNullOpts.mkNullable
types.attrs
''{fg = "#F07178";}''
uncovered =
helpers.defaultNullOpts.mkNullable types.attrs ''{fg = "#F07178";}''
"Highlight group for uncovered signs.";
partial =
helpers.defaultNullOpts.mkNullable
types.attrs
''{fg = "#AA71F0";}''
partial =
helpers.defaultNullOpts.mkNullable types.attrs ''{fg = "#AA71F0";}''
"Highlight group for partial coverage signs.";
summaryBorder =
helpers.defaultNullOpts.mkNullable
types.attrs
''{link = "FloatBorder";}''
summaryBorder =
helpers.defaultNullOpts.mkNullable types.attrs ''{link = "FloatBorder";}''
"Border highlight group of the summary pop-up.";
summaryNormal =
helpers.defaultNullOpts.mkNullable
types.attrs
''{link = "NormalFloat";}''
summaryNormal =
helpers.defaultNullOpts.mkNullable types.attrs ''{link = "NormalFloat";}''
"Normal text highlight group of the summary pop-up.";
summaryCursorLine =
helpers.defaultNullOpts.mkNullable
types.attrs
''{link = "CursorLine";}''
summaryCursorLine =
helpers.defaultNullOpts.mkNullable types.attrs ''{link = "CursorLine";}''
"Cursor line highlight group of the summary pop-up.";
summaryHeader =
helpers.defaultNullOpts.mkNullable
types.attrs
''{ style = "bold,underline"; sp = "bg"; }''
summaryHeader =
helpers.defaultNullOpts.mkNullable types.attrs ''{ style = "bold,underline"; sp = "bg"; }''
"Header text highlight group of the summary pop-up.";
summaryPass =
helpers.defaultNullOpts.mkNullable
types.attrs
''{link = "CoverageCovered";}''
summaryPass =
helpers.defaultNullOpts.mkNullable types.attrs ''{link = "CoverageCovered";}''
"Pass text highlight group of the summary pop-up.";
summaryFail =
helpers.defaultNullOpts.mkNullable
types.attrs
''{link = "CoverageUncovered";}''
summaryFail =
helpers.defaultNullOpts.mkNullable types.attrs ''{link = "CoverageUncovered";}''
"Fail text highlight group of the summary pop-up.";
};
};
loadCoverageCb = helpers.defaultNullOpts.mkLuaFn "nil" ''
A lua function that will be called when a coverage file is loaded.
loadCoverageCb = helpers.defaultNullOpts.mkLuaFn "nil" ''
A lua function that will be called when a coverage file is loaded.
Example:
```
function (ftype)
vim.notify("Loaded " .. ftype .. " coverage")
end
```
'';
Example:
```
function (ftype)
vim.notify("Loaded " .. ftype .. " coverage")
end
```
'';
signs =
mapAttrs
signs =
mapAttrs
(
optionName: {
optionName:
{
prettyName ? optionName,
defaults,
}: {
hl =
helpers.defaultNullOpts.mkStr
defaults.hl
"The highlight group used for ${prettyName} signs.";
}:
{
hl = helpers.defaultNullOpts.mkStr defaults.hl "The highlight group used for ${prettyName} signs.";
text =
helpers.defaultNullOpts.mkStr
defaults.text
"The text used for ${prettyName} signs.";
text = helpers.defaultNullOpts.mkStr defaults.text "The text used for ${prettyName} signs.";
}
)
{
@ -191,132 +165,112 @@ in {
};
};
signGroup = helpers.defaultNullOpts.mkStr "coverage" ''
Name of the sign group used when placing the signs.
See `:h sign-group`.
'';
signGroup = helpers.defaultNullOpts.mkStr "coverage" ''
Name of the sign group used when placing the signs.
See `:h sign-group`.
'';
summary = {
widthPercentage =
helpers.defaultNullOpts.mkNullable
(types.numbers.between 0.0 1.0)
"0.70"
"Width of the pop-up window.";
summary = {
widthPercentage = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0
1.0
) "0.70" "Width of the pop-up window.";
heightPercentage =
helpers.defaultNullOpts.mkNullable
(types.numbers.between 0.0 1.0)
"0.50"
"Height of the pop-up window.";
heightPercentage = helpers.defaultNullOpts.mkNullable (types.numbers.between 0.0
1.0
) "0.50" "Height of the pop-up window.";
borders =
mapAttrs
(
optionName: default:
helpers.defaultNullOpts.mkStr default ""
)
{
topleft = "";
topright = "";
top = "";
left = "";
right = "";
botleft = "";
botright = "";
bot = "";
highlight = "Normal:CoverageSummaryBorder";
};
minCoverage =
helpers.defaultNullOpts.mkNullable
(types.numbers.between 0 100)
"80"
''
Minimum coverage percentage.
Values below this are highlighted with the fail group, values above are highlighted with
the pass group.
'';
borders = mapAttrs (optionName: default: helpers.defaultNullOpts.mkStr default "") {
topleft = "";
topright = "";
top = "";
left = "";
right = "";
botleft = "";
botright = "";
bot = "";
highlight = "Normal:CoverageSummaryBorder";
};
lang = helpers.defaultNullOpts.mkNullable types.attrs "see upstream documentation" ''
Each key corresponds with the `filetype` of the language and maps to an attrs of
configuration values that differ.
See plugin documentation for language specific options.
Example:
```nix
{
python = {
coverage_file = ".coverage";
coverage_command = "coverage json --fail-under=0 -q -o -";
};
ruby = {
coverage_file = "coverage/coverage.json";
};
}
```
minCoverage = helpers.defaultNullOpts.mkNullable (types.numbers.between 0 100) "80" ''
Minimum coverage percentage.
Values below this are highlighted with the fail group, values above are highlighted with
the pass group.
'';
lcovFile =
helpers.mkNullOrOption
types.str
"File that the plugin will try to read lcov coverage from.";
};
config = let
setupOptions = with cfg;
{
auto_reload = autoReload;
auto_reload_timeout_ms = autoReloadTimeoutMs;
inherit commands;
highlights = with highlights; {
inherit covered uncovered partial;
summary_border = summaryBorder;
summary_normal = summaryNormal;
summary_cursor_line = summaryCursorLine;
summary_header = summaryHeader;
summary_pass = summaryPass;
summary_fail = summaryFail;
};
load_coverage_cb = loadCoverageCb;
inherit signs;
sign_group = signGroup;
summary = with summary; {
width_percentage = widthPercentage;
height_percentage = heightPercentage;
inherit borders;
min_coverage = minCoverage;
};
inherit lang;
lcov_file = lcovFile;
}
// cfg.extraOptions;
in
lang = helpers.defaultNullOpts.mkNullable types.attrs "see upstream documentation" ''
Each key corresponds with the `filetype` of the language and maps to an attrs of
configuration values that differ.
See plugin documentation for language specific options.
Example:
```nix
{
python = {
coverage_file = ".coverage";
coverage_command = "coverage json --fail-under=0 -q -o -";
};
ruby = {
coverage_file = "coverage/coverage.json";
};
}
```
'';
lcovFile = helpers.mkNullOrOption types.str "File that the plugin will try to read lcov coverage from.";
};
config =
let
setupOptions =
with cfg;
{
auto_reload = autoReload;
auto_reload_timeout_ms = autoReloadTimeoutMs;
inherit commands;
highlights = with highlights; {
inherit covered uncovered partial;
summary_border = summaryBorder;
summary_normal = summaryNormal;
summary_cursor_line = summaryCursorLine;
summary_header = summaryHeader;
summary_pass = summaryPass;
summary_fail = summaryFail;
};
load_coverage_cb = loadCoverageCb;
inherit signs;
sign_group = signGroup;
summary = with summary; {
width_percentage = widthPercentage;
height_percentage = heightPercentage;
inherit borders;
min_coverage = minCoverage;
};
inherit lang;
lcov_file = lcovFile;
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("coverage").setup(${helpers.toLuaObject setupOptions})
'';
keymaps =
flatten
(
mapAttrsToList
(
optionName: properties: let
key = cfg.keymaps.${optionName};
in
optional
(key != null)
{
mode = "n";
inherit key;
action = ":Coverage${properties.command}<CR>";
options.silent = cfg.keymapsSilent;
}
)
keymapsDef
);
keymaps = flatten (
mapAttrsToList (
optionName: properties:
let
key = cfg.keymaps.${optionName};
in
optional (key != null) {
mode = "n";
inherit key;
action = ":Coverage${properties.command}<CR>";
options.silent = cfg.keymapsSilent;
}
) keymapsDef
);
};
}

View file

@ -5,45 +5,37 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.cursorline;
in {
options.plugins.cursorline =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "nvim-cursorline";
in
{
options.plugins.cursorline = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "nvim-cursorline";
package = helpers.mkPackageOption "nvim-cursorline" pkgs.vimPlugins.nvim-cursorline;
package = helpers.mkPackageOption "nvim-cursorline" pkgs.vimPlugins.nvim-cursorline;
cursorline = {
enable =
helpers.defaultNullOpts.mkBool true
"Show / hide cursorline in connection with cursor moving.";
cursorline = {
enable = helpers.defaultNullOpts.mkBool true "Show / hide cursorline in connection with cursor moving.";
timeout =
helpers.defaultNullOpts.mkInt 1000
"Time (in ms) after which the cursorline appears.";
timeout = helpers.defaultNullOpts.mkInt 1000 "Time (in ms) after which the cursorline appears.";
number =
helpers.defaultNullOpts.mkBool false
"Whether to also highlight the line number.";
};
cursorword = {
enable = helpers.defaultNullOpts.mkBool true "Underlines the word under the cursor.";
minLength = helpers.defaultNullOpts.mkInt 3 "Minimum length for underlined words.";
hl =
helpers.defaultNullOpts.mkNullable
types.attrs
"{underline = true;}"
"Highliht definition map for cursorword highlighting.";
};
number = helpers.defaultNullOpts.mkBool false "Whether to also highlight the line number.";
};
cursorword = {
enable = helpers.defaultNullOpts.mkBool true "Underlines the word under the cursor.";
config = let
options =
{
minLength = helpers.defaultNullOpts.mkInt 3 "Minimum length for underlined words.";
hl =
helpers.defaultNullOpts.mkNullable types.attrs "{underline = true;}"
"Highliht definition map for cursorword highlighting.";
};
};
config =
let
options = {
cursorline = with cfg.cursorline; {
inherit enable timeout number;
};
@ -52,11 +44,10 @@ in {
min_length = minLength;
inherit hl;
};
}
// cfg.extraOptions;
in
} // cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require('nvim-cursorline').setup(${helpers.toLuaObject options})

View file

@ -5,9 +5,11 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.dashboard;
in {
in
{
options = {
plugins.dashboard = {
enable = mkEnableOption "dashboard";
@ -28,32 +30,36 @@ in {
center = mkOption {
description = "Center section";
type = types.nullOr (types.listOf (types.submodule {
options = {
icon = mkOption {
description = "Item icon";
type = types.nullOr types.str;
default = null;
};
type = types.nullOr (
types.listOf (
types.submodule {
options = {
icon = mkOption {
description = "Item icon";
type = types.nullOr types.str;
default = null;
};
desc = mkOption {
description = "Item description";
type = types.str;
};
desc = mkOption {
description = "Item description";
type = types.str;
};
shortcut = mkOption {
description = "Item shortcut";
type = types.nullOr types.str;
default = null;
};
shortcut = mkOption {
description = "Item shortcut";
type = types.nullOr types.str;
default = null;
};
action = mkOption {
description = "Item action";
type = types.nullOr types.str;
default = null;
};
};
}));
action = mkOption {
description = "Item action";
type = types.nullOr types.str;
default = null;
};
};
}
)
);
default = null;
};
@ -92,7 +98,7 @@ in {
};
};
};
default = {};
default = { };
};
hideStatusline = mkOption {
@ -109,32 +115,32 @@ in {
};
};
config = let
options = {
custom_header = cfg.header;
custom_footer = cfg.footer;
custom_center = cfg.center;
config =
let
options = {
custom_header = cfg.header;
custom_footer = cfg.footer;
custom_center = cfg.center;
preview_file_path = cfg.preview.file;
preview_file_height = cfg.preview.height;
preview_file_width = cfg.preview.width;
preview_command = cfg.preview.command;
preview_file_path = cfg.preview.file;
preview_file_height = cfg.preview.height;
preview_file_width = cfg.preview.width;
preview_command = cfg.preview.command;
hide_statusline = cfg.hideStatusline;
hide_tabline = cfg.hideTabline;
hide_statusline = cfg.hideStatusline;
hide_tabline = cfg.hideTabline;
session_directory = cfg.sessionDirectory;
};
session_directory = cfg.sessionDirectory;
};
filteredOptions = filterAttrs (_: v: v != null) options;
in
filteredOptions = filterAttrs (_: v: v != null) options;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
local dashboard = require("dashboard")
${toString (mapAttrsToList (n: v: "dashboard.${n} = ${helpers.toLuaObject v}\n")
filteredOptions)}
${toString (mapAttrsToList (n: v: "dashboard.${n} = ${helpers.toLuaObject v}\n") filteredOptions)}
'';
};
}

View file

@ -6,28 +6,35 @@
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
name = "direnv";
originalName = "direnv.vim";
defaultPackage = pkgs.vimPlugins.direnv-vim;
globalPrefix = "direnv_";
extraPackages = [pkgs.direnv];
helpers.vim-plugin.mkVimPlugin config {
name = "direnv";
originalName = "direnv.vim";
defaultPackage = pkgs.vimPlugins.direnv-vim;
globalPrefix = "direnv_";
extraPackages = [ pkgs.direnv ];
maintainers = [helpers.maintainers.alisonjenkins];
maintainers = [ helpers.maintainers.alisonjenkins ];
settingsOptions = {
direnv_auto = helpers.defaultNullOpts.mkBool true ''
It will not execute :DirenvExport automatically if the value is false. Default: true.
'';
settingsOptions = {
direnv_auto = helpers.defaultNullOpts.mkBool true ''
It will not execute :DirenvExport automatically if the value is false. Default: true.
'';
direnv_edit_mode =
helpers.defaultNullOpts.mkEnum ["edit" "split" "tabedit" "vsplit"]
"edit" ''
direnv_edit_mode =
helpers.defaultNullOpts.mkEnum
[
"edit"
"split"
"tabedit"
"vsplit"
]
"edit"
''
Select the command to open buffers to edit. Default: 'edit'.
'';
direnv_silent_load = helpers.defaultNullOpts.mkBool true ''
Stop echoing output from Direnv command. Default: true
'';
};
}
direnv_silent_load = helpers.defaultNullOpts.mkBool true ''
Stop echoing output from Direnv command. Default: true
'';
};
}

View file

@ -6,16 +6,18 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "dressing";
originalName = "dressing.nvim";
defaultPackage = pkgs.vimPlugins.dressing-nvim;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "dressing";
originalName = "dressing.nvim";
defaultPackage = pkgs.vimPlugins.dressing-nvim;
maintainers = [helpers.maintainers.AndresBermeoMarinelli];
maintainers = [ helpers.maintainers.AndresBermeoMarinelli ];
settingsOptions = let
settingsOptions =
let
intOrRatio = with types; either ints.unsigned (numbers.between 0.0 1.0);
in {
in
{
input = {
enabled = helpers.defaultNullOpts.mkBool true ''
Enable the `vim.ui.input` implementation.
@ -29,9 +31,16 @@ with lib;
Trim trailing `:` from prompt.
'';
title_pos = helpers.defaultNullOpts.mkEnumFirstDefault ["left" "right" "center"] ''
Position of title.
'';
title_pos =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"left"
"right"
"center"
]
''
Position of title.
'';
insert_only = helpers.defaultNullOpts.mkBool true ''
When true, `<Esc>` will close the modal.
@ -43,10 +52,17 @@ with lib;
border = helpers.defaultNullOpts.mkBorder "rounded" "the input window" "";
relative = helpers.defaultNullOpts.mkEnumFirstDefault ["cursor" "win" "editor"] ''
Affects the dimensions of the window with respect to this setting.
If 'editor' or 'win', will default to being centered.
'';
relative =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"cursor"
"win"
"editor"
]
''
Affects the dimensions of the window with respect to this setting.
If 'editor' or 'win', will default to being centered.
'';
prefer_width = helpers.defaultNullOpts.mkNullable intOrRatio "40" ''
Can be an integer or a float between 0 and 1 (e.g. 0.4 for 40%).
@ -57,79 +73,57 @@ with lib;
'';
max_width =
helpers.defaultNullOpts.mkNullable
(
with types;
either
intOrRatio
(listOf intOrRatio)
)
"[140 0.9]"
''
Max width of window.
helpers.defaultNullOpts.mkNullable (with types; either intOrRatio (listOf intOrRatio)) "[140 0.9]"
''
Max width of window.
Can be a list of mixed types, e.g. `[140 0.9]` means "less than 140 columns or 90% of
total."
'';
Can be a list of mixed types, e.g. `[140 0.9]` means "less than 140 columns or 90% of
total."
'';
min_width =
helpers.defaultNullOpts.mkNullable
(
with types;
either
intOrRatio
(listOf intOrRatio)
)
"[20 0.2]"
''
Min width of window.
helpers.defaultNullOpts.mkNullable (with types; either intOrRatio (listOf intOrRatio)) "[20 0.2]"
''
Min width of window.
Can be a list of mixed types, e.g. `[140 0.9]` means "less than 140 columns or 90% of
total."
'';
Can be a list of mixed types, e.g. `[140 0.9]` means "less than 140 columns or 90% of
total."
'';
buf_options = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" ''
An attribute set of neovim buffer options.
'';
win_options =
helpers.defaultNullOpts.mkAttrsOf types.anything
''
{
wrap = false;
list = true;
listchars = "precedes:...,extends:...";
sidescrolloff = 0;
}
''
"An attribute set of window options.";
win_options = helpers.defaultNullOpts.mkAttrsOf types.anything ''
{
wrap = false;
list = true;
listchars = "precedes:...,extends:...";
sidescrolloff = 0;
}
'' "An attribute set of window options.";
mappings =
helpers.defaultNullOpts.mkAttrsOf
(
with types;
attrsOf
(either str (enum [false]))
)
''
{
n = {
"<Esc>" = "Close";
"<CR>" = "Confirm";
};
i = {
"<C-c>" = "Close";
"<CR>" = "Confirm";
"<Up>" = "HistoryPrev";
"<Down>" = "HistoryNext";
};
}
''
''
Mappings for defined modes.
helpers.defaultNullOpts.mkAttrsOf (with types; attrsOf (either str (enum [ false ])))
''
{
n = {
"<Esc>" = "Close";
"<CR>" = "Confirm";
};
i = {
"<C-c>" = "Close";
"<CR>" = "Confirm";
"<Up>" = "HistoryPrev";
"<Down>" = "HistoryNext";
};
}
''
''
Mappings for defined modes.
To disable a default mapping in a specific mode, set it to `false`.
'';
To disable a default mapping in a specific mode, set it to `false`.
'';
override = helpers.defaultNullOpts.mkLuaFn "function(conf) return conf end" ''
Lua function that takes config that is passed to nvim_open_win.
@ -150,76 +144,61 @@ with lib;
Enable the vim.ui.select implementation.
'';
backend =
helpers.defaultNullOpts.mkListOf types.str
''
["telescope" "fzf_lua" "fzf" "builtin" "nui"]
''
"Priority list of preferred vim.select implementations. ";
backend = helpers.defaultNullOpts.mkListOf types.str ''
["telescope" "fzf_lua" "fzf" "builtin" "nui"]
'' "Priority list of preferred vim.select implementations. ";
trim_prompt = helpers.defaultNullOpts.mkBool true ''
Trim trailing `:` from prompt.
'';
telescope =
helpers.defaultNullOpts.mkNullable
(
with helpers.nixvimTypes;
either
strLua
(attrsOf anything)
)
"null"
''
Options for telescope selector.
helpers.defaultNullOpts.mkNullable (with helpers.nixvimTypes; either strLua (attrsOf anything))
"null"
''
Options for telescope selector.
Can be a raw lua string like:
Can be a raw lua string like:
`telescope = \'\'require("telescope.themes").get_ivy({})\'\'`
`telescope = \'\'require("telescope.themes").get_ivy({})\'\'`
or an attribute set of telescope settings.
'';
or an attribute set of telescope settings.
'';
fzf = {
window =
helpers.defaultNullOpts.mkAttrsOf types.anything
''
{
width = 0.5;
height = 0.4;
}
''
"Window options for fzf selector. ";
window = helpers.defaultNullOpts.mkAttrsOf types.anything ''
{
width = 0.5;
height = 0.4;
}
'' "Window options for fzf selector. ";
};
fzf_lua = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" ''
Options for fzf-lua selector.
'';
nui =
helpers.defaultNullOpts.mkAttrsOf types.anything
''
{
position = "50%";
size = null;
relative = "editor";
border = {
style = "rounded";
};
buf_options = {
swapfile = false;
filetype = "DressingSelect";
};
win_options = {
winblend = 0;
};
max_width = 80;
max_height = 40;
min_width = 40;
min_height = 10;
}
''
"Options for nui selector. ";
nui = helpers.defaultNullOpts.mkAttrsOf types.anything ''
{
position = "50%";
size = null;
relative = "editor";
border = {
style = "rounded";
};
buf_options = {
swapfile = false;
filetype = "DressingSelect";
};
win_options = {
winblend = 0;
};
max_width = 80;
max_height = 40;
min_width = 40;
min_height = 10;
}
'' "Options for nui selector. ";
builtin = {
show_numbers = helpers.defaultNullOpts.mkBool true ''
@ -228,115 +207,87 @@ with lib;
border = helpers.defaultNullOpts.mkBorder "rounded" "the select window" "";
relative = helpers.defaultNullOpts.mkEnumFirstDefault ["editor" "win" "cursor"] ''
Affects the dimensions of the window with respect to this setting.
If 'editor' or 'win', will default to being centered.
'';
relative =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"editor"
"win"
"cursor"
]
''
Affects the dimensions of the window with respect to this setting.
If 'editor' or 'win', will default to being centered.
'';
buf_options = helpers.defaultNullOpts.mkAttrsOf types.anything "{}" ''
An attribute set of buffer options.
'';
win_options =
helpers.defaultNullOpts.mkAttrsOf types.anything
''
{
cursorline = true;
cursorlineopt = "both";
}
''
"An attribute set of window options.";
win_options = helpers.defaultNullOpts.mkAttrsOf types.anything ''
{
cursorline = true;
cursorlineopt = "both";
}
'' "An attribute set of window options.";
width = helpers.defaultNullOpts.mkNullable intOrRatio "null" ''
Can be an integer or a float between 0 and 1 (e.g. 0.4 for 40%).
'';
max_width =
helpers.defaultNullOpts.mkNullable
(
with types;
either
intOrRatio
(listOf intOrRatio)
)
"[140 0.8]"
''
Max width of window.
helpers.defaultNullOpts.mkNullable (with types; either intOrRatio (listOf intOrRatio)) "[140 0.8]"
''
Max width of window.
Can be a list of mixed types, e.g. `[140 0.8]` means "less than 140 columns or 80%
of total."
'';
Can be a list of mixed types, e.g. `[140 0.8]` means "less than 140 columns or 80%
of total."
'';
min_width =
helpers.defaultNullOpts.mkNullable
(
with types;
either
intOrRatio
(listOf intOrRatio)
)
"[40 0.2]"
''
Min width of window.
helpers.defaultNullOpts.mkNullable (with types; either intOrRatio (listOf intOrRatio)) "[40 0.2]"
''
Min width of window.
Can be a list of mixed types, e.g. `[40 0.2]` means "less than 40 columns or 20%
of total."
'';
Can be a list of mixed types, e.g. `[40 0.2]` means "less than 40 columns or 20%
of total."
'';
height = helpers.defaultNullOpts.mkNullable intOrRatio "null" ''
Can be an integer or a float between 0 and 1 (e.g. 0.4 for 40%).
'';
max_height =
helpers.defaultNullOpts.mkNullable
(
with types;
either
intOrRatio
(listOf intOrRatio)
)
"0.9"
''
Max height of window.
helpers.defaultNullOpts.mkNullable (with types; either intOrRatio (listOf intOrRatio)) "0.9"
''
Max height of window.
Can be a list of mixed types, e.g. `[140 0.8]` means "less than 140 rows or 80%
of total."
'';
Can be a list of mixed types, e.g. `[140 0.8]` means "less than 140 rows or 80%
of total."
'';
min_height =
helpers.defaultNullOpts.mkNullable
(
with types;
either
intOrRatio
(listOf intOrRatio)
)
"[10 0.2]"
''
Min height of window.
helpers.defaultNullOpts.mkNullable (with types; either intOrRatio (listOf intOrRatio)) "[10 0.2]"
''
Min height of window.
Can be a list of mixed types, e.g. `[10 0.2]` means "less than 10 rows or 20%
of total."
'';
Can be a list of mixed types, e.g. `[10 0.2]` means "less than 10 rows or 20%
of total."
'';
mappings =
helpers.defaultNullOpts.mkAttrsOf
(
with types;
either str (enum [false])
)
''
{
"<Esc>" = "Close";
"<C-c>" = "Close";
"<CR>" = "Confirm";
}
''
''
Mappings in normal mode for the builtin selector.
helpers.defaultNullOpts.mkAttrsOf (with types; either str (enum [ false ]))
''
{
"<Esc>" = "Close";
"<C-c>" = "Close";
"<CR>" = "Confirm";
}
''
''
Mappings in normal mode for the builtin selector.
To disable a default mapping in a specific mode, set it to `false`.
'';
To disable a default mapping in a specific mode, set it to `false`.
'';
override = helpers.defaultNullOpts.mkLuaFn "function(conf) return conf end" ''
Lua function that takes config that is passed to nvim_open_win.
@ -372,32 +323,38 @@ with lib;
};
};
settingsExample = {
input = {
enabled = true;
mappings = {
n = {
"<Esc>" = "Close";
"<CR>" = "Confirm";
};
i = {
"<C-c>" = "Close";
"<CR>" = "Confirm";
"<Up>" = "HistoryPrev";
"<Down>" = "HistoryNext";
};
settingsExample = {
input = {
enabled = true;
mappings = {
n = {
"<Esc>" = "Close";
"<CR>" = "Confirm";
};
};
select = {
enabled = true;
backend = ["telescope" "fzf_lua" "fzf" "builtin" "nui"];
builtin = {
mappings = {
"<Esc>" = "Close";
"<C-c>" = "Close";
"<CR>" = "Confirm";
};
i = {
"<C-c>" = "Close";
"<CR>" = "Confirm";
"<Up>" = "HistoryPrev";
"<Down>" = "HistoryNext";
};
};
};
}
select = {
enabled = true;
backend = [
"telescope"
"fzf_lua"
"fzf"
"builtin"
"nui"
];
builtin = {
mappings = {
"<Esc>" = "Close";
"<C-c>" = "Close";
"<CR>" = "Confirm";
};
};
};
};
}

View file

@ -5,9 +5,11 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.easyescape;
in {
in
{
options = {
plugins.easyescape = {
enable = mkEnableOption "easyescape";
@ -15,9 +17,5 @@ in {
package = helpers.mkPackageOption "easyescape" pkgs.vimPlugins.vim-easyescape;
};
};
config = mkIf cfg.enable {
extraPlugins = [
cfg.package
];
};
config = mkIf cfg.enable { extraPlugins = [ cfg.package ]; };
}

View file

@ -7,83 +7,91 @@
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
name = "emmet";
originalName = "emmet-vim";
defaultPackage = pkgs.vimPlugins.emmet-vim;
globalPrefix = "user_emmet_";
mkVimPlugin config {
name = "emmet";
originalName = "emmet-vim";
defaultPackage = pkgs.vimPlugins.emmet-vim;
globalPrefix = "user_emmet_";
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-03-01: remove 2024-05-01
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"mode"
];
imports = [
(
mkRenamedOptionModule
["plugins" "emmet" "leader"]
["plugins" "emmet" "settings" "leader_key"]
)
];
# TODO introduced 2024-03-01: remove 2024-05-01
deprecateExtraConfig = true;
optionsRenamedToSettings = [ "mode" ];
imports = [
(mkRenamedOptionModule
[
"plugins"
"emmet"
"leader"
]
[
"plugins"
"emmet"
"settings"
"leader_key"
]
)
];
settingsOptions = {
mode = helpers.defaultNullOpts.mkStr "a" ''
Choose modes, in which Emmet mappings will be created.
Default value: 'a' - all modes.
- 'n' - normal mode.
- 'i' - insert mode.
- 'v' - visual mode.
settingsOptions = {
mode = helpers.defaultNullOpts.mkStr "a" ''
Choose modes, in which Emmet mappings will be created.
Default value: 'a' - all modes.
- 'n' - normal mode.
- 'i' - insert mode.
- 'v' - visual mode.
Examples:
- create Emmet mappings only for normal mode: `n`
- create Emmet mappings for insert, normal and visual modes: `inv`
- create Emmet mappings for all modes: `a`
'';
Examples:
- create Emmet mappings only for normal mode: `n`
- create Emmet mappings for insert, normal and visual modes: `inv`
- create Emmet mappings for all modes: `a`
'';
leader_key = helpers.defaultNullOpts.mkStr "<C-y>" ''
Leading keys to run Emmet functions.
'';
leader_key = helpers.defaultNullOpts.mkStr "<C-y>" ''
Leading keys to run Emmet functions.
'';
settings = helpers.mkNullOrOption (with types; attrsOf anything) ''
Emmet settings.
settings = helpers.mkNullOrOption (with types; attrsOf anything) ''
Emmet settings.
Defaults: see https://github.com/mattn/emmet-vim/blob/master/autoload/emmet.vim
'';
};
Defaults: see https://github.com/mattn/emmet-vim/blob/master/autoload/emmet.vim
'';
};
settingsExample = {
mode = "inv";
leader = "<C-Z>";
settings = {
variables = {
lang = "ja";
settingsExample = {
mode = "inv";
leader = "<C-Z>";
settings = {
variables = {
lang = "ja";
};
html = {
default_attributes = {
option = {
value = null;
};
textarea = {
id = null;
name = null;
cols = 10;
rows = 10;
};
};
html = {
default_attributes = {
option = {value = null;};
textarea = {
id = null;
name = null;
cols = 10;
rows = 10;
};
};
snippets = {
"html:5" = ''
<!DOCTYPE html>
<html lang=\"$\{lang}\">
<head>
\t<meta charset=\"$\{charset}\">
\t<title></title>
\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
</head>
<body>\n\t$\{child}|\n</body>
</html>
'';
};
snippets = {
"html:5" = ''
<!DOCTYPE html>
<html lang=\"$\{lang}\">
<head>
\t<meta charset=\"$\{charset}\">
\t<title></title>
\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
</head>
<body>\n\t$\{child}|\n</body>
</html>
'';
};
};
};
}
};
}

View file

@ -10,7 +10,7 @@ helpers.vim-plugin.mkVimPlugin config {
originalName = "vim-endwise";
defaultPackage = pkgs.vimPlugins.vim-endwise;
maintainers = [lib.maintainers.GaetanLepage];
maintainers = [ lib.maintainers.GaetanLepage ];
# This plugin has no config options
}

View file

@ -5,453 +5,534 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.flash;
in {
options.plugins.flash = let
configOpts = {
labels = helpers.defaultNullOpts.mkStr "asdfghjklqwertyuiopzxcvbnm" ''
Labels appear next to the matches, allowing you to quickly jump to any location. Labels are
guaranteed not to exist as a continuation of the search pattern.
'';
search = {
automatic = mkOption {
type = types.bool;
default = false;
description = ''
Automatically set the values according to context. Same as passing `search = {}` in lua
'';
};
multiWindow = helpers.defaultNullOpts.mkBool true "search/jump in all windows";
forward = helpers.defaultNullOpts.mkBool true "search direction";
wrap = helpers.defaultNullOpts.mkBool true ''
when `false`, find only matches in the given direction
in
{
options.plugins.flash =
let
configOpts = {
labels = helpers.defaultNullOpts.mkStr "asdfghjklqwertyuiopzxcvbnm" ''
Labels appear next to the matches, allowing you to quickly jump to any location. Labels are
guaranteed not to exist as a continuation of the search pattern.
'';
mode =
helpers.defaultNullOpts.mkNullable
(with types; either (enum ["exact" "search" "fuzzy"]) helpers.nixvimTypes.rawLua) ''"exact"'' ''
- exact: exact match
- search: regular search
- fuzzy: fuzzy search
- fun(str): custom search function that returns a pattern
For example, to only match at the beginning of a word:
function(str)
return "\\<" .. str
end
search = {
automatic = mkOption {
type = types.bool;
default = false;
description = ''
Automatically set the values according to context. Same as passing `search = {}` in lua
'';
};
multiWindow = helpers.defaultNullOpts.mkBool true "search/jump in all windows";
forward = helpers.defaultNullOpts.mkBool true "search direction";
wrap = helpers.defaultNullOpts.mkBool true ''
when `false`, find only matches in the given direction
'';
incremental = helpers.defaultNullOpts.mkBool false "behave like `incsearch`";
exclude =
helpers.defaultNullOpts.mkNullable (with types; listOf (either str helpers.nixvimTypes.rawLua)) ''
[
"notify"
"cmp_menu"
"noice"
"flash_prompt"
mode =
helpers.defaultNullOpts.mkNullable
(
helpers.mkRaw
'''
function(win)
return not vim.api.nvim_win_get_config(win).focusable
end
'''
with types;
either (enum [
"exact"
"search"
"fuzzy"
]) helpers.nixvimTypes.rawLua
)
]
'' ''
Excluded filetypes and custom window filters
''"exact"''
''
- exact: exact match
- search: regular search
- fuzzy: fuzzy search
- fun(str): custom search function that returns a pattern
For example, to only match at the beginning of a word:
function(str)
return "\\<" .. str
end
'';
incremental = helpers.defaultNullOpts.mkBool false "behave like `incsearch`";
exclude =
helpers.defaultNullOpts.mkNullable (with types; listOf (either str helpers.nixvimTypes.rawLua))
''
[
"notify"
"cmp_menu"
"noice"
"flash_prompt"
(
helpers.mkRaw
'''
function(win)
return not vim.api.nvim_win_get_config(win).focusable
end
'''
)
]
''
''
Excluded filetypes and custom window filters
'';
trigger = helpers.defaultNullOpts.mkStr "" ''
Optional trigger character that needs to be typed before a jump label can be used.
It's NOT recommended to set this, unless you know what you're doing
'';
trigger = helpers.defaultNullOpts.mkStr "" ''
Optional trigger character that needs to be typed before a jump label can be used.
It's NOT recommended to set this, unless you know what you're doing
'';
maxLength =
helpers.defaultNullOpts.mkNullable
(with types; either (enum [false]) types.int) "false" ''
max pattern length. If the pattern length is equal to this labels will no longer be
skipped. When it exceeds this length it will either end in a jump or terminate the search
'';
};
jump = {
jumplist = helpers.defaultNullOpts.mkBool true "save location in the jumplist";
pos = helpers.defaultNullOpts.mkEnumFirstDefault ["start" "end" "range"] "jump position";
history = helpers.defaultNullOpts.mkBool false "add pattern to search history";
register = helpers.defaultNullOpts.mkBool false "add pattern to search register";
nohlsearch = helpers.defaultNullOpts.mkBool false "clear highlight after jump";
autojump = helpers.defaultNullOpts.mkBool false ''
automatically jump when there is only one match
'';
inclusive = helpers.mkNullOrOption types.bool ''
You can force inclusive/exclusive jumps by setting the `inclusive` option. By default it
will be automatically set based on the mode.
'';
offset = helpers.mkNullOrOption types.int ''
jump position offset. Not used for range jumps.
0: default
1: when pos == "end" and pos < current position
'';
};
label = {
uppercase = helpers.defaultNullOpts.mkBool true "allow uppercase labels";
exclude = helpers.defaultNullOpts.mkStr "" ''
add any labels with the correct case here, that you want to exclude
'';
current = helpers.defaultNullOpts.mkBool true ''
add a label for the first match in the current window.
you can always jump to the first match with `<CR>`
'';
after = helpers.defaultNullOpts.mkNullable (with types; either bool (listOf int)) "true" ''
show the label after the match
'';
before = helpers.defaultNullOpts.mkNullable (with types; either bool (listOf int)) "false" ''
show the label before the match
'';
style = helpers.defaultNullOpts.mkEnum ["eol" "overlay" "right_align" "inline"] "overlay" ''
position of the label extmark
'';
reuse = helpers.defaultNullOpts.mkEnumFirstDefault ["lowercase" "all" "none"] ''
flash tries to re-use labels that were already assigned to a position,
when typing more characters. By default only lower-case labels are re-used.
'';
distance = helpers.defaultNullOpts.mkBool true ''
for the current window, label targets closer to the cursor first
'';
minPatternLength = helpers.defaultNullOpts.mkInt 0 ''
minimum pattern length to show labels
Ignored for custom labelers.
'';
rainbow = {
enabled = helpers.defaultNullOpts.mkBool false ''
Enable this to use rainbow colors to highlight labels
Can be useful for visualizing Treesitter ranges.
'';
shade = helpers.defaultNullOpts.mkNullable (types.ints.between 1 9) "5" "";
maxLength =
helpers.defaultNullOpts.mkNullable (with types; either (enum [ false ]) types.int) "false"
''
max pattern length. If the pattern length is equal to this labels will no longer be
skipped. When it exceeds this length it will either end in a jump or terminate the search
'';
};
format =
helpers.defaultNullOpts.mkLuaFn ''
format = function(opts)
return { { opts.match.label, opts.hl_group } }
end
'' ''
With `format`, you can change how the label is rendered.
Should return a list of `[text, highlight]` tuples.
@class Flash.Format
@field state Flash.State
@field match Flash.Match
@field hl_group string
@field after boolean
@type fun(opts:Flash.Format): string[][]
jump = {
jumplist = helpers.defaultNullOpts.mkBool true "save location in the jumplist";
pos = helpers.defaultNullOpts.mkEnumFirstDefault [
"start"
"end"
"range"
] "jump position";
history = helpers.defaultNullOpts.mkBool false "add pattern to search history";
register = helpers.defaultNullOpts.mkBool false "add pattern to search register";
nohlsearch = helpers.defaultNullOpts.mkBool false "clear highlight after jump";
autojump = helpers.defaultNullOpts.mkBool false ''
automatically jump when there is only one match
'';
};
highlight = {
backdrop = helpers.defaultNullOpts.mkBool true "show a backdrop with hl FlashBackdrop";
inclusive = helpers.mkNullOrOption types.bool ''
You can force inclusive/exclusive jumps by setting the `inclusive` option. By default it
will be automatically set based on the mode.
'';
matches = helpers.defaultNullOpts.mkBool true "Highlight the search matches";
offset = helpers.mkNullOrOption types.int ''
jump position offset. Not used for range jumps.
0: default
1: when pos == "end" and pos < current position
'';
};
priority = helpers.defaultNullOpts.mkPositiveInt 5000 "extmark priority";
label = {
uppercase = helpers.defaultNullOpts.mkBool true "allow uppercase labels";
groups = builtins.mapAttrs (_: default: helpers.defaultNullOpts.mkStr default "") {
match = "FlashMatch";
current = "FlashCurrent";
backdrop = "FlashBackdrop";
label = "FlashLabel";
exclude = helpers.defaultNullOpts.mkStr "" ''
add any labels with the correct case here, that you want to exclude
'';
current = helpers.defaultNullOpts.mkBool true ''
add a label for the first match in the current window.
you can always jump to the first match with `<CR>`
'';
after = helpers.defaultNullOpts.mkNullable (with types; either bool (listOf int)) "true" ''
show the label after the match
'';
before = helpers.defaultNullOpts.mkNullable (with types; either bool (listOf int)) "false" ''
show the label before the match
'';
style =
helpers.defaultNullOpts.mkEnum
[
"eol"
"overlay"
"right_align"
"inline"
]
"overlay"
''
position of the label extmark
'';
reuse =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"lowercase"
"all"
"none"
]
''
flash tries to re-use labels that were already assigned to a position,
when typing more characters. By default only lower-case labels are re-used.
'';
distance = helpers.defaultNullOpts.mkBool true ''
for the current window, label targets closer to the cursor first
'';
minPatternLength = helpers.defaultNullOpts.mkInt 0 ''
minimum pattern length to show labels
Ignored for custom labelers.
'';
rainbow = {
enabled = helpers.defaultNullOpts.mkBool false ''
Enable this to use rainbow colors to highlight labels
Can be useful for visualizing Treesitter ranges.
'';
shade = helpers.defaultNullOpts.mkNullable (types.ints.between 1 9) "5" "";
};
format =
helpers.defaultNullOpts.mkLuaFn
''
format = function(opts)
return { { opts.match.label, opts.hl_group } }
end
''
''
With `format`, you can change how the label is rendered.
Should return a list of `[text, highlight]` tuples.
@class Flash.Format
@field state Flash.State
@field match Flash.Match
@field hl_group string
@field after boolean
@type fun(opts:Flash.Format): string[][]
'';
};
highlight = {
backdrop = helpers.defaultNullOpts.mkBool true "show a backdrop with hl FlashBackdrop";
matches = helpers.defaultNullOpts.mkBool true "Highlight the search matches";
priority = helpers.defaultNullOpts.mkPositiveInt 5000 "extmark priority";
groups = builtins.mapAttrs (_: default: helpers.defaultNullOpts.mkStr default "") {
match = "FlashMatch";
current = "FlashCurrent";
backdrop = "FlashBackdrop";
label = "FlashLabel";
};
};
action = helpers.defaultNullOpts.mkLuaFn "nil" ''
action to perform when picking a label.
defaults to the jumping logic depending on the mode.
@type fun(match:Flash.Match, state:Flash.State)
'';
pattern = helpers.defaultNullOpts.mkStr "" "initial pattern to use when opening flash";
continue = helpers.defaultNullOpts.mkBool false ''
When `true`, flash will try to continue the last search
'';
config = helpers.defaultNullOpts.mkLuaFn "nil" ''
Set config to a function to dynamically change the config
@type fun(opts:Flash.Config)
'';
prompt = {
enabled = helpers.defaultNullOpts.mkBool true ''
options for the floating window that shows the prompt, for regular jumps
'';
# Not sure what is the type...
prefix = helpers.defaultNullOpts.mkNullable (types.listOf types.anything) ''
[ ["" "FlashPromptIcon"] ]
'' "";
winConfig = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) ''
{
relative = "editor";
width = 1;
height = 1;
row = -1;
col = 0;
zindex = 1000;
}
'' "See nvim_open_win for more details";
};
remoteOp = {
restore = helpers.defaultNullOpts.mkBool false ''
restore window views and cursor position after doing a remote operation
'';
motion = helpers.defaultNullOpts.mkBool false ''
For `jump.pos = "range"`, this setting is ignored.
- `true`: always enter a new motion when doing a remote operation
- `false`: use the window's cursor position and jump target
- `nil`: act as `true` for remote windows, `false` for the current window
'';
};
};
action = helpers.defaultNullOpts.mkLuaFn "nil" ''
action to perform when picking a label.
defaults to the jumping logic depending on the mode.
@type fun(match:Flash.Match, state:Flash.State)
'';
pattern = helpers.defaultNullOpts.mkStr "" "initial pattern to use when opening flash";
continue = helpers.defaultNullOpts.mkBool false ''
When `true`, flash will try to continue the last search
'';
config = helpers.defaultNullOpts.mkLuaFn "nil" ''
Set config to a function to dynamically change the config
@type fun(opts:Flash.Config)
'';
prompt = {
enabled = helpers.defaultNullOpts.mkBool true ''
options for the floating window that shows the prompt, for regular jumps
'';
# Not sure what is the type...
prefix = helpers.defaultNullOpts.mkNullable (types.listOf types.anything) ''
[ ["" "FlashPromptIcon"] ]
'' "";
winConfig = helpers.defaultNullOpts.mkNullable (types.attrsOf types.anything) ''
{
relative = "editor";
width = 1;
height = 1;
row = -1;
col = 0;
zindex = 1000;
}
'' "See nvim_open_win for more details";
};
remoteOp = {
restore = helpers.defaultNullOpts.mkBool false ''
restore window views and cursor position after doing a remote operation
'';
motion = helpers.defaultNullOpts.mkBool false ''
For `jump.pos = "range"`, this setting is ignored.
- `true`: always enter a new motion when doing a remote operation
- `false`: use the window's cursor position and jump target
- `nil`: act as `true` for remote windows, `false` for the current window
'';
};
};
in
in
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "flash.nvim";
package = helpers.mkPackageOption "flash.nvim" pkgs.vimPlugins.flash-nvim;
modes = let
mkModeConfig = extra: default: desc:
helpers.defaultNullOpts.mkNullable (types.submodule {
options = configOpts // extra;
})
default
desc;
in {
search =
mkModeConfig {
enabled = helpers.defaultNullOpts.mkBool true ''
when `true`, flash will be activated during regular search by default.
You can always toggle when searching with `require("flash").toggle()`
'';
} ''
{
enabled = true;
highlight = { backdrop = false; };
jump = { history = true; register = true; nohlsearch = true; };
/*
forward will be automatically set to the search direction
mode is always set to 'search'
incremental is set to 'true' when 'incsearch' is enabled
*/
search.automatic = true;
}
'' ''
options used when flash is activated through a regular search with `/` or `?`
'';
char =
mkModeConfig {
enabled = helpers.defaultNullOpts.mkBool true "";
autohide = helpers.defaultNullOpts.mkBool false ''
hide after jump when not using jump labels
'';
jumpLabels = helpers.defaultNullOpts.mkBool false "show jump labels";
multiLine = helpers.defaultNullOpts.mkBool true ''
set to `false` to use the current line only
'';
keys =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.str) ''
helpers.listToUnkeyedAttrs [ "f" "F" "t" "T" ";" "," ]
'' ''
by default all keymaps are enabled, but you can disable some of them,
by removing them from the list.
If you rather use another key, you can map them
to something else, e.g., `{ ";" = "L"; "," = "H"; }`
modes =
let
mkModeConfig =
extra: default: desc:
helpers.defaultNullOpts.mkNullable (types.submodule {
options = configOpts // extra;
}) default desc;
in
{
search =
mkModeConfig
{
enabled = helpers.defaultNullOpts.mkBool true ''
when `true`, flash will be activated during regular search by default.
You can always toggle when searching with `require("flash").toggle()`
'';
}
''
{
enabled = true;
highlight = { backdrop = false; };
jump = { history = true; register = true; nohlsearch = true; };
/*
forward will be automatically set to the search direction
mode is always set to 'search'
incremental is set to 'true' when 'incsearch' is enabled
*/
search.automatic = true;
}
''
''
options used when flash is activated through a regular search with `/` or `?`
'';
char =
mkModeConfig
{
enabled = helpers.defaultNullOpts.mkBool true "";
charActions =
helpers.defaultNullOpts.mkLuaFn ''
function(motion)
return {
[";"] = "next", -- set to right to always go right
[","] = "prev", -- set to left to always go left
-- clever-f style
[motion:lower()] = "next",
[motion:upper()] = "prev",
-- jump2d style: same case goes next, opposite case goes prev
-- [motion] = "next",
-- [motion:match("%l") and motion:upper() or motion:lower()] = "prev",
}
end
'' ''
The direction for `prev` and `next` is determined by the motion.
`left` and `right` are always left and right.
autohide = helpers.defaultNullOpts.mkBool false ''
hide after jump when not using jump labels
'';
jumpLabels = helpers.defaultNullOpts.mkBool false "show jump labels";
multiLine = helpers.defaultNullOpts.mkBool true ''
set to `false` to use the current line only
'';
keys =
helpers.defaultNullOpts.mkNullable (types.attrsOf types.str)
''
helpers.listToUnkeyedAttrs [ "f" "F" "t" "T" ";" "," ]
''
''
by default all keymaps are enabled, but you can disable some of them,
by removing them from the list.
If you rather use another key, you can map them
to something else, e.g., `{ ";" = "L"; "," = "H"; }`
'';
charActions =
helpers.defaultNullOpts.mkLuaFn
''
function(motion)
return {
[";"] = "next", -- set to right to always go right
[","] = "prev", -- set to left to always go left
-- clever-f style
[motion:lower()] = "next",
[motion:upper()] = "prev",
-- jump2d style: same case goes next, opposite case goes prev
-- [motion] = "next",
-- [motion:match("%l") and motion:upper() or motion:lower()] = "prev",
}
end
''
''
The direction for `prev` and `next` is determined by the motion.
`left` and `right` are always left and right.
'';
}
''
{
enabled = true;
/* dynamic configuration for ftFT motions */
config = '''
function(opts)
-- autohide flash when in operator-pending mode
opts.autohide = vim.fn.mode(true):find("no") and vim.v.operator == "y"
-- disable jump labels when not enabled, when using a count,
-- or when recording/executing registers
opts.jump_labels = opts.jump_labels
and vim.v.count == 0
and vim.fn.reg_executing() == ""
and vim.fn.reg_recording() == ""
-- Show jump labels only in operator-pending mode
-- opts.jump_labels = vim.v.count == 0 and vim.fn.mode(true):find("o")
end
''';
autohide = false;
jumpLabels = false;
multiLine = false;
label = { exclude = "hjkliardc"; };
keys = helpers.listToUnkeyedAttrs [ "f" "F" "t" "T" ";" "," ];
charActions = '''
function(motion)
return {
[";"] = "next", -- set to right to always go right
[","] = "prev", -- set to left to always go left
-- clever-f style
[motion:lower()] = "next",
[motion:upper()] = "prev",
-- jump2d style: same case goes next, opposite case goes prev
-- [motion] = "next",
-- [motion:match("%l") and motion:upper() or motion:lower()] = "prev",
}
end
''';
search = { wrap = false; };
highlight = { backdrop = true; };
jump = { register = false; };
}
''
"options used when flash is activated through a regular search with `/` or `?`";
treesitter =
mkModeConfig { }
''
{
labels = "abcdefghijklmnopqrstuvwxyz";
jump = { pos = "range"; };
search = { incremental = false; };
label = { before = true; after = true; style = "inline"; };
highlight = { backdrop = false; matches = false; };
}helpers.ifNonNull'
''
''
options used for treesitter selections `require("flash").treesitter()`
'';
} ''
treesitterSearch = mkModeConfig { } ''
{
enabled = true;
/* dynamic configuration for ftFT motions */
config = '''
function(opts)
-- autohide flash when in operator-pending mode
opts.autohide = vim.fn.mode(true):find("no") and vim.v.operator == "y"
-- disable jump labels when not enabled, when using a count,
-- or when recording/executing registers
opts.jump_labels = opts.jump_labels
and vim.v.count == 0
and vim.fn.reg_executing() == ""
and vim.fn.reg_recording() == ""
-- Show jump labels only in operator-pending mode
-- opts.jump_labels = vim.v.count == 0 and vim.fn.mode(true):find("o")
end
''';
autohide = false;
jumpLabels = false;
multiLine = false;
label = { exclude = "hjkliardc"; };
keys = helpers.listToUnkeyedAttrs [ "f" "F" "t" "T" ";" "," ];
charActions = '''
function(motion)
return {
[";"] = "next", -- set to right to always go right
[","] = "prev", -- set to left to always go left
-- clever-f style
[motion:lower()] = "next",
[motion:upper()] = "prev",
-- jump2d style: same case goes next, opposite case goes prev
-- [motion] = "next",
-- [motion:match("%l") and motion:upper() or motion:lower()] = "prev",
}
end
''';
search = { wrap = false; };
highlight = { backdrop = true; };
jump = { register = false; };
}
'' "options used when flash is activated through a regular search with `/` or `?`";
treesitter =
mkModeConfig {} ''
{
labels = "abcdefghijklmnopqrstuvwxyz";
jump = { pos = "range"; };
search = { incremental = false; };
search = { multiWindow = true; wrap = true; incremental = false; };
remoteOp = { restore = true };
label = { before = true; after = true; style = "inline"; };
highlight = { backdrop = false; matches = false; };
}helpers.ifNonNull'
'' ''
options used for treesitter selections `require("flash").treesitter()`
'';
treesitterSearch = mkModeConfig {} ''
{
jump = { pos = "range"; };
search = { multiWindow = true; wrap = true; incremental = false; };
remoteOp = { restore = true };
label = { before = true; after = true; style = "inline"; };
}
'' "";
remote = mkModeConfig {} ''
{ remoteOp = { restore = true; motion = true; }; }
'' "options used for remote flash";
};
}
'' "";
remote = mkModeConfig { } ''
{ remoteOp = { restore = true; motion = true; }; }
'' "options used for remote flash";
};
}
// configOpts;
config = let
mkGlobalConfig = c: {
inherit (c) labels;
search =
if c.search.automatic
then helpers.emptyTable
else {
multi_window = c.search.multiWindow;
inherit (c.search) forward wrap mode incremental exclude trigger;
max_length = c.search.maxLength;
config =
let
mkGlobalConfig = c: {
inherit (c) labels;
search =
if c.search.automatic then
helpers.emptyTable
else
{
multi_window = c.search.multiWindow;
inherit (c.search)
forward
wrap
mode
incremental
exclude
trigger
;
max_length = c.search.maxLength;
};
jump = {
inherit (c.jump)
jumplist
pos
history
register
nohlsearch
autojump
inclusive
offset
;
};
jump = {
inherit (c.jump) jumplist pos history register nohlsearch autojump inclusive offset;
};
label = {
inherit (c.label) uppercase exclude current after before style reuse distance;
min_pattern_length = c.label.minPatternLength;
rainbow = {
inherit (c.label.rainbow) enabled shade;
label = {
inherit (c.label)
uppercase
exclude
current
after
before
style
reuse
distance
;
min_pattern_length = c.label.minPatternLength;
rainbow = {
inherit (c.label.rainbow) enabled shade;
};
inherit (c.label) format;
};
highlight = {
inherit (c.highlight)
backdrop
matches
priority
groups
;
};
inherit (c)
action
pattern
continue
config
;
prompt = {
inherit (c.prompt) enabled prefix;
win_config = c.prompt.winConfig;
};
remote_op = {
inherit (c.remoteOp) restore motion;
};
inherit (c.label) format;
};
highlight = {
inherit (c.highlight) backdrop matches priority groups;
};
inherit (c) action pattern continue config;
prompt = {
inherit (c.prompt) enabled prefix;
win_config = c.prompt.winConfig;
};
remote_op = {
inherit (c.remoteOp) restore motion;
};
};
options =
(mkGlobalConfig cfg)
// {
modes = let
mkModeConfig = c: extra:
helpers.ifNonNull' c (
(mkGlobalConfig c) // (extra c)
);
in {
search =
mkModeConfig cfg.modes.search
(c: {
inherit (c) enabled;
});
char =
mkModeConfig cfg.modes.char
(c: {
inherit (c) enabled autohide;
jump_labels = c.jumpLabels;
multi_line = c.multiLine;
inherit (c) keys charActions;
});
treesitter = mkModeConfig cfg.modes.treesitter (c: {});
treesitter_search = mkModeConfig cfg.modes.treesitterSearch (c: {});
remote = mkModeConfig cfg.modes.remote (c: {});
};
}
// cfg.extraOptions;
in
options =
(mkGlobalConfig cfg)
// {
modes =
let
mkModeConfig = c: extra: helpers.ifNonNull' c ((mkGlobalConfig c) // (extra c));
in
{
search = mkModeConfig cfg.modes.search (c: {
inherit (c) enabled;
});
char = mkModeConfig cfg.modes.char (c: {
inherit (c) enabled autohide;
jump_labels = c.jumpLabels;
multi_line = c.multiLine;
inherit (c) keys charActions;
});
treesitter = mkModeConfig cfg.modes.treesitter (c: { });
treesitter_search = mkModeConfig cfg.modes.treesitterSearch (c: { });
remote = mkModeConfig cfg.modes.remote (c: { });
};
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require('flash').setup(${helpers.toLuaObject options})

View file

@ -5,7 +5,8 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.floaterm;
settings = {
@ -28,7 +29,11 @@ with lib; let
};
wintype = {
type = types.enum ["float" "split" "vsplit"];
type = types.enum [
"float"
"split"
"vsplit"
];
description = ''
'float'(nvim's floating or vim's popup) by default.
Set it to 'split' or 'vsplit' if you don't want to use floating or popup window.
@ -104,7 +109,13 @@ with lib; let
};
opener = {
type = types.enum ["edit" "split" "vsplit" "tabe" "drop"];
type = types.enum [
"edit"
"split"
"vsplit"
"tabe"
"drop"
];
description = ''
Command used for opening a file in the outside nvim from within `:terminal`.
@ -113,7 +124,11 @@ with lib; let
};
autoclose = {
type = types.enum [0 1 2];
type = types.enum [
0
1
2
];
description = ''
Whether to close floaterm window once the job gets finished.
@ -126,7 +141,11 @@ with lib; let
};
autohide = {
type = types.enum [0 1 2];
type = types.enum [
0
1
2
];
description = ''
Whether to hide previous floaterms before switching to or opening a another one.
@ -147,38 +166,37 @@ with lib; let
'';
};
};
in {
options.plugins.floaterm = let
# Misc options
# `OPTION = VALUE`
# which will translate to `globals.floaterm_OPTION = VALUE;`
miscOptions =
mapAttrs
(name: value: helpers.mkNullOrOption value.type value.description)
settings;
in
{
options.plugins.floaterm =
let
# Misc options
# `OPTION = VALUE`
# which will translate to `globals.floaterm_OPTION = VALUE;`
miscOptions = mapAttrs (name: value: helpers.mkNullOrOption value.type value.description) settings;
# Keymaps options
# `keymaps.ACTION = KEY`
# which will translate to `globals.floaterm_keymap_ACTION = KEY;`
keymapOptions = listToAttrs (
map (
name: {
inherit name;
value = helpers.mkNullOrOption types.str "Key to map to ${name}";
}
) [
"new"
"prev"
"next"
"first"
"last"
"hide"
"show"
"kill"
"toggle"
]
);
in
# Keymaps options
# `keymaps.ACTION = KEY`
# which will translate to `globals.floaterm_keymap_ACTION = KEY;`
keymapOptions = listToAttrs (
map
(name: {
inherit name;
value = helpers.mkNullOrOption types.str "Key to map to ${name}";
})
[
"new"
"prev"
"next"
"first"
"last"
"hide"
"show"
"kill"
"toggle"
]
);
in
{
enable = mkEnableOption "floaterm";
@ -189,28 +207,24 @@ in {
// miscOptions;
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
globals = let
# misc options
optionGlobals = listToAttrs (
map
(optionName: {
name = "floaterm_${optionName}";
value = cfg.${optionName};
})
(attrNames settings)
);
globals =
let
# misc options
optionGlobals = listToAttrs (
map (optionName: {
name = "floaterm_${optionName}";
value = cfg.${optionName};
}) (attrNames settings)
);
# keymaps options
keymapGlobals =
mapAttrs'
(name: key: {
# keymaps options
keymapGlobals = mapAttrs' (name: key: {
name = "floaterm_keymap_${name}";
value = key;
})
cfg.keymaps;
in
}) cfg.keymaps;
in
optionGlobals // keymapGlobals;
};
}

View file

@ -5,7 +5,8 @@
pkgs,
...
}:
with lib; let
with lib;
let
settingsOptions = {
fzf_bin = helpers.mkNullOrStr ''
The path to the `fzf` binary to use.
@ -29,114 +30,105 @@ with lib; let
};
};
in
helpers.neovim-plugin.mkNeovimPlugin config {
name = "fzf-lua";
defaultPackage = pkgs.vimPlugins.fzf-lua;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "fzf-lua";
defaultPackage = pkgs.vimPlugins.fzf-lua;
extraPackages = [pkgs.fzf];
extraPackages = [ pkgs.fzf ];
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
inherit
settingsOptions
settingsExample
;
inherit settingsOptions settingsExample;
extraOptions = {
fzfPackage = mkOption {
type = with types; nullOr package;
default = pkgs.fzf;
description = ''
The fzf package to use.
Set to `null` to not install any package.
'';
example = pkgs.skim;
};
extraOptions = {
fzfPackage = mkOption {
type = with types; nullOr package;
default = pkgs.fzf;
description = ''
The fzf package to use.
Set to `null` to not install any package.
'';
example = pkgs.skim;
};
iconsEnabled = mkOption {
type = types.bool;
description = "Toggle icon support. Installs nvim-web-devicons.";
default = true;
};
iconsEnabled = mkOption {
type = types.bool;
description = "Toggle icon support. Installs nvim-web-devicons.";
default = true;
};
profile =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"default"
"fzf-native"
"fzf-tmux"
"fzf-vim"
"max-perf"
"telescope"
"skim"
]
"Preconfigured profile to use";
profile = helpers.defaultNullOpts.mkEnumFirstDefault [
"default"
"fzf-native"
"fzf-tmux"
"fzf-vim"
"max-perf"
"telescope"
"skim"
] "Preconfigured profile to use";
keymaps = mkOption {
type = with types;
attrsOf
(either str (
submodule {
options = {
action = mkOption {
type = types.str;
description = "The `fzf-lua` action to run";
example = "git_files";
};
settings = helpers.mkSettingsOption {
options = settingsOptions;
description = "`fzf-lua` settings for this command.";
example = settingsExample;
};
mode = helpers.keymaps.mkModeOption "n";
options = helpers.keymaps.mapConfigOptions;
};
}
));
description = "Keymaps for Fzf-Lua.";
default = {};
example = {
"<leader>fg" = "live_grep";
"<C-p>" = {
action = "git_files";
settings = {
previewers.cat.cmd = "${pkgs.coreutils}/bin/cat";
winopts.height = 0.5;
};
keymaps = mkOption {
type =
with types;
attrsOf (
either str (submodule {
options = {
silent = true;
desc = "Fzf-Lua Git Files";
action = mkOption {
type = types.str;
description = "The `fzf-lua` action to run";
example = "git_files";
};
settings = helpers.mkSettingsOption {
options = settingsOptions;
description = "`fzf-lua` settings for this command.";
example = settingsExample;
};
mode = helpers.keymaps.mkModeOption "n";
options = helpers.keymaps.mapConfigOptions;
};
})
);
description = "Keymaps for Fzf-Lua.";
default = { };
example = {
"<leader>fg" = "live_grep";
"<C-p>" = {
action = "git_files";
settings = {
previewers.cat.cmd = "${pkgs.coreutils}/bin/cat";
winopts.height = 0.5;
};
options = {
silent = true;
desc = "Fzf-Lua Git Files";
};
};
};
};
};
extraConfig = cfg: {
extraPlugins =
optional
cfg.iconsEnabled
pkgs.vimPlugins.nvim-web-devicons;
extraConfig = cfg: {
extraPlugins = optional cfg.iconsEnabled pkgs.vimPlugins.nvim-web-devicons;
extraPackages = optional (cfg.fzfPackage != null) cfg.fzfPackage;
extraPackages = optional (cfg.fzfPackage != null) cfg.fzfPackage;
plugins.fzf-lua.settings.__unkeyed_profile = cfg.profile;
plugins.fzf-lua.settings.__unkeyed_profile = cfg.profile;
keymaps =
mapAttrsToList
(
key: mapping: let
actionStr =
if isString mapping
then "${mapping}()"
else "${mapping.action}(${helpers.toLuaObject mapping.settings})";
in {
inherit key;
mode = mapping.mode or "n";
action.__raw = "function() require('fzf-lua').${actionStr} end";
options = mapping.options or {};
}
)
cfg.keymaps;
};
}
keymaps = mapAttrsToList (
key: mapping:
let
actionStr =
if isString mapping then
"${mapping}()"
else
"${mapping.action}(${helpers.toLuaObject mapping.settings})";
in
{
inherit key;
mode = mapping.mode or "n";
action.__raw = "function() require('fzf-lua').${actionStr} end";
options = mapping.options or { };
}
) cfg.keymaps;
};
}

View file

@ -7,35 +7,43 @@
}:
with helpers.vim-plugin;
with lib;
mkVimPlugin config {
name = "goyo";
originalName = "goyo.vim";
defaultPackage = pkgs.vimPlugins.goyo-vim;
globalPrefix = "goyo_";
mkVimPlugin config {
name = "goyo";
originalName = "goyo.vim";
defaultPackage = pkgs.vimPlugins.goyo-vim;
globalPrefix = "goyo_";
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-03-01: remove 2024-05-01
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"width"
"height"
];
imports = [
(
mkRenamedOptionModule
["plugins" "goyo" "showLineNumbers"]
["plugins" "goyo" "settings" "linenr"]
)
];
# TODO introduced 2024-03-01: remove 2024-05-01
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"width"
"height"
];
imports = [
(mkRenamedOptionModule
[
"plugins"
"goyo"
"showLineNumbers"
]
[
"plugins"
"goyo"
"settings"
"linenr"
]
)
];
settingsOptions = {
width = helpers.mkNullOrOption types.ints.unsigned "width";
settingsOptions = {
width = helpers.mkNullOrOption types.ints.unsigned "width";
height = helpers.mkNullOrOption types.ints.unsigned "height";
height = helpers.mkNullOrOption types.ints.unsigned "height";
linenr = helpers.defaultNullOpts.mkBool false ''
Show line numbers when in Goyo mode.
'';
};
}
linenr = helpers.defaultNullOpts.mkBool false ''
Show line numbers when in Goyo mode.
'';
};
}

View file

@ -5,161 +5,179 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.hardtime;
in {
in
{
options = {
plugins.hardtime =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "hardtime";
plugins.hardtime = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "hardtime";
package = helpers.mkPackageOption "hardtime" pkgs.vimPlugins.hardtime-nvim;
package = helpers.mkPackageOption "hardtime" pkgs.vimPlugins.hardtime-nvim;
maxTime = helpers.defaultNullOpts.mkUnsignedInt 1000 ''
Maximum time (in milliseconds) to consider key presses as repeated.
'';
maxTime = helpers.defaultNullOpts.mkUnsignedInt 1000 ''
Maximum time (in milliseconds) to consider key presses as repeated.
'';
maxCount = helpers.defaultNullOpts.mkUnsignedInt 2 ''
Maximum count of repeated key presses allowed within the `max_time` period.
'';
maxCount = helpers.defaultNullOpts.mkUnsignedInt 2 ''
Maximum count of repeated key presses allowed within the `max_time` period.
'';
disableMouse = helpers.defaultNullOpts.mkBool true ''
Disable mouse support.
'';
disableMouse = helpers.defaultNullOpts.mkBool true ''
Disable mouse support.
'';
hint = helpers.defaultNullOpts.mkBool true ''
Enable hint messages for better commands.
'';
hint = helpers.defaultNullOpts.mkBool true ''
Enable hint messages for better commands.
'';
notification = helpers.defaultNullOpts.mkBool true ''
Enable notification messages for restricted and disabled keys.
'';
notification = helpers.defaultNullOpts.mkBool true ''
Enable notification messages for restricted and disabled keys.
'';
allowDifferentKey = helpers.defaultNullOpts.mkBool false ''
Allow different keys to reset the count.
'';
allowDifferentKey = helpers.defaultNullOpts.mkBool false ''
Allow different keys to reset the count.
'';
enabled = helpers.defaultNullOpts.mkBool true ''
Whether the plugin in enabled by default or not.
'';
enabled = helpers.defaultNullOpts.mkBool true ''
Whether the plugin in enabled by default or not.
'';
resettingKeys = helpers.mkNullOrOption (with types; attrsOf (listOf str)) ''
Keys in what modes that reset the count.
resettingKeys = helpers.mkNullOrOption (with types; attrsOf (listOf str)) ''
Keys in what modes that reset the count.
default:
```nix
{
"1" = [ "n" "x" ];
"2" = [ "n" "x" ];
"3" = [ "n" "x" ];
"4" = [ "n" "x" ];
"5" = [ "n" "x" ];
"6" = [ "n" "x" ];
"7" = [ "n" "x" ];
"8" = [ "n" "x" ];
"9" = [ "n" "x" ];
"c" = [ "n" ];
"C" = [ "n" ];
"d" = [ "n" ];
"x" = [ "n" ];
"X" = [ "n" ];
"y" = [ "n" ];
"Y" = [ "n" ];
"p" = [ "n" ];
"P" = [ "n" ];
}
```
'';
default:
```nix
{
"1" = [ "n" "x" ];
"2" = [ "n" "x" ];
"3" = [ "n" "x" ];
"4" = [ "n" "x" ];
"5" = [ "n" "x" ];
"6" = [ "n" "x" ];
"7" = [ "n" "x" ];
"8" = [ "n" "x" ];
"9" = [ "n" "x" ];
"c" = [ "n" ];
"C" = [ "n" ];
"d" = [ "n" ];
"x" = [ "n" ];
"X" = [ "n" ];
"y" = [ "n" ];
"Y" = [ "n" ];
"p" = [ "n" ];
"P" = [ "n" ];
}
```
'';
restrictedKeys = helpers.mkNullOrOption (with types; attrsOf (listOf str)) ''
Keys in what modes triggering the count mechanism.
restrictedKeys = helpers.mkNullOrOption (with types; attrsOf (listOf str)) ''
Keys in what modes triggering the count mechanism.
default:
```nix
{
"h" = [ "n" "x" ];
"j" = [ "n" "x" ];
"k" = [ "n" "x" ];
"l" = [ "n" "x" ];
"-" = [ "n" "x" ];
"+" = [ "n" "x" ];
"gj" = [ "n" "x" ];
"gk" = [ "n" "x" ];
"<CR>" = [ "n" "x" ];
"<C-M>" = [ "n" "x" ];
"<C-N>" = [ "n" "x" ];
"<C-P>" = [ "n" "x" ];
}
```
'';
default:
```nix
{
"h" = [ "n" "x" ];
"j" = [ "n" "x" ];
"k" = [ "n" "x" ];
"l" = [ "n" "x" ];
"-" = [ "n" "x" ];
"+" = [ "n" "x" ];
"gj" = [ "n" "x" ];
"gk" = [ "n" "x" ];
"<CR>" = [ "n" "x" ];
"<C-M>" = [ "n" "x" ];
"<C-N>" = [ "n" "x" ];
"<C-P>" = [ "n" "x" ];
}
```
'';
restrictionMode = helpers.defaultNullOpts.mkEnumFirstDefault ["block" "hint"] ''
The behavior when `restricted_keys` trigger count mechanism.
'';
restrictionMode =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"block"
"hint"
]
''
The behavior when `restricted_keys` trigger count mechanism.
'';
disabledKeys = helpers.mkNullOrOption (with types; attrsOf (listOf str)) ''
Keys in what modes are disabled.
disabledKeys = helpers.mkNullOrOption (with types; attrsOf (listOf str)) ''
Keys in what modes are disabled.
default:
```nix
{
"<Up>" = [ "" "i" ];
"<Down>" = [ "" "i" ];
"<Left>" = [ "" "i" ];
"<Right>" = [ "" "i" ];
}
```
'';
default:
```nix
{
"<Up>" = [ "" "i" ];
"<Down>" = [ "" "i" ];
"<Left>" = [ "" "i" ];
"<Right>" = [ "" "i" ];
}
```
'';
disabledFiletypes = helpers.mkNullOrOption (with types; listOf str) ''
`hardtime.nvim` is disabled under these filetypes.
disabledFiletypes = helpers.mkNullOrOption (with types; listOf str) ''
`hardtime.nvim` is disabled under these filetypes.
default:
```nix
["qf" "netrw" "NvimTree" "lazy" "mason"]
```
'';
default:
```nix
["qf" "netrw" "NvimTree" "lazy" "mason"]
```
'';
hints = helpers.mkNullOrOption (with types;
attrsOf (submodule {
options = {
message = lib.mkOption {
description = "Hint message to be displayed.";
type = helpers.nixvimTypes.rawLua;
hints =
helpers.mkNullOrOption
(
with types;
attrsOf (submodule {
options = {
message = lib.mkOption {
description = "Hint message to be displayed.";
type = helpers.nixvimTypes.rawLua;
};
length = lib.mkOption {
description = "The length of actual key strokes that matches this pattern.";
type = types.ints.unsigned;
};
};
length = lib.mkOption {
description = "The length of actual key strokes that matches this pattern.";
type = types.ints.unsigned;
};
};
})) ''
`key` is a string pattern you want to match, `value` is a table
of hint massage and pattern length.
'';
};
})
)
''
`key` is a string pattern you want to match, `value` is a table
of hint massage and pattern length.
'';
};
};
config = let
setupOptions = with cfg;
{
inherit hint notification enabled hints;
config =
let
setupOptions =
with cfg;
{
inherit
hint
notification
enabled
hints
;
max_time = maxTime;
max_count = maxCount;
disable_mouse = disableMouse;
allow_different_key = allowDifferentKey;
resetting_keys = resettingKeys;
restricted_keys = restrictedKeys;
restriction_mode = restrictionMode;
disabled_keys = disabledKeys;
disabled_filetypes = disabledFiletypes;
}
// extraOptions;
in
max_time = maxTime;
max_count = maxCount;
disable_mouse = disableMouse;
allow_different_key = allowDifferentKey;
resetting_keys = resettingKeys;
restricted_keys = restrictedKeys;
restriction_mode = restrictionMode;
disabled_keys = disabledKeys;
disabled_filetypes = disabledFiletypes;
}
// extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("hardtime").setup(${helpers.toLuaObject setupOptions})

View file

@ -5,7 +5,8 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.harpoon;
projectConfigModule = types.submodule {
@ -19,186 +20,164 @@ with lib; let
'';
};
};
in {
options.plugins.harpoon =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "harpoon";
in
{
options.plugins.harpoon = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "harpoon";
package = helpers.mkPackageOption "harpoon" pkgs.vimPlugins.harpoon;
package = helpers.mkPackageOption "harpoon" pkgs.vimPlugins.harpoon;
enableTelescope = mkEnableOption "telescope integration";
enableTelescope = mkEnableOption "telescope integration";
keymapsSilent = mkOption {
type = types.bool;
description = "Whether harpoon keymaps should be silent.";
default = false;
};
keymaps = {
addFile = helpers.mkNullOrOption types.str ''
Keymap for marking the current file.";
'';
toggleQuickMenu = helpers.mkNullOrOption types.str ''
Keymap for toggling the quick menu.";
'';
navFile = helpers.mkNullOrOption (with types; attrsOf str) ''
Keymaps for navigating to marks.
Examples:
navFile = {
"1" = "<C-j>";
"2" = "<C-k>";
"3" = "<C-l>";
"4" = "<C-m>";
};
'';
navNext = helpers.mkNullOrOption types.str ''
Keymap for navigating to next mark.";
'';
navPrev = helpers.mkNullOrOption types.str ''
Keymap for navigating to previous mark.";
'';
gotoTerminal = helpers.mkNullOrOption (with types; attrsOf str) ''
Keymaps for navigating to terminals.
Examples:
gotoTerminal = {
"1" = "<C-j>";
"2" = "<C-k>";
"3" = "<C-l>";
"4" = "<C-m>";
};
'';
cmdToggleQuickMenu = helpers.mkNullOrOption types.str ''
Keymap for toggling the cmd quick menu.
'';
tmuxGotoTerminal = helpers.mkNullOrOption (with types; attrsOf str) ''
Keymaps for navigating to tmux windows/panes.
Attributes can either be tmux window ids or pane identifiers.
Examples:
tmuxGotoTerminal = {
"1" = "<C-1>";
"2" = "<C-2>";
"{down-of}" = "<leader>g";
};
'';
};
saveOnToggle = helpers.defaultNullOpts.mkBool false ''
Sets the marks upon calling `toggle` on the ui, instead of require `:w`.
'';
saveOnChange = helpers.defaultNullOpts.mkBool true ''
Saves the harpoon file upon every change. disabling is unrecommended.
'';
enterOnSendcmd = helpers.defaultNullOpts.mkBool false ''
Sets harpoon to run the command immediately as it's passed to the terminal when calling `sendCommand`.
'';
tmuxAutocloseWindows = helpers.defaultNullOpts.mkBool false ''
Closes any tmux windows harpoon that harpoon creates when you close Neovim.
'';
excludedFiletypes =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
''["harpoon"]''
"Filetypes that you want to prevent from adding to the harpoon list menu.";
markBranch = helpers.defaultNullOpts.mkBool false ''
Set marks specific to each git branch inside git repository.
'';
projects = mkOption {
default = {};
description = ''
Predefined projetcs. The keys of this attrs should be the path to the project.
$HOME is working.
'';
example = ''
projects = {
"$HOME/personal/vim-with-me/server" = {
termCommands = [
"./env && npx ts-node src/index.ts"
];
};
};
'';
type = types.attrsOf projectConfigModule;
};
menu = {
width = helpers.defaultNullOpts.mkInt 60 ''
Menu window width
'';
height = helpers.defaultNullOpts.mkInt 10 ''
Menu window height
'';
borderChars =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
''["" "" "" "" "" "" "" ""]''
"Border characters";
};
keymapsSilent = mkOption {
type = types.bool;
description = "Whether harpoon keymaps should be silent.";
default = false;
};
config = let
projects =
builtins.mapAttrs
(
name: value: {
term.cmds = value.termCommands;
mark.marks =
helpers.ifNonNull' value.marks
(
map
(
mark: {
filename = mark;
}
)
value.marks
);
keymaps = {
addFile = helpers.mkNullOrOption types.str ''
Keymap for marking the current file.";
'';
toggleQuickMenu = helpers.mkNullOrOption types.str ''
Keymap for toggling the quick menu.";
'';
navFile = helpers.mkNullOrOption (with types; attrsOf str) ''
Keymaps for navigating to marks.
Examples:
navFile = {
"1" = "<C-j>";
"2" = "<C-k>";
"3" = "<C-l>";
"4" = "<C-m>";
};
'';
navNext = helpers.mkNullOrOption types.str ''
Keymap for navigating to next mark.";
'';
navPrev = helpers.mkNullOrOption types.str ''
Keymap for navigating to previous mark.";
'';
gotoTerminal = helpers.mkNullOrOption (with types; attrsOf str) ''
Keymaps for navigating to terminals.
Examples:
gotoTerminal = {
"1" = "<C-j>";
"2" = "<C-k>";
"3" = "<C-l>";
"4" = "<C-m>";
};
'';
cmdToggleQuickMenu = helpers.mkNullOrOption types.str ''
Keymap for toggling the cmd quick menu.
'';
tmuxGotoTerminal = helpers.mkNullOrOption (with types; attrsOf str) ''
Keymaps for navigating to tmux windows/panes.
Attributes can either be tmux window ids or pane identifiers.
Examples:
tmuxGotoTerminal = {
"1" = "<C-1>";
"2" = "<C-2>";
"{down-of}" = "<leader>g";
};
'';
};
saveOnToggle = helpers.defaultNullOpts.mkBool false ''
Sets the marks upon calling `toggle` on the ui, instead of require `:w`.
'';
saveOnChange = helpers.defaultNullOpts.mkBool true ''
Saves the harpoon file upon every change. disabling is unrecommended.
'';
enterOnSendcmd = helpers.defaultNullOpts.mkBool false ''
Sets harpoon to run the command immediately as it's passed to the terminal when calling `sendCommand`.
'';
tmuxAutocloseWindows = helpers.defaultNullOpts.mkBool false ''
Closes any tmux windows harpoon that harpoon creates when you close Neovim.
'';
excludedFiletypes = helpers.defaultNullOpts.mkNullable (
with types; listOf str
) ''["harpoon"]'' "Filetypes that you want to prevent from adding to the harpoon list menu.";
markBranch = helpers.defaultNullOpts.mkBool false ''
Set marks specific to each git branch inside git repository.
'';
projects = mkOption {
default = { };
description = ''
Predefined projetcs. The keys of this attrs should be the path to the project.
$HOME is working.
'';
example = ''
projects = {
"$HOME/personal/vim-with-me/server" = {
termCommands = [
"./env && npx ts-node src/index.ts"
];
};
};
'';
type = types.attrsOf projectConfigModule;
};
menu = {
width = helpers.defaultNullOpts.mkInt 60 ''
Menu window width
'';
height = helpers.defaultNullOpts.mkInt 10 ''
Menu window height
'';
borderChars = helpers.defaultNullOpts.mkNullable (
with types; listOf str
) ''["" "" "" "" "" "" "" ""]'' "Border characters";
};
};
config =
let
projects = builtins.mapAttrs (name: value: {
term.cmds = value.termCommands;
mark.marks = helpers.ifNonNull' value.marks (map (mark: { filename = mark; }) value.marks);
}) cfg.projects;
setupOptions =
with cfg;
{
global_settings = {
save_on_toggle = saveOnToggle;
save_on_change = saveOnChange;
enter_on_sendcmd = enterOnSendcmd;
tmux_autoclose_windows = tmuxAutocloseWindows;
excluded_filetypes = excludedFiletypes;
mark_branch = markBranch;
};
inherit projects;
menu = {
inherit (menu) width height;
borderchars = menu.borderChars;
};
}
)
cfg.projects;
setupOptions = with cfg;
{
global_settings = {
save_on_toggle = saveOnToggle;
save_on_change = saveOnChange;
enter_on_sendcmd = enterOnSendcmd;
tmux_autoclose_windows = tmuxAutocloseWindows;
excluded_filetypes = excludedFiletypes;
mark_branch = markBranch;
};
inherit projects;
menu = {
inherit
(menu)
width
height
;
borderchars = menu.borderChars;
};
}
// cfg.extraOptions;
in
// cfg.extraOptions;
in
mkIf cfg.enable {
assertions = [
{
@ -207,84 +186,67 @@ in {
}
];
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = let
telescopeCfg = ''require("telescope").load_extension("harpoon")'';
in ''
require('harpoon').setup(${helpers.toLuaObject setupOptions})
${
if cfg.enableTelescope
then telescopeCfg
else ""
}
'';
keymaps = let
km = cfg.keymaps;
simpleMappings = flatten (
mapAttrsToList
(
optionName: luaFunc: let
key = km.${optionName};
in
optional
(key != null)
{
inherit key;
action.__raw = luaFunc;
}
)
{
addFile = "require('harpoon.mark').add_file";
toggleQuickMenu = "require('harpoon.ui').toggle_quick_menu";
navNext = "require('harpoon.ui').nav_next";
navPrev = "require('harpoon.ui').nav_prev";
cmdToggleQuickMenu = "require('harpoon.cmd-ui').toggle_quick_menu";
}
);
mkNavMappings = name: genLuaFunc: let
mappingsAttrs = km.${name};
extraConfigLua =
let
telescopeCfg = ''require("telescope").load_extension("harpoon")'';
in
flatten
(
optionals
(mappingsAttrs != null)
(
mapAttrsToList
(id: key: {
inherit key;
action.__raw = genLuaFunc id;
})
mappingsAttrs
)
''
require('harpoon').setup(${helpers.toLuaObject setupOptions})
${if cfg.enableTelescope then telescopeCfg else ""}
'';
keymaps =
let
km = cfg.keymaps;
simpleMappings = flatten (
mapAttrsToList
(
optionName: luaFunc:
let
key = km.${optionName};
in
optional (key != null) {
inherit key;
action.__raw = luaFunc;
}
)
{
addFile = "require('harpoon.mark').add_file";
toggleQuickMenu = "require('harpoon.ui').toggle_quick_menu";
navNext = "require('harpoon.ui').nav_next";
navPrev = "require('harpoon.ui').nav_prev";
cmdToggleQuickMenu = "require('harpoon.cmd-ui').toggle_quick_menu";
}
);
allMappings =
simpleMappings
++ (
mkNavMappings
"navFile"
(id: "function() require('harpoon.ui').nav_file(${id}) end")
)
++ (
mkNavMappings
"gotoTerminal"
(id: "function() require('harpoon.term').gotoTerminal(${id}) end")
)
++ (
mkNavMappings
"tmuxGotoTerminal"
(id: "function() require('harpoon.tmux').gotoTerminal(${id}) end")
);
in
helpers.keymaps.mkKeymaps
{
mkNavMappings =
name: genLuaFunc:
let
mappingsAttrs = km.${name};
in
flatten (
optionals (mappingsAttrs != null) (
mapAttrsToList (id: key: {
inherit key;
action.__raw = genLuaFunc id;
}) mappingsAttrs
)
);
allMappings =
simpleMappings
++ (mkNavMappings "navFile" (id: "function() require('harpoon.ui').nav_file(${id}) end"))
++ (mkNavMappings "gotoTerminal" (id: "function() require('harpoon.term').gotoTerminal(${id}) end"))
++ (mkNavMappings "tmuxGotoTerminal" (
id: "function() require('harpoon.tmux').gotoTerminal(${id}) end"
));
in
helpers.keymaps.mkKeymaps {
mode = "n";
options.silent = cfg.keymapsSilent;
}
allMappings;
} allMappings;
};
}

View file

@ -6,280 +6,283 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "hop";
originalName = "hop.nvim";
defaultPackage = pkgs.vimPlugins.hop-nvim;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "hop";
originalName = "hop.nvim";
defaultPackage = pkgs.vimPlugins.hop-nvim;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
description = ''
Hop doesnt set any keybindings; you will have to define them by yourself.
If you want to create a key binding from within nixvim:
```nix
keymaps = [
{
key = "f";
action.__raw = \'\'
function()
require'hop'.hint_char1({
direction = require'hop.hint'.HintDirection.AFTER_CURSOR,
current_line_only = true
})
end
\'\';
options.remap = true;
}
{
key = "F";
action.__raw = \'\'
function()
require'hop'.hint_char1({
direction = require'hop.hint'.HintDirection.BEFORE_CURSOR,
current_line_only = true
})
end
\'\';
options.remap = true;
}
{
key = "t";
action.__raw = \'\'
function()
require'hop'.hint_char1({
direction = require'hop.hint'.HintDirection.AFTER_CURSOR,
current_line_only = true,
hint_offset = -1
})
end
\'\';
options.remap = true;
}
{
key = "T";
action.__raw = \'\'
function()
require'hop'.hint_char1({
direction = require'hop.hint'.HintDirection.BEFORE_CURSOR,
current_line_only = true,
hint_offset = 1
})
end
\'\';
options.remap = true;
}
];
```
description = ''
Hop doesnt set any keybindings; you will have to define them by yourself.
If you want to create a key binding from within nixvim:
```nix
keymaps = [
{
key = "f";
action.__raw = \'\'
function()
require'hop'.hint_char1({
direction = require'hop.hint'.HintDirection.AFTER_CURSOR,
current_line_only = true
})
end
\'\';
options.remap = true;
}
{
key = "F";
action.__raw = \'\'
function()
require'hop'.hint_char1({
direction = require'hop.hint'.HintDirection.BEFORE_CURSOR,
current_line_only = true
})
end
\'\';
options.remap = true;
}
{
key = "t";
action.__raw = \'\'
function()
require'hop'.hint_char1({
direction = require'hop.hint'.HintDirection.AFTER_CURSOR,
current_line_only = true,
hint_offset = -1
})
end
\'\';
options.remap = true;
}
{
key = "T";
action.__raw = \'\'
function()
require'hop'.hint_char1({
direction = require'hop.hint'.HintDirection.BEFORE_CURSOR,
current_line_only = true,
hint_offset = 1
})
end
\'\';
options.remap = true;
}
];
```
'';
settingsOptions = {
keys = helpers.defaultNullOpts.mkStr "asdghklqwertyuiopzxcvbnmfj" ''
A string representing all the keys that can be part of a permutation.
Every character (key) used in the string will be used as part of a permutation.
The shortest permutation is a permutation of a single character, and, depending on the
content of your buffer, you might end up with 3-character (or more) permutations in worst
situations.
However, it is important to notice that if you decide to provide `keys`, you have to ensure
to use enough characters in the string, otherwise you might get very long sequences and a
not so pleasant experience.
'';
settingsOptions = {
keys = helpers.defaultNullOpts.mkStr "asdghklqwertyuiopzxcvbnmfj" ''
A string representing all the keys that can be part of a permutation.
Every character (key) used in the string will be used as part of a permutation.
The shortest permutation is a permutation of a single character, and, depending on the
content of your buffer, you might end up with 3-character (or more) permutations in worst
situations.
quit_key = helpers.defaultNullOpts.mkStr "<Esc>" ''
A string representing a key that will quit Hop mode without also feeding that key into
Neovim to be treated as a normal key press.
However, it is important to notice that if you decide to provide `keys`, you have to ensure
to use enough characters in the string, otherwise you might get very long sequences and a
not so pleasant experience.
'';
It is possible to quit hopping by pressing any key that is not present in |hop-config-keys|;
however, when you do this, the key normal function is also performed.
For example if, hopping in |visual-mode|, pressing <Esc> will quit hopping and also exit
|visual-mode|.
quit_key = helpers.defaultNullOpts.mkStr "<Esc>" ''
A string representing a key that will quit Hop mode without also feeding that key into
Neovim to be treated as a normal key press.
If the user presses `quit_key`, Hop will be quit without the key normal function being
performed.
For example if hopping in |visual-mode| with `quit_key` set to '<Esc>', pressing <Esc> will
quit hopping without quitting |visual-mode|.
It is possible to quit hopping by pressing any key that is not present in |hop-config-keys|;
however, when you do this, the key normal function is also performed.
For example if, hopping in |visual-mode|, pressing <Esc> will quit hopping and also exit
|visual-mode|.
If you don't want to use a `quit_key`, set `quit_key` to an empty string.
If the user presses `quit_key`, Hop will be quit without the key normal function being
performed.
For example if hopping in |visual-mode| with `quit_key` set to '<Esc>', pressing <Esc> will
quit hopping without quitting |visual-mode|.
Note: `quit_key` should only contain a single key or be an empty string.
If you don't want to use a `quit_key`, set `quit_key` to an empty string.
Note: `quit_key` should not contain a key that is also present in |hop-config-keys|.
'';
Note: `quit_key` should only contain a single key or be an empty string.
perm_method = helpers.defaultNullOpts.mkLuaFn "require'hop.perm'.TrieBacktrackFilling" ''
Permutation method to use.
Note: `quit_key` should not contain a key that is also present in |hop-config-keys|.
'';
Permutation methods allow to change the way permutations (i.e. hints sequence labels) are
generated internally.
There is currently only one possible option:
- `TrieBacktrackFilling`:
Permutation algorithm based on tries and backtrack filling.
perm_method = helpers.defaultNullOpts.mkLuaFn "require'hop.perm'.TrieBacktrackFilling" ''
Permutation method to use.
This algorithm uses the full potential of |hop-config-keys| by using them all to saturate
a trie, representing all the permutations.
Once a layer is saturated, this algorithm will backtrack (from the end of the trie,
deepest first) and create a new layer in the trie, ensuring that the first permutations
will be shorter than the last ones.
Permutation methods allow to change the way permutations (i.e. hints sequence labels) are
generated internally.
There is currently only one possible option:
- `TrieBacktrackFilling`:
Permutation algorithm based on tries and backtrack filling.
Because of the last, deepest trie insertion mechanism and trie saturation, this algorithm
yields a much better distribution across your buffer, and you should get 1-sequences and
2-sequences most of the time.
Each dimension grows exponentially, so you get `keys_length²` 2-sequence keys,
`keys_length³` 3-sequence keys, etc in the worst cases.
'';
This algorithm uses the full potential of |hop-config-keys| by using them all to saturate
a trie, representing all the permutations.
Once a layer is saturated, this algorithm will backtrack (from the end of the trie,
deepest first) and create a new layer in the trie, ensuring that the first permutations
will be shorter than the last ones.
reverse_distribution = helpers.defaultNullOpts.mkBool false ''
The default behavior for key sequence distribution in your buffer is to concentrate shorter
sequences near the cursor, grouping 1-character sequences around.
As hints get further from the cursor, the dimension of the sequences will grow, making the
furthest sequences the longest ones to type.
Because of the last, deepest trie insertion mechanism and trie saturation, this algorithm
yields a much better distribution across your buffer, and you should get 1-sequences and
2-sequences most of the time.
Each dimension grows exponentially, so you get `keys_length²` 2-sequence keys,
`keys_length³` 3-sequence keys, etc in the worst cases.
'';
Set this option to `true` to reverse the density and concentrate the shortest sequences
(1-character) around the furthest words and the longest sequences around the cursor.
'';
reverse_distribution = helpers.defaultNullOpts.mkBool false ''
The default behavior for key sequence distribution in your buffer is to concentrate shorter
sequences near the cursor, grouping 1-character sequences around.
As hints get further from the cursor, the dimension of the sequences will grow, making the
furthest sequences the longest ones to type.
x_bias = helpers.defaultNullOpts.mkUnsignedInt 10 ''
This Determines which hints get shorter key sequences.
The default value has a more balanced distribution around the cursor but increasing it means
that hints which are closer vertically will have a shorter key sequences.
Set this option to `true` to reverse the density and concentrate the shortest sequences
(1-character) around the furthest words and the longest sequences around the cursor.
'';
For instance, when `x_bias` is set to 100, hints located at the end of the line will have
shorter key sequence compared to hints in the lines above or below.
'';
x_bias = helpers.defaultNullOpts.mkUnsignedInt 10 ''
This Determines which hints get shorter key sequences.
The default value has a more balanced distribution around the cursor but increasing it means
that hints which are closer vertically will have a shorter key sequences.
teasing = helpers.defaultNullOpts.mkBool true ''
Boolean value stating whether Hop should tease you when you do something you are not
supposed to.
For instance, when `x_bias` is set to 100, hints located at the end of the line will have
shorter key sequence compared to hints in the lines above or below.
'';
If you find this setting annoying, feel free to turn it to `false`.
'';
teasing = helpers.defaultNullOpts.mkBool true ''
Boolean value stating whether Hop should tease you when you do something you are not
supposed to.
virtual_cursor = helpers.defaultNullOpts.mkBool true ''
Creates a virtual cursor in place of actual cursor when hop waits for
user input to indicate the active window.
'';
If you find this setting annoying, feel free to turn it to `false`.
'';
jump_on_sole_occurrence = helpers.defaultNullOpts.mkBool true ''
Immediately jump without displaying hints if only one occurrence exists.
'';
virtual_cursor = helpers.defaultNullOpts.mkBool true ''
Creates a virtual cursor in place of actual cursor when hop waits for
user input to indicate the active window.
'';
ignore_injections = helpers.defaultNullOpts.mkBool false ''
Ignore injected languages when jumping to treesitter node.
'';
jump_on_sole_occurrence = helpers.defaultNullOpts.mkBool true ''
Immediately jump without displaying hints if only one occurrence exists.
'';
case_insensitive = helpers.defaultNullOpts.mkBool true ''
Use case-insensitive matching by default for commands requiring user input.
'';
ignore_injections = helpers.defaultNullOpts.mkBool false ''
Ignore injected languages when jumping to treesitter node.
'';
create_hl_autocmd = helpers.defaultNullOpts.mkBool true ''
Create and set highlight autocommands to automatically apply highlights.
You will want this if you use a theme that clears all highlights before
applying its colorscheme.
'';
case_insensitive = helpers.defaultNullOpts.mkBool true ''
Use case-insensitive matching by default for commands requiring user input.
'';
dim_unmatched = helpers.defaultNullOpts.mkBool true ''
Whether or not dim the unmatched text to emphasize the hint chars.
'';
create_hl_autocmd = helpers.defaultNullOpts.mkBool true ''
Create and set highlight autocommands to automatically apply highlights.
You will want this if you use a theme that clears all highlights before
applying its colorscheme.
'';
direction = helpers.mkNullOrLua ''
Direction in which to hint.
See `|hop.hint.HintDirection|` for further details.
dim_unmatched = helpers.defaultNullOpts.mkBool true ''
Whether or not dim the unmatched text to emphasize the hint chars.
'';
Setting this in the user configuration will make all commands default to that direction,
unless overridden.
'';
direction = helpers.mkNullOrLua ''
Direction in which to hint.
See `|hop.hint.HintDirection|` for further details.
hint_position = helpers.defaultNullOpts.mkLua "require'hop.hint'.HintPosition.BEGIN" ''
Position of hint in match. See |hop.hint.HintPosition| for further
details.
'';
Setting this in the user configuration will make all commands default to that direction,
unless overridden.
'';
hint_type = helpers.defaultNullOpts.mkLua "require'hop.hint'.HintType.OVERLAY" ''
How to show the hint char.
hint_position = helpers.defaultNullOpts.mkLua "require'hop.hint'.HintPosition.BEGIN" ''
Position of hint in match. See |hop.hint.HintPosition| for further
details.
'';
Possible values:
- "overlay": display over the specified column, without shifting the underlying text.
- "inline": display at the specified column, and shift the buffer text to the right as needed.
'';
hint_type = helpers.defaultNullOpts.mkLua "require'hop.hint'.HintType.OVERLAY" ''
How to show the hint char.
hint_offset = helpers.defaultNullOpts.mkUnsignedInt 0 ''
Offset to apply to a jump location.
Possible values:
- "overlay": display over the specified column, without shifting the underlying text.
- "inline": display at the specified column, and shift the buffer text to the right as needed.
'';
If it is non-zero, the jump target will be offset horizontally from the selected jump position
by `hint_offset` character(s).
hint_offset = helpers.defaultNullOpts.mkUnsignedInt 0 ''
Offset to apply to a jump location.
This option can be used for emulating the motion commands |t| and |T| where the cursor is
positioned on/before the target position.
'';
If it is non-zero, the jump target will be offset horizontally from the selected jump position
by `hint_offset` character(s).
current_line_only = helpers.defaultNullOpts.mkBool false ''
Apply Hop commands only to the current line.
This option can be used for emulating the motion commands |t| and |T| where the cursor is
positioned on/before the target position.
'';
Note: Trying to use this option along with `multi_windows` is unsound.
'';
current_line_only = helpers.defaultNullOpts.mkBool false ''
Apply Hop commands only to the current line.
uppercase_labels = helpers.defaultNullOpts.mkBool false ''
Display labels as uppercase.
This option only affects the displayed labels; you still select them by typing the keys on your
keyboard.
'';
Note: Trying to use this option along with `multi_windows` is unsound.
'';
yank_register = helpers.defaultNullOpts.mkStr "" ''
Determines which one of the `registers` stores the yanked text.
'';
uppercase_labels = helpers.defaultNullOpts.mkBool false ''
Display labels as uppercase.
This option only affects the displayed labels; you still select them by typing the keys on your
keyboard.
'';
extensions = helpers.mkNullOrOption (with types; listOf str) ''
List-table of extensions to enable (names).
As described in `|hop-extension|`, extensions for which the name in that list must have a
`register(opts)` function in their public API for Hop to correctly initialized them.
'';
yank_register = helpers.defaultNullOpts.mkStr "" ''
Determines which one of the `registers` stores the yanked text.
'';
multi_windows = helpers.defaultNullOpts.mkBool false ''
Enable cross-windows support and hint all the currently visible windows.
This behavior allows you to jump around any position in any buffer currently visible in a
window.
Although a powerful a feature, remember that enabling this will also generate many more
sequence combinations, so you could get deeper sequences to type (most of the time it
should be good if you have enough keys in `|hop-config-keys|`).
'';
extensions = helpers.mkNullOrOption (with types; listOf str) ''
List-table of extensions to enable (names).
As described in `|hop-extension|`, extensions for which the name in that list must have a
`register(opts)` function in their public API for Hop to correctly initialized them.
'';
excluded_filetypes = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Skip hinting windows with the excluded filetypes.
Those windows to check filetypes are collected only when you enable `multi_windows` or
execute `MW`-commands.
This option is useful to skip the windows which are only for displaying something but not
for editing.
'';
multi_windows = helpers.defaultNullOpts.mkBool false ''
Enable cross-windows support and hint all the currently visible windows.
This behavior allows you to jump around any position in any buffer currently visible in a
window.
Although a powerful a feature, remember that enabling this will also generate many more
sequence combinations, so you could get deeper sequences to type (most of the time it
should be good if you have enough keys in `|hop-config-keys|`).
'';
match_mappings = helpers.defaultNullOpts.mkListOf types.str "[]" ''
This option allows you to specify the match mappings to use when applying the hint.
If you set a non-empty `match_mappings`, the hint will be used as a key to look up the
pattern to search for.
excluded_filetypes = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Skip hinting windows with the excluded filetypes.
Those windows to check filetypes are collected only when you enable `multi_windows` or
execute `MW`-commands.
This option is useful to skip the windows which are only for displaying something but not
for editing.
'';
Currently supported mappings:~
- 'fa' : farsi characters
- 'zh' : Basic characters for Chinese
- 'zh_sc' : Simplified Chinese
- 'zh_tc' : Traditional Chinese
match_mappings = helpers.defaultNullOpts.mkListOf types.str "[]" ''
This option allows you to specify the match mappings to use when applying the hint.
If you set a non-empty `match_mappings`, the hint will be used as a key to look up the
pattern to search for.
For example, if `match_mappings` is set to `["zh" "zh_sc"], the characters in "zh" and
"zh_sc" can be mixed to match together.
'';
};
Currently supported mappings:~
- 'fa' : farsi characters
- 'zh' : Basic characters for Chinese
- 'zh_sc' : Simplified Chinese
- 'zh_tc' : Traditional Chinese
For example, if `match_mappings` is set to `["zh" "zh_sc"], the characters in "zh" and
"zh_sc" can be mixed to match together.
'';
};
settingsExample = {
keys = "asdghklqwertyuiopzxcvbnmfj";
quit_key = "<Esc>";
reverse_distribution = false;
x_bias = 10;
teasing = true;
virtual_cursor = true;
jump_on_sole_occurrence = true;
case_insensitive = false;
dim_unmatched = true;
direction = "require'hop.hint'.HintDirection.BEFORE_CURSOR";
hint_position = "require'hop.hint'.HintPosition.BEGIN";
hint_type = "require'hop.hint'.HintType.OVERLAY";
match_mappings = ["zh" "zh_sc"];
};
}
settingsExample = {
keys = "asdghklqwertyuiopzxcvbnmfj";
quit_key = "<Esc>";
reverse_distribution = false;
x_bias = 10;
teasing = true;
virtual_cursor = true;
jump_on_sole_occurrence = true;
case_insensitive = false;
dim_unmatched = true;
direction = "require'hop.hint'.HintDirection.BEFORE_CURSOR";
hint_position = "require'hop.hint'.HintPosition.BEGIN";
hint_type = "require'hop.hint'.HintType.OVERLAY";
match_mappings = [
"zh"
"zh_sc"
];
};
}

View file

@ -6,47 +6,47 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "hydra";
originalName = "hydra.nvim";
defaultPackage = pkgs.vimPlugins.hydra-nvim;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "hydra";
originalName = "hydra.nvim";
defaultPackage = pkgs.vimPlugins.hydra-nvim;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
extraOptions = {
# A list of `Hydra` definitions
hydras = import ./hydras-option.nix {inherit lib helpers;};
};
extraOptions = {
# A list of `Hydra` definitions
hydras = import ./hydras-option.nix { inherit lib helpers; };
};
settingsOptions = import ./hydra-config-opts.nix {inherit lib helpers;};
settingsOptions = import ./hydra-config-opts.nix { inherit lib helpers; };
settingsExample = {
exit = false;
foreign_keys = "run";
color = "red";
buffer = true;
invoke_on_body = false;
desc = null;
on_enter = ''
function()
print('hello')
end
'';
timeout = 5000;
hint = false;
};
settingsExample = {
exit = false;
foreign_keys = "run";
color = "red";
buffer = true;
invoke_on_body = false;
desc = null;
on_enter = ''
function()
print('hello')
end
'';
timeout = 5000;
hint = false;
};
callSetup = false;
extraConfig = cfg: {
extraConfigLua = ''
hydra = require('hydra')
callSetup = false;
extraConfig = cfg: {
extraConfigLua = ''
hydra = require('hydra')
hydra.setup(${helpers.toLuaObject cfg.settings})
hydra.setup(${helpers.toLuaObject cfg.settings})
__hydra_defs = ${helpers.toLuaObject cfg.hydras}
for _, hydra_config in ipairs(__hydra_defs) do
hydra(hydra_config)
end
'';
};
}
__hydra_defs = ${helpers.toLuaObject cfg.hydras}
for _, hydra_config in ipairs(__hydra_defs) do
hydra(hydra_config)
end
'';
};
}

View file

@ -5,12 +5,9 @@
# - for `plugins.hydra.hydras.[].config`
#
# -> https://github.com/nvimtools/hydra.nvim?tab=readme-ov-file#config
{ helpers, lib, ... }:
with lib;
{
helpers,
lib,
...
}:
with lib; {
debug = helpers.defaultNullOpts.mkBool false ''
Whether to enable debug mode.
'';
@ -19,28 +16,28 @@ with lib; {
Set the default exit value for each head in the hydra.
'';
foreign_keys = helpers.defaultNullOpts.mkEnum ["warn" "run"] "null" ''
Decides what to do when a key which doesn't belong to any head is pressed
- `null`: hydra exits and foreign key behaves normally, as if the hydra wasn't active
- `"warn"`: hydra stays active, issues a warning and doesn't run the foreign key
- `"run"`: hydra stays active, runs the foreign key
'';
foreign_keys =
helpers.defaultNullOpts.mkEnum
[
"warn"
"run"
]
"null"
''
Decides what to do when a key which doesn't belong to any head is pressed
- `null`: hydra exits and foreign key behaves normally, as if the hydra wasn't active
- `"warn"`: hydra stays active, issues a warning and doesn't run the foreign key
- `"run"`: hydra stays active, runs the foreign key
'';
color = helpers.defaultNullOpts.mkStr "red" ''
See `:h hydra-colors`.
`"red" | "amaranth" | "teal" | "pink"`
'';
buffer =
helpers.defaultNullOpts.mkNullable
(
with types;
either
(enum [true])
ints.unsigned
)
"null"
"Define a hydra for the given buffer, pass `true` for current buf.";
buffer = helpers.defaultNullOpts.mkNullable (
with types; either (enum [ true ]) ints.unsigned
) "null" "Define a hydra for the given buffer, pass `true` for current buf.";
invoke_on_body = helpers.defaultNullOpts.mkBool false ''
When true, summon the hydra after pressing only the `body` keys.
@ -73,32 +70,30 @@ with lib; {
By default hydras wait forever (`false`).
'';
hint = let
hintConfigType = types.submodule {
freeformType = with types; attrsOf anything;
options = {
type =
helpers.mkNullOrOption
(types.enum
[
"window"
"cmdline"
"statusline"
"statuslinemanual"
])
''
- "window": show hint in a floating window
- "cmdline": show hint in the echo area
- "statusline": show auto-generated hint in the status line
- "statuslinemanual": Do not show a hint, but return a custom status line hint from
`require("hydra.statusline").get_hint()`
hint =
let
hintConfigType = types.submodule {
freeformType = with types; attrsOf anything;
options = {
type =
helpers.mkNullOrOption
(types.enum [
"window"
"cmdline"
"statusline"
"statuslinemanual"
])
''
- "window": show hint in a floating window
- "cmdline": show hint in the echo area
- "statusline": show auto-generated hint in the status line
- "statuslinemanual": Do not show a hint, but return a custom status line hint from
`require("hydra.statusline").get_hint()`
Defaults to "window" if `hint` is passed to the hydra otherwise defaults to "cmdline".
'';
Defaults to "window" if `hint` is passed to the hydra otherwise defaults to "cmdline".
'';
position =
helpers.defaultNullOpts.mkEnum
[
position = helpers.defaultNullOpts.mkEnum [
"top-left"
"top"
"top-right"
@ -108,82 +103,74 @@ with lib; {
"bottom-left"
"bottom"
"bottom-right"
]
"bottom"
"Set the position of the hint window.";
] "bottom" "Set the position of the hint window.";
offset = helpers.defaultNullOpts.mkInt 0 ''
Offset of the floating window from the nearest editor border.
'';
float_opts = helpers.mkNullOrOption (with types; attrsOf anything) ''
Options passed to `nvim_open_win()`. See `:h nvim_open_win()`.
Lets you set `border`, `header`, `footer`, etc.
Note: `row`, `col`, `height`, `width`, `relative`, and `anchor` should not be overridden.
'';
show_name = helpers.defaultNullOpts.mkBool true ''
Show the hydras name (or "HYDRA:" if not given a name), at the beginning of an
auto-generated hint.
'';
hide_on_load = helpers.defaultNullOpts.mkBool false ''
If set to true, this will prevent the hydra's hint window from displaying immediately.
Note: you can still show the window manually by calling `Hydra.hint:show()` and manually
close it with `Hydra.hint:close()`.
'';
funcs = mkOption {
type = with helpers.nixvimTypes; attrsOf strLuaFn;
description = ''
Table from function names to function.
Functions should return a string.
These functions can be used in hints with `%{func_name}` more in `:h hydra-hint`.
offset = helpers.defaultNullOpts.mkInt 0 ''
Offset of the floating window from the nearest editor border.
'';
default = {};
example = {
number = ''
function()
if vim.o.number then
return '[x]'
else
return '[ ]'
end
end
float_opts = helpers.mkNullOrOption (with types; attrsOf anything) ''
Options passed to `nvim_open_win()`. See `:h nvim_open_win()`.
Lets you set `border`, `header`, `footer`, etc.
Note: `row`, `col`, `height`, `width`, `relative`, and `anchor` should not be overridden.
'';
show_name = helpers.defaultNullOpts.mkBool true ''
Show the hydras name (or "HYDRA:" if not given a name), at the beginning of an
auto-generated hint.
'';
hide_on_load = helpers.defaultNullOpts.mkBool false ''
If set to true, this will prevent the hydra's hint window from displaying immediately.
Note: you can still show the window manually by calling `Hydra.hint:show()` and manually
close it with `Hydra.hint:close()`.
'';
funcs = mkOption {
type = with helpers.nixvimTypes; attrsOf strLuaFn;
description = ''
Table from function names to function.
Functions should return a string.
These functions can be used in hints with `%{func_name}` more in `:h hydra-hint`.
'';
relativenumber = ''
function()
if vim.o.relativenumber then
return '[x]'
else
return '[ ]'
default = { };
example = {
number = ''
function()
if vim.o.number then
return '[x]'
else
return '[ ]'
end
end
end
'';
'';
relativenumber = ''
function()
if vim.o.relativenumber then
return '[x]'
else
return '[ ]'
end
end
'';
};
apply = mapAttrs (_: helpers.mkRaw);
};
apply = mapAttrs (_: helpers.mkRaw);
};
};
};
in
helpers.defaultNullOpts.mkNullable
(
with types;
either
(enum [false])
hintConfigType
)
''
{
show_name = true;
position = "bottom";
offset = 0;
}
''
''
Configure the hint.
Set to `false` to disable.
'';
in
helpers.defaultNullOpts.mkNullable (with types; either (enum [ false ]) hintConfigType)
''
{
show_name = true;
position = "bottom";
offset = 0;
}
''
''
Configure the hint.
Set to `false` to disable.
'';
}

View file

@ -1,8 +1,6 @@
{
lib,
helpers,
}:
with lib; let
{ lib, helpers }:
with lib;
let
hydraType = types.submodule {
freeformType = with types; attrsOf anything;
options = {
@ -11,16 +9,9 @@ with lib; let
Only used in auto-generated hint.
'';
mode =
helpers.defaultNullOpts.mkNullable
(
with helpers.nixvimTypes;
either
helpers.keymaps.modeEnum
(listOf helpers.keymaps.modeEnum)
)
"n"
"Modes where the hydra exists, same as `vim.keymap.set()` accepts.";
mode = helpers.defaultNullOpts.mkNullable (
with helpers.nixvimTypes; either helpers.keymaps.modeEnum (listOf helpers.keymaps.modeEnum)
) "n" "Modes where the hydra exists, same as `vim.keymap.set()` accepts.";
body = helpers.mkNullOrStr ''
Key required to activate the hydra, when excluded, you can use `Hydra:activate()`.
@ -35,79 +26,74 @@ with lib; let
for more information.
'';
config = import ./hydra-config-opts.nix {inherit lib helpers;};
config = import ./hydra-config-opts.nix { inherit lib helpers; };
heads = let
headsOptType = types.submodule {
freeformType = with types; attrsOf anything;
options = {
private = helpers.defaultNullOpts.mkBool false ''
"When the hydra hides, this head does not stick out".
Private heads are unreachable outside of the hydra state.
'';
heads =
let
headsOptType = types.submodule {
freeformType = with types; attrsOf anything;
options = {
private = helpers.defaultNullOpts.mkBool false ''
"When the hydra hides, this head does not stick out".
Private heads are unreachable outside of the hydra state.
'';
exit = helpers.defaultNullOpts.mkBool false ''
When true, stops the hydra after executing this head.
NOTE:
- All exit heads are private
- If no exit head is specified, `esc` is set by default
'';
exit = helpers.defaultNullOpts.mkBool false ''
When true, stops the hydra after executing this head.
NOTE:
- All exit heads are private
- If no exit head is specified, `esc` is set by default
'';
exit_before = helpers.defaultNullOpts.mkBool false ''
Like `exit`, but stops the hydra BEFORE executing the command.
'';
exit_before = helpers.defaultNullOpts.mkBool false ''
Like `exit`, but stops the hydra BEFORE executing the command.
'';
ok_key = helpers.defaultNullOpts.mkBool true ''
When set to `false`, `config.on_key` isn't run after this head.
'';
ok_key = helpers.defaultNullOpts.mkBool true ''
When set to `false`, `config.on_key` isn't run after this head.
'';
desc = helpers.mkNullOrStr ''
Value shown in auto-generated hint.
When false, this key doesn't show up in the auto-generated hint.
'';
desc = helpers.mkNullOrStr ''
Value shown in auto-generated hint.
When false, this key doesn't show up in the auto-generated hint.
'';
expr = helpers.defaultNullOpts.mkBool false ''
Same as the builtin `expr` map option.
See `:h :map-expression`.
'';
expr = helpers.defaultNullOpts.mkBool false ''
Same as the builtin `expr` map option.
See `:h :map-expression`.
'';
silent = helpers.defaultNullOpts.mkBool false ''
Same as the builtin `silent` map option.
See `:h :map-silent`.
'';
silent = helpers.defaultNullOpts.mkBool false ''
Same as the builtin `silent` map option.
See `:h :map-silent`.
'';
nowait = helpers.defaultNullOpts.mkBool false ''
For Pink Hydras only.
Allows binding a key which will immediately perform its action and not wait
`timeoutlen` for a possible continuation.
'';
nowait = helpers.defaultNullOpts.mkBool false ''
For Pink Hydras only.
Allows binding a key which will immediately perform its action and not wait
`timeoutlen` for a possible continuation.
'';
mode =
helpers.mkNullOrOption
(
with helpers.nixvimTypes;
either
helpers.keymaps.modeEnum
(listOf helpers.keymaps.modeEnum)
)
"Override `mode` for this head.";
mode = helpers.mkNullOrOption (
with helpers.nixvimTypes; either helpers.keymaps.modeEnum (listOf helpers.keymaps.modeEnum)
) "Override `mode` for this head.";
};
};
};
headType = with helpers.nixvimTypes;
# More precisely, a tuple: [head action opts]
listOf (
nullOr ( # action can be `null`
oneOf [
str # for `head` and `action`
rawLua # for `action`
headsOptType # for opts
]
)
);
in
helpers.mkNullOrOption
(types.listOf headType)
''
headType =
with helpers.nixvimTypes;
# More precisely, a tuple: [head action opts]
listOf (
nullOr (
# action can be `null`
oneOf [
str # for `head` and `action`
rawLua # for `action`
headsOptType # for opts
]
)
);
in
helpers.mkNullOrOption (types.listOf headType) ''
Each Hydra's head has the form:
`[head rhs opts]
@ -123,107 +109,138 @@ with lib; let
};
};
in
mkOption {
type = types.listOf hydraType;
default = [];
example = [
{
name = "git";
hint.__raw = ''
[[
_J_: next hunk _s_: stage hunk _d_: show deleted _b_: blame line
_K_: prev hunk _u_: undo stage hunk _p_: preview hunk _B_: blame show full
^ ^ _S_: stage buffer ^ ^ _/_: show base file
^
^ ^ _<Enter>_: Neogit _q_: exit
]]
'';
config = {
color = "pink";
invoke_on_body = true;
hint = {
position = "bottom";
};
on_enter = ''
function()
vim.bo.modifiable = false
gitsigns.toggle_signs(true)
gitsigns.toggle_linehl(true)
end
'';
on_exit = ''
function()
gitsigns.toggle_signs(false)
gitsigns.toggle_linehl(false)
gitsigns.toggle_deleted(false)
vim.cmd("echo") -- clear the echo area
end
'';
mkOption {
type = types.listOf hydraType;
default = [ ];
example = [
{
name = "git";
hint.__raw = ''
[[
_J_: next hunk _s_: stage hunk _d_: show deleted _b_: blame line
_K_: prev hunk _u_: undo stage hunk _p_: preview hunk _B_: blame show full
^ ^ _S_: stage buffer ^ ^ _/_: show base file
^
^ ^ _<Enter>_: Neogit _q_: exit
]]
'';
config = {
color = "pink";
invoke_on_body = true;
hint = {
position = "bottom";
};
mode = ["n" "x"];
body = "<leader>g";
heads = [
[
"J"
{
__raw = ''
function()
if vim.wo.diff then
return "]c"
end
vim.schedule(function()
gitsigns.next_hunk()
end)
return "<Ignore>"
on_enter = ''
function()
vim.bo.modifiable = false
gitsigns.toggle_signs(true)
gitsigns.toggle_linehl(true)
end
'';
on_exit = ''
function()
gitsigns.toggle_signs(false)
gitsigns.toggle_linehl(false)
gitsigns.toggle_deleted(false)
vim.cmd("echo") -- clear the echo area
end
'';
};
mode = [
"n"
"x"
];
body = "<leader>g";
heads = [
[
"J"
{
__raw = ''
function()
if vim.wo.diff then
return "]c"
end
'';
}
{expr = true;}
]
[
"K"
{
__raw = ''
function()
if vim.wo.diff then
return "[c"
end
vim.schedule(function()
gitsigns.prev_hunk()
end)
return "<Ignore>"
vim.schedule(function()
gitsigns.next_hunk()
end)
return "<Ignore>"
end
'';
}
{ expr = true; }
]
[
"K"
{
__raw = ''
function()
if vim.wo.diff then
return "[c"
end
'';
}
{expr = true;}
]
["s" ":Gitsigns stage_hunk<CR>" {silent = true;}]
["u" {__raw = "require('gitsigns').undo_stage_hunk";}]
["S" {__raw = "require('gitsigns').stage_buffer";}]
["p" {__raw = "require('gitsigns').preview_hunk";}]
["d" {__raw = "require('gitsigns').toggle_deleted";} {nowait = true;}]
["b" {__raw = "require('gitsigns').blame_line";}]
[
"B"
{
__raw = ''
function()
gitsigns.blame_line({ full = true })
end,
'';
}
]
["/" {__raw = "require('gitsigns').show";} {exit = true;}]
["<Enter>" "<cmd>Neogit<CR>" {exit = true;}]
[
"q"
null
{
exit = true;
nowait = true;
}
]
];
}
];
}
vim.schedule(function()
gitsigns.prev_hunk()
end)
return "<Ignore>"
end
'';
}
{ expr = true; }
]
[
"s"
":Gitsigns stage_hunk<CR>"
{ silent = true; }
]
[
"u"
{ __raw = "require('gitsigns').undo_stage_hunk"; }
]
[
"S"
{ __raw = "require('gitsigns').stage_buffer"; }
]
[
"p"
{ __raw = "require('gitsigns').preview_hunk"; }
]
[
"d"
{ __raw = "require('gitsigns').toggle_deleted"; }
{ nowait = true; }
]
[
"b"
{ __raw = "require('gitsigns').blame_line"; }
]
[
"B"
{
__raw = ''
function()
gitsigns.blame_line({ full = true })
end,
'';
}
]
[
"/"
{ __raw = "require('gitsigns').show"; }
{ exit = true; }
]
[
"<Enter>"
"<cmd>Neogit<CR>"
{ exit = true; }
]
[
"q"
null
{
exit = true;
nowait = true;
}
]
];
}
];
}

View file

@ -5,7 +5,8 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.illuminate;
mkListStr = helpers.defaultNullOpts.mkNullable (types.listOf types.str);
@ -64,9 +65,11 @@ with lib; let
Filetypes to illuminate, this is overridden by `filetypes_denylist`.
'';
};
in {
options.plugins.illuminate = with helpers;
with defaultNullOpts;
in
{
options.plugins.illuminate =
with helpers;
with defaultNullOpts;
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "vim-illuminate";
@ -75,63 +78,65 @@ in {
filetypeOverrides =
helpers.defaultNullOpts.mkNullable
(with types; attrsOf (submodule {options = commonOptions;}))
"{}"
''
Filetype specific overrides.
The keys are strings to represent the filetype.
'';
(
with types;
attrsOf (submodule {
options = commonOptions;
})
)
"{}"
''
Filetype specific overrides.
The keys are strings to represent the filetype.
'';
largeFileOverrides = mkOption {
type = types.submodule {
options = commonOptions // filetypeOptions;
};
type = types.submodule { options = commonOptions // filetypeOptions; };
description = ''
Config to use for large files (based on large_file_cutoff).
Supports the same keys passed to .configure
If null, illuminate will be disabled for large files.
'';
default = {};
default = { };
};
}
// commonOptions
// filetypeOptions;
config = let
filetypeSetupOptions = filetypeOptions:
with filetypeOptions; {
filetypes_denylist = filetypesDenylist;
filetypes_allowlist = filetypesAllowlist;
};
commonSetupOptions = opts:
with opts; {
inherit providers;
inherit delay;
modes_denylist = modesDenylist;
modes_allowlist = modesAllowlist;
providers_regex_syntax_denylist = providersRegexSyntaxDenylist;
providers_regex_syntax_allowlist = providersRegexSyntaxAllowlist;
under_cursor = underCursor;
large_file_cutoff = largeFileCutoff;
min_count_to_highlight = minCountToHighlight;
};
setupOptions = with cfg;
{
large_file_overrides = (commonSetupOptions largeFileOverrides) // (filetypeSetupOptions largeFileOverrides);
config =
let
filetypeSetupOptions =
filetypeOptions: with filetypeOptions; {
filetypes_denylist = filetypesDenylist;
filetypes_allowlist = filetypesAllowlist;
};
commonSetupOptions =
opts: with opts; {
inherit providers;
inherit delay;
modes_denylist = modesDenylist;
modes_allowlist = modesAllowlist;
providers_regex_syntax_denylist = providersRegexSyntaxDenylist;
providers_regex_syntax_allowlist = providersRegexSyntaxAllowlist;
under_cursor = underCursor;
large_file_cutoff = largeFileCutoff;
min_count_to_highlight = minCountToHighlight;
};
setupOptions =
with cfg;
{
large_file_overrides =
(commonSetupOptions largeFileOverrides) // (filetypeSetupOptions largeFileOverrides);
filetype_overrides =
helpers.ifNonNull' filetypeOverrides
(
mapAttrs
(_: commonSetupOptions)
filetypeOverrides
filetype_overrides = helpers.ifNonNull' filetypeOverrides (
mapAttrs (_: commonSetupOptions) filetypeOverrides
);
}
// (filetypeSetupOptions cfg)
// (commonSetupOptions cfg);
in
}
// (filetypeSetupOptions cfg)
// (commonSetupOptions cfg);
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("illuminate").configure(${helpers.toLuaObject setupOptions})

View file

@ -8,116 +8,123 @@
with lib;
# This plugin is only configured through keymaps, so we use `mkVimPlugin` without the
# `globalPrefix` argument to avoid the creation of the `settings` option.
helpers.vim-plugin.mkVimPlugin config {
name = "improved-search";
originalName = "improved-search.nvim";
defaultPackage = pkgs.vimPlugins.improved-search-nvim;
helpers.vim-plugin.mkVimPlugin config {
name = "improved-search";
originalName = "improved-search.nvim";
defaultPackage = pkgs.vimPlugins.improved-search-nvim;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
extraOptions = {
keymaps = mkOption {
description = ''
Keymap definitions for search functions
extraOptions = {
keymaps = mkOption {
description = ''
Keymap definitions for search functions
See [here](https://github.com/backdround/improved-search.nvim?tab=readme-ov-file#functions-and-operators) for the list of available callbacks.
'';
type = with helpers.nixvimTypes;
listOf (
submodule {
options = {
key = mkOption {
type = str;
description = "The key to map.";
example = "!";
};
See [here](https://github.com/backdround/improved-search.nvim?tab=readme-ov-file#functions-and-operators) for the list of available callbacks.
'';
type =
with helpers.nixvimTypes;
listOf (submodule {
options = {
key = mkOption {
type = str;
description = "The key to map.";
example = "!";
};
mode = helpers.keymaps.mkModeOption "";
mode = helpers.keymaps.mkModeOption "";
action = mkOption {
type = with helpers.nixvimTypes;
maybeRaw (
# https://github.com/backdround/improved-search.nvim?tab=readme-ov-file#functions-and-operators
enum [
"stable_next"
"stable_previous"
"current_word"
"current_word_strict"
"in_place"
"in_place_strict"
"forward"
"forward_strict"
"backward"
"backward_strict"
]
);
description = ''
The action to execute.
action = mkOption {
type =
with helpers.nixvimTypes;
maybeRaw (
# https://github.com/backdround/improved-search.nvim?tab=readme-ov-file#functions-and-operators
enum [
"stable_next"
"stable_previous"
"current_word"
"current_word_strict"
"in_place"
"in_place_strict"
"forward"
"forward_strict"
"backward"
"backward_strict"
]
);
description = ''
The action to execute.
See [here](https://github.com/backdround/improved-search.nvim?tab=readme-ov-file#functions-and-operators) for the list of available callbacks.
'';
example = "in_place";
};
See [here](https://github.com/backdround/improved-search.nvim?tab=readme-ov-file#functions-and-operators) for the list of available callbacks.
'';
example = "in_place";
};
options = helpers.keymaps.mapConfigOptions;
};
}
);
default = [];
example = [
{
mode = ["n" "x" "o"];
key = "n";
action = "stable_next";
}
{
mode = ["n" "x" "o"];
key = "N";
action = "stable_previous";
}
{
mode = "n";
key = "!";
action = "current_word";
options.desc = "Search current word without moving";
}
{
mode = "x";
key = "!";
action = "in_place";
}
{
mode = "x";
key = "*";
action = "forward";
}
{
mode = "x";
key = "#";
action = "backward";
}
{
mode = "n";
key = "|";
action = "in_place";
}
];
};
options = helpers.keymaps.mapConfigOptions;
};
});
default = [ ];
example = [
{
mode = [
"n"
"x"
"o"
];
key = "n";
action = "stable_next";
}
{
mode = [
"n"
"x"
"o"
];
key = "N";
action = "stable_previous";
}
{
mode = "n";
key = "!";
action = "current_word";
options.desc = "Search current word without moving";
}
{
mode = "x";
key = "!";
action = "in_place";
}
{
mode = "x";
key = "*";
action = "forward";
}
{
mode = "x";
key = "#";
action = "backward";
}
{
mode = "n";
key = "|";
action = "in_place";
}
];
};
};
extraConfig = cfg: {
keymaps =
map (
keymap: {
inherit (keymap) key options mode;
action =
if isString keymap.action
# One of the plugin builtin functions
then helpers.mkRaw "require('improved-search').${keymap.action}"
# If the user specifies a raw action directly
else keymap.action;
}
)
cfg.keymaps;
};
}
extraConfig = cfg: {
keymaps = map (keymap: {
inherit (keymap) key options mode;
action =
if
isString keymap.action
# One of the plugin builtin functions
then
helpers.mkRaw "require('improved-search').${keymap.action}"
# If the user specifies a raw action directly
else
keymap.action;
}) cfg.keymaps;
};
}

View file

@ -6,158 +6,227 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "indent-blankline";
originalName = "indent-blankline.nvim";
luaName = "ibl";
defaultPackage = pkgs.vimPlugins.indent-blankline-nvim;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "indent-blankline";
originalName = "indent-blankline.nvim";
luaName = "ibl";
defaultPackage = pkgs.vimPlugins.indent-blankline-nvim;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-03-10: remove 2024-05-10
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"debounce"
["viewportBuffer" "min"]
["viewportBuffer" "max"]
["indent" "char"]
["indent" "tabChar"]
["indent" "highlight"]
["indent" "smartIndentCap"]
["indent" "priority"]
["whitespace" "highlight"]
["whitespace" "removeBlanklineTrail"]
["scope" "enabled"]
["scope" "char"]
["scope" "showStart"]
["scope" "showEnd"]
["scope" "showExactScope"]
["scope" "injectedLanguages"]
["scope" "highlight"]
["scope" "priority"]
["scope" "include" "nodeType"]
["scope" "exclude" "language"]
["scope" "exclude" "nodeType"]
["exclude" "filetypes"]
["exclude" "buftypes"]
];
# TODO introduced 2024-03-10: remove 2024-05-10
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"debounce"
[
"viewportBuffer"
"min"
]
[
"viewportBuffer"
"max"
]
[
"indent"
"char"
]
[
"indent"
"tabChar"
]
[
"indent"
"highlight"
]
[
"indent"
"smartIndentCap"
]
[
"indent"
"priority"
]
[
"whitespace"
"highlight"
]
[
"whitespace"
"removeBlanklineTrail"
]
[
"scope"
"enabled"
]
[
"scope"
"char"
]
[
"scope"
"showStart"
]
[
"scope"
"showEnd"
]
[
"scope"
"showExactScope"
]
[
"scope"
"injectedLanguages"
]
[
"scope"
"highlight"
]
[
"scope"
"priority"
]
[
"scope"
"include"
"nodeType"
]
[
"scope"
"exclude"
"language"
]
[
"scope"
"exclude"
"nodeType"
]
[
"exclude"
"filetypes"
]
[
"exclude"
"buftypes"
]
];
settingsOptions = {
debounce = helpers.defaultNullOpts.mkUnsignedInt 200 ''
Sets the amount indent-blankline debounces refreshes in milliseconds.
settingsOptions = {
debounce = helpers.defaultNullOpts.mkUnsignedInt 200 ''
Sets the amount indent-blankline debounces refreshes in milliseconds.
'';
viewport_buffer = {
min = helpers.defaultNullOpts.mkUnsignedInt 30 ''
Minimum number of lines above and below of what is currently visible in the window for
which indentation guides will be generated.
'';
viewport_buffer = {
min = helpers.defaultNullOpts.mkUnsignedInt 30 ''
Minimum number of lines above and below of what is currently visible in the window for
which indentation guides will be generated.
'';
max = helpers.defaultNullOpts.mkUnsignedInt 500 ''
Maximum number of lines above and below of what is currently visible in the window for
which indentation guides will be generated.
'';
};
max = helpers.defaultNullOpts.mkUnsignedInt 500 ''
Maximum number of lines above and below of what is currently visible in the window for
which indentation guides will be generated.
indent = {
char = helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) "" ''
Character, or list of characters, that get used to display the indentation guide.
Each character has to have a display width of 0 or 1.
'';
tab_char = helpers.mkNullOrOption (with types; either str (listOf str)) ''
Character, or list of characters, that get used to display the indentation guide for tabs.
Each character has to have a display width of 0 or 1.
Default: uses `|lcs-tab|` if `|'list'|` is set, otherwise, uses
`|ibl.config.indent.char|`.
'';
highlight = helpers.mkNullOrOption (with types; either str (listOf str)) ''
Highlight group, or list of highlight groups, that get applied to the indentation guide.
Default: `|hl-IblIndent|`
'';
smart_indent_cap = helpers.defaultNullOpts.mkBool true ''
Caps the number of indentation levels by looking at the surrounding code.
'';
priority = helpers.defaultNullOpts.mkUnsignedInt 1 ''
Virtual text priority for the indentation guide.
'';
};
whitespace = {
highlight = helpers.mkNullOrOption (with types; either str (listOf str)) ''
Highlight group, or list of highlight groups, that get applied to the whitespace.
Default: `|hl-IblWhitespace|`
'';
remove_blankline_trail = helpers.defaultNullOpts.mkBool true ''
Removes trailing whitespace on blanklines.
Turn this off if you want to add background color to the whitespace highlight group.
'';
};
scope = {
enabled = helpers.defaultNullOpts.mkBool true "Enables or disables scope.";
char = helpers.mkNullOrOption (with types; either str (listOf str)) ''
Character, or list of characters, that get used to display the scope indentation guide.
Each character has to have a display width of 0 or 1.
Default: `indent.char`
'';
show_start = helpers.defaultNullOpts.mkBool true ''
Shows an underline on the first line of the scope.
'';
show_end = helpers.defaultNullOpts.mkBool true ''
Shows an underline on the last line of the scope.
'';
show_exact_scope = helpers.defaultNullOpts.mkBool false ''
Shows an underline on the first line of the scope starting at the exact start of the scope
(even if this is to the right of the indent guide) and an underline on the last line of
the scope ending at the exact end of the scope.
'';
injected_languages = helpers.defaultNullOpts.mkBool true ''
Checks for the current scope in injected treesitter languages.
This also influences if the scope gets excluded or not.
'';
highlight = helpers.mkNullOrOption (with types; either str (listOf str)) ''
Highlight group, or list of highlight groups, that get applied to the scope.
Default: `|hl-IblScope|`
'';
priority = helpers.defaultNullOpts.mkUnsignedInt 1024 ''
Virtual text priority for the scope.
'';
include = {
node_type = helpers.defaultNullOpts.mkAttrsOf (with types; listOf str) "{}" ''
Map of language to a list of node types which can be used as scope.
- Use `*` as the language to act as a wildcard for all languages.
- Use `*` as a node type to act as a wildcard for all node types.
'';
};
indent = {
char = helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) "" ''
Character, or list of characters, that get used to display the indentation guide.
Each character has to have a display width of 0 or 1.
exclude = {
language = helpers.defaultNullOpts.mkListOf types.str "[]" ''
List of treesitter languages for which scope is disabled.
'';
tab_char = helpers.mkNullOrOption (with types; either str (listOf str)) ''
Character, or list of characters, that get used to display the indentation guide for tabs.
Each character has to have a display width of 0 or 1.
Default: uses `|lcs-tab|` if `|'list'|` is set, otherwise, uses
`|ibl.config.indent.char|`.
'';
highlight = helpers.mkNullOrOption (with types; either str (listOf str)) ''
Highlight group, or list of highlight groups, that get applied to the indentation guide.
Default: `|hl-IblIndent|`
'';
smart_indent_cap = helpers.defaultNullOpts.mkBool true ''
Caps the number of indentation levels by looking at the surrounding code.
'';
priority = helpers.defaultNullOpts.mkUnsignedInt 1 ''
Virtual text priority for the indentation guide.
'';
};
whitespace = {
highlight = helpers.mkNullOrOption (with types; either str (listOf str)) ''
Highlight group, or list of highlight groups, that get applied to the whitespace.
Default: `|hl-IblWhitespace|`
'';
remove_blankline_trail = helpers.defaultNullOpts.mkBool true ''
Removes trailing whitespace on blanklines.
Turn this off if you want to add background color to the whitespace highlight group.
'';
};
scope = {
enabled = helpers.defaultNullOpts.mkBool true "Enables or disables scope.";
char = helpers.mkNullOrOption (with types; either str (listOf str)) ''
Character, or list of characters, that get used to display the scope indentation guide.
Each character has to have a display width of 0 or 1.
Default: `indent.char`
'';
show_start = helpers.defaultNullOpts.mkBool true ''
Shows an underline on the first line of the scope.
'';
show_end = helpers.defaultNullOpts.mkBool true ''
Shows an underline on the last line of the scope.
'';
show_exact_scope = helpers.defaultNullOpts.mkBool false ''
Shows an underline on the first line of the scope starting at the exact start of the scope
(even if this is to the right of the indent guide) and an underline on the last line of
the scope ending at the exact end of the scope.
'';
injected_languages = helpers.defaultNullOpts.mkBool true ''
Checks for the current scope in injected treesitter languages.
This also influences if the scope gets excluded or not.
'';
highlight = helpers.mkNullOrOption (with types; either str (listOf str)) ''
Highlight group, or list of highlight groups, that get applied to the scope.
Default: `|hl-IblScope|`
'';
priority = helpers.defaultNullOpts.mkUnsignedInt 1024 ''
Virtual text priority for the scope.
'';
include = {
node_type = helpers.defaultNullOpts.mkAttrsOf (with types; listOf str) "{}" ''
Map of language to a list of node types which can be used as scope.
- Use `*` as the language to act as a wildcard for all languages.
- Use `*` as a node type to act as a wildcard for all node types.
'';
};
exclude = {
language = helpers.defaultNullOpts.mkListOf types.str "[]" ''
List of treesitter languages for which scope is disabled.
'';
node_type =
helpers.defaultNullOpts.mkAttrsOf (with types; (listOf str))
node_type =
helpers.defaultNullOpts.mkAttrsOf (with types; (listOf str))
''
{
"*" = ["source_file" "program"];
@ -170,62 +239,59 @@ with lib;
Use `*` as a wildcard for all languages.
'';
};
};
exclude = {
filetypes =
helpers.defaultNullOpts.mkListOf types.str
''
[
"lspinfo"
"packer"
"checkhealth"
"help"
"man"
"gitcommit"
"TelescopePrompt"
"TelescopeResults"
"\'\'"
]
''
"List of filetypes for which indent-blankline is disabled.";
buftypes =
helpers.defaultNullOpts.mkListOf types.str
''
[
"terminal"
"nofile"
"quickfix"
"prompt"
]
''
"List of buftypes for which indent-blankline is disabled.";
};
};
settingsExample = {
indent = {
char = "";
};
scope = {
show_start = false;
show_end = false;
show_exact_scope = true;
};
exclude = {
filetypes = [
""
"checkhealth"
"help"
exclude = {
filetypes = helpers.defaultNullOpts.mkListOf types.str ''
[
"lspinfo"
"packer"
"checkhealth"
"help"
"man"
"gitcommit"
"TelescopePrompt"
"TelescopeResults"
"yaml"
];
buftypes = ["terminal" "quickfix"];
};
"\'\'"
]
'' "List of filetypes for which indent-blankline is disabled.";
buftypes = helpers.defaultNullOpts.mkListOf types.str ''
[
"terminal"
"nofile"
"quickfix"
"prompt"
]
'' "List of buftypes for which indent-blankline is disabled.";
};
}
};
settingsExample = {
indent = {
char = "";
};
scope = {
show_start = false;
show_end = false;
show_exact_scope = true;
};
exclude = {
filetypes = [
""
"checkhealth"
"help"
"lspinfo"
"packer"
"TelescopePrompt"
"TelescopeResults"
"yaml"
];
buftypes = [
"terminal"
"quickfix"
];
};
};
}

View file

@ -6,20 +6,27 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config
{
name = "indent-o-matic";
defaultPackage = pkgs.vimPlugins.indent-o-matic;
maintainers = [helpers.maintainers.alisonjenkins];
settingsOptions = {
max_lines = helpers.defaultNullOpts.mkInt 2048 "Number of lines without indentation before giving up (use -1 for infinite)";
skip_multiline = helpers.defaultNullOpts.mkBool false "Skip multi-line comments and strings (more accurate detection but less performant)";
standard_widths = helpers.defaultNullOpts.mkListOf types.ints.unsigned ''[2 4 8]'' "Space indentations that should be detected";
};
helpers.neovim-plugin.mkNeovimPlugin config {
name = "indent-o-matic";
defaultPackage = pkgs.vimPlugins.indent-o-matic;
maintainers = [ helpers.maintainers.alisonjenkins ];
settingsOptions = {
max_lines =
helpers.defaultNullOpts.mkInt 2048
"Number of lines without indentation before giving up (use -1 for infinite)";
skip_multiline = helpers.defaultNullOpts.mkBool false "Skip multi-line comments and strings (more accurate detection but less performant)";
standard_widths =
helpers.defaultNullOpts.mkListOf types.ints.unsigned ''[2 4 8]''
"Space indentations that should be detected";
};
settingsExample = {
max_lines = 2048;
skip_multiline = false;
standard_widths = [2 4 8];
};
}
settingsExample = {
max_lines = 2048;
skip_multiline = false;
standard_widths = [
2
4
8
];
};
}

View file

@ -7,94 +7,94 @@
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
name = "instant";
originalName = "instant.nvim";
defaultPackage = pkgs.vimPlugins.instant-nvim;
globalPrefix = "instant_";
mkVimPlugin config {
name = "instant";
originalName = "instant.nvim";
defaultPackage = pkgs.vimPlugins.instant-nvim;
globalPrefix = "instant_";
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-03-02: remove 2024-05-02
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"username"
"onlyCwd"
"cursorHlGroupUser1"
"cursorHlGroupUser2"
"cursorHlGroupUser3"
"cursorHlGroupUser4"
"cursorHlGroupDefault"
"nameHlGroupUser1"
"nameHlGroupUser2"
"nameHlGroupUser3"
"nameHlGroupUser4"
"nameHlGroupDefault"
];
# TODO introduced 2024-03-02: remove 2024-05-02
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"username"
"onlyCwd"
"cursorHlGroupUser1"
"cursorHlGroupUser2"
"cursorHlGroupUser3"
"cursorHlGroupUser4"
"cursorHlGroupDefault"
"nameHlGroupUser1"
"nameHlGroupUser2"
"nameHlGroupUser3"
"nameHlGroupUser4"
"nameHlGroupDefault"
];
settingsOptions = {
username = helpers.mkNullOrStr ''
Username.
Explicitly set to `null` if you do not want this option to be set.
'';
settingsOptions = {
username = helpers.mkNullOrStr ''
Username.
Explicitly set to `null` if you do not want this option to be set.
'';
only_cwd = helpers.defaultNullOpts.mkBool true ''
Choose whether to share files only in the current working directory in session mode.
'';
only_cwd = helpers.defaultNullOpts.mkBool true ''
Choose whether to share files only in the current working directory in session mode.
'';
cursor_hl_group_user1 = helpers.defaultNullOpts.mkStr "Cursor" ''
Cursor highlight group for user 1.
'';
cursor_hl_group_user1 = helpers.defaultNullOpts.mkStr "Cursor" ''
Cursor highlight group for user 1.
'';
cursor_hl_group_user2 = helpers.defaultNullOpts.mkStr "Cursor" ''
Cursor highlight group for user 2.
'';
cursor_hl_group_user2 = helpers.defaultNullOpts.mkStr "Cursor" ''
Cursor highlight group for user 2.
'';
cursor_hl_group_user3 = helpers.defaultNullOpts.mkStr "Cursor" ''
Cursor highlight group for user 3.
'';
cursor_hl_group_user3 = helpers.defaultNullOpts.mkStr "Cursor" ''
Cursor highlight group for user 3.
'';
cursor_hl_group_user4 = helpers.defaultNullOpts.mkStr "Cursor" ''
Cursor highlight group for user 4.
'';
cursor_hl_group_user4 = helpers.defaultNullOpts.mkStr "Cursor" ''
Cursor highlight group for user 4.
'';
cursor_hl_group_default = helpers.defaultNullOpts.mkStr "Cursor" ''
Cursor highlight group for any other userr.
'';
cursor_hl_group_default = helpers.defaultNullOpts.mkStr "Cursor" ''
Cursor highlight group for any other userr.
'';
name_hl_group_user1 = helpers.defaultNullOpts.mkStr "CursorLineNr" ''
Virtual text highlight group for user 1.
'';
name_hl_group_user1 = helpers.defaultNullOpts.mkStr "CursorLineNr" ''
Virtual text highlight group for user 1.
'';
name_hl_group_user2 = helpers.defaultNullOpts.mkStr "CursorLineNr" ''
Virtual text highlight group for user 2.
'';
name_hl_group_user2 = helpers.defaultNullOpts.mkStr "CursorLineNr" ''
Virtual text highlight group for user 2.
'';
name_hl_group_user3 = helpers.defaultNullOpts.mkStr "CursorLineNr" ''
Virtual text highlight group for user 3.
'';
name_hl_group_user3 = helpers.defaultNullOpts.mkStr "CursorLineNr" ''
Virtual text highlight group for user 3.
'';
name_hl_group_user4 = helpers.defaultNullOpts.mkStr "CursorLineNr" ''
Virtual text highlight group for user 4.
'';
name_hl_group_user4 = helpers.defaultNullOpts.mkStr "CursorLineNr" ''
Virtual text highlight group for user 4.
'';
name_hl_group_default = helpers.defaultNullOpts.mkStr "CursorLineNr" ''
Virtual text highlight group for any other user.
'';
};
name_hl_group_default = helpers.defaultNullOpts.mkStr "CursorLineNr" ''
Virtual text highlight group for any other user.
'';
};
settingsExample = {
username = "Joe";
onlyCwd = true;
cursor_hl_group_user1 = "Cursor";
cursor_hl_group_user2 = "Cursor";
cursor_hl_group_user3 = "Cursor";
cursor_hl_group_user4 = "Cursor";
cursor_hl_group_default = "Cursor";
name_hl_group_user1 = "CursorLineNr";
name_hl_group_user2 = "CursorLineNr";
name_hl_group_user3 = "CursorLineNr";
name_hl_group_user4 = "CursorLineNr";
name_hl_group_default = "CursorLineNr";
};
}
settingsExample = {
username = "Joe";
onlyCwd = true;
cursor_hl_group_user1 = "Cursor";
cursor_hl_group_user2 = "Cursor";
cursor_hl_group_user3 = "Cursor";
cursor_hl_group_user4 = "Cursor";
cursor_hl_group_default = "Cursor";
name_hl_group_user1 = "CursorLineNr";
name_hl_group_user2 = "CursorLineNr";
name_hl_group_user3 = "CursorLineNr";
name_hl_group_user4 = "CursorLineNr";
name_hl_group_default = "CursorLineNr";
};
}

View file

@ -5,9 +5,11 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.intellitab;
in {
in
{
options = {
plugins.intellitab = {
enable = mkEnableOption "intellitab.nvim";
@ -17,7 +19,7 @@ in {
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
keymaps = [
{

View file

@ -4,46 +4,42 @@
config,
pkgs,
...
}: let
}:
let
cfg = config.plugins.lastplace;
in
with lib; {
options.plugins.lastplace =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "lastplace";
with lib;
{
options.plugins.lastplace = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "lastplace";
package = helpers.mkPackageOption "lastplace" pkgs.vimPlugins.nvim-lastplace;
package = helpers.mkPackageOption "lastplace" pkgs.vimPlugins.nvim-lastplace;
ignoreBuftype =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
''["quickfix" "nofix" "help"]''
"The list of buffer types to ignore by lastplace.";
ignoreBuftype =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["quickfix" "nofix" "help"]''
"The list of buffer types to ignore by lastplace.";
ignoreFiletype =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
''["gitcommit" "gitrebase" "svn" "hgcommit"]''
"The list of file types to ignore by lastplace.";
ignoreFiletype =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
''["gitcommit" "gitrebase" "svn" "hgcommit"]''
"The list of file types to ignore by lastplace.";
openFolds =
helpers.defaultNullOpts.mkBool true
"Whether closed folds are automatically opened when jumping to the last edit position.";
};
openFolds = helpers.defaultNullOpts.mkBool true "Whether closed folds are automatically opened when jumping to the last edit position.";
};
config = let
options =
{
lastplace_ignore_buftype = cfg.ignoreBuftype;
lastplace_ignore_filetype = cfg.ignoreFiletype;
lastplace_open_folds = cfg.openFolds;
}
// cfg.extraOptions;
config =
let
options = {
lastplace_ignore_buftype = cfg.ignoreBuftype;
lastplace_ignore_filetype = cfg.ignoreFiletype;
lastplace_open_folds = cfg.openFolds;
} // cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
mkIf cfg.enable {
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require('nvim-lastplace').setup(${helpers.toLuaObject options})
'';
};
}
extraConfigLua = ''
require('nvim-lastplace').setup(${helpers.toLuaObject options})
'';
};
}

View file

@ -5,56 +5,46 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.leap;
in {
options.plugins.leap =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "leap.nvim";
in
{
options.plugins.leap = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "leap.nvim";
package = helpers.mkPackageOption "leap.nvim" pkgs.vimPlugins.leap-nvim;
package = helpers.mkPackageOption "leap.nvim" pkgs.vimPlugins.leap-nvim;
addDefaultMappings = mkOption {
type = types.bool;
default = true;
description = "Whether to enable the default mappings.";
};
addDefaultMappings = mkOption {
type = types.bool;
default = true;
description = "Whether to enable the default mappings.";
};
maxPhaseOneTargets = helpers.mkNullOrOption types.int ''
By default, the plugin shows labels and/or highlights matches right after the first input
character.
This option disables ahead-of-time displaying of target beacons beyond a certain number of
phase one targets (to mitigate visual noise in extreme cases).
Setting it to 0 disables two-phase processing altogether.
'';
maxPhaseOneTargets = helpers.mkNullOrOption types.int ''
By default, the plugin shows labels and/or highlights matches right after the first input
character.
This option disables ahead-of-time displaying of target beacons beyond a certain number of
phase one targets (to mitigate visual noise in extreme cases).
Setting it to 0 disables two-phase processing altogether.
'';
highlightUnlabeledPhaseOneTargets = helpers.defaultNullOpts.mkBool false ''
Whether to highlight unlabeled (i.e., directly reachable) matches after the first input
character.
'';
highlightUnlabeledPhaseOneTargets = helpers.defaultNullOpts.mkBool false ''
Whether to highlight unlabeled (i.e., directly reachable) matches after the first input
character.
'';
maxHighlightedTraversalTargets = helpers.defaultNullOpts.mkInt 10 ''
Number of targets to be highlighted after the cursor in `|leap-traversal|` mode (when there
are no labels at all).
'';
maxHighlightedTraversalTargets = helpers.defaultNullOpts.mkInt 10 ''
Number of targets to be highlighted after the cursor in `|leap-traversal|` mode (when there
are no labels at all).
'';
caseSensitive = helpers.defaultNullOpts.mkBool false ''
Whether to consider case in search patterns.
'';
caseSensitive = helpers.defaultNullOpts.mkBool false ''
Whether to consider case in search patterns.
'';
equivalenceClasses =
helpers.defaultNullOpts.mkNullable
(
with types;
listOf
(
either
str
(listOf str)
)
)
''[" \t\r\n"]''
equivalenceClasses =
helpers.defaultNullOpts.mkNullable (with types; listOf (either str (listOf str))) ''[" \t\r\n"]''
''
A character will match any other in its equivalence class. The sets can
either be defined as strings or tables.
@ -78,18 +68,17 @@ in {
time.
'';
substituteChars = helpers.defaultNullOpts.mkNullable (with types; attrsOf str) "{}" ''
The keys in this attrs will be substituted in labels and highlighted matches by the given
characters.
This way special (e.g. whitespace) characters can be made visible in matches, or even be
used as labels.
substituteChars = helpers.defaultNullOpts.mkNullable (with types; attrsOf str) "{}" ''
The keys in this attrs will be substituted in labels and highlighted matches by the given
characters.
This way special (e.g. whitespace) characters can be made visible in matches, or even be
used as labels.
Example: `{"\r" = "¬";}`
'';
Example: `{"\r" = "¬";}`
'';
safeLabels =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
safeLabels =
helpers.defaultNullOpts.mkNullable (with types; listOf str)
''["s" "f" "n" "u" "t" "/" "S" "F" "N" "L" "H" "M" "U" "G" "T" "?" "Z"]''
''
When the number of matches does not exceed the number of these "safe" labels plus one, the
@ -103,9 +92,8 @@ in {
target before executing the operation.
'';
labels =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
labels =
helpers.defaultNullOpts.mkNullable (with types; listOf str)
''
[
"s" "f" "n" "j" "k" "l" "h" "o" "d" "w" "e" "m" "b" "u" "y" "v" "r" "g" "t" "c" "x" "/"
@ -122,69 +110,71 @@ in {
In this case, do not forget to set `special_keys.next_group` to something "safe" too.
'';
specialKeys = {
nextTarget = helpers.defaultNullOpts.mkStr "<enter>" ''
Key captured by the plugin at runtime to jump to the next match in traversal mode
(`|leap-traversal|`)
'';
specialKeys = {
nextTarget = helpers.defaultNullOpts.mkStr "<enter>" ''
Key captured by the plugin at runtime to jump to the next match in traversal mode
(`|leap-traversal|`)
'';
prevTarget = helpers.defaultNullOpts.mkStr "<tab>" ''
Key captured by the plugin at runtime to jump to the previous match in traversal mode
(`|leap-traversal|`)
'';
prevTarget = helpers.defaultNullOpts.mkStr "<tab>" ''
Key captured by the plugin at runtime to jump to the previous match in traversal mode
(`|leap-traversal|`)
'';
nextGroup = helpers.defaultNullOpts.mkStr "<space>" ''
Key captured by the plugin at runtime to switch to the next group of matches, when there
are more matches than available labels.
'';
nextGroup = helpers.defaultNullOpts.mkStr "<space>" ''
Key captured by the plugin at runtime to switch to the next group of matches, when there
are more matches than available labels.
'';
prevGroup = helpers.defaultNullOpts.mkStr "<tab>" ''
Key captured by the plugin at runtime to switch to the previous group of matches, when
there are more matches than available labels.
'';
prevGroup = helpers.defaultNullOpts.mkStr "<tab>" ''
Key captured by the plugin at runtime to switch to the previous group of matches, when
there are more matches than available labels.
'';
multiAccept = helpers.defaultNullOpts.mkStr "<enter>" ''
Key captured by the plugin at runtime to accept the selection in `|leap-multiselect|`
mode.
'';
multiAccept = helpers.defaultNullOpts.mkStr "<enter>" ''
Key captured by the plugin at runtime to accept the selection in `|leap-multiselect|`
mode.
'';
multiRevert = helpers.defaultNullOpts.mkStr "<backspace>" ''
Key captured by the plugin at runtime to deselect the last selected target in
`|leap-multiselect|` mode.
'';
};
multiRevert = helpers.defaultNullOpts.mkStr "<backspace>" ''
Key captured by the plugin at runtime to deselect the last selected target in
`|leap-multiselect|` mode.
'';
};
};
config = let
options = with cfg;
{
max_phase_one_targets = maxPhaseOneTargets;
highlight_unlabeled_phase_one_targets = highlightUnlabeledPhaseOneTargets;
max_highlighted_traversal_targets = maxHighlightedTraversalTargets;
case_sensitive = caseSensitive;
equivalence_classes = equivalenceClasses;
substitute_chars = substituteChars;
safe_labels = safeLabels;
inherit labels;
special_keys = with specialKeys; {
next_target = nextTarget;
prev_target = prevTarget;
next_group = nextGroup;
prev_group = prevGroup;
multi_accept = multiAccept;
multi_revert = multiRevert;
};
}
// cfg.extraOptions;
in
config =
let
options =
with cfg;
{
max_phase_one_targets = maxPhaseOneTargets;
highlight_unlabeled_phase_one_targets = highlightUnlabeledPhaseOneTargets;
max_highlighted_traversal_targets = maxHighlightedTraversalTargets;
case_sensitive = caseSensitive;
equivalence_classes = equivalenceClasses;
substitute_chars = substituteChars;
safe_labels = safeLabels;
inherit labels;
special_keys = with specialKeys; {
next_target = nextTarget;
prev_target = prevTarget;
next_group = nextGroup;
prev_group = prevGroup;
multi_accept = multiAccept;
multi_revert = multiRevert;
};
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua =
(optionalString cfg.addDefaultMappings ''
require('leap').add_default_mappings()
'')
+ (optionalString (options != {}) ''
+ (optionalString (options != { }) ''
require('leap').opts = vim.tbl_deep_extend(
"keep",
${helpers.toLuaObject options},

View file

@ -7,83 +7,87 @@
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
name = "magma-nvim";
originalName = "magma-nvim";
defaultPackage = pkgs.vimPlugins.magma-nvim-goose;
globalPrefix = "magma_";
mkVimPlugin config {
name = "magma-nvim";
originalName = "magma-nvim";
defaultPackage = pkgs.vimPlugins.magma-nvim-goose;
globalPrefix = "magma_";
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-03-02: remove 2024-05-02
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"imageProvider"
"automaticallyOpenOutput"
"wrapOutput"
"outputWindowBorders"
"cellHighlightGroup"
"savePath"
"showMimetypeDebug"
];
# TODO introduced 2024-03-02: remove 2024-05-02
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"imageProvider"
"automaticallyOpenOutput"
"wrapOutput"
"outputWindowBorders"
"cellHighlightGroup"
"savePath"
"showMimetypeDebug"
];
settingsOptions = {
image_provider = helpers.defaultNullOpts.mkEnumFirstDefault ["none" "ueberzug" "kitty"] ''
This configures how to display images. The following options are available:
- "none" -- don't show images.
- "ueberzug" -- use Ueberzug to display images.
- "kitty" -- use the Kitty protocol to display images.
'';
automatically_open_output = helpers.defaultNullOpts.mkBool true ''
If this is true, then whenever you have an active cell its output window will be
automatically shown.
If this is false, then the output window will only be automatically shown when you've just
evaluated the code.
So, if you take your cursor out of the cell, and then come back, the output window won't be
opened (but the cell will be highlighted).
This means that there will be nothing covering your code.
You can then open the output window at will using `:MagmaShowOutput`.
'';
wrap_output = helpers.defaultNullOpts.mkBool true ''
If this is true, then text output in the output window will be wrapped (akin to `set wrap`).
'';
output_window_borders = helpers.defaultNullOpts.mkBool true ''
If this is true, then the output window will have rounded borders.
If it is false, it will have no borders.
'';
cell_highlight_group = helpers.defaultNullOpts.mkStr "CursorLine" ''
The highlight group to be used for highlighting cells.
'';
save_path =
helpers.defaultNullOpts.mkStr
''{__raw = "vim.fn.stdpath('data') .. '/magma'";}''
settingsOptions = {
image_provider =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"none"
"ueberzug"
"kitty"
]
''
Where to save/load with `:MagmaSave` and `:MagmaLoad` (with no parameters).
The generated file is placed in this directory, with the filename itself being the
buffer's name, with `%` replaced by `%%` and `/` replaced by `%`, and postfixed with the
extension `.json`.
This configures how to display images. The following options are available:
- "none" -- don't show images.
- "ueberzug" -- use Ueberzug to display images.
- "kitty" -- use the Kitty protocol to display images.
'';
show_mimetype_debug = helpers.defaultNullOpts.mkBool false ''
If this is true, then before any non-iostream output chunk, Magma shows the mimetypes it
received for it.
This is meant for debugging and adding new mimetypes.
'';
};
automatically_open_output = helpers.defaultNullOpts.mkBool true ''
If this is true, then whenever you have an active cell its output window will be
automatically shown.
settingsExample = {
image_provider = "none";
automatically_open_output = true;
wrap_output = true;
output_window_borders = true;
cell_highlight_group = "CursorLine";
save_path.__raw = "vim.fn.stdpath('data') .. '/magma'";
show_mimetype_debug = false;
};
}
If this is false, then the output window will only be automatically shown when you've just
evaluated the code.
So, if you take your cursor out of the cell, and then come back, the output window won't be
opened (but the cell will be highlighted).
This means that there will be nothing covering your code.
You can then open the output window at will using `:MagmaShowOutput`.
'';
wrap_output = helpers.defaultNullOpts.mkBool true ''
If this is true, then text output in the output window will be wrapped (akin to `set wrap`).
'';
output_window_borders = helpers.defaultNullOpts.mkBool true ''
If this is true, then the output window will have rounded borders.
If it is false, it will have no borders.
'';
cell_highlight_group = helpers.defaultNullOpts.mkStr "CursorLine" ''
The highlight group to be used for highlighting cells.
'';
save_path = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.stdpath('data') .. '/magma'";}'' ''
Where to save/load with `:MagmaSave` and `:MagmaLoad` (with no parameters).
The generated file is placed in this directory, with the filename itself being the
buffer's name, with `%` replaced by `%%` and `/` replaced by `%`, and postfixed with the
extension `.json`.
'';
show_mimetype_debug = helpers.defaultNullOpts.mkBool false ''
If this is true, then before any non-iostream output chunk, Magma shows the mimetypes it
received for it.
This is meant for debugging and adding new mimetypes.
'';
};
settingsExample = {
image_provider = "none";
automatically_open_output = true;
wrap_output = true;
output_window_borders = true;
cell_highlight_group = "CursorLine";
save_path.__raw = "vim.fn.stdpath('data') .. '/magma'";
show_mimetype_debug = false;
};
}

View file

@ -5,45 +5,36 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.mark-radar;
in {
options.plugins.mark-radar =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "mark-radar";
in
{
options.plugins.mark-radar = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "mark-radar";
package = helpers.mkPackageOption "mark-radar" pkgs.vimPlugins.mark-radar-nvim;
package = helpers.mkPackageOption "mark-radar" pkgs.vimPlugins.mark-radar-nvim;
setDefaultMappings =
helpers.defaultNullOpts.mkBool true
"Whether to set default mappings.";
setDefaultMappings = helpers.defaultNullOpts.mkBool true "Whether to set default mappings.";
highlightGroup =
helpers.defaultNullOpts.mkStr "RadarMark"
"The name of the highlight group to use.";
highlightGroup = helpers.defaultNullOpts.mkStr "RadarMark" "The name of the highlight group to use.";
backgroundHighlight =
helpers.defaultNullOpts.mkBool true
"Whether to highlight the background.";
backgroundHighlight = helpers.defaultNullOpts.mkBool true "Whether to highlight the background.";
backgroundHighlightGroup =
helpers.defaultNullOpts.mkStr "RadarBackground"
"The name of the highlight group to use for the background.";
};
backgroundHighlightGroup = helpers.defaultNullOpts.mkStr "RadarBackground" "The name of the highlight group to use for the background.";
};
config = let
setupOptions =
{
config =
let
setupOptions = {
set_default_mappings = cfg.setDefaultMappings;
highlight_group = cfg.highlightGroup;
background_highlight = cfg.backgroundHighlight;
background_highlight_group = cfg.backgroundHighlightGroup;
}
// cfg.extraOptions;
in
} // cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("mark-radar").setup(${helpers.toLuaObject setupOptions})

View file

@ -5,75 +5,78 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.marks;
in {
meta.maintainers = [maintainers.GaetanLepage];
in
{
meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.marks =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "marks.nvim";
options.plugins.marks = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "marks.nvim";
package = helpers.mkPackageOption "marks.nvim" pkgs.vimPlugins.marks-nvim;
package = helpers.mkPackageOption "marks.nvim" pkgs.vimPlugins.marks-nvim;
builtinMarks = helpers.defaultNullOpts.mkListOf (types.enum ["'" "^" "." "<" ">"]) "[]" ''
Which builtin marks to track and show. If set, these marks will also show up in the
signcolumn and will update on `|CursorMoved|`.
'';
builtinMarks =
helpers.defaultNullOpts.mkListOf
(types.enum [
"'"
"^"
"."
"<"
">"
])
"[]"
''
Which builtin marks to track and show. If set, these marks will also show up in the
signcolumn and will update on `|CursorMoved|`.
'';
defaultMappings = helpers.defaultNullOpts.mkBool true ''
Whether to use the default plugin mappings or not.
See `|marks-mappings|` for more.
'';
defaultMappings = helpers.defaultNullOpts.mkBool true ''
Whether to use the default plugin mappings or not.
See `|marks-mappings|` for more.
'';
signs = helpers.defaultNullOpts.mkBool true ''
Whether to show marks in the signcolumn or not.
If set to true, its recommended to also set `|signcolumn|` to "auto", for cases where
multiple marks are placed on the same line.
'';
signs = helpers.defaultNullOpts.mkBool true ''
Whether to show marks in the signcolumn or not.
If set to true, its recommended to also set `|signcolumn|` to "auto", for cases where
multiple marks are placed on the same line.
'';
cyclic = helpers.defaultNullOpts.mkBool true ''
Whether forward/backwards movement should cycle back to the beginning/end of buffer.
'';
cyclic = helpers.defaultNullOpts.mkBool true ''
Whether forward/backwards movement should cycle back to the beginning/end of buffer.
'';
forceWriteShada = helpers.defaultNullOpts.mkBool false ''
If true, then deleting global (uppercase) marks will also update the `|shada|` file
accordingly and force deletion of the mark permanently.
This option can be destructive and should be set only after reading more about the shada
file.
'';
forceWriteShada = helpers.defaultNullOpts.mkBool false ''
If true, then deleting global (uppercase) marks will also update the `|shada|` file
accordingly and force deletion of the mark permanently.
This option can be destructive and should be set only after reading more about the shada
file.
'';
refreshInterval = helpers.defaultNullOpts.mkUnsignedInt 150 ''
How often (in ms) `marks.nvim` should update the marks list and recompute mark
positions/redraw signs.
Lower values means that mark positions and signs will refresh much quicker, but may incur a
higher performance penalty, whereas higher values may result in better performance, but may
also cause noticeable lag in signs updating.
'';
refreshInterval = helpers.defaultNullOpts.mkUnsignedInt 150 ''
How often (in ms) `marks.nvim` should update the marks list and recompute mark
positions/redraw signs.
Lower values means that mark positions and signs will refresh much quicker, but may incur a
higher performance penalty, whereas higher values may result in better performance, but may
also cause noticeable lag in signs updating.
'';
signPriority =
helpers.defaultNullOpts.mkNullable
signPriority =
helpers.defaultNullOpts.mkNullable
(
with types;
either
ints.unsigned
(submodule {
freeformType = attrs;
options =
mapAttrs
(
name: desc:
helpers.mkNullOrOption ints.unsigned "Sign priority for ${desc}."
)
{
lower = "lowercase marks";
upper = "uppercase marks";
builtin = "builtin marks";
bookmark = "bookmarks";
};
})
) "10"
either ints.unsigned (submodule {
freeformType = attrs;
options = mapAttrs (name: desc: helpers.mkNullOrOption ints.unsigned "Sign priority for ${desc}.") {
lower = "lowercase marks";
upper = "uppercase marks";
builtin = "builtin marks";
bookmark = "bookmarks";
};
})
)
"10"
''
The sign priority to be used for marks.
Can either be a number, in which case the priority applies to all types of marks, or a
@ -85,64 +88,64 @@ in {
- bookmark: sign priority for bookmarks
'';
excludedFiletypes = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Which filetypes to ignore.
If a buffer with this filetype is opened, then `marks.nvim` will not track any marks set in
this buffer, and will not display any signs.
Setting and moving to marks with ` or ' will still work, but movement commands like "m]" or
"m[" will not.
'';
excludedFiletypes = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Which filetypes to ignore.
If a buffer with this filetype is opened, then `marks.nvim` will not track any marks set in
this buffer, and will not display any signs.
Setting and moving to marks with ` or ' will still work, but movement commands like "m]" or
"m[" will not.
'';
excludedBuftypes = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Which buftypes to ignore.
If a buffer with this buftype is opened, then `marks.nvim` will not track any marks set in
this buffer, and will not display any signs.
Setting and moving to marks with ` or ' will still work, but movement commands like "m]" or
"m[" will not.
'';
excludedBuftypes = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Which buftypes to ignore.
If a buffer with this buftype is opened, then `marks.nvim` will not track any marks set in
this buffer, and will not display any signs.
Setting and moving to marks with ` or ' will still work, but movement commands like "m]" or
"m[" will not.
'';
bookmarks = mkOption {
description = "Configuration table for each bookmark group (see `|marks-bookmarks|`).";
type = with types;
attrsOf (
submodule {
options = {
sign = helpers.mkNullOrOption (either str (enum [false])) ''
The character to use in the signcolumn for this bookmark group.
bookmarks = mkOption {
description = "Configuration table for each bookmark group (see `|marks-bookmarks|`).";
type =
with types;
attrsOf (submodule {
options = {
sign = helpers.mkNullOrOption (either str (enum [ false ])) ''
The character to use in the signcolumn for this bookmark group.
Defaults to "!@#$%^&*()" - in order from group 1 to 10.
Set to `false` to turn off signs for this bookmark.
'';
Defaults to "!@#$%^&*()" - in order from group 1 to 10.
Set to `false` to turn off signs for this bookmark.
'';
virtText = helpers.mkNullOrOption str ''
Virtual text annotations to place at the eol of a bookmark.
Defaults to `null`, meaning no virtual text.
'';
virtText = helpers.mkNullOrOption str ''
Virtual text annotations to place at the eol of a bookmark.
Defaults to `null`, meaning no virtual text.
'';
annotate = helpers.defaultNullOpts.mkBool false ''
When true, explicitly prompts the user for an annotation that will be displayed
above the bookmark.
'';
};
}
);
default = {};
apply = mapAttrs (_: v:
with v; {
inherit sign;
virt_text = virtText;
inherit annotate;
});
};
mappings = helpers.defaultNullOpts.mkAttrsOf (with types; either str (enum [false])) "{}" ''
Custom mappings.
Set a mapping to `false` to disable it.
'';
annotate = helpers.defaultNullOpts.mkBool false ''
When true, explicitly prompts the user for an annotation that will be displayed
above the bookmark.
'';
};
});
default = { };
apply = mapAttrs (
_: v: with v; {
inherit sign;
virt_text = virtText;
inherit annotate;
}
);
};
mappings = helpers.defaultNullOpts.mkAttrsOf (with types; either str (enum [ false ])) "{}" ''
Custom mappings.
Set a mapping to `false` to disable it.
'';
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
assertions = [
{
@ -153,34 +156,30 @@ in {
}
];
extraConfigLua = let
bookmarks =
mapAttrs'
(
bookmarkNumber: bookmarkOptions:
nameValuePair "bookmark_${bookmarkNumber}" bookmarkOptions
)
cfg.bookmarks;
extraConfigLua =
let
bookmarks = mapAttrs' (
bookmarkNumber: bookmarkOptions: nameValuePair "bookmark_${bookmarkNumber}" bookmarkOptions
) cfg.bookmarks;
setupOptions = with cfg;
{
builtin_marks = builtinMarks;
default_mappings = defaultMappings;
inherit
signs
cyclic
;
force_write_shada = forceWriteShada;
refresh_interval = refreshInterval;
sign_priority = signPriority;
excluded_filetypes = excludedFiletypes;
excluded_buftypes = excludedBuftypes;
inherit mappings;
}
// bookmarks
// cfg.extraOptions;
in ''
require('marks').setup(${helpers.toLuaObject setupOptions})
'';
setupOptions =
with cfg;
{
builtin_marks = builtinMarks;
default_mappings = defaultMappings;
inherit signs cyclic;
force_write_shada = forceWriteShada;
refresh_interval = refreshInterval;
sign_priority = signPriority;
excluded_filetypes = excludedFiletypes;
excluded_buftypes = excludedBuftypes;
inherit mappings;
}
// bookmarks
// cfg.extraOptions;
in
''
require('marks').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -5,9 +5,11 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.mini;
in {
in
{
options.plugins.mini = {
enable = mkEnableOption "mini.nvim";
@ -15,7 +17,7 @@ in {
modules = mkOption {
type = with types; attrsOf attrs;
default = {};
default = { };
description = ''
Enable and configure the mini modules.
The keys are the names of the modules (without the `mini.` prefix).
@ -27,22 +29,18 @@ in {
n_lines = 50;
search_method = "cover_or_next";
};
surround = {};
surround = { };
};
};
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua =
concatLines
(
mapAttrsToList
(
name: config: "require('mini.${name}').setup(${helpers.toLuaObject config})"
)
cfg.modules
);
extraConfigLua = concatLines (
mapAttrsToList (
name: config: "require('mini.${name}').setup(${helpers.toLuaObject config})"
) cfg.modules
);
};
}

View file

@ -5,24 +5,24 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.mkdnflow;
in {
options.plugins.mkdnflow =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "mkdnflow.nvim";
in
{
options.plugins.mkdnflow = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "mkdnflow.nvim";
package = helpers.mkPackageOption "mkdnflow.nvim" pkgs.vimPlugins.mkdnflow-nvim;
package = helpers.mkPackageOption "mkdnflow.nvim" pkgs.vimPlugins.mkdnflow-nvim;
modules =
mapAttrs
modules =
mapAttrs
(
moduleName: metadata:
helpers.defaultNullOpts.mkBool metadata.default ''
Enable module ${moduleName}.
${metadata.description}
''
helpers.defaultNullOpts.mkBool metadata.default ''
Enable module ${moduleName}.
${metadata.description}
''
)
{
bib = {
@ -78,9 +78,8 @@ in {
};
};
filetypes =
helpers.defaultNullOpts.mkNullable
(with types; attrsOf bool)
filetypes =
helpers.defaultNullOpts.mkNullable (with types; attrsOf bool)
"{md = true; rmd = true; markdown = true;}"
''
A matching extension will enable the plugin's functionality for a file with that
@ -94,153 +93,166 @@ in {
Setting an extension to `false` is the same as not including it in the list.
'';
createDirs = helpers.defaultNullOpts.mkBool true ''
- `true`: Directories referenced in a link will be (recursively) created if they do not
exist.
- `false`: No action will be taken when directories referenced in a link do not exist.
Neovim will open a new file, but you will get an error when you attempt to write the
file.
'';
createDirs = helpers.defaultNullOpts.mkBool true ''
- `true`: Directories referenced in a link will be (recursively) created if they do not
exist.
- `false`: No action will be taken when directories referenced in a link do not exist.
Neovim will open a new file, but you will get an error when you attempt to write the
file.
'';
perspective = {
priority = helpers.defaultNullOpts.mkEnumFirstDefault ["first" "current" "root"] ''
Specifies the priority perspective to take when interpreting link paths
- `first` (default): Links will be interpreted relative to the first-opened file (when
the current instance of Neovim was started)
- `current`: Links will be interpreted relative to the current file
- `root`: Links will be interpreted relative to the root directory of the current
notebook (requires `perspective.root_tell` to be specified)
'';
fallback = helpers.defaultNullOpts.mkEnumFirstDefault ["first" "current" "root"] ''
Specifies the backup perspective to take if priority isn't possible (e.g. if it is
`root` but no root directory is found).
- `first` (default): Links will be interpreted relative to the first-opened file (when
the current instance of Neovim was started)
- `current`: Links will be interpreted relative to the current file
- `root`: Links will be interpreted relative to the root directory of the current
notebook (requires `perspective.root_tell` to be specified)
'';
rootTell =
helpers.defaultNullOpts.mkNullable
(with types; either (enum [false]) str)
"false"
perspective = {
priority =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"first"
"current"
"root"
]
''
- `<any file name>`: Any arbitrary filename by which the plugin can uniquely identify
the root directory of the current notebook.
- If `false` is used instead, the plugin will never search for a root directory, even
if `perspective.priority` is set to `root`.
Specifies the priority perspective to take when interpreting link paths
- `first` (default): Links will be interpreted relative to the first-opened file (when
the current instance of Neovim was started)
- `current`: Links will be interpreted relative to the current file
- `root`: Links will be interpreted relative to the root directory of the current
notebook (requires `perspective.root_tell` to be specified)
'';
nvimWdHeel = helpers.defaultNullOpts.mkBool false ''
Specifies whether changes in perspective will result in corresponding changes to
Neovim's working directory.
- `true`: Changes in perspective will be reflected in the nvim working directory.
(In other words, the working directory will "heel" to the plugin's perspective.)
This helps ensure (at least) that path completions (if using a completion plugin with
support for paths) will be accurate and usable.
- `false` (default): Neovim's working directory will not be affected by Mkdnflow.
'';
update = helpers.defaultNullOpts.mkBool true ''
Determines whether the plugin looks to determine if a followed link is in a different
notebook/wiki than before.
If it is, the perspective will be updated.
Requires `rootTell` to be defined and `priority` to be `root`.
- `true` (default): Perspective will be updated when following a link to a file in a
separate notebook/wiki (or navigating backwards to a file in another notebook/wiki).
- `false`: Perspective will be not updated when following a link to a file in a separate
notebook/wiki.
Under the hood, links in the file in the separate notebook/wiki will be interpreted
relative to the original notebook/wiki.
'';
};
wrap = helpers.defaultNullOpts.mkBool false ''
- `true`: When jumping to next/previous links or headings, the cursor will continue
searching at the beginning/end of the file.
- `false`: When jumping to next/previous links or headings, the cursor will stop searching
at the end/beginning of the file.
'';
bib = {
defaultPath = helpers.mkNullOrOption types.str ''
Specifies a path to a default `.bib` file to look for citation keys in (need not be in
root directory of notebook).
'';
findInRoot = helpers.defaultNullOpts.mkBool true ''
- `true`: When `perspective.priority` is also set to `root` (and a root directory was
found), the plugin will search for bib files to reference in the notebook's top-level
directory.
If `bib.default_path` is also specified, the default path will be appended to the list
of bib files found in the top level directory so that it will also be searched.
- `false`: The notebook's root directory will not be searched for bib files.
'';
};
silent = helpers.defaultNullOpts.mkBool false ''
- `true`: The plugin will not display any messages in the console except compatibility
warnings related to your config.
- `false`: The plugin will display messages to the console (all messages from the plugin
start with ).
'';
links = {
style = helpers.defaultNullOpts.mkEnumFirstDefault ["markdown" "wiki"] ''
- `markdown`: Links will be expected in the standard markdown format:
`[<title>](<source>)`
- `wiki`: Links will be expected in the unofficial wiki-link style, specifically the
title-after-pipe format (see https://github.com/jgm/pandoc/pull/7705):
`[[<source>|<title>]]`.
'';
conceal = helpers.defaultNullOpts.mkBool false ''
- `true`: Link sources and delimiters will be concealed (depending on which link style
is selected)
- `false`: Link sources and delimiters will not be concealed by mkdnflow
'';
context = helpers.defaultNullOpts.mkInt 0 ''
- `0` (default): When following or jumping to links, assume that no link will be split
over multiple lines
- `n`: When following or jumping to links, consider `n` lines before and after a given
line (useful if you ever permit links to be interrupted by a hard line break)
'';
implicitExtension = helpers.mkNullOrOption types.str ''
A string that instructs the plugin (a) how to interpret links to files that do not have
an extension, and (b) that new links should be created without an explicit extension.
'';
transformExplicit =
helpers.defaultNullOpts.mkStrLuaFnOr (types.enum [false])
"false"
fallback =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"first"
"current"
"root"
]
''
A function that transforms the text to be inserted as the source/path of a link when a
link is created.
Anchor links are not currently customizable.
If you want all link paths to be explicitly prefixed with the year, for instance, and
for the path to be converted to uppercase, you could provide the following function
under this key.
(NOTE: The previous functionality specified under the `prefix` key has been migrated
here to provide greater flexibility.)
Specifies the backup perspective to take if priority isn't possible (e.g. if it is
`root` but no root directory is found).
Example:
```lua
function(input)
return(string.upper(os.date('%Y-')..input))
end
```
- `first` (default): Links will be interpreted relative to the first-opened file (when
the current instance of Neovim was started)
- `current`: Links will be interpreted relative to the current file
- `root`: Links will be interpreted relative to the root directory of the current
notebook (requires `perspective.root_tell` to be specified)
'';
transformImplicit =
helpers.defaultNullOpts.mkStrLuaFnOr (types.enum [false])
rootTell = helpers.defaultNullOpts.mkNullable (with types; either (enum [ false ]) str) "false" ''
- `<any file name>`: Any arbitrary filename by which the plugin can uniquely identify
the root directory of the current notebook.
- If `false` is used instead, the plugin will never search for a root directory, even
if `perspective.priority` is set to `root`.
'';
nvimWdHeel = helpers.defaultNullOpts.mkBool false ''
Specifies whether changes in perspective will result in corresponding changes to
Neovim's working directory.
- `true`: Changes in perspective will be reflected in the nvim working directory.
(In other words, the working directory will "heel" to the plugin's perspective.)
This helps ensure (at least) that path completions (if using a completion plugin with
support for paths) will be accurate and usable.
- `false` (default): Neovim's working directory will not be affected by Mkdnflow.
'';
update = helpers.defaultNullOpts.mkBool true ''
Determines whether the plugin looks to determine if a followed link is in a different
notebook/wiki than before.
If it is, the perspective will be updated.
Requires `rootTell` to be defined and `priority` to be `root`.
- `true` (default): Perspective will be updated when following a link to a file in a
separate notebook/wiki (or navigating backwards to a file in another notebook/wiki).
- `false`: Perspective will be not updated when following a link to a file in a separate
notebook/wiki.
Under the hood, links in the file in the separate notebook/wiki will be interpreted
relative to the original notebook/wiki.
'';
};
wrap = helpers.defaultNullOpts.mkBool false ''
- `true`: When jumping to next/previous links or headings, the cursor will continue
searching at the beginning/end of the file.
- `false`: When jumping to next/previous links or headings, the cursor will stop searching
at the end/beginning of the file.
'';
bib = {
defaultPath = helpers.mkNullOrOption types.str ''
Specifies a path to a default `.bib` file to look for citation keys in (need not be in
root directory of notebook).
'';
findInRoot = helpers.defaultNullOpts.mkBool true ''
- `true`: When `perspective.priority` is also set to `root` (and a root directory was
found), the plugin will search for bib files to reference in the notebook's top-level
directory.
If `bib.default_path` is also specified, the default path will be appended to the list
of bib files found in the top level directory so that it will also be searched.
- `false`: The notebook's root directory will not be searched for bib files.
'';
};
silent = helpers.defaultNullOpts.mkBool false ''
- `true`: The plugin will not display any messages in the console except compatibility
warnings related to your config.
- `false`: The plugin will display messages to the console (all messages from the plugin
start with ).
'';
links = {
style =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"markdown"
"wiki"
]
''
- `markdown`: Links will be expected in the standard markdown format:
`[<title>](<source>)`
- `wiki`: Links will be expected in the unofficial wiki-link style, specifically the
title-after-pipe format (see https://github.com/jgm/pandoc/pull/7705):
`[[<source>|<title>]]`.
'';
conceal = helpers.defaultNullOpts.mkBool false ''
- `true`: Link sources and delimiters will be concealed (depending on which link style
is selected)
- `false`: Link sources and delimiters will not be concealed by mkdnflow
'';
context = helpers.defaultNullOpts.mkInt 0 ''
- `0` (default): When following or jumping to links, assume that no link will be split
over multiple lines
- `n`: When following or jumping to links, consider `n` lines before and after a given
line (useful if you ever permit links to be interrupted by a hard line break)
'';
implicitExtension = helpers.mkNullOrOption types.str ''
A string that instructs the plugin (a) how to interpret links to files that do not have
an extension, and (b) that new links should be created without an explicit extension.
'';
transformExplicit = helpers.defaultNullOpts.mkStrLuaFnOr (types.enum [ false ]) "false" ''
A function that transforms the text to be inserted as the source/path of a link when a
link is created.
Anchor links are not currently customizable.
If you want all link paths to be explicitly prefixed with the year, for instance, and
for the path to be converted to uppercase, you could provide the following function
under this key.
(NOTE: The previous functionality specified under the `prefix` key has been migrated
here to provide greater flexibility.)
Example:
```lua
function(input)
return(string.upper(os.date('%Y-')..input))
end
```
'';
transformImplicit =
helpers.defaultNullOpts.mkStrLuaFnOr (types.enum [ false ])
''
function(text)
text = text:gsub(" ", "-")
@ -267,145 +279,145 @@ in {
end
```
'';
};
};
toDo = {
symbols = helpers.defaultNullOpts.mkNullable (with types; listOf str) ''[" " "-" "X"]'' ''
A list of symbols (each no more than one character) that represent to-do list completion
statuses.
`MkdnToggleToDo` references these when toggling the status of a to-do item.
Three are expected: one representing not-yet-started to-dos (default: `' '`), one
representing in-progress to-dos (default: `-`), and one representing complete to-dos
(default: `X`).
toDo = {
symbols = helpers.defaultNullOpts.mkNullable (with types; listOf str) ''[" " "-" "X"]'' ''
A list of symbols (each no more than one character) that represent to-do list completion
statuses.
`MkdnToggleToDo` references these when toggling the status of a to-do item.
Three are expected: one representing not-yet-started to-dos (default: `' '`), one
representing in-progress to-dos (default: `-`), and one representing complete to-dos
(default: `X`).
NOTE: Native Lua support for UTF-8 characters is limited, so in order to ensure all
functionality works as intended if you are using non-ascii to-do symbols, you'll need to
install the luarocks module "luautf8".
'';
NOTE: Native Lua support for UTF-8 characters is limited, so in order to ensure all
functionality works as intended if you are using non-ascii to-do symbols, you'll need to
install the luarocks module "luautf8".
'';
updateParents = helpers.defaultNullOpts.mkBool true ''
Whether parent to-dos' statuses should be updated based on child to-do status changes
performed via `MkdnToggleToDo`
updateParents = helpers.defaultNullOpts.mkBool true ''
Whether parent to-dos' statuses should be updated based on child to-do status changes
performed via `MkdnToggleToDo`
- `true` (default): Parent to-do statuses will be inferred and automatically updated
when a child to-do's status is changed
- `false`: To-do items can be toggled, but parent to-do statuses (if any) will not be
automatically changed
'';
- `true` (default): Parent to-do statuses will be inferred and automatically updated
when a child to-do's status is changed
- `false`: To-do items can be toggled, but parent to-do statuses (if any) will not be
automatically changed
'';
notStarted = helpers.defaultNullOpts.mkStr " " ''
This option can be used to stipulate which symbols shall be used when updating a parent
to-do's status when a child to-do's status is changed.
This is **not required**: if `toDo.symbols` is customized but this option is not
provided, the plugin will attempt to infer what the meanings of the symbols in your list
are by their order.
notStarted = helpers.defaultNullOpts.mkStr " " ''
This option can be used to stipulate which symbols shall be used when updating a parent
to-do's status when a child to-do's status is changed.
This is **not required**: if `toDo.symbols` is customized but this option is not
provided, the plugin will attempt to infer what the meanings of the symbols in your list
are by their order.
For example, if you set `toDo.symbols` as `[" " "" ""]`, `" "` will be assigned to
`toDo.notStarted`, "" will be assigned to `toDo.inProgress`, etc.
If more than three symbols are specified, the first will be used as `notStarted`, the
second will be used as `inProgress`, and the last will be used as `complete`.
If two symbols are provided (e.g. `" ", ""`), the first will be used as both
`notStarted` and `inProgress`, and the second will be used as `complete`.
For example, if you set `toDo.symbols` as `[" " "" ""]`, `" "` will be assigned to
`toDo.notStarted`, "" will be assigned to `toDo.inProgress`, etc.
If more than three symbols are specified, the first will be used as `notStarted`, the
second will be used as `inProgress`, and the last will be used as `complete`.
If two symbols are provided (e.g. `" ", ""`), the first will be used as both
`notStarted` and `inProgress`, and the second will be used as `complete`.
`toDo.notStarted` stipulates which symbol represents a not-yet-started to-do.
'';
`toDo.notStarted` stipulates which symbol represents a not-yet-started to-do.
'';
inProgress = helpers.defaultNullOpts.mkStr "-" ''
This option can be used to stipulate which symbols shall be used when updating a parent
to-do's status when a child to-do's status is changed.
This is **not required**: if `toDo.symbols` is customized but this option is not
provided, the plugin will attempt to infer what the meanings of the symbols in your list
are by their order.
inProgress = helpers.defaultNullOpts.mkStr "-" ''
This option can be used to stipulate which symbols shall be used when updating a parent
to-do's status when a child to-do's status is changed.
This is **not required**: if `toDo.symbols` is customized but this option is not
provided, the plugin will attempt to infer what the meanings of the symbols in your list
are by their order.
For example, if you set `toDo.symbols` as `[" " "" ""]`, `" "` will be assigned to
`toDo.notStarted`, "" will be assigned to `toDo.inProgress`, etc.
If more than three symbols are specified, the first will be used as `notStarted`, the
second will be used as `inProgress`, and the last will be used as `complete`.
If two symbols are provided (e.g. `" ", ""`), the first will be used as both
`notStarted` and `inProgress`, and the second will be used as `complete`.
For example, if you set `toDo.symbols` as `[" " "" ""]`, `" "` will be assigned to
`toDo.notStarted`, "" will be assigned to `toDo.inProgress`, etc.
If more than three symbols are specified, the first will be used as `notStarted`, the
second will be used as `inProgress`, and the last will be used as `complete`.
If two symbols are provided (e.g. `" ", ""`), the first will be used as both
`notStarted` and `inProgress`, and the second will be used as `complete`.
`toDo.inProgress` stipulates which symbol represents an in-progress to-do.
'';
`toDo.inProgress` stipulates which symbol represents an in-progress to-do.
'';
complete = helpers.defaultNullOpts.mkStr "X" ''
This option can be used to stipulate which symbols shall be used when updating a parent
to-do's status when a child to-do's status is changed.
This is **not required**: if `toDo.symbols` is customized but this option is not
provided, the plugin will attempt to infer what the meanings of the symbols in your list
are by their order.
complete = helpers.defaultNullOpts.mkStr "X" ''
This option can be used to stipulate which symbols shall be used when updating a parent
to-do's status when a child to-do's status is changed.
This is **not required**: if `toDo.symbols` is customized but this option is not
provided, the plugin will attempt to infer what the meanings of the symbols in your list
are by their order.
For example, if you set `toDo.symbols` as `[" " "" ""]`, `" "` will be assigned to
`toDo.notStarted`, "" will be assigned to `toDo.inProgress`, etc.
If more than three symbols are specified, the first will be used as `notStarted`, the
second will be used as `inProgress`, and the last will be used as `complete`.
If two symbols are provided (e.g. `" ", ""`), the first will be used as both
`notStarted` and `inProgress`, and the second will be used as `complete`.
For example, if you set `toDo.symbols` as `[" " "" ""]`, `" "` will be assigned to
`toDo.notStarted`, "" will be assigned to `toDo.inProgress`, etc.
If more than three symbols are specified, the first will be used as `notStarted`, the
second will be used as `inProgress`, and the last will be used as `complete`.
If two symbols are provided (e.g. `" ", ""`), the first will be used as both
`notStarted` and `inProgress`, and the second will be used as `complete`.
`toDo.complete` stipulates which symbol represents a complete to-do.
`toDo.complete` stipulates which symbol represents a complete to-do.
'';
};
tables = {
trimWhitespace = helpers.defaultNullOpts.mkBool true ''
Whether extra whitespace should be trimmed from the end of a table cell when a table is
formatted.
'';
formatOnMove = helpers.defaultNullOpts.mkBool true ''
Whether tables should be formatted each time the cursor is moved via
`MkdnTableNext/PrevCell` or `MkdnTableNext/Prev/Row`.
'';
autoExtendRows = helpers.defaultNullOpts.mkBool false ''
Whether a new row should automatically be added to a table when `:MkdnTableNextRow` is
triggered when the cursor is in the final row of the table.
If `false`, the cursor will simply leave the table for the next line.
'';
autoExtendCols = helpers.defaultNullOpts.mkBool false ''
Whether a new column should automatically be added to a table when `:MkdnTableNextCell`
is triggered when the cursor is in the final column of the table.
If false, the cursor will jump to the first cell of the next row, unless the cursor is
already in the last row, in which case nothing will happen.
'';
};
yaml = {
bib = {
override = helpers.defaultNullOpts.mkBool false ''
Whether or not a bib path specified in a yaml block should be the only source
considered for bib references in that file.
'';
};
};
tables = {
trimWhitespace = helpers.defaultNullOpts.mkBool true ''
Whether extra whitespace should be trimmed from the end of a table cell when a table is
formatted.
'';
formatOnMove = helpers.defaultNullOpts.mkBool true ''
Whether tables should be formatted each time the cursor is moved via
`MkdnTableNext/PrevCell` or `MkdnTableNext/Prev/Row`.
'';
autoExtendRows = helpers.defaultNullOpts.mkBool false ''
Whether a new row should automatically be added to a table when `:MkdnTableNextRow` is
triggered when the cursor is in the final row of the table.
If `false`, the cursor will simply leave the table for the next line.
'';
autoExtendCols = helpers.defaultNullOpts.mkBool false ''
Whether a new column should automatically be added to a table when `:MkdnTableNextCell`
is triggered when the cursor is in the final column of the table.
If false, the cursor will jump to the first cell of the next row, unless the cursor is
already in the last row, in which case nothing will happen.
'';
};
yaml = {
bib = {
override = helpers.defaultNullOpts.mkBool false ''
Whether or not a bib path specified in a yaml block should be the only source
considered for bib references in that file.
'';
};
};
mappings =
helpers.defaultNullOpts.mkNullable
mappings =
helpers.defaultNullOpts.mkNullable
(
with types;
attrsOf
(
either
(enum [false])
(submodule {
options = {
modes = mkOption {
type = either str (listOf str);
description = ''
Either a string or list representing the mode(s) that the mapping should apply
in.
'';
example = ["n" "v"];
};
key = mkOption {
type = str;
description = "String representing the keymap.";
example = "<Space>";
};
attrsOf (
either (enum [ false ]) (submodule {
options = {
modes = mkOption {
type = either str (listOf str);
description = ''
Either a string or list representing the mode(s) that the mapping should apply
in.
'';
example = [
"n"
"v"
];
};
})
)
key = mkOption {
type = str;
description = "String representing the keymap.";
example = "<Space>";
};
};
})
)
)
''
{
@ -532,86 +544,83 @@ in {
`mkdnflow.nvim/plugin/mkdnflow.lua` (see `:h Mkdnflow-commands` for a list).
Set to `false` to disable a mapping.
'';
};
};
config = let
setupOptions = with cfg;
{
modules = with modules; {
inherit
bib
buffers
conceal
cursor
folds
links
lists
maps
paths
tables
yaml
;
};
inherit filetypes;
create_dirs = createDirs;
perspective = with perspective; {
inherit
priority
fallback
;
root_tell = rootTell;
nvim_wd_heel = nvimWdHeel;
inherit update;
};
inherit wrap;
bib = with bib; {
default_path = defaultPath;
find_in_root = findInRoot;
};
inherit silent;
links = with links; {
inherit
style
conceal
context
;
implicit_extension = implicitExtension;
transform_implicit = transformImplicit;
transform_explicit = transformExplicit;
};
to_do = with toDo; {
inherit symbols;
update_parents = updateParents;
not_started = notStarted;
in_progress = inProgress;
inherit complete;
};
tables = with tables; {
trim_whitespace = trimWhitespace;
format_on_move = formatOnMove;
auto_extend_rows = autoExtendRows;
auto_extend_cols = autoExtendCols;
};
yaml = with yaml; {
bib = with bib; {
inherit override;
config =
let
setupOptions =
with cfg;
{
modules = with modules; {
inherit
bib
buffers
conceal
cursor
folds
links
lists
maps
paths
tables
yaml
;
};
};
mappings = helpers.ifNonNull' mappings (
mapAttrs
(
action: options:
if isBool options
then options
else [options.modes options.key]
)
mappings
);
}
// cfg.extraOptions;
in
inherit filetypes;
create_dirs = createDirs;
perspective = with perspective; {
inherit priority fallback;
root_tell = rootTell;
nvim_wd_heel = nvimWdHeel;
inherit update;
};
inherit wrap;
bib = with bib; {
default_path = defaultPath;
find_in_root = findInRoot;
};
inherit silent;
links = with links; {
inherit style conceal context;
implicit_extension = implicitExtension;
transform_implicit = transformImplicit;
transform_explicit = transformExplicit;
};
to_do = with toDo; {
inherit symbols;
update_parents = updateParents;
not_started = notStarted;
in_progress = inProgress;
inherit complete;
};
tables = with tables; {
trim_whitespace = trimWhitespace;
format_on_move = formatOnMove;
auto_extend_rows = autoExtendRows;
auto_extend_cols = autoExtendCols;
};
yaml = with yaml; {
bib = with bib; {
inherit override;
};
};
mappings = helpers.ifNonNull' mappings (
mapAttrs (
action: options:
if isBool options then
options
else
[
options.modes
options.key
]
) mappings
);
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("mkdnflow").setup(${helpers.toLuaObject setupOptions})

View file

@ -7,216 +7,230 @@
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
name = "molten";
originalName = "molten-nvim";
defaultPackage = pkgs.vimPlugins.molten-nvim;
globalPrefix = "molten_";
mkVimPlugin config {
name = "molten";
originalName = "molten-nvim";
defaultPackage = pkgs.vimPlugins.molten-nvim;
globalPrefix = "molten_";
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-03-01: remove 2024-05-01
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"autoOpenOutput"
"copyOutput"
"enterOutputBehavior"
"imageProvider"
"outputCropBorder"
"outputShowMore"
"outputVirtLines"
"outputWinBorder"
"outputWinCoverGutter"
"outputWinHideOnLeave"
"outputWinMaxHeight"
"outputWinMaxWidth"
"outputWinStyle"
"savePath"
"useBorderHighlights"
"virtLinesOffBy1"
"wrapOutput"
"showMimetypeDebug"
];
# TODO introduced 2024-03-01: remove 2024-05-01
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"autoOpenOutput"
"copyOutput"
"enterOutputBehavior"
"imageProvider"
"outputCropBorder"
"outputShowMore"
"outputVirtLines"
"outputWinBorder"
"outputWinCoverGutter"
"outputWinHideOnLeave"
"outputWinMaxHeight"
"outputWinMaxWidth"
"outputWinStyle"
"savePath"
"useBorderHighlights"
"virtLinesOffBy1"
"wrapOutput"
"showMimetypeDebug"
];
settingsOptions = {
auto_image_popup = helpers.defaultNullOpts.mkBool false ''
When true, cells that produce an image output will open the image output automatically with
python's `Image.show()`.
'';
settingsOptions = {
auto_image_popup = helpers.defaultNullOpts.mkBool false ''
When true, cells that produce an image output will open the image output automatically with
python's `Image.show()`.
'';
auto_init_behavior = helpers.defaultNullOpts.mkStr "init" ''
When set to "raise" commands which would otherwise ask for a kernel when they're run without
a running kernel will instead raise an exception.
Useful for other plugins that want to use `pcall` and do their own error handling.
'';
auto_init_behavior = helpers.defaultNullOpts.mkStr "init" ''
When set to "raise" commands which would otherwise ask for a kernel when they're run without
a running kernel will instead raise an exception.
Useful for other plugins that want to use `pcall` and do their own error handling.
'';
auto_open_html_in_browser = helpers.defaultNullOpts.mkBool false ''
Automatically open HTML outputs in a browser. related: `open_cmd`.
'';
auto_open_html_in_browser = helpers.defaultNullOpts.mkBool false ''
Automatically open HTML outputs in a browser. related: `open_cmd`.
'';
auto_open_output = helpers.defaultNullOpts.mkBool true ''
Automatically open the floating output window when your cursor moves into a cell.
'';
auto_open_output = helpers.defaultNullOpts.mkBool true ''
Automatically open the floating output window when your cursor moves into a cell.
'';
cover_empty_lines = helpers.defaultNullOpts.mkBool false ''
The output window and virtual text will be shown just below the last line of code in the
cell.
'';
cover_empty_lines = helpers.defaultNullOpts.mkBool false ''
The output window and virtual text will be shown just below the last line of code in the
cell.
'';
cover_lines_starting_with = helpers.defaultNullOpts.mkListOf types.str "[]" ''
When `cover_empty_lines` is `true`, also covers lines starting with these strings.
'';
cover_lines_starting_with = helpers.defaultNullOpts.mkListOf types.str "[]" ''
When `cover_empty_lines` is `true`, also covers lines starting with these strings.
'';
copy_output = helpers.defaultNullOpts.mkBool false ''
Copy evaluation output to clipboard automatically (requires `pyperclip`).
'';
copy_output = helpers.defaultNullOpts.mkBool false ''
Copy evaluation output to clipboard automatically (requires `pyperclip`).
'';
enter_output_behavior =
helpers.defaultNullOpts.mkEnumFirstDefault
["open_then_enter" "open_and_enter" "no_open"]
"The behavior of [MoltenEnterOutput](https://github.com/benlubas/molten-nvim#moltenenteroutput).";
enter_output_behavior = helpers.defaultNullOpts.mkEnumFirstDefault [
"open_then_enter"
"open_and_enter"
"no_open"
] "The behavior of [MoltenEnterOutput](https://github.com/benlubas/molten-nvim#moltenenteroutput).";
image_provider = helpers.defaultNullOpts.mkEnumFirstDefault ["none" "image.nvim"] ''
How images are displayed.
'';
open_cmd = helpers.mkNullOrOption types.str ''
Defaults to `xdg-open` on Linux, `open` on Darwin, and `start` on Windows.
But you can override it to whatever you want.
The command is called like: `subprocess.run([open_cmd, filepath])`
'';
output_crop_border = helpers.defaultNullOpts.mkBool true ''
'crops' the bottom border of the output window when it would otherwise just sit at the
bottom of the screen.
'';
output_show_more = helpers.defaultNullOpts.mkBool false ''
When the window can't display the entire contents of the output buffer, shows the number of
extra lines in the window footer (requires nvim 10.0+ and a window border).
'';
output_virt_lines = helpers.defaultNullOpts.mkBool false ''
Pad the main buffer with virtual lines so the floating window doesn't cover anything while
it's open.
'';
output_win_border = helpers.defaultNullOpts.mkBorder ''["" "" "" ""]'' "output window" "";
output_win_cover_gutter = helpers.defaultNullOpts.mkBool true ''
Should the output window cover the gutter (numbers and sign col), or not.
If you change this, you probably also want to change `output_win_style`.
'';
output_win_hide_on_leave = helpers.defaultNullOpts.mkBool true ''
After leaving the output window (via `:q` or switching windows), do not attempt to redraw
the output window.
'';
output_win_max_height = helpers.defaultNullOpts.mkUnsignedInt 999999 ''
Max height of the output window.
'';
output_win_max_width = helpers.defaultNullOpts.mkUnsignedInt 999999 ''
Max width of the output window.
'';
output_win_style = helpers.defaultNullOpts.mkEnum [false "minimal"] "false" ''
Value passed to the style option in `:h nvim_open_win()`.
'';
save_path =
helpers.defaultNullOpts.mkStr
''{__raw = "vim.fn.stdpath('data')..'/molten'";}''
"Where to save/load data with `:MoltenSave` and `:MoltenLoad`.";
tick_rate = helpers.defaultNullOpts.mkUnsignedInt 500 ''
How often (in ms) we poll the kernel for updates.
Determines how quickly the ui will update, if you want a snappier experience, you can set
this to 150 or 200.
'';
use_border_highlights = helpers.defaultNullOpts.mkBool false ''
When true, uses different highlights for output border depending on the state of the cell
(running, done, error).
'';
limit_output_chars = helpers.defaultNullOpts.mkUnsignedInt 1000000 ''
Limit on the number of chars in an output.
If you're lagging your editor with too much output text, decrease it.
'';
virt_lines_off_by_1 = helpers.defaultNullOpts.mkBool false ''
Allows the output window to cover exactly one line of the regular buffer when
`output_virt_lines` is `true`, also effects where `virt_text_output` is displayed.
(useful for running code in a markdown file where that covered line will just be ```).
'';
virt_text_output = helpers.defaultNullOpts.mkBool false ''
When true, show output as virtual text below the cell, virtual text stays after leaving the
cell.
When true, output window doesn't open automatically on run.
Effected by `virt_lines_off_by_1`.
'';
virt_text_max_lines = helpers.defaultNullOpts.mkUnsignedInt 12 ''
Max height of the virtual text.
'';
wrap_output = helpers.defaultNullOpts.mkBool false ''
Wrap output text.
'';
show_mimetype_debug = helpers.defaultNullOpts.mkBool false ''
Before any non-iostream output chunk, the mime-type for that output chunk is shown.
Meant for debugging/plugin development.
'';
};
settingsExample = {
auto_open_output = true;
copy_output = false;
enter_output_behavior = "open_then_enter";
image_provider = "none";
output_crop_border = true;
output_show_more = false;
output_virt_lines = false;
output_win_border = ["" "" "" ""];
output_win_cover_gutter = true;
output_win_hide_on_leave = true;
output_win_style = false;
save_path.__raw = "vim.fn.stdpath('data')..'/molten'";
use_border_highlights = false;
virt_lines_off_by1 = false;
wrap_output = false;
show_mimetype_debug = false;
};
extraOptions = {
python3Dependencies = mkOption {
type = with types; functionTo (listOf package);
default = p:
with p; [
pynvim
jupyter-client
cairosvg
ipython
nbformat
];
defaultText = literalExpression ''
p: with p; [
pynvim
jupyter-client
cairosvg
ipython
nbformat
]
image_provider =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"none"
"image.nvim"
]
''
How images are displayed.
'';
description = "Python packages to add to the `PYTHONPATH` of neovim.";
};
};
extraConfig = cfg: {
extraPython3Packages = cfg.python3Dependencies;
open_cmd = helpers.mkNullOrOption types.str ''
Defaults to `xdg-open` on Linux, `open` on Darwin, and `start` on Windows.
But you can override it to whatever you want.
The command is called like: `subprocess.run([open_cmd, filepath])`
'';
output_crop_border = helpers.defaultNullOpts.mkBool true ''
'crops' the bottom border of the output window when it would otherwise just sit at the
bottom of the screen.
'';
output_show_more = helpers.defaultNullOpts.mkBool false ''
When the window can't display the entire contents of the output buffer, shows the number of
extra lines in the window footer (requires nvim 10.0+ and a window border).
'';
output_virt_lines = helpers.defaultNullOpts.mkBool false ''
Pad the main buffer with virtual lines so the floating window doesn't cover anything while
it's open.
'';
output_win_border = helpers.defaultNullOpts.mkBorder ''["" "" "" ""]'' "output window" "";
output_win_cover_gutter = helpers.defaultNullOpts.mkBool true ''
Should the output window cover the gutter (numbers and sign col), or not.
If you change this, you probably also want to change `output_win_style`.
'';
output_win_hide_on_leave = helpers.defaultNullOpts.mkBool true ''
After leaving the output window (via `:q` or switching windows), do not attempt to redraw
the output window.
'';
output_win_max_height = helpers.defaultNullOpts.mkUnsignedInt 999999 ''
Max height of the output window.
'';
output_win_max_width = helpers.defaultNullOpts.mkUnsignedInt 999999 ''
Max width of the output window.
'';
output_win_style =
helpers.defaultNullOpts.mkEnum
[
false
"minimal"
]
"false"
''
Value passed to the style option in `:h nvim_open_win()`.
'';
save_path = helpers.defaultNullOpts.mkStr ''{__raw = "vim.fn.stdpath('data')..'/molten'";}'' "Where to save/load data with `:MoltenSave` and `:MoltenLoad`.";
tick_rate = helpers.defaultNullOpts.mkUnsignedInt 500 ''
How often (in ms) we poll the kernel for updates.
Determines how quickly the ui will update, if you want a snappier experience, you can set
this to 150 or 200.
'';
use_border_highlights = helpers.defaultNullOpts.mkBool false ''
When true, uses different highlights for output border depending on the state of the cell
(running, done, error).
'';
limit_output_chars = helpers.defaultNullOpts.mkUnsignedInt 1000000 ''
Limit on the number of chars in an output.
If you're lagging your editor with too much output text, decrease it.
'';
virt_lines_off_by_1 = helpers.defaultNullOpts.mkBool false ''
Allows the output window to cover exactly one line of the regular buffer when
`output_virt_lines` is `true`, also effects where `virt_text_output` is displayed.
(useful for running code in a markdown file where that covered line will just be ```).
'';
virt_text_output = helpers.defaultNullOpts.mkBool false ''
When true, show output as virtual text below the cell, virtual text stays after leaving the
cell.
When true, output window doesn't open automatically on run.
Effected by `virt_lines_off_by_1`.
'';
virt_text_max_lines = helpers.defaultNullOpts.mkUnsignedInt 12 ''
Max height of the virtual text.
'';
wrap_output = helpers.defaultNullOpts.mkBool false ''
Wrap output text.
'';
show_mimetype_debug = helpers.defaultNullOpts.mkBool false ''
Before any non-iostream output chunk, the mime-type for that output chunk is shown.
Meant for debugging/plugin development.
'';
};
settingsExample = {
auto_open_output = true;
copy_output = false;
enter_output_behavior = "open_then_enter";
image_provider = "none";
output_crop_border = true;
output_show_more = false;
output_virt_lines = false;
output_win_border = [
""
""
""
""
];
output_win_cover_gutter = true;
output_win_hide_on_leave = true;
output_win_style = false;
save_path.__raw = "vim.fn.stdpath('data')..'/molten'";
use_border_highlights = false;
virt_lines_off_by1 = false;
wrap_output = false;
show_mimetype_debug = false;
};
extraOptions = {
python3Dependencies = mkOption {
type = with types; functionTo (listOf package);
default =
p: with p; [
pynvim
jupyter-client
cairosvg
ipython
nbformat
];
defaultText = literalExpression ''
p: with p; [
pynvim
jupyter-client
cairosvg
ipython
nbformat
]
'';
description = "Python packages to add to the `PYTHONPATH` of neovim.";
};
}
};
extraConfig = cfg: { extraPython3Packages = cfg.python3Dependencies; };
}

View file

@ -5,234 +5,237 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.multicursors;
keyOptionType = with types;
attrsOf (
submodule {
options = {
method = mkOption {
type = either str (enum [false]);
description = ''
Assigning `"nil"` exits from multi cursor mode.
Assigning `false` removes the binding
'';
example = ''
function()
require('multicursors.utils').call_on_selections(
function(selection)
vim.api.nvim_win_set_cursor(0, { selection.row + 1, selection.col + 1 })
local line_count = selection.end_row - selection.row + 1
vim.cmd('normal ' .. line_count .. 'gcc')
end
)
end
'';
};
keyOptionType =
with types;
attrsOf (submodule {
options = {
method = mkOption {
type = either str (enum [ false ]);
description = ''
Assigning `"nil"` exits from multi cursor mode.
Assigning `false` removes the binding
'';
example = ''
function()
require('multicursors.utils').call_on_selections(
function(selection)
vim.api.nvim_win_set_cursor(0, { selection.row + 1, selection.col + 1 })
local line_count = selection.end_row - selection.row + 1
vim.cmd('normal ' .. line_count .. 'gcc')
end
)
end
'';
};
opts = mkOption {
type = attrsOf str;
default = {};
description = "You can pass `:map-arguments` here.";
example = {
desc = "comment selections";
};
opts = mkOption {
type = attrsOf str;
default = { };
description = "You can pass `:map-arguments` here.";
example = {
desc = "comment selections";
};
};
}
);
in {
};
});
in
{
options = {
plugins.multicursors =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "multicursors.nvim";
plugins.multicursors = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "multicursors.nvim";
package = helpers.mkPackageOption "multicursors.nvim" pkgs.vimPlugins.multicursors-nvim;
package = helpers.mkPackageOption "multicursors.nvim" pkgs.vimPlugins.multicursors-nvim;
debugMode = helpers.defaultNullOpts.mkBool false "Enable debug mode.";
debugMode = helpers.defaultNullOpts.mkBool false "Enable debug mode.";
createCommands = helpers.defaultNullOpts.mkBool true "Create Multicursor user commands.";
createCommands = helpers.defaultNullOpts.mkBool true "Create Multicursor user commands.";
updatetime = helpers.defaultNullOpts.mkUnsignedInt 50 ''
Selections get updated if this many milliseconds nothing is typed in the insert mode see
`:help updatetime`.
updatetime = helpers.defaultNullOpts.mkUnsignedInt 50 ''
Selections get updated if this many milliseconds nothing is typed in the insert mode see
`:help updatetime`.
'';
nowait = helpers.defaultNullOpts.mkBool true "see `:help :map-nowait`.";
normalKeys = helpers.mkNullOrOption keyOptionType ''
Normal mode key mappings.
Default: see the [README.md](https://github.com/smoka7/multicursors.nvim)
Example:
```nix
{
# to change default lhs of key mapping, change the key
"," = {
# assigning `null` to method exits from multi cursor mode
# assigning `false` to method removes the binding
method = "require 'multicursors.normal_mode'.clear_others";
# you can pass :map-arguments here
opts = { desc = "Clear others"; };
};
"<C-/>" = {
method = \'\'
function()
require('multicursors.utils').call_on_selections(
function(selection)
vim.api.nvim_win_set_cursor(0, { selection.row + 1, selection.col + 1 })
local line_count = selection.end_row - selection.row + 1
vim.cmd('normal ' .. line_count .. 'gcc')
end
)
end
\'\';
opts = { desc = "comment selections"; };
};
}
```
'';
insertKeys = helpers.mkNullOrOption keyOptionType ''
Insert mode key mappings.
Default: see the [README.md](https://github.com/smoka7/multicursors.nvim)
'';
extendKeys = helpers.mkNullOrOption keyOptionType ''
Insert mode key mappings.
Default: see the [README.md](https://github.com/smoka7/multicursors.nvim)
'';
hintConfig = {
type =
helpers.mkNullOrOption
(types.enum [
"window"
"cmdline"
"statusline"
])
''
- "window": show hint in a floating window;
- "cmdline": show hint in a echo area;
- "statusline": show auto-generated hint in the statusline.
'';
position = helpers.defaultNullOpts.mkEnum [
"top-left"
"top"
"top-right"
"middle-left"
"middle"
"middle-right"
"bottom-left"
"bottom"
"bottom-right"
] "bottom" "Set the position of the hint.";
offset = helpers.mkNullOrOption types.int ''
The offset from the nearest editor border.
(valid when `type` if `"window"`).
'';
nowait = helpers.defaultNullOpts.mkBool true "see `:help :map-nowait`.";
border = helpers.defaultNullOpts.mkBorder "none" "the hint window" "";
normalKeys = helpers.mkNullOrOption keyOptionType ''
Normal mode key mappings.
Default: see the [README.md](https://github.com/smoka7/multicursors.nvim)
Example:
```nix
{
# to change default lhs of key mapping, change the key
"," = {
# assigning `null` to method exits from multi cursor mode
# assigning `false` to method removes the binding
method = "require 'multicursors.normal_mode'.clear_others";
# you can pass :map-arguments here
opts = { desc = "Clear others"; };
};
"<C-/>" = {
method = \'\'
function()
require('multicursors.utils').call_on_selections(
function(selection)
vim.api.nvim_win_set_cursor(0, { selection.row + 1, selection.col + 1 })
local line_count = selection.end_row - selection.row + 1
vim.cmd('normal ' .. line_count .. 'gcc')
end
)
end
\'\';
opts = { desc = "comment selections"; };
};
}
```
showName = helpers.mkNullOrOption types.bool ''
Show hydras name or `HYDRA:` label at the beginning of an auto-generated hint.
'';
insertKeys = helpers.mkNullOrOption keyOptionType ''
Insert mode key mappings.
Default: see the [README.md](https://github.com/smoka7/multicursors.nvim)
funcs = helpers.mkNullOrOption (with types; attrsOf str) ''
Attrs where keys are function names and values are functions themselves.
Each function should return string.
This functions can be required from hint with `%{func_name}` syntaxis.
'';
};
extendKeys = helpers.mkNullOrOption keyOptionType ''
Insert mode key mappings.
Default: see the [README.md](https://github.com/smoka7/multicursors.nvim)
'';
hintConfig = {
type = helpers.mkNullOrOption (types.enum ["window" "cmdline" "statusline"]) ''
- "window": show hint in a floating window;
- "cmdline": show hint in a echo area;
- "statusline": show auto-generated hint in the statusline.
'';
position =
helpers.defaultNullOpts.mkEnum
[
"top-left"
"top"
"top-right"
"middle-left"
"middle"
"middle-right"
"bottom-left"
"bottom"
"bottom-right"
]
"bottom"
"Set the position of the hint.";
offset = helpers.mkNullOrOption types.int ''
The offset from the nearest editor border.
(valid when `type` if `"window"`).
'';
border = helpers.defaultNullOpts.mkBorder "none" "the hint window" "";
showName = helpers.mkNullOrOption types.bool ''
Show hydras name or `HYDRA:` label at the beginning of an auto-generated hint.
'';
funcs = helpers.mkNullOrOption (with types; attrsOf str) ''
Attrs where keys are function names and values are functions themselves.
Each function should return string.
This functions can be required from hint with `%{func_name}` syntaxis.
'';
};
generateHints =
genAttrs
["normal" "insert" "extend"]
generateHints =
genAttrs
[
"normal"
"insert"
"extend"
]
(
mode:
helpers.defaultNullOpts.mkNullable (with types; either bool str) "false" ''
Hints for ${mode} mode.
helpers.defaultNullOpts.mkNullable (with types; either bool str) "false" ''
Hints for ${mode} mode.
Accepted values:
- `true`: generate hints
- `false`: don't generate hints
- str: provide your own hints
''
Accepted values:
- `true`: generate hints
- `false`: don't generate hints
- str: provide your own hints
''
);
};
};
};
config = let
setupOptions = with cfg; let
mkMaps = value:
helpers.ifNonNull' value (
mapAttrs
(
key: mapping:
with mapping; {
method =
# `false`
if isBool method
then method
else helpers.mkRaw method;
inherit opts;
}
)
value
);
in
{
DEBUG_MODE = debugMode;
create_commands = createCommands;
inherit
updatetime
nowait
;
normal_keys = mkMaps normalKeys;
insert_keys = mkMaps insertKeys;
extend_keys = mkMaps extendKeys;
hint_config = with hintConfig; {
inherit
type
position
offset
border
;
show_name = showName;
funcs =
helpers.ifNonNull' funcs
(mapAttrs (name: helpers.mkRaw) funcs);
};
generate_hints =
genAttrs
["normal" "insert" "extend"]
(
mode: let
value = generateHints.${mode};
in
helpers.ifNonNull'
value
config =
let
setupOptions =
with cfg;
let
mkMaps =
value:
helpers.ifNonNull' value (
mapAttrs (
key: mapping: with mapping; {
method =
# `false`
if isBool method then method else helpers.mkRaw method;
inherit opts;
}
) value
);
in
{
DEBUG_MODE = debugMode;
create_commands = createCommands;
inherit updatetime nowait;
normal_keys = mkMaps normalKeys;
insert_keys = mkMaps insertKeys;
extend_keys = mkMaps extendKeys;
hint_config = with hintConfig; {
inherit
type
position
offset
border
;
show_name = showName;
funcs = helpers.ifNonNull' funcs (mapAttrs (name: helpers.mkRaw) funcs);
};
generate_hints =
genAttrs
[
"normal"
"insert"
"extend"
]
(
if isBool value
then value
else
helpers.mkRaw ''
[[
${value}
]]
''
)
);
}
// extraOptions;
in
mode:
let
value = generateHints.${mode};
in
helpers.ifNonNull' value (
if isBool value then
value
else
helpers.mkRaw ''
[[
${value}
]]
''
)
);
}
// extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("multicursors").setup(${helpers.toLuaObject setupOptions})

View file

@ -5,170 +5,151 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.navbuddy;
percentageType = types.ints.between 0 100;
mkPercentageOpt = default: helpers.defaultNullOpts.mkNullable percentageType (toString default);
in {
options.plugins.navbuddy =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "nvim-navbuddy";
in
{
options.plugins.navbuddy = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "nvim-navbuddy";
package = helpers.mkPackageOption "nvim-navbuddy" pkgs.vimPlugins.nvim-navbuddy;
package = helpers.mkPackageOption "nvim-navbuddy" pkgs.vimPlugins.nvim-navbuddy;
window = {
border = helpers.defaultNullOpts.mkBorder "rounded" "window border" ''
"rounded", "double", "solid", "none" or an array with eight chars building up the border in a clockwise fashion
starting with the top-left corner. eg: { "", "" ,"", "", "", "", "", "" }.
'';
size =
helpers.defaultNullOpts.mkNullable
(
with types;
either
percentageType
(submodule {
options = {
height = mkPercentageOpt 40 "The height size (in %).";
width = mkPercentageOpt 100 "The width size (in %).";
};
})
)
"60"
"The size of the window.";
position =
helpers.defaultNullOpts.mkNullable
(
with types;
either
percentageType
(submodule {
options = {
height = mkPercentageOpt 40 "The height size (in %).";
width = mkPercentageOpt 100 "The width size (in %).";
};
})
)
"50"
"The position of the window.";
scrolloff = helpers.mkNullOrOption types.int ''
scrolloff value within navbuddy window
'';
sections = {
left = {
size = mkPercentageOpt 20 "The height size (in %).";
border = helpers.defaultNullOpts.mkBorder "rounded" "left section border" ''
"rounded", "double", "solid", "none" or an array with eight chars building up the border in a clockwise fashion
starting with the top-left corner. eg: { "", "" ,"", "", "", "", "", "" }.
'';
};
mid = {
size = mkPercentageOpt 40 "The height size (in %).";
border = helpers.defaultNullOpts.mkBorder "rounded" "mid section border" ''
"rounded", "double", "solid", "none" or an array with eight chars building up the border in a clockwise fashion
starting with the top-left corner. eg: { "", "" ,"", "", "", "", "", "" }.
'';
};
right = {
border = helpers.defaultNullOpts.mkBorder "rounded" "right section border" ''
"rounded", "double", "solid", "none" or an array with eight chars building up the border in a clockwise fashion
starting with the top-left corner. eg: { "", "" ,"", "", "", "", "", "" }.
'';
preview = helpers.defaultNullOpts.mkEnum ["leaf" "always" "never"] "leaf" ''
Right section can show previews too.
Options: "leaf", "always" or "never"
'';
};
};
};
nodeMarkers = {
enabled = helpers.defaultNullOpts.mkBool true "Enable node markers.";
icons = {
leaf = helpers.defaultNullOpts.mkStr " " ''
The icon to use for leaf nodes.
'';
leafSelected = helpers.defaultNullOpts.mkStr " " ''
The icon to use for selected leaf node.
'';
branch = helpers.defaultNullOpts.mkStr " " ''
The icon to use for branch nodes.
'';
};
};
icons =
mapAttrs
(
name: default:
helpers.defaultNullOpts.mkStr default "icon for ${name}."
)
{
File = "󰈙 ";
Module = " ";
Namespace = "󰌗 ";
Package = " ";
Class = "󰌗 ";
Method = "󰆧 ";
Property = " ";
Field = " ";
Constructor = " ";
Enum = "󰕘";
Interface = "󰕘";
Function = "󰊕 ";
Variable = "󰆧 ";
Constant = "󰏿 ";
String = "󰀬 ";
Number = "󰎠 ";
Boolean = " ";
Array = "󰅪 ";
Object = "󰅩 ";
Key = "󰌋 ";
Null = "󰟢 ";
EnumMember = " ";
Struct = "󰌗 ";
Event = " ";
Operator = "󰆕 ";
TypeParameter = "󰊄 ";
};
useDefaultMapping = helpers.defaultNullOpts.mkBool true ''
If set to false, only mappings set by user are set. Else default mappings are used for keys that are not set by user
window = {
border = helpers.defaultNullOpts.mkBorder "rounded" "window border" ''
"rounded", "double", "solid", "none" or an array with eight chars building up the border in a clockwise fashion
starting with the top-left corner. eg: { "", "" ,"", "", "", "", "", "" }.
'';
keymapsSilent = mkOption {
type = types.bool;
description = "Whether navbuddy keymaps should be silent";
default = false;
};
size = helpers.defaultNullOpts.mkNullable (
with types;
either percentageType (submodule {
options = {
height = mkPercentageOpt 40 "The height size (in %).";
mappings =
helpers.defaultNullOpts.mkNullable
(
with types;
attrsOf
(
either
str
helpers.nixvimTypes.rawLua
)
)
width = mkPercentageOpt 100 "The width size (in %).";
};
})
) "60" "The size of the window.";
position = helpers.defaultNullOpts.mkNullable (
with types;
either percentageType (submodule {
options = {
height = mkPercentageOpt 40 "The height size (in %).";
width = mkPercentageOpt 100 "The width size (in %).";
};
})
) "50" "The position of the window.";
scrolloff = helpers.mkNullOrOption types.int ''
scrolloff value within navbuddy window
'';
sections = {
left = {
size = mkPercentageOpt 20 "The height size (in %).";
border = helpers.defaultNullOpts.mkBorder "rounded" "left section border" ''
"rounded", "double", "solid", "none" or an array with eight chars building up the border in a clockwise fashion
starting with the top-left corner. eg: { "", "" ,"", "", "", "", "", "" }.
'';
};
mid = {
size = mkPercentageOpt 40 "The height size (in %).";
border = helpers.defaultNullOpts.mkBorder "rounded" "mid section border" ''
"rounded", "double", "solid", "none" or an array with eight chars building up the border in a clockwise fashion
starting with the top-left corner. eg: { "", "" ,"", "", "", "", "", "" }.
'';
};
right = {
border = helpers.defaultNullOpts.mkBorder "rounded" "right section border" ''
"rounded", "double", "solid", "none" or an array with eight chars building up the border in a clockwise fashion
starting with the top-left corner. eg: { "", "" ,"", "", "", "", "", "" }.
'';
preview =
helpers.defaultNullOpts.mkEnum
[
"leaf"
"always"
"never"
]
"leaf"
''
Right section can show previews too.
Options: "leaf", "always" or "never"
'';
};
};
};
nodeMarkers = {
enabled = helpers.defaultNullOpts.mkBool true "Enable node markers.";
icons = {
leaf = helpers.defaultNullOpts.mkStr " " ''
The icon to use for leaf nodes.
'';
leafSelected = helpers.defaultNullOpts.mkStr " " ''
The icon to use for selected leaf node.
'';
branch = helpers.defaultNullOpts.mkStr " " ''
The icon to use for branch nodes.
'';
};
};
icons = mapAttrs (name: default: helpers.defaultNullOpts.mkStr default "icon for ${name}.") {
File = "󰈙 ";
Module = " ";
Namespace = "󰌗 ";
Package = " ";
Class = "󰌗 ";
Method = "󰆧 ";
Property = " ";
Field = " ";
Constructor = " ";
Enum = "󰕘";
Interface = "󰕘";
Function = "󰊕 ";
Variable = "󰆧 ";
Constant = "󰏿 ";
String = "󰀬 ";
Number = "󰎠 ";
Boolean = " ";
Array = "󰅪 ";
Object = "󰅩 ";
Key = "󰌋 ";
Null = "󰟢 ";
EnumMember = " ";
Struct = "󰌗 ";
Event = " ";
Operator = "󰆕 ";
TypeParameter = "󰊄 ";
};
useDefaultMapping = helpers.defaultNullOpts.mkBool true ''
If set to false, only mappings set by user are set. Else default mappings are used for keys that are not set by user
'';
keymapsSilent = mkOption {
type = types.bool;
description = "Whether navbuddy keymaps should be silent";
default = false;
};
mappings =
helpers.defaultNullOpts.mkNullable (with types; attrsOf (either str helpers.nixvimTypes.rawLua))
''
{
"<esc>" = "close";
@ -217,65 +198,71 @@ in {
Or it can a `rawLua`.
'';
lsp = {
autoAttach = helpers.defaultNullOpts.mkBool false ''
If set to true, you don't need to manually use attach function
'';
lsp = {
autoAttach = helpers.defaultNullOpts.mkBool false ''
If set to true, you don't need to manually use attach function
'';
preference = helpers.mkNullOrOption (with types; listOf str) ''
list of lsp server names in order of preference
'';
};
sourceBuffer = {
followNode = helpers.defaultNullOpts.mkBool true "Keep the current node in focus on the source buffer";
highlight = helpers.defaultNullOpts.mkBool true "Highlight the currently focused node";
reorient = helpers.defaultNullOpts.mkEnum ["smart" "top" "mid" "none"] "smart" ''
Right section can show previews too.
Options: "leaf", "always" or "never"
'';
scrolloff = helpers.defaultNullOpts.mkInt null ''
scrolloff value when navbuddy is open.
'';
};
preference = helpers.mkNullOrOption (with types; listOf str) ''
list of lsp server names in order of preference
'';
};
config = let
setupOptions = with cfg;
{
inherit window;
node_markers = with nodeMarkers; {
inherit enabled;
icons = with icons; {
inherit leaf branch;
leaf_selected = leafSelected;
sourceBuffer = {
followNode = helpers.defaultNullOpts.mkBool true "Keep the current node in focus on the source buffer";
highlight = helpers.defaultNullOpts.mkBool true "Highlight the currently focused node";
reorient =
helpers.defaultNullOpts.mkEnum
[
"smart"
"top"
"mid"
"none"
]
"smart"
''
Right section can show previews too.
Options: "leaf", "always" or "never"
'';
scrolloff = helpers.defaultNullOpts.mkInt null ''
scrolloff value when navbuddy is open.
'';
};
};
config =
let
setupOptions =
with cfg;
{
inherit window;
node_markers = with nodeMarkers; {
inherit enabled;
icons = with icons; {
inherit leaf branch;
leaf_selected = leafSelected;
};
};
};
inherit icons;
use_default_mapping = useDefaultMapping;
lsp = with lsp; {
auto_attach = autoAttach;
inherit preference;
};
source_buffer = sourceBuffer;
mappings =
helpers.ifNonNull' cfg.mappings
(mapAttrs
(
key: action:
if isString action
then helpers.mkRaw "actions.${action}()"
else action
)
mappings);
}
// cfg.extraOptions;
in
inherit icons;
use_default_mapping = useDefaultMapping;
lsp = with lsp; {
auto_attach = autoAttach;
inherit preference;
};
source_buffer = sourceBuffer;
mappings = helpers.ifNonNull' cfg.mappings (
mapAttrs (
key: action: if isString action then helpers.mkRaw "actions.${action}()" else action
) mappings
);
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
local actions = require("nvim-navbuddy.actions")

View file

@ -6,65 +6,83 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "neocord";
defaultPackage = pkgs.vimPlugins.neocord;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "neocord";
defaultPackage = pkgs.vimPlugins.neocord;
maintainers = [];
maintainers = [ ];
settingsOptions = {
# General options.
auto_update = helpers.defaultNullOpts.mkBool true ''
Update activity based on autocmd events.
If `false`, map or manually execute
`:lua package.loaded.neocord:update()`
'';
settingsOptions = {
# General options.
auto_update = helpers.defaultNullOpts.mkBool true ''
Update activity based on autocmd events.
If `false`, map or manually execute
`:lua package.loaded.neocord:update()`
'';
logo = helpers.defaultNullOpts.mkStr "auto" ''
Update the Logo to the specified option ("auto" or url).
'';
logo = helpers.defaultNullOpts.mkStr "auto" ''
Update the Logo to the specified option ("auto" or url).
'';
logo_tooltip = helpers.mkNullOrStr ''
Sets the logo tooltip
'';
logo_tooltip = helpers.mkNullOrStr ''
Sets the logo tooltip
'';
main_image = helpers.defaultNullOpts.mkEnum ["language" "logo"] "language" ''
Main image display (either "language" or "logo")
'';
main_image =
helpers.defaultNullOpts.mkEnum
[
"language"
"logo"
]
"language"
''
Main image display (either "language" or "logo")
'';
client_id = helpers.defaultNullOpts.mkStr "1157438221865717891" ''
Use your own Discord application client id. (not recommended)
'';
client_id = helpers.defaultNullOpts.mkStr "1157438221865717891" ''
Use your own Discord application client id. (not recommended)
'';
log_level = helpers.defaultNullOpts.mkEnum ["debug" "info" "warn" "error"] "null" ''
Log messages at or above this level.
'';
log_level =
helpers.defaultNullOpts.mkEnum
[
"debug"
"info"
"warn"
"error"
]
"null"
''
Log messages at or above this level.
'';
debounce_timeout = helpers.defaultNullOpts.mkInt 10 ''
Number of seconds to debounce events.
(or calls to `:lua package.loaded.neocord:update(<filename>, true)`)
'';
debounce_timeout = helpers.defaultNullOpts.mkInt 10 ''
Number of seconds to debounce events.
(or calls to `:lua package.loaded.neocord:update(<filename>, true)`)
'';
enable_line_number = helpers.defaultNullOpts.mkBool false ''
Displays the current line number instead of the current project.
'';
enable_line_number = helpers.defaultNullOpts.mkBool false ''
Displays the current line number instead of the current project.
'';
blacklist = helpers.defaultNullOpts.mkListOf types.str "[]" ''
A list of strings or Lua patterns that disable Rich Presence if the
current file name, path, or workspace matches.
'';
blacklist = helpers.defaultNullOpts.mkListOf types.str "[]" ''
A list of strings or Lua patterns that disable Rich Presence if the
current file name, path, or workspace matches.
'';
buttons =
helpers.defaultNullOpts.mkNullable
(with types;
either
helpers.nixvimTypes.rawLua
(listOf (submodule {
options = {
label = helpers.mkNullOrOption str "";
url = helpers.mkNullOrOption str "";
};
})))
buttons =
helpers.defaultNullOpts.mkNullable
(
with types;
either helpers.nixvimTypes.rawLua (
listOf (submodule {
options = {
label = helpers.mkNullOrOption str "";
url = helpers.mkNullOrOption str "";
};
})
)
)
"[]"
''
Button configurations which will always appear in Rich Presence.
@ -74,99 +92,99 @@ with lib;
Can also be a lua function: `function(buffer: string, repo_url: string|nil): table`
'';
file_assets = helpers.mkNullOrOption (with types; attrsOf (listOf str)) ''
Custom file asset definitions keyed by file names and extensions.
List elements for each attribute (filetype):
`name`: The name of the asset shown as the title of the file in Discord.
`source`: The source of the asset, either an art asset key or the URL of an image asset.
Example:
```nix
{
# Use art assets uploaded in Discord application for the configured client id
js = [ "JavaScript" "javascript" ];
ts = [ "TypeScript" "typescript" ];
# Use image URLs
rs = [ "Rust" "https://www.rust-lang.org/logos/rust-logo-512x512.png" ];
go = [ "Go" "https://go.dev/blog/go-brand/Go-Logo/PNG/Go-Logo_Aqua.png" ];
};
```
'';
file_assets = helpers.mkNullOrOption (with types; attrsOf (listOf str)) ''
Custom file asset definitions keyed by file names and extensions.
List elements for each attribute (filetype):
`name`: The name of the asset shown as the title of the file in Discord.
`source`: The source of the asset, either an art asset key or the URL of an image asset.
Example:
```nix
{
# Use art assets uploaded in Discord application for the configured client id
js = [ "JavaScript" "javascript" ];
ts = [ "TypeScript" "typescript" ];
# Use image URLs
rs = [ "Rust" "https://www.rust-lang.org/logos/rust-logo-512x512.png" ];
go = [ "Go" "https://go.dev/blog/go-brand/Go-Logo/PNG/Go-Logo_Aqua.png" ];
};
```
'';
show_time = helpers.defaultNullOpts.mkBool true "Show the timer.";
show_time = helpers.defaultNullOpts.mkBool true "Show the timer.";
global_timer = helpers.defaultNullOpts.mkBool false "if set true, timer won't update when any event are triggered.";
global_timer = helpers.defaultNullOpts.mkBool false "if set true, timer won't update when any event are triggered.";
# Rich presence text options.
editing_text = helpers.defaultNullOpts.mkStr "Editing %s" ''
String rendered when an editable file is loaded in the buffer.
Can also be a lua function:
`function(filename: string): string`
'';
# Rich presence text options.
editing_text = helpers.defaultNullOpts.mkStr "Editing %s" ''
String rendered when an editable file is loaded in the buffer.
Can also be a lua function:
`function(filename: string): string`
'';
file_explorer_text = helpers.defaultNullOpts.mkStr "Browsing %s" ''
String rendered when browsing a file explorer.
Can also be a lua function:
`function(file_explorer_name: string): string`
'';
file_explorer_text = helpers.defaultNullOpts.mkStr "Browsing %s" ''
String rendered when browsing a file explorer.
Can also be a lua function:
`function(file_explorer_name: string): string`
'';
git_commit_text = helpers.defaultNullOpts.mkStr "Committing changes" ''
String rendered when committing changes in git.
Can also be a lua function:
`function(filename: string): string`
'';
git_commit_text = helpers.defaultNullOpts.mkStr "Committing changes" ''
String rendered when committing changes in git.
Can also be a lua function:
`function(filename: string): string`
'';
plugin_manager_text = helpers.defaultNullOpts.mkStr "Managing plugins" ''
String rendered when managing plugins.
Can also be a lua function:
`function(plugin_manager_name: string): string`
'';
plugin_manager_text = helpers.defaultNullOpts.mkStr "Managing plugins" ''
String rendered when managing plugins.
Can also be a lua function:
`function(plugin_manager_name: string): string`
'';
reading_text = helpers.defaultNullOpts.mkStr "Reading %s" ''
String rendered when a read-only/unmodifiable file is loaded into the buffer.
Can also be a lua function:
`function(filename: string): string`
'';
reading_text = helpers.defaultNullOpts.mkStr "Reading %s" ''
String rendered when a read-only/unmodifiable file is loaded into the buffer.
Can also be a lua function:
`function(filename: string): string`
'';
workspace_text = helpers.defaultNullOpts.mkStr "Working on %s" ''
String rendered when in a git repository.
Can also be a lua function:
`function(project_name: string|nil, filename: string): string`
'';
workspace_text = helpers.defaultNullOpts.mkStr "Working on %s" ''
String rendered when in a git repository.
Can also be a lua function:
`function(project_name: string|nil, filename: string): string`
'';
line_number_text = helpers.defaultNullOpts.mkStr "Line %s out of %s" ''
String rendered when `enableLineNumber` is set to `true` to display the current line number.
Can also be a lua function:
`function(line_number: number, line_count: number): string`
'';
line_number_text = helpers.defaultNullOpts.mkStr "Line %s out of %s" ''
String rendered when `enableLineNumber` is set to `true` to display the current line number.
Can also be a lua function:
`function(line_number: number, line_count: number): string`
'';
terminal_text = helpers.defaultNullOpts.mkStr "Using Terminal" ''
Format string rendered when in terminal mode.
'';
};
terminal_text = helpers.defaultNullOpts.mkStr "Using Terminal" ''
Format string rendered when in terminal mode.
'';
};
settingsExample = {
#General options
auto_update = true;
logo = "auto";
logo_tooltip = null;
main_image = "language";
client_id = "1157438221865717891";
log_level = null;
debounce_timeout = 10;
enable_line_number = false;
blacklist = [];
file_assets = null;
show_time = true;
global_timer = false;
settingsExample = {
#General options
auto_update = true;
logo = "auto";
logo_tooltip = null;
main_image = "language";
client_id = "1157438221865717891";
log_level = null;
debounce_timeout = 10;
enable_line_number = false;
blacklist = [ ];
file_assets = null;
show_time = true;
global_timer = false;
# Rich Presence text options
editing_text = "Editing...";
file_explorer_text = "Browsing...";
git_commit_text = "Committing changes...";
plugin_manager_text = "Managing plugins...";
reading_text = "Reading...";
workspace_text = "Working on %s";
line_number_text = "Line %s out of %s";
terminal_text = "Using Terminal...";
};
}
# Rich Presence text options
editing_text = "Editing...";
file_explorer_text = "Browsing...";
git_commit_text = "Committing changes...";
plugin_manager_text = "Managing plugins...";
reading_text = "Reading...";
workspace_text = "Working on %s";
line_number_text = "Line %s out of %s";
terminal_text = "Using Terminal...";
};
}

View file

@ -5,7 +5,8 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.neogen;
keymapDef = {
@ -41,172 +42,177 @@ with lib; let
description = "Generates annotation for file.";
};
};
in {
options.plugins.neogen =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "neogen";
in
{
options.plugins.neogen = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "neogen";
package = helpers.mkPackageOption "neogen" pkgs.vimPlugins.neogen;
package = helpers.mkPackageOption "neogen" pkgs.vimPlugins.neogen;
keymaps = mapAttrs (optionsName: properties: helpers.mkNullOrOption types.str properties.description) keymapDef;
keymaps = mapAttrs (
optionsName: properties: helpers.mkNullOrOption types.str properties.description
) keymapDef;
keymapsSilent = mkOption {
type = types.bool;
description = "Whether Neogen keymaps should be silent";
default = false;
};
inputAfterComment = helpers.defaultNullOpts.mkBool true ''
If true, go to annotation after insertion, and change to insert mode
'';
enablePlaceholders = helpers.defaultNullOpts.mkBool true ''
If true, enables placeholders when inserting annotation
'';
languages = helpers.defaultNullOpts.mkNullable types.attrs "see upstream documentation" ''
Configuration for languages.
`template.annotation_convention` (default: check the language default configurations):
Change the annotation convention to use with the language.
`template.use_default_comment` (default: true):
Prepend any template line with the default comment for the filetype
`template.position` (fun(node: userdata, type: string):(number,number)?):
Provide an absolute position for the annotation.
If return values are nil, use default position
`template.append`:
If you want to customize the position of the annotation.
`template.append.child_name`:
What child node to use for appending the annotation.
`template.append.position` (before/after):
Relative positioning with `child_name`.
`template.<convention_name>` (replace <convention_name> with an annotation convention):
Template for an annotation convention.
To know more about how to create your own template, go here:
https://github.com/danymat/neogen/blob/main/docs/adding-languages.md#default-generator
Example:
```nix
{
csharp = {
template = {
annotation_convention = "...";
};
};
}
```
'';
snippetEngine = helpers.mkNullOrOption types.str ''
Use a snippet engine to generate annotations.
Some snippet engines come out of the box bundled with neogen:
- `"luasnip"` (https://github.com/L3MON4D3/LuaSnip)
- `"snippy"` (https://github.com/dcampos/nvim-snippy)
- `"vsnip"` (https://github.com/hrsh7th/vim-vsnip)
'';
placeholderHighlight = helpers.defaultNullOpts.mkStr "DiagnosticHint" ''
Placeholders highlights to use. If you don't want custom highlight, pass "None"
'';
placeholdersText = {
description = helpers.defaultNullOpts.mkStr "[TODO:description]" ''
Placeholder for description.
'';
tparam = helpers.defaultNullOpts.mkStr "[TODO:tparam]" ''
Placeholder for tparam.
'';
parameter = helpers.defaultNullOpts.mkStr "[TODO:parameter]" ''
Placeholder for parameter.
'';
return = helpers.defaultNullOpts.mkStr "[TODO:return]" ''
Placeholder for return.
'';
class = helpers.defaultNullOpts.mkStr "[TODO:class]" ''
Placeholder for class.
'';
throw = helpers.defaultNullOpts.mkStr "[TODO:throw]" ''
Placeholder for throw.
'';
varargs = helpers.defaultNullOpts.mkStr "[TODO:varargs]" ''
Placeholder for varargs.
'';
type = helpers.defaultNullOpts.mkStr "[TODO:type]" ''
Placeholder for type.
'';
attribute = helpers.defaultNullOpts.mkStr "[TODO:attribute]" ''
Placeholder for attribute.
'';
args = helpers.defaultNullOpts.mkStr "[TODO:args]" ''
Placeholder for args.
'';
kwargs = helpers.defaultNullOpts.mkStr "[TODO:kwargs]" ''
Placeholder for kwargs.
'';
};
keymapsSilent = mkOption {
type = types.bool;
description = "Whether Neogen keymaps should be silent";
default = false;
};
inputAfterComment = helpers.defaultNullOpts.mkBool true ''
If true, go to annotation after insertion, and change to insert mode
'';
enablePlaceholders = helpers.defaultNullOpts.mkBool true ''
If true, enables placeholders when inserting annotation
'';
languages = helpers.defaultNullOpts.mkNullable types.attrs "see upstream documentation" ''
Configuration for languages.
`template.annotation_convention` (default: check the language default configurations):
Change the annotation convention to use with the language.
`template.use_default_comment` (default: true):
Prepend any template line with the default comment for the filetype
`template.position` (fun(node: userdata, type: string):(number,number)?):
Provide an absolute position for the annotation.
If return values are nil, use default position
`template.append`:
If you want to customize the position of the annotation.
`template.append.child_name`:
What child node to use for appending the annotation.
`template.append.position` (before/after):
Relative positioning with `child_name`.
`template.<convention_name>` (replace <convention_name> with an annotation convention):
Template for an annotation convention.
To know more about how to create your own template, go here:
https://github.com/danymat/neogen/blob/main/docs/adding-languages.md#default-generator
Example:
```nix
{
csharp = {
template = {
annotation_convention = "...";
};
};
}
```
'';
snippetEngine = helpers.mkNullOrOption types.str ''
Use a snippet engine to generate annotations.
Some snippet engines come out of the box bundled with neogen:
- `"luasnip"` (https://github.com/L3MON4D3/LuaSnip)
- `"snippy"` (https://github.com/dcampos/nvim-snippy)
- `"vsnip"` (https://github.com/hrsh7th/vim-vsnip)
'';
placeholderHighlight = helpers.defaultNullOpts.mkStr "DiagnosticHint" ''
Placeholders highlights to use. If you don't want custom highlight, pass "None"
'';
placeholdersText = {
description = helpers.defaultNullOpts.mkStr "[TODO:description]" ''
Placeholder for description.
'';
tparam = helpers.defaultNullOpts.mkStr "[TODO:tparam]" ''
Placeholder for tparam.
'';
parameter = helpers.defaultNullOpts.mkStr "[TODO:parameter]" ''
Placeholder for parameter.
'';
return = helpers.defaultNullOpts.mkStr "[TODO:return]" ''
Placeholder for return.
'';
class = helpers.defaultNullOpts.mkStr "[TODO:class]" ''
Placeholder for class.
'';
throw = helpers.defaultNullOpts.mkStr "[TODO:throw]" ''
Placeholder for throw.
'';
varargs = helpers.defaultNullOpts.mkStr "[TODO:varargs]" ''
Placeholder for varargs.
'';
type = helpers.defaultNullOpts.mkStr "[TODO:type]" ''
Placeholder for type.
'';
attribute = helpers.defaultNullOpts.mkStr "[TODO:attribute]" ''
Placeholder for attribute.
'';
args = helpers.defaultNullOpts.mkStr "[TODO:args]" ''
Placeholder for args.
'';
kwargs = helpers.defaultNullOpts.mkStr "[TODO:kwargs]" ''
Placeholder for kwargs.
'';
};
};
# TODO introduced 2024-03-07: remove 2024-05-07
imports = [
(
mkRenamedOptionModule
["plugins" "neogen" "placeholderHighligt"]
["plugins" "neogen" "placeholderHighlight"]
(mkRenamedOptionModule
[
"plugins"
"neogen"
"placeholderHighligt"
]
[
"plugins"
"neogen"
"placeholderHighlight"
]
)
];
config = let
setupOptions = with cfg; {
enabled = enable;
input_after_comment = inputAfterComment;
inherit languages;
snippet_engine = snippetEngine;
enable_placeholders = enablePlaceholders;
placeholder_text = placeholdersText;
placeholder_hl = placeholderHighlight;
};
in
config =
let
setupOptions = with cfg; {
enabled = enable;
input_after_comment = inputAfterComment;
inherit languages;
snippet_engine = snippetEngine;
enable_placeholders = enablePlaceholders;
placeholder_text = placeholdersText;
placeholder_hl = placeholderHighlight;
};
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("neogen").setup(${helpers.toLuaObject setupOptions})
'';
keymaps =
flatten
(
mapAttrsToList
(
optionName: properties: let
key = cfg.keymaps.${optionName};
in
optional (key != null)
{
mode = "n";
inherit key;
action = ":Neogen ${properties.command}<CR>";
options.silent = cfg.keymapsSilent;
}
)
keymapDef
);
keymaps = flatten (
mapAttrsToList (
optionName: properties:
let
key = cfg.keymaps.${optionName};
in
optional (key != null) {
mode = "n";
inherit key;
action = ":Neogen ${properties.command}<CR>";
options.silent = cfg.keymapsSilent;
}
) keymapDef
);
};
}

View file

@ -4,108 +4,111 @@
config,
pkgs,
...
}: let
}:
let
cfg = config.plugins.neorg;
in
with lib; {
options.plugins.neorg =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "neorg";
with lib;
{
options.plugins.neorg = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "neorg";
package = helpers.mkPackageOption "neorg" pkgs.vimPlugins.neorg;
package = helpers.mkPackageOption "neorg" pkgs.vimPlugins.neorg;
lazyLoading =
helpers.defaultNullOpts.mkBool false ''
'';
lazyLoading = helpers.defaultNullOpts.mkBool false '''';
logger = let
modes = {
trace = {
hl = "Comment";
level = "trace";
};
debug = {
hl = "Comment";
level = "debug";
};
info = {
hl = "None";
level = "info";
};
warn = {
hl = "WarningMsg";
level = "warn";
};
error = {
hl = "ErrorMsg";
level = "error";
};
fatal = {
hl = "ErrorMsg";
level = 5;
};
logger =
let
modes = {
trace = {
hl = "Comment";
level = "trace";
};
debug = {
hl = "Comment";
level = "debug";
};
info = {
hl = "None";
level = "info";
};
warn = {
hl = "WarningMsg";
level = "warn";
};
error = {
hl = "ErrorMsg";
level = "error";
};
fatal = {
hl = "ErrorMsg";
level = 5;
};
in {
plugin = helpers.defaultNullOpts.mkStr "neorg" ''
Name of the plugin. Prepended to log messages
'';
useConsole = helpers.defaultNullOpts.mkBool true ''
Should print the output to neovim while running
'';
highlights = helpers.defaultNullOpts.mkBool true ''
Should highlighting be used in console (using echohl)
'';
useFile = helpers.defaultNullOpts.mkBool true ''
Should write to a file
'';
level = helpers.defaultNullOpts.mkEnum (attrNames modes) "warn" ''
Any messages above this level will be logged
'';
modes =
mapAttrs
(mode: defaults:
helpers.mkCompositeOption "Settings for mode ${mode}." {
hl = helpers.defaultNullOpts.mkStr defaults.hl ''
Highlight for mode ${mode}.
'';
level = helpers.defaultNullOpts.mkLogLevel defaults.level ''
Level for mode ${mode}.
'';
})
modes;
floatPrecision = helpers.defaultNullOpts.mkNullable types.float "0.01" ''
Can limit the number of decimals displayed for floats
'';
};
in
{
plugin = helpers.defaultNullOpts.mkStr "neorg" ''
Name of the plugin. Prepended to log messages
'';
modules = mkOption {
type = with types; attrsOf attrs;
description = "Modules configuration.";
default = {};
example = {
"core.defaults" = {__empty = null;};
"core.dirman" = {
config = {
workspaces = {
work = "~/notes/work";
home = "~/notes/home";
};
};
useConsole = helpers.defaultNullOpts.mkBool true ''
Should print the output to neovim while running
'';
highlights = helpers.defaultNullOpts.mkBool true ''
Should highlighting be used in console (using echohl)
'';
useFile = helpers.defaultNullOpts.mkBool true ''
Should write to a file
'';
level = helpers.defaultNullOpts.mkEnum (attrNames modes) "warn" ''
Any messages above this level will be logged
'';
modes = mapAttrs (
mode: defaults:
helpers.mkCompositeOption "Settings for mode ${mode}." {
hl = helpers.defaultNullOpts.mkStr defaults.hl ''
Highlight for mode ${mode}.
'';
level = helpers.defaultNullOpts.mkLogLevel defaults.level ''
Level for mode ${mode}.
'';
}
) modes;
floatPrecision = helpers.defaultNullOpts.mkNullable types.float "0.01" ''
Can limit the number of decimals displayed for floats
'';
};
modules = mkOption {
type = with types; attrsOf attrs;
description = "Modules configuration.";
default = { };
example = {
"core.defaults" = {
__empty = null;
};
"core.dirman" = {
config = {
workspaces = {
work = "~/notes/work";
home = "~/notes/home";
};
};
};
};
};
};
config = let
setupOptions = with cfg;
config =
let
setupOptions =
with cfg;
{
lazy_loading = lazyLoading;
@ -116,21 +119,15 @@ in
use_file = useFile;
inherit level;
modes =
filter (v: v != null)
(
mapAttrsToList
(mode: modeConfig:
helpers.ifNonNull' modeConfig {
name = mode;
inherit
(modeConfig)
hl
level
;
})
modes
);
modes = filter (v: v != null) (
mapAttrsToList (
mode: modeConfig:
helpers.ifNonNull' modeConfig {
name = mode;
inherit (modeConfig) hl level;
}
) modes
);
float_precision = floatPrecision;
};
@ -140,35 +137,21 @@ in
telescopeSupport = hasAttr "core.integrations.telescope" cfg.modules;
in
mkIf cfg.enable {
warnings =
(
optional
(telescopeSupport && (!config.plugins.telescope.enable))
''
Telescope support for neorg (`core.integrations.telescope`) is enabled but the
telescope plugin is not.
''
)
++ (
optional
((hasAttr "core.defaults" cfg.modules) && (!config.plugins.treesitter.enable))
''
Neorg's `core.defaults` module is enabled but `plugins.treesitter` is not.
Treesitter is required when using the `core.defaults`.
''
);
mkIf cfg.enable {
warnings =
(optional (telescopeSupport && (!config.plugins.telescope.enable)) ''
Telescope support for neorg (`core.integrations.telescope`) is enabled but the
telescope plugin is not.
'')
++ (optional ((hasAttr "core.defaults" cfg.modules) && (!config.plugins.treesitter.enable)) ''
Neorg's `core.defaults` module is enabled but `plugins.treesitter` is not.
Treesitter is required when using the `core.defaults`.
'');
extraPlugins =
[cfg.package]
++ (
optional
telescopeSupport
pkgs.vimPlugins.neorg-telescope
);
extraPlugins = [ cfg.package ] ++ (optional telescopeSupport pkgs.vimPlugins.neorg-telescope);
extraConfigLua = ''
require('neorg').setup(${helpers.toLuaObject setupOptions})
'';
};
}
extraConfigLua = ''
require('neorg').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -5,7 +5,8 @@
pkgs,
...
}:
with lib; {
with lib;
{
options.plugins.netman = {
enable = mkEnableOption "netman.nvim, a framework to access remote resources";
@ -14,15 +15,16 @@ with lib; {
neoTreeIntegration = mkEnableOption "support for netman as a neo-tree source";
};
config = let
cfg = config.plugins.netman;
in
config =
let
cfg = config.plugins.netman;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("netman")
'';
plugins.neo-tree.extraSources = mkIf cfg.neoTreeIntegration ["netman.ui.neo-tree"];
plugins.neo-tree.extraSources = mkIf cfg.neoTreeIntegration [ "netman.ui.neo-tree" ];
};
}

View file

@ -5,29 +5,29 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.nix-develop;
in {
options.plugins.nix-develop =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "nix-develop.nvim";
in
{
options.plugins.nix-develop = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "nix-develop.nvim";
package = helpers.mkPackageOption "nix-develop.nvim" pkgs.vimPlugins.nix-develop-nvim;
package = helpers.mkPackageOption "nix-develop.nvim" pkgs.vimPlugins.nix-develop-nvim;
ignoredVariables = mkOption {
type = types.attrsOf types.bool;
default = {};
};
separatedVariables = mkOption {
type = types.attrsOf types.str;
default = {};
};
ignoredVariables = mkOption {
type = types.attrsOf types.bool;
default = { };
};
separatedVariables = mkOption {
type = types.attrsOf types.str;
default = { };
};
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
local __ignored_variables = ${helpers.toLuaObject cfg.ignoredVariables}
for ignoredVariable, shouldIgnore in ipairs(__ignored_variables) do

View file

@ -5,45 +5,40 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.notify;
in {
options.plugins.notify =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "nvim-notify";
in
{
options.plugins.notify = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "nvim-notify";
package = helpers.mkPackageOption "nvim-notify" pkgs.vimPlugins.nvim-notify;
package = helpers.mkPackageOption "nvim-notify" pkgs.vimPlugins.nvim-notify;
level = helpers.defaultNullOpts.mkLogLevel "info" ''
Minimum log level to display. See `vim.log.levels`.
'';
level = helpers.defaultNullOpts.mkLogLevel "info" ''
Minimum log level to display. See `vim.log.levels`.
'';
timeout = helpers.defaultNullOpts.mkUnsignedInt 5000 "Default timeout for notification.";
timeout = helpers.defaultNullOpts.mkUnsignedInt 5000 "Default timeout for notification.";
maxWidth = helpers.mkNullOrOption (with types; either ints.unsigned helpers.nixvimTypes.rawLua) ''
Max number of columns for messages.
'';
maxWidth = helpers.mkNullOrOption (with types; either ints.unsigned helpers.nixvimTypes.rawLua) ''
Max number of columns for messages.
'';
maxHeight = helpers.mkNullOrOption (with types; either ints.unsigned helpers.nixvimTypes.rawLua) ''
Max number of lines for a message.
'';
maxHeight = helpers.mkNullOrOption (with types; either ints.unsigned helpers.nixvimTypes.rawLua) ''
Max number of lines for a message.
'';
stages =
helpers.defaultNullOpts.mkNullable
stages =
helpers.defaultNullOpts.mkNullable
(
with types;
either
(
enum
[
"fade"
"slide"
"fade_in_slide_out"
"static"
]
)
(listOf str)
either (enum [
"fade"
"slide"
"fade_in_slide_out"
"static"
]) (listOf str)
)
"fade_in_slide_out"
''
@ -51,18 +46,14 @@ in {
Can be either one of the builtin stages or an array of lua functions.
'';
backgroundColour = helpers.defaultNullOpts.mkStr "NotifyBackground" ''
For stages that change opacity this is treated as the highlight behind the window.
Set this to either a highlight group, an RGB hex value e.g. "#000000" or a function
returning an RGB code for dynamic values.
'';
backgroundColour = helpers.defaultNullOpts.mkStr "NotifyBackground" ''
For stages that change opacity this is treated as the highlight behind the window.
Set this to either a highlight group, an RGB hex value e.g. "#000000" or a function
returning an RGB code for dynamic values.
'';
icons =
mapAttrs
(
name: default:
helpers.defaultNullOpts.mkStr default "Icon for the ${name} level."
)
icons =
mapAttrs (name: default: helpers.defaultNullOpts.mkStr default "Icon for the ${name} level.")
{
error = "";
warn = "";
@ -71,76 +62,61 @@ in {
trace = "";
};
onOpen = helpers.defaultNullOpts.mkLuaFn "nil" ''
Function called when a new window is opened, use for changing win settings/config.
'';
onOpen = helpers.defaultNullOpts.mkLuaFn "nil" ''
Function called when a new window is opened, use for changing win settings/config.
'';
onClose = helpers.defaultNullOpts.mkLuaFn "nil" ''
Function called when a new window is closed.
'';
onClose = helpers.defaultNullOpts.mkLuaFn "nil" ''
Function called when a new window is closed.
'';
render =
helpers.defaultNullOpts.mkNullable
(
with types;
either
(enum ["default" "minimal"])
helpers.nixvimTypes.rawLua
)
render = helpers.defaultNullOpts.mkNullable (
with types;
either (enum [
"default"
"Function to render a notification buffer or a built-in renderer name.";
"minimal"
]) helpers.nixvimTypes.rawLua
) "default" "Function to render a notification buffer or a built-in renderer name.";
minimumWidth = helpers.defaultNullOpts.mkUnsignedInt 50 ''
Minimum width for notification windows.
'';
minimumWidth = helpers.defaultNullOpts.mkUnsignedInt 50 ''
Minimum width for notification windows.
'';
fps = helpers.defaultNullOpts.mkPositiveInt 30 ''
Frames per second for animation stages, higher value means smoother animations but more CPU
usage.
'';
fps = helpers.defaultNullOpts.mkPositiveInt 30 ''
Frames per second for animation stages, higher value means smoother animations but more CPU
usage.
'';
topDown = helpers.defaultNullOpts.mkBool true ''
Whether or not to position the notifications at the top or not.
'';
};
topDown = helpers.defaultNullOpts.mkBool true ''
Whether or not to position the notifications at the top or not.
'';
};
config = let
setupOptions = with cfg;
{
inherit
level
timeout
;
max_width = maxWidth;
max_height = maxHeight;
stages =
helpers.ifNonNull' stages
(
if isString stages
then stages
else map helpers.mkRaw stages
);
background_colour = backgroundColour;
icons =
mapAttrs'
(
name: value: {
name = strings.toUpper name;
inherit value;
}
)
icons;
on_open = onOpen;
on_close = onClose;
inherit render;
minimum_width = minimumWidth;
inherit fps;
top_down = topDown;
}
// cfg.extraOptions;
in
config =
let
setupOptions =
with cfg;
{
inherit level timeout;
max_width = maxWidth;
max_height = maxHeight;
stages = helpers.ifNonNull' stages (if isString stages then stages else map helpers.mkRaw stages);
background_colour = backgroundColour;
icons = mapAttrs' (name: value: {
name = strings.toUpper name;
inherit value;
}) icons;
on_open = onOpen;
on_close = onClose;
inherit render;
minimum_width = minimumWidth;
inherit fps;
top_down = topDown;
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
vim.notify = require('notify');

View file

@ -6,207 +6,195 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "nvim-autopairs";
defaultPackage = pkgs.vimPlugins.nvim-autopairs;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "nvim-autopairs";
defaultPackage = pkgs.vimPlugins.nvim-autopairs;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO: introduced 2024-03-27, remove on 2024-05-27
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"disableInMacro"
"disableInVisualblock"
"disableInReplaceMode"
"ignoredNextChar"
"enableMoveright"
"enableCheckBracketLine"
"enableBracketInQuote"
"enableAbbr"
"breakUndo"
"checkTs"
"tsConfig"
"mapCr"
"mapBs"
"mapCH"
"mapCW"
];
imports = let
basePluginPaths = ["plugins" "nvim-autopairs"];
settingsPath = basePluginPaths ++ ["settings"];
in [
(
mkRenamedOptionModule
(basePluginPaths ++ ["disabledFiletypes"])
(settingsPath ++ ["disable_filetype"])
)
(
mkRenamedOptionModule
(basePluginPaths ++ ["enableAfterQuote"])
(settingsPath ++ ["enable_afterquote"])
)
(
mkRemovedOptionModule
(basePluginPaths ++ ["pairs"])
''
This option was having no effect.
If you want to customize pairs, please use `extraConfigLua` to define them as described in the plugin documentation.
''
)
# TODO: introduced 2024-03-27, remove on 2024-05-27
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"disableInMacro"
"disableInVisualblock"
"disableInReplaceMode"
"ignoredNextChar"
"enableMoveright"
"enableCheckBracketLine"
"enableBracketInQuote"
"enableAbbr"
"breakUndo"
"checkTs"
"tsConfig"
"mapCr"
"mapBs"
"mapCH"
"mapCW"
];
imports =
let
basePluginPaths = [
"plugins"
"nvim-autopairs"
];
settingsPath = basePluginPaths ++ [ "settings" ];
in
[
(mkRenamedOptionModule (basePluginPaths ++ [ "disabledFiletypes" ]) (
settingsPath ++ [ "disable_filetype" ]
))
(mkRenamedOptionModule (basePluginPaths ++ [ "enableAfterQuote" ]) (
settingsPath ++ [ "enable_afterquote" ]
))
(mkRemovedOptionModule (basePluginPaths ++ [ "pairs" ]) ''
This option was having no effect.
If you want to customize pairs, please use `extraConfigLua` to define them as described in the plugin documentation.
'')
];
settingsOptions = {
disable_filetype =
helpers.defaultNullOpts.mkListOf types.str
''["TelescopePrompt" "spectre_panel"]''
settingsOptions = {
disable_filetype =
helpers.defaultNullOpts.mkListOf types.str ''["TelescopePrompt" "spectre_panel"]''
"Disabled filetypes.";
disable_in_macro = helpers.defaultNullOpts.mkBool false ''
Disable when recording or executing a macro.
disable_in_macro = helpers.defaultNullOpts.mkBool false ''
Disable when recording or executing a macro.
'';
disable_in_visualblock = helpers.defaultNullOpts.mkBool false ''
Disable when insert after visual block mode.
'';
disable_in_replace_mode = helpers.defaultNullOpts.mkBool true ''
Disable in replace mode.
'';
ignored_next_char = helpers.defaultNullOpts.mkLua "[=[[%w%%%'%[%\"%.%`%$]]=]" ''
Regexp to ignore if it matches the next character.
'';
enable_moveright = helpers.defaultNullOpts.mkBool true ''
Enable moveright.
'';
enable_afterquote = helpers.defaultNullOpts.mkBool true ''
Add bracket pairs after quote.
'';
enable_check_bracket_line = helpers.defaultNullOpts.mkBool true ''
Check bracket in same line.
'';
enable_bracket_in_quote = helpers.defaultNullOpts.mkBool true ''
Enable bracket in quote.
'';
enable_abbr = helpers.defaultNullOpts.mkBool false ''
Trigger abbreviation.
'';
break_undo = helpers.defaultNullOpts.mkBool true ''
Switch for basic rule break undo sequence.
'';
check_ts = helpers.defaultNullOpts.mkBool false ''
Use treesitter to check for a pair.
'';
ts_config = helpers.defaultNullOpts.mkAttrsOf types.anything ''
{
lua = [
"string"
"source"
"string_content"
];
javascript = [
"string"
"template_string"
];
}
'' "Configuration for TreeSitter.";
map_cr = helpers.defaultNullOpts.mkBool true ''
Map the `<CR>` key to confirm the completion.
'';
map_bs = helpers.defaultNullOpts.mkBool true ''
Map the `<BS>` key to delete the pair.
'';
map_c_h = helpers.defaultNullOpts.mkBool false ''
Map the `<C-h>` key to delete a pair.
'';
map_c_w = helpers.defaultNullOpts.mkBool false ''
Map the `<C-w>` key to delete a pair if possible.
'';
fast_wrap = {
map = helpers.defaultNullOpts.mkStr "<M-e>" ''
The key to trigger fast_wrap.
'';
disable_in_visualblock = helpers.defaultNullOpts.mkBool false ''
Disable when insert after visual block mode.
chars = helpers.defaultNullOpts.mkListOf types.str ''["{" "[" "(" "\"" "'"]'' ''
Characters for which to enable fast wrap.
'';
disable_in_replace_mode = helpers.defaultNullOpts.mkBool true ''
Disable in replace mode.
pattern = helpers.defaultNullOpts.mkLua ''[=[[%'%"%>%]%)%}%,%`]]=]'' ''
The pattern to match against.
'';
ignored_next_char = helpers.defaultNullOpts.mkLua "[=[[%w%%%'%[%\"%.%`%$]]=]" ''
Regexp to ignore if it matches the next character.
end_key = helpers.defaultNullOpts.mkStr "$" ''
End key.
'';
enable_moveright = helpers.defaultNullOpts.mkBool true ''
Enable moveright.
before_key = helpers.defaultNullOpts.mkStr "h" ''
Before key.
'';
enable_afterquote = helpers.defaultNullOpts.mkBool true ''
Add bracket pairs after quote.
after_key = helpers.defaultNullOpts.mkStr "l" ''
After key.
'';
enable_check_bracket_line = helpers.defaultNullOpts.mkBool true ''
Check bracket in same line.
cursor_pos_before = helpers.defaultNullOpts.mkBool true ''
Whether the cursor should be placed before or after the substitution.
'';
enable_bracket_in_quote = helpers.defaultNullOpts.mkBool true ''
Enable bracket in quote.
keys = helpers.defaultNullOpts.mkStr "qwertyuiopzxcvbnmasdfghjkl" '''';
highlight = helpers.defaultNullOpts.mkStr "Search" ''
Which highlight group to use for the match.
'';
enable_abbr = helpers.defaultNullOpts.mkBool false ''
Trigger abbreviation.
highlight_grey = helpers.defaultNullOpts.mkStr "Comment" ''
Which highlight group to use for the grey part.
'';
break_undo = helpers.defaultNullOpts.mkBool true ''
Switch for basic rule break undo sequence.
manual_position = helpers.defaultNullOpts.mkBool true ''
Whether to enable manual position.
'';
check_ts = helpers.defaultNullOpts.mkBool false ''
Use treesitter to check for a pair.
use_virt_lines = helpers.defaultNullOpts.mkBool true ''
Whether to use `virt_lines`.
'';
ts_config =
helpers.defaultNullOpts.mkAttrsOf types.anything
''
{
lua = [
"string"
"source"
"string_content"
];
javascript = [
"string"
"template_string"
];
}
''
"Configuration for TreeSitter.";
map_cr = helpers.defaultNullOpts.mkBool true ''
Map the `<CR>` key to confirm the completion.
'';
map_bs = helpers.defaultNullOpts.mkBool true ''
Map the `<BS>` key to delete the pair.
'';
map_c_h = helpers.defaultNullOpts.mkBool false ''
Map the `<C-h>` key to delete a pair.
'';
map_c_w = helpers.defaultNullOpts.mkBool false ''
Map the `<C-w>` key to delete a pair if possible.
'';
fast_wrap = {
map = helpers.defaultNullOpts.mkStr "<M-e>" ''
The key to trigger fast_wrap.
'';
chars = helpers.defaultNullOpts.mkListOf types.str ''["{" "[" "(" "\"" "'"]'' ''
Characters for which to enable fast wrap.
'';
pattern = helpers.defaultNullOpts.mkLua ''[=[[%'%"%>%]%)%}%,%`]]=]'' ''
The pattern to match against.
'';
end_key = helpers.defaultNullOpts.mkStr "$" ''
End key.
'';
before_key = helpers.defaultNullOpts.mkStr "h" ''
Before key.
'';
after_key = helpers.defaultNullOpts.mkStr "l" ''
After key.
'';
cursor_pos_before = helpers.defaultNullOpts.mkBool true ''
Whether the cursor should be placed before or after the substitution.
'';
keys =
helpers.defaultNullOpts.mkStr "qwertyuiopzxcvbnmasdfghjkl" ''
'';
highlight = helpers.defaultNullOpts.mkStr "Search" ''
Which highlight group to use for the match.
'';
highlight_grey = helpers.defaultNullOpts.mkStr "Comment" ''
Which highlight group to use for the grey part.
'';
manual_position = helpers.defaultNullOpts.mkBool true ''
Whether to enable manual position.
'';
use_virt_lines = helpers.defaultNullOpts.mkBool true ''
Whether to use `virt_lines`.
'';
};
};
};
settingsExample = {
disable_filetype = ["TelescopePrompt"];
fast_wrap = {
map = "<M-e>";
end_key = "$";
};
settingsExample = {
disable_filetype = [ "TelescopePrompt" ];
fast_wrap = {
map = "<M-e>";
end_key = "$";
};
};
extraConfig = cfg: {
warnings =
optional (
(isBool cfg.settings.check_ts)
&& cfg.settings.check_ts
&& !config.plugins.treesitter.enable
)
extraConfig = cfg: {
warnings =
optional
((isBool cfg.settings.check_ts) && cfg.settings.check_ts && !config.plugins.treesitter.enable)
''
Nixvim (plugins.nvim-autopairs): You have set `settings.check_ts` to `true` but have not enabled the treesitter plugin.
We suggest you to set `plugins.treesitter.enable` to `true`.
'';
};
}
};
}

View file

@ -5,124 +5,122 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.nvim-bqf;
in {
options.plugins.nvim-bqf =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "nvim-bqf";
in
{
options.plugins.nvim-bqf = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "nvim-bqf";
package = helpers.mkPackageOption "nvim-bqf" pkgs.vimPlugins.nvim-bqf;
package = helpers.mkPackageOption "nvim-bqf" pkgs.vimPlugins.nvim-bqf;
autoEnable = helpers.defaultNullOpts.mkBool true ''
Enable nvim-bqf in quickfix window automatically.
autoEnable = helpers.defaultNullOpts.mkBool true ''
Enable nvim-bqf in quickfix window automatically.
'';
magicWindow = helpers.defaultNullOpts.mkBool true ''
Give the window magic, when the window is split horizontally, keep the distance between the
current line and the top/bottom border of neovim unchanged.
It's a bit like a floating window, but the window is indeed a normal window, without any
floating attributes.
'';
autoResizeHeight = helpers.defaultNullOpts.mkBool false ''
Resize quickfix window height automatically.
Shrink higher height to size of list in quickfix window, otherwise extend height to size of
list or to default height (10).
'';
preview = {
autoPreview = helpers.defaultNullOpts.mkBool true ''
Enable preview in quickfix window automatically.
'';
magicWindow = helpers.defaultNullOpts.mkBool true ''
Give the window magic, when the window is split horizontally, keep the distance between the
current line and the top/bottom border of neovim unchanged.
It's a bit like a floating window, but the window is indeed a normal window, without any
floating attributes.
'';
autoResizeHeight = helpers.defaultNullOpts.mkBool false ''
Resize quickfix window height automatically.
Shrink higher height to size of list in quickfix window, otherwise extend height to size of
list or to default height (10).
'';
preview = {
autoPreview = helpers.defaultNullOpts.mkBool true ''
Enable preview in quickfix window automatically.
'';
borderChars =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
borderChars =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
"[ \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" \"\" ]"
''
Border and scroll bar chars, they respectively represent:
vline, vline, hline, hline, ulcorner, urcorner, blcorner, brcorner, sbar
'';
showTitle = helpers.defaultNullOpts.mkBool true ''
Show the window title.
'';
delaySyntax = helpers.defaultNullOpts.mkInt 50 ''
Delay time, to do syntax for previewed buffer, unit is millisecond.
'';
winHeight = helpers.defaultNullOpts.mkInt 15 ''
The height of preview window for horizontal layout.
Large value (like 999) perform preview window as a "full" mode.
'';
winVheight = helpers.defaultNullOpts.mkInt 15 ''
The height of preview window for vertical layout.
'';
wrap = helpers.defaultNullOpts.mkBool false ''
Wrap the line, `:h wrap` for detail.
'';
bufLabel = helpers.defaultNullOpts.mkBool true ''
Add label of current item buffer at the end of the item line.
'';
shouldPreviewCb = helpers.defaultNullOpts.mkLuaFn "nil" ''
A callback function to decide whether to preview while switching buffer, with
(bufnr: number, qwinid: number) parameters.
'';
};
funcMap = helpers.mkNullOrOption (types.attrsOf types.str) ''
The table for {function = key}.
Example (some default values):
funcMap = {
open = "<CR>";
tab = "t";
sclear = "z<Tab>";
};
showTitle = helpers.defaultNullOpts.mkBool true ''
Show the window title.
'';
filter = {
fzf = {
actionFor = {
"ctrl-t" = helpers.defaultNullOpts.mkStr "tabedit" ''
Press ctrl-t to open up the item in a new tab.
'';
delaySyntax = helpers.defaultNullOpts.mkInt 50 ''
Delay time, to do syntax for previewed buffer, unit is millisecond.
'';
"ctrl-v" = helpers.defaultNullOpts.mkStr "vsplit" ''
Press ctrl-v to open up the item in a new vertical split.
'';
winHeight = helpers.defaultNullOpts.mkInt 15 ''
The height of preview window for horizontal layout.
Large value (like 999) perform preview window as a "full" mode.
'';
"ctrl-x" = helpers.defaultNullOpts.mkStr "split" ''
Press ctrl-x to open up the item in a new horizontal split.
'';
winVheight = helpers.defaultNullOpts.mkInt 15 ''
The height of preview window for vertical layout.
'';
"ctrl-q" = helpers.defaultNullOpts.mkStr "signtoggle" ''
Press ctrl-q to toggle sign for the selected items.
'';
wrap = helpers.defaultNullOpts.mkBool false ''
Wrap the line, `:h wrap` for detail.
'';
"ctrl-c" = helpers.defaultNullOpts.mkStr "closeall" ''
Press ctrl-c to close quickfix window and abort fzf.
'';
};
bufLabel = helpers.defaultNullOpts.mkBool true ''
Add label of current item buffer at the end of the item line.
'';
extraOpts =
helpers.defaultNullOpts.mkNullable
(types.listOf types.str)
"[ \"--bind\" \"ctrl-o:toggle-all\" ]"
"Extra options for fzf.";
};
};
shouldPreviewCb = helpers.defaultNullOpts.mkLuaFn "nil" ''
A callback function to decide whether to preview while switching buffer, with
(bufnr: number, qwinid: number) parameters.
'';
};
config = let
options =
{
funcMap = helpers.mkNullOrOption (types.attrsOf types.str) ''
The table for {function = key}.
Example (some default values):
funcMap = {
open = "<CR>";
tab = "t";
sclear = "z<Tab>";
};
'';
filter = {
fzf = {
actionFor = {
"ctrl-t" = helpers.defaultNullOpts.mkStr "tabedit" ''
Press ctrl-t to open up the item in a new tab.
'';
"ctrl-v" = helpers.defaultNullOpts.mkStr "vsplit" ''
Press ctrl-v to open up the item in a new vertical split.
'';
"ctrl-x" = helpers.defaultNullOpts.mkStr "split" ''
Press ctrl-x to open up the item in a new horizontal split.
'';
"ctrl-q" = helpers.defaultNullOpts.mkStr "signtoggle" ''
Press ctrl-q to toggle sign for the selected items.
'';
"ctrl-c" = helpers.defaultNullOpts.mkStr "closeall" ''
Press ctrl-c to close quickfix window and abort fzf.
'';
};
extraOpts =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[ \"--bind\" \"ctrl-o:toggle-all\" ]"
"Extra options for fzf.";
};
};
};
config =
let
options = {
auto_enable = cfg.autoEnable;
magic_window = cfg.magicWindow;
auto_resize_height = cfg.autoResizeHeight;
@ -144,11 +142,10 @@ in {
extra_opts = extraOpts;
};
};
}
// cfg.extraOptions;
in
} // cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require('bqf').setup(${helpers.toLuaObject options})

View file

@ -5,7 +5,8 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.nvim-colorizer;
colorizer-options = {
@ -56,7 +57,13 @@ with lib; let
};
mode = mkOption {
description = "Set the display mode";
type = types.nullOr (types.enum ["foreground" "background" "virtualtext"]);
type = types.nullOr (
types.enum [
"foreground"
"background"
"virtualtext"
]
);
default = null;
};
tailwind = mkOption {
@ -64,7 +71,11 @@ with lib; let
type = types.nullOr (
types.oneOf [
types.bool
(types.enum ["normal" "lsp" "both"])
(types.enum [
"normal"
"lsp"
"both"
])
]
);
default = null;
@ -87,7 +98,8 @@ with lib; let
default = null;
};
};
in {
in
{
options = {
plugins.nvim-colorizer = {
enable = mkEnableOption "nvim-colorizer";
@ -97,27 +109,23 @@ in {
fileTypes = mkOption {
description = "Enable and/or configure highlighting for certain filetypes";
type = types.nullOr (
types.listOf (types.oneOf [
types.str
(types.submodule {
options =
{
language = mkOption {
type = types.str;
};
}
// colorizer-options;
})
])
types.listOf (
types.oneOf [
types.str
(types.submodule {
options = {
language = mkOption { type = types.str; };
} // colorizer-options;
})
]
)
);
default = null;
};
userDefaultOptions = mkOption {
description = "Default options";
type = types.nullOr (types.submodule {
options = colorizer-options;
});
type = types.nullOr (types.submodule { options = colorizer-options; });
default = null;
};
@ -130,32 +138,33 @@ in {
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = let
filetypes =
if (cfg.fileTypes != null)
then
(
let
list =
map (
extraConfigLua =
let
filetypes =
if (cfg.fileTypes != null) then
(
let
list = map (
v:
if builtins.isAttrs v
then v.language + " = " + helpers.toLuaObject (builtins.removeAttrs v ["language"])
else "'${v}'"
)
cfg.fileTypes;
in
if builtins.isAttrs v then
v.language + " = " + helpers.toLuaObject (builtins.removeAttrs v [ "language" ])
else
"'${v}'"
) cfg.fileTypes;
in
"{" + (concatStringsSep "," list) + "}"
)
else "nil";
in ''
require("colorizer").setup({
filetypes = ${filetypes},
user_default_options = ${helpers.toLuaObject cfg.userDefaultOptions},
buftypes = ${helpers.toLuaObject cfg.bufTypes},
})
'';
)
else
"nil";
in
''
require("colorizer").setup({
filetypes = ${filetypes},
user_default_options = ${helpers.toLuaObject cfg.userDefaultOptions},
buftypes = ${helpers.toLuaObject cfg.bufTypes},
})
'';
};
}

View file

@ -5,14 +5,14 @@
config,
...
}:
with lib; {
with lib;
{
options.plugins.nvim-osc52 = {
enable = mkEnableOption "nvim-osc52, a plugin to use OSC52 sequences to copy/paste";
package = helpers.mkPackageOption "nvim-osc52" pkgs.vimPlugins.nvim-osc52;
maxLength =
helpers.defaultNullOpts.mkInt 0 "Maximum length of selection (0 for no limit)";
maxLength = helpers.defaultNullOpts.mkInt 0 "Maximum length of selection (0 for no limit)";
silent = helpers.defaultNullOpts.mkBool false "Disable message on successful copy";
trim = helpers.defaultNullOpts.mkBool false "Trim text before copy";
@ -45,19 +45,20 @@ with lib; {
};
};
config = let
cfg = config.plugins.nvim-osc52;
setupOptions = with cfg; {
inherit silent trim;
max_length = maxLength;
};
in
config =
let
cfg = config.plugins.nvim-osc52;
setupOptions = with cfg; {
inherit silent trim;
max_length = maxLength;
};
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
keymaps = with cfg.keymaps;
mkIf enable
[
keymaps =
with cfg.keymaps;
mkIf enable [
{
mode = "n";
key = copy;

View file

@ -5,73 +5,75 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.nvim-ufo;
in {
options.plugins.nvim-ufo =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "nvim-ufo";
in
{
options.plugins.nvim-ufo = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "nvim-ufo";
package = helpers.mkPackageOption "nvim-ufo" pkgs.vimPlugins.nvim-ufo;
package = helpers.mkPackageOption "nvim-ufo" pkgs.vimPlugins.nvim-ufo;
openFoldHlTimeout = helpers.defaultNullOpts.mkInt 400 ''
Time in millisecond between the range to be highlgihted and to be cleared
while opening the folded line, `0` value will disable the highlight
'';
openFoldHlTimeout = helpers.defaultNullOpts.mkInt 400 ''
Time in millisecond between the range to be highlgihted and to be cleared
while opening the folded line, `0` value will disable the highlight
'';
providerSelector = helpers.defaultNullOpts.mkLuaFn "null" ''
A lua function as a selector for fold providers.
'';
providerSelector = helpers.defaultNullOpts.mkLuaFn "null" ''
A lua function as a selector for fold providers.
'';
closeFoldKinds = helpers.mkNullOrOption types.attrs ''
After the buffer is displayed (opened for the first time), close the
folds whose range with `kind` field is included in this option. For now,
'lsp' provider's standardized kinds are 'comment', 'imports' and 'region',
run `UfoInspect` for details if your provider has extended the kinds.
'';
closeFoldKinds = helpers.mkNullOrOption types.attrs ''
After the buffer is displayed (opened for the first time), close the
folds whose range with `kind` field is included in this option. For now,
'lsp' provider's standardized kinds are 'comment', 'imports' and 'region',
run `UfoInspect` for details if your provider has extended the kinds.
'';
foldVirtTextHandler = helpers.defaultNullOpts.mkLuaFn "null" "A lua function to customize fold virtual text";
foldVirtTextHandler = helpers.defaultNullOpts.mkLuaFn "null" "A lua function to customize fold virtual text";
enableGetFoldVirtText = helpers.defaultNullOpts.mkBool false ''
Enable a function with `lnum` as a parameter to capture the virtual text
for the folded lines and export the function to `get_fold_virt_text` field of
ctx table as 6th parameter in `fold_virt_text_handler`
'';
enableGetFoldVirtText = helpers.defaultNullOpts.mkBool false ''
Enable a function with `lnum` as a parameter to capture the virtual text
for the folded lines and export the function to `get_fold_virt_text` field of
ctx table as 6th parameter in `fold_virt_text_handler`
'';
preview = {
winConfig = {
border = helpers.defaultNullOpts.mkBorder "rounded" "preview window" "";
preview = {
winConfig = {
border = helpers.defaultNullOpts.mkBorder "rounded" "preview window" "";
winblend = helpers.defaultNullOpts.mkInt 12 "The winblend for preview window, `:h winblend`";
winblend = helpers.defaultNullOpts.mkInt 12 "The winblend for preview window, `:h winblend`";
winhighlight = helpers.defaultNullOpts.mkStr "Normal:Normal" "The winhighlight for preview window, `:h winhighlight`";
winhighlight = helpers.defaultNullOpts.mkStr "Normal:Normal" "The winhighlight for preview window, `:h winhighlight`";
maxheight = helpers.defaultNullOpts.mkInt 20 "The max height of preview window";
};
mappings = helpers.mkNullOrOption types.attrs "Mappings for preview window";
maxheight = helpers.defaultNullOpts.mkInt 20 "The max height of preview window";
};
mappings = helpers.mkNullOrOption types.attrs "Mappings for preview window";
};
};
config = let
options = with cfg;
{
open_fold_hl_timeout = openFoldHlTimeout;
provider_selector = providerSelector;
close_fold_kinds = closeFoldKinds;
fold_virt_text_handler = foldVirtTextHandler;
enable_get_fold_virt_text = enableGetFoldVirtText;
config =
let
options =
with cfg;
{
open_fold_hl_timeout = openFoldHlTimeout;
provider_selector = providerSelector;
close_fold_kinds = closeFoldKinds;
fold_virt_text_handler = foldVirtTextHandler;
enable_get_fold_virt_text = enableGetFoldVirtText;
preview = with preview; {
inherit mappings;
win_config = winConfig;
};
}
// cfg.extraOptions;
in
preview = with preview; {
inherit mappings;
win_config = winConfig;
};
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("ufo").setup(${helpers.toLuaObject options})

View file

@ -6,113 +6,213 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "obsidian";
originalName = "obsidian.nvim";
defaultPackage = pkgs.vimPlugins.obsidian-nvim;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "obsidian";
originalName = "obsidian.nvim";
defaultPackage = pkgs.vimPlugins.obsidian-nvim;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
## DEPRECATIONS
# Introduced 2024-03-12
# TODO: remove 2024-05-12
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"dir"
"logLevel"
"notesSubdir"
["templates" "subdir"]
["templates" "dateFormat"]
["templates" "timeFormat"]
["templates" "substitutions"]
"noteIdFunc"
"followUrlFunc"
"noteFrontmatterFunc"
"disableFrontmatter"
["completion" "nvimCmp"]
["completion" "minChars"]
"mappings"
["dailyNotes" "folder"]
["dailyNotes" "dateFormat"]
["dailyNotes" "aliasFormat"]
["dailyNotes" "template"]
"useAdvancedUri"
"openAppForeground"
"sortBy"
"sortReversed"
"openNotesIn"
["ui" "enable"]
["ui" "updateDebounce"]
["ui" "externalLinkIcon" "char"]
["ui" "externalLinkIcon" "hlGroup"]
["ui" "referenceText" "hlGroup"]
["ui" "highlightText" "hlGroup"]
["ui" "tags" "hlGroup"]
["ui" "hlGroups"]
["attachments" "imgFolder"]
["attachments" "imgTextFunc"]
"yamlParser"
];
imports = let
basePluginPath = ["plugins" "obsidian"];
## DEPRECATIONS
# Introduced 2024-03-12
# TODO: remove 2024-05-12
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"dir"
"logLevel"
"notesSubdir"
[
"templates"
"subdir"
]
[
"templates"
"dateFormat"
]
[
"templates"
"timeFormat"
]
[
"templates"
"substitutions"
]
"noteIdFunc"
"followUrlFunc"
"noteFrontmatterFunc"
"disableFrontmatter"
[
"completion"
"nvimCmp"
]
[
"completion"
"minChars"
]
"mappings"
[
"dailyNotes"
"folder"
]
[
"dailyNotes"
"dateFormat"
]
[
"dailyNotes"
"aliasFormat"
]
[
"dailyNotes"
"template"
]
"useAdvancedUri"
"openAppForeground"
"sortBy"
"sortReversed"
"openNotesIn"
[
"ui"
"enable"
]
[
"ui"
"updateDebounce"
]
[
"ui"
"externalLinkIcon"
"char"
]
[
"ui"
"externalLinkIcon"
"hlGroup"
]
[
"ui"
"referenceText"
"hlGroup"
]
[
"ui"
"highlightText"
"hlGroup"
]
[
"ui"
"tags"
"hlGroup"
]
[
"ui"
"hlGroups"
]
[
"attachments"
"imgFolder"
]
[
"attachments"
"imgTextFunc"
]
"yamlParser"
];
imports =
let
basePluginPath = [
"plugins"
"obsidian"
];
in
[
(
# We have to remove the option here because the user could set old-style camelCase options in each workspaces element.
mkRemovedOptionModule (
basePluginPath ++ [ "workspaces" ]
) "Please use `plugins.obsidian.settings.workspaces` instead."
)
(mkRenamedOptionModule (basePluginPath ++ [ "finder" ]) (
basePluginPath
++ [
"settings"
"picker"
"name"
]
))
(
# https://github.com/epwalsh/obsidian.nvim/blob/656d9c2c64528839db8b2d9a091843b3c90155a2/CHANGELOG.md?plain=1#L184
mkRenamedOptionModule
(
basePluginPath
++ [
"completion"
"newNotesLocation"
]
)
(
basePluginPath
++ [
"settings"
"new_notes_location"
]
)
)
(
# We have to remove the option here because the user could set old-style camelCase options in each checkbox element.
mkRemovedOptionModule (
basePluginPath
++ [
"ui"
"checkboxes"
]
) "Please use `plugins.obsidian.settings.ui.checkboxes` instead."
)
]
++ (map
(
optionPath:
mkRemovedOptionModule (basePluginPath ++ optionPath) "This option was deprecated by upstream."
)
[
( # We have to remove the option here because the user could set old-style camelCase options in each workspaces element.
mkRemovedOptionModule
(basePluginPath ++ ["workspaces"])
"Please use `plugins.obsidian.settings.workspaces` instead."
)
(
mkRenamedOptionModule
(basePluginPath ++ ["finder"])
(basePluginPath ++ ["settings" "picker" "name"])
)
(
# https://github.com/epwalsh/obsidian.nvim/blob/656d9c2c64528839db8b2d9a091843b3c90155a2/CHANGELOG.md?plain=1#L184
mkRenamedOptionModule
(basePluginPath ++ ["completion" "newNotesLocation"])
(basePluginPath ++ ["settings" "new_notes_location"])
)
( # We have to remove the option here because the user could set old-style camelCase options in each checkbox element.
mkRemovedOptionModule
(basePluginPath ++ ["ui" "checkboxes"])
"Please use `plugins.obsidian.settings.ui.checkboxes` instead."
)
]
++ (map (
optionPath:
mkRemovedOptionModule
(basePluginPath ++ optionPath)
"This option was deprecated by upstream."
)
[ "detectCwd" ]
[ "backlinks" ]
[
["detectCwd"]
["backlinks"]
["completion" "prependNoteId"]
["completion" "prependNotePath"]
["completion" "usePathOnly"]
]);
"completion"
"prependNoteId"
]
[
"completion"
"prependNotePath"
]
[
"completion"
"usePathOnly"
]
]
);
settingsOptions = let
opts = import ./options.nix {inherit lib helpers;};
settingsOptions =
let
opts = import ./options.nix { inherit lib helpers; };
in
{
dir = helpers.mkNullOrOption types.str ''
Alternatively to `workspaces` - and for backwards compatibility - you can set `dir` to a
single path instead of `workspaces`.
{
dir = helpers.mkNullOrOption types.str ''
Alternatively to `workspaces` - and for backwards compatibility - you can set `dir` to a
single path instead of `workspaces`.
For example:
```nix
dir = "~/vaults/work";
```
'';
For example:
```nix
dir = "~/vaults/work";
```
'';
workspaces =
helpers.defaultNullOpts.mkNullable
workspaces =
helpers.defaultNullOpts.mkNullable
(
with types;
listOf
(types.submodule {
listOf (
types.submodule {
options = {
name = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
@ -126,7 +226,8 @@ with lib;
overrides = opts;
};
})
}
)
)
"[]"
''
@ -137,36 +238,35 @@ with lib;
You can also provide configuration overrides for each workspace through the `overrides`
field.
'';
}
// opts;
settingsExample = {
workspaces = [
{
name = "work";
path = "~/obsidian/work";
}
// opts;
settingsExample = {
workspaces = [
{
name = "work";
path = "~/obsidian/work";
}
{
name = "startup";
path = "~/obsidian/startup";
}
];
new_notes_location = "current_dir";
completion = {
nvim_cmp = true;
min_chars = 2;
};
{
name = "startup";
path = "~/obsidian/startup";
}
];
new_notes_location = "current_dir";
completion = {
nvim_cmp = true;
min_chars = 2;
};
};
extraConfig = cfg: {
warnings = let
extraConfig = cfg: {
warnings =
let
nvimCmpEnabled = isBool cfg.settings.completion.nvim_cmp && cfg.settings.completion.nvim_cmp;
in
optional
(nvimCmpEnabled && !config.plugins.cmp.enable)
''
Nixvim (plugins.obsidian): You have enabled `completion.nvim_cmp` but `plugins.cmp.enable` is `false`.
You should probably enable `nvim-cmp`.
'';
};
}
optional (nvimCmpEnabled && !config.plugins.cmp.enable) ''
Nixvim (plugins.obsidian): You have enabled `completion.nvim_cmp` but `plugins.cmp.enable` is `false`.
You should probably enable `nvim-cmp`.
'';
};
}

View file

@ -1,8 +1,6 @@
{ lib, helpers }:
with lib;
{
lib,
helpers,
}:
with lib; {
# https://github.com/epwalsh/obsidian.nvim/blob/main/lua/obsidian/config.lua
log_level = helpers.defaultNullOpts.mkLogLevel "info" ''
@ -32,20 +30,24 @@ with lib; {
Example: "%H:%M"
'';
substitutions =
helpers.defaultNullOpts.mkAttrsOf
(with helpers.nixvimTypes; either str rawLua)
"{}"
"A map for custom variables, the key should be the variable and the value a function.";
substitutions = helpers.defaultNullOpts.mkAttrsOf (
with helpers.nixvimTypes; either str rawLua
) "{}" "A map for custom variables, the key should be the variable and the value a function.";
};
new_notes_location = helpers.defaultNullOpts.mkEnumFirstDefault ["current_dir" "notes_subdir"] ''
Where to put new notes created from completion.
new_notes_location =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"current_dir"
"notes_subdir"
]
''
Where to put new notes created from completion.
Valid options are
- "current_dir" - put new notes in same directory as the current buffer.
- "notes_subdir" - put new notes in the default notes subdirectory.
'';
Valid options are
- "current_dir" - put new notes in same directory as the current buffer.
- "notes_subdir" - put new notes in the default notes subdirectory.
'';
note_id_func = helpers.mkNullOrLuaFn ''
Customize how names/IDs for new notes are created.
@ -89,31 +91,29 @@ with lib; {
```
'';
wiki_link_func =
helpers.mkNullOrLuaFn
''
Customize how wiki links are formatted.
wiki_link_func = helpers.mkNullOrLuaFn ''
Customize how wiki links are formatted.
```lua
---@param opts {path: string, label: string, id: string|?}
---@return string
```
```lua
---@param opts {path: string, label: string, id: string|?}
---@return string
```
Example:
```lua
function(opts)
if opts.id == nil then
return string.format("[[%s]]", opts.label)
elseif opts.label ~= opts.id then
return string.format("[[%s|%s]]", opts.id, opts.label)
else
return string.format("[[%s]]", opts.id)
end
Example:
```lua
function(opts)
if opts.id == nil then
return string.format("[[%s]]", opts.label)
elseif opts.label ~= opts.id then
return string.format("[[%s|%s]]", opts.id, opts.label)
else
return string.format("[[%s]]", opts.id)
end
```
end
```
Default: See source
'';
Default: See source
'';
markdown_link_func = helpers.mkNullOrLuaFn ''
Customize how markdown links are formatted.
@ -133,9 +133,15 @@ with lib; {
Default: See source
'';
preferred_link_style = helpers.defaultNullOpts.mkEnumFirstDefault ["wiki" "markdown"] ''
Either 'wiki' or 'markdown'.
'';
preferred_link_style =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"wiki"
"markdown"
]
''
Either 'wiki' or 'markdown'.
'';
follow_url_func = helpers.mkNullOrLuaFn ''
By default when you use `:ObsidianFollowLink` on a link to an external URL it will be
@ -210,8 +216,8 @@ with lib; {
mappings =
helpers.defaultNullOpts.mkNullable
(
with types;
(
with types;
attrsOf (submodule {
options = {
action = mkOption {
@ -219,67 +225,72 @@ with lib; {
description = "The lua code for this keymap action.";
apply = helpers.mkRaw;
};
opts =
helpers.keymaps.mapConfigOptions
// {
buffer = helpers.defaultNullOpts.mkBool false ''
If true, the mapping will be effective in the current buffer only.
'';
};
opts = helpers.keymaps.mapConfigOptions // {
buffer = helpers.defaultNullOpts.mkBool false ''
If true, the mapping will be effective in the current buffer only.
'';
};
};
})
)
''
{
gf = {
action = "require('obsidian').util.gf_passthrough";
opts = {
noremap = false;
expr = true;
buffer = true;
)
''
{
gf = {
action = "require('obsidian').util.gf_passthrough";
opts = {
noremap = false;
expr = true;
buffer = true;
};
};
};
"<leader>ch" = {
action = "require('obsidian').util.toggle_checkbox";
opts.buffer = true;
};
}
''
''
Configure key mappings.
'';
"<leader>ch" = {
action = "require('obsidian').util.toggle_checkbox";
opts.buffer = true;
};
}
''
''
Configure key mappings.
'';
picker = {
name = helpers.mkNullOrOption (types.enum ["telescope.nvim" "fzf-lua" "mini.pick"]) ''
Set your preferred picker.
'';
name =
helpers.mkNullOrOption
(types.enum [
"telescope.nvim"
"fzf-lua"
"mini.pick"
])
''
Set your preferred picker.
'';
note_mappings =
helpers.defaultNullOpts.mkAttrsOf types.str
''
{
new = "<C-x>";
insert_link = "<C-l>";
}
''
''
Optional, configure note mappings for the picker. These are the defaults.
Not all pickers support all mappings.
'';
''
{
new = "<C-x>";
insert_link = "<C-l>";
}
''
''
Optional, configure note mappings for the picker. These are the defaults.
Not all pickers support all mappings.
'';
tag_mappings =
helpers.defaultNullOpts.mkAttrsOf types.str
''
{
tag_note = "<C-x>";
insert_tag = "<C-l>";
}
''
''
Optional, configure tag mappings for the picker. These are the defaults.
Not all pickers support all mappings.
'';
''
{
tag_note = "<C-x>";
insert_tag = "<C-l>";
}
''
''
Optional, configure tag mappings for the picker. These are the defaults.
Not all pickers support all mappings.
'';
};
daily_notes = {
@ -313,24 +324,40 @@ with lib; {
Set to true to force `:ObsidianOpen` to bring the app to the foreground.
'';
sort_by = helpers.defaultNullOpts.mkEnum ["path" "modified" "accessed" "created"] "modified" ''
Sort search results by "path", "modified", "accessed", or "created".
The recommend value is "modified" and `true` for `sortReversed`, which means, for example,
that `:ObsidianQuickSwitch` will show the notes sorted by latest modified time.
'';
sort_by =
helpers.defaultNullOpts.mkEnum
[
"path"
"modified"
"accessed"
"created"
]
"modified"
''
Sort search results by "path", "modified", "accessed", or "created".
The recommend value is "modified" and `true` for `sortReversed`, which means, for example,
that `:ObsidianQuickSwitch` will show the notes sorted by latest modified time.
'';
sort_reversed = helpers.defaultNullOpts.mkBool true ''
Whether search results should be reversed.
'';
open_notes_in = helpers.defaultNullOpts.mkEnumFirstDefault ["current" "vsplit" "hsplit"] ''
Determines how certain commands open notes.
open_notes_in =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"current"
"vsplit"
"hsplit"
]
''
Determines how certain commands open notes.
The valid options are:
- "current" (the default) - to always open in the current window
- "vsplit" - to open in a vertical split if there's not already a vertical split
- "hsplit" - to open in a horizontal split if there's not already a horizontal split
'';
The valid options are:
- "current" (the default) - to always open in the current window
- "vsplit" - to open in a vertical split if there's not already a vertical split
- "hsplit" - to open in a horizontal split if there's not already a horizontal split
'';
ui = {
enable = helpers.defaultNullOpts.mkBool true ''
@ -343,51 +370,49 @@ with lib; {
checkboxes =
helpers.defaultNullOpts.mkNullable
(
with types;
attrsOf (
submodule {
options = {
char = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
description = "The character to use for this checkbox.";
};
hl_group = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
description = "The name of the highlight group to use for this checkbox.";
};
(
with types;
attrsOf (submodule {
options = {
char = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
description = "The character to use for this checkbox.";
};
}
)
)
''
{
" " = {
char = "󰄱";
hl_group = "ObsidianTodo";
};
"x" = {
char = "";
hl_group = "ObsidianDone";
};
">" = {
char = "";
hl_group = "ObsidianRightArrow";
};
"~" = {
char = "󰰱";
hl_group = "ObsidianTilde";
};
}
''
''
Define how various check-boxes are displayed.
You can also add more custom ones...
NOTE: the 'char' value has to be a single character, and the highlight groups are defined
in the `ui.hl_groups` option.
'';
hl_group = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
description = "The name of the highlight group to use for this checkbox.";
};
};
})
)
''
{
" " = {
char = "󰄱";
hl_group = "ObsidianTodo";
};
"x" = {
char = "";
hl_group = "ObsidianDone";
};
">" = {
char = "";
hl_group = "ObsidianRightArrow";
};
"~" = {
char = "󰰱";
hl_group = "ObsidianTilde";
};
}
''
''
Define how various check-boxes are displayed.
You can also add more custom ones...
NOTE: the 'char' value has to be a single character, and the highlight groups are defined
in the `ui.hl_groups` option.
'';
bullets = {
char = helpers.defaultNullOpts.mkStr "" ''
@ -427,44 +452,40 @@ with lib; {
'';
};
hl_groups =
helpers.defaultNullOpts.mkNullable
(with helpers.nixvimTypes; attrsOf highlight)
''
{
ObsidianTodo = {
bold = true;
fg = "#f78c6c";
};
ObsidianDone = {
bold = true;
fg = "#89ddff";
};
ObsidianRightArrow = {
bold = true;
fg = "#f78c6c";
};
ObsidianTilde = {
bold = true;
fg = "#ff5370";
};
ObsidianRefText = {
underline = true;
fg = "#c792ea";
};
ObsidianExtLinkIcon = {
fg = "#c792ea";
};
ObsidianTag = {
italic = true;
fg = "#89ddff";
};
ObsidianHighlightText = {
bg = "#75662e";
};
}
''
"Highlight group definitions.";
hl_groups = helpers.defaultNullOpts.mkNullable (with helpers.nixvimTypes; attrsOf highlight) ''
{
ObsidianTodo = {
bold = true;
fg = "#f78c6c";
};
ObsidianDone = {
bold = true;
fg = "#89ddff";
};
ObsidianRightArrow = {
bold = true;
fg = "#f78c6c";
};
ObsidianTilde = {
bold = true;
fg = "#ff5370";
};
ObsidianRefText = {
underline = true;
fg = "#c792ea";
};
ObsidianExtLinkIcon = {
fg = "#c792ea";
};
ObsidianTag = {
italic = true;
fg = "#89ddff";
};
ObsidianHighlightText = {
bg = "#75662e";
};
}
'' "Highlight group definitions.";
};
attachments = {
@ -478,32 +499,32 @@ with lib; {
img_text_func =
helpers.defaultNullOpts.mkLuaFn
''
function(client, path)
---@type string
local link_path
local vault_relative_path = client:vault_relative_path(path)
if vault_relative_path ~= nil then
-- Use relative path if the image is saved in the vault dir.
link_path = vault_relative_path
else
-- Otherwise use the absolute path.
link_path = tostring(path)
''
function(client, path)
---@type string
local link_path
local vault_relative_path = client:vault_relative_path(path)
if vault_relative_path ~= nil then
-- Use relative path if the image is saved in the vault dir.
link_path = vault_relative_path
else
-- Otherwise use the absolute path.
link_path = tostring(path)
end
local display_name = vim.fs.basename(link_path)
return string.format("![%s](%s)", display_name, link_path)
end
local display_name = vim.fs.basename(link_path)
return string.format("![%s](%s)", display_name, link_path)
end
''
''
A function that determines the text to insert in the note when pasting an image.
It takes two arguments, the `obsidian.Client` and a plenary `Path` to the image file.
''
''
A function that determines the text to insert in the note when pasting an image.
It takes two arguments, the `obsidian.Client` and a plenary `Path` to the image file.
```lua
@param client obsidian.Client
@param path Path the absolute path to the image file
@return string
```
'';
```lua
@param client obsidian.Client
@param path Path the absolute path to the image file
@return string
```
'';
confirm_img_paste = helpers.defaultNullOpts.mkBool true ''
Whether to prompt for confirmation when pasting an image.
@ -542,15 +563,21 @@ with lib; {
'';
};
yaml_parser = helpers.defaultNullOpts.mkEnumFirstDefault ["native" "yq"] ''
Set the YAML parser to use.
yaml_parser =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"native"
"yq"
]
''
Set the YAML parser to use.
The valid options are:
- "native" - uses a pure Lua parser that's fast but potentially misses some edge cases.
- "yq" - uses the command-line tool yq (https://github.com/mikefarah/yq), which is more robust
but much slower and needs to be installed separately.
The valid options are:
- "native" - uses a pure Lua parser that's fast but potentially misses some edge cases.
- "yq" - uses the command-line tool yq (https://github.com/mikefarah/yq), which is more robust
but much slower and needs to be installed separately.
In general you should be using the native parser unless you run into a bug with it, in which
case you can temporarily switch to the "yq" parser until the bug is fixed.
'';
In general you should be using the native parser unless you run into a bug with it, in which
case you can temporarily switch to the "yq" parser until the bug is fixed.
'';
}

View file

@ -6,117 +6,219 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "oil";
originalName = "oil.nvim";
defaultPackage = pkgs.vimPlugins.oil-nvim;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "oil";
originalName = "oil.nvim";
defaultPackage = pkgs.vimPlugins.oil-nvim;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-03-18: remove 2024-05-18
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"defaultFileExplorer"
["bufOptions" "buflisted"]
["bufOptions" "bufhidden"]
["winOptions" "wrap"]
["winOptions" "signcolumn"]
["winOptions" "cursorcolumn"]
["winOptions" "foldcolumn"]
["winOptions" "spell"]
["winOptions" "list"]
["winOptions" "conceallevel"]
["winOptions" "concealcursor"]
"deleteToTrash"
"skipConfirmForSimpleEdits"
"promptSaveOnSelectNewEntry"
"cleanupDelayMs"
"keymaps"
"useDefaultKeymaps"
["viewOptions" "showHidden"]
["viewOptions" "isHiddenFile"]
["viewOptions" "isAlwaysHidden"]
["float" "padding"]
["float" "maxWidth"]
["float" "maxHeight"]
["float" "border"]
["float" "winOptions" "winblend"]
["preview" "maxWidth"]
["preview" "minWidth"]
["preview" "width"]
["preview" "maxHeight"]
["preview" "minHeight"]
["preview" "height"]
["preview" "border"]
["preview" "winOptions" "winblend"]
["progress" "maxWidth"]
["progress" "minWidth"]
["progress" "width"]
["progress" "maxHeight"]
["progress" "minHeight"]
["progress" "height"]
["progress" "border"]
["progress" "winOptions" "winblend"]
["progress" "minimizedBorder"]
];
imports = let
basePluginPath = ["plugins" "oil"];
settingsPath = basePluginPath ++ ["settings"];
in [
(
mkRemovedOptionModule
(basePluginPath ++ ["columns"])
"Use `plugins.oil.settings.columns` instead but beware, the format has changed."
)
(
mkRenamedOptionModule
(basePluginPath ++ ["lspRenameAutosave"])
(settingsPath ++ ["lsp_file_method" "autosave_changes"])
)
(
mkRemovedOptionModule
(basePluginPath ++ ["trashCommand"])
"This option has been deprecated by upstream."
)
(
mkRemovedOptionModule
(basePluginPath ++ ["restoreWinOptions"])
"This option has been deprecated by upstream."
)
# TODO introduced 2024-03-18: remove 2024-05-18
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"defaultFileExplorer"
[
"bufOptions"
"buflisted"
]
[
"bufOptions"
"bufhidden"
]
[
"winOptions"
"wrap"
]
[
"winOptions"
"signcolumn"
]
[
"winOptions"
"cursorcolumn"
]
[
"winOptions"
"foldcolumn"
]
[
"winOptions"
"spell"
]
[
"winOptions"
"list"
]
[
"winOptions"
"conceallevel"
]
[
"winOptions"
"concealcursor"
]
"deleteToTrash"
"skipConfirmForSimpleEdits"
"promptSaveOnSelectNewEntry"
"cleanupDelayMs"
"keymaps"
"useDefaultKeymaps"
[
"viewOptions"
"showHidden"
]
[
"viewOptions"
"isHiddenFile"
]
[
"viewOptions"
"isAlwaysHidden"
]
[
"float"
"padding"
]
[
"float"
"maxWidth"
]
[
"float"
"maxHeight"
]
[
"float"
"border"
]
[
"float"
"winOptions"
"winblend"
]
[
"preview"
"maxWidth"
]
[
"preview"
"minWidth"
]
[
"preview"
"width"
]
[
"preview"
"maxHeight"
]
[
"preview"
"minHeight"
]
[
"preview"
"height"
]
[
"preview"
"border"
]
[
"preview"
"winOptions"
"winblend"
]
[
"progress"
"maxWidth"
]
[
"progress"
"minWidth"
]
[
"progress"
"width"
]
[
"progress"
"maxHeight"
]
[
"progress"
"minHeight"
]
[
"progress"
"height"
]
[
"progress"
"border"
]
[
"progress"
"winOptions"
"winblend"
]
[
"progress"
"minimizedBorder"
]
];
imports =
let
basePluginPath = [
"plugins"
"oil"
];
settingsPath = basePluginPath ++ [ "settings" ];
in
[
(mkRemovedOptionModule (
basePluginPath ++ [ "columns" ]
) "Use `plugins.oil.settings.columns` instead but beware, the format has changed.")
(mkRenamedOptionModule (basePluginPath ++ [ "lspRenameAutosave" ]) (
settingsPath
++ [
"lsp_file_method"
"autosave_changes"
]
))
(mkRemovedOptionModule (
basePluginPath ++ [ "trashCommand" ]
) "This option has been deprecated by upstream.")
(mkRemovedOptionModule (
basePluginPath ++ [ "restoreWinOptions" ]
) "This option has been deprecated by upstream.")
];
settingsOptions = let
dimensionType = with types;
settingsOptions =
let
dimensionType =
with types;
oneOf [
ints.unsigned
(numbers.between 0.0 1.0)
(
listOf
(
either
ints.unsigned
(numbers.between 0.0 1.0)
)
)
(listOf (either ints.unsigned (numbers.between 0.0 1.0)))
];
in {
in
{
default_file_explorer = helpers.defaultNullOpts.mkBool true ''
Oil will take over directory buffers (e.g. `vim .` or `:e src/`).
Set to false if you still want to use netrw.
'';
columns = mkOption {
type = with helpers.nixvimTypes;
listOf
(
oneOf
[
str
(attrsOf anything)
rawLua
]
);
default = [];
type =
with helpers.nixvimTypes;
listOf (oneOf [
str
(attrsOf anything)
rawLua
]);
default = [ ];
description = ''
Columns can be specified as a string to use default arguments (e.g. `"icon"`),
or as a table to pass parameters (e.g. `{"size", highlight = "Special"}`)
@ -175,20 +277,13 @@ with lib;
'';
cleanup_delay_ms =
helpers.defaultNullOpts.mkNullable
(
with types;
either
types.ints.unsigned
(enum [false])
)
"2000"
''
Oil will automatically delete hidden buffers after this delay.
You can set the delay to false to disable cleanup entirely.
Note that the cleanup process only starts when none of the oil buffers are currently
displayed.
'';
helpers.defaultNullOpts.mkNullable (with types; either types.ints.unsigned (enum [ false ])) "2000"
''
Oil will automatically delete hidden buffers after this delay.
You can set the delay to false to disable cleanup entirely.
Note that the cleanup process only starts when none of the oil buffers are currently
displayed.
'';
lsp_file_method = {
timeout_ms = helpers.defaultNullOpts.mkUnsignedInt 1000 ''
@ -202,18 +297,11 @@ with lib;
};
constrain_cursor =
helpers.defaultNullOpts.mkNullable
(
with types;
either
str
(enum [false])
)
"editable"
''
Constrain the cursor to the editable parts of the oil buffer.
Set to `false` to disable, or "name" to keep it on the file names.
'';
helpers.defaultNullOpts.mkNullable (with types; either str (enum [ false ])) "editable"
''
Constrain the cursor to the editable parts of the oil buffer.
Set to `false` to disable, or "name" to keep it on the file names.
'';
experimental_watch_for_changes = helpers.defaultNullOpts.mkBool false ''
Set to true to watch the filesystem for changes and reload oil.
@ -221,44 +309,43 @@ with lib;
keymaps =
helpers.defaultNullOpts.mkAttrsOf
(
with types;
oneOf
[
(
with types;
oneOf [
str
(attrsOf anything)
(enum [false])
(enum [ false ])
]
)
''
{
"g?" = "actions.show_help";
"<CR>" = "actions.select";
"<C-s>" = "actions.select_vsplit";
"<C-h>" = "actions.select_split";
"<C-t>" = "actions.select_tab";
"<C-p>" = "actions.preview";
"<C-c>" = "actions.close";
"<C-l>" = "actions.refresh";
"-" = "actions.parent";
"_" = "actions.open_cwd";
"`" = "actions.cd";
"~" = "actions.tcd";
"gs" = "actions.change_sort";
"gx" = "actions.open_external";
"g." = "actions.toggle_hidden";
"g\\" = "actions.toggle_trash";
}
''
''
Keymaps in oil buffer.
Can be any value that `vim.keymap.set` accepts OR a table of keymap options with a
`callback` (e.g. `{ callback = function() ... end, desc = "", mode = "n" }`).
Additionally, if it is a string that matches "actions.<name>", it will use the mapping at
`require("oil.actions").<name>`.
Set to `false` to remove a keymap.
See `:help oil-actions` for a list of all available actions.
'';
)
''
{
"g?" = "actions.show_help";
"<CR>" = "actions.select";
"<C-s>" = "actions.select_vsplit";
"<C-h>" = "actions.select_split";
"<C-t>" = "actions.select_tab";
"<C-p>" = "actions.preview";
"<C-c>" = "actions.close";
"<C-l>" = "actions.refresh";
"-" = "actions.parent";
"_" = "actions.open_cwd";
"`" = "actions.cd";
"~" = "actions.tcd";
"gs" = "actions.change_sort";
"gx" = "actions.open_external";
"g." = "actions.toggle_hidden";
"g\\" = "actions.toggle_trash";
}
''
''
Keymaps in oil buffer.
Can be any value that `vim.keymap.set` accepts OR a table of keymap options with a
`callback` (e.g. `{ callback = function() ... end, desc = "", mode = "n" }`).
Additionally, if it is a string that matches "actions.<name>", it will use the mapping at
`require("oil.actions").<name>`.
Set to `false` to remove a keymap.
See `:help oil-actions` for a list of all available actions.
'';
keymaps_help = helpers.defaultNullOpts.mkAttrsOf types.anything ''{border = "rounded";}'' ''
Configuration for the floating keymaps help window.
@ -273,23 +360,17 @@ with lib;
Show files and directories that start with "."
'';
is_hidden_file =
helpers.defaultNullOpts.mkLuaFn
''
function(name, bufnr)
return vim.startswith(name, ".")
end
''
"This function defines what is considered a 'hidden' file.";
is_hidden_file = helpers.defaultNullOpts.mkLuaFn ''
function(name, bufnr)
return vim.startswith(name, ".")
end
'' "This function defines what is considered a 'hidden' file.";
is_always_hidden =
helpers.defaultNullOpts.mkLuaFn
''
function(name, bufnr)
return false
end
''
"This function defines what will never be shown, even when `show_hidden` is set.";
is_always_hidden = helpers.defaultNullOpts.mkLuaFn ''
function(name, bufnr)
return false
end
'' "This function defines what will never be shown, even when `show_hidden` is set.";
natural_order = helpers.defaultNullOpts.mkBool true ''
Sort file names in a more intuitive order for humans.
@ -298,16 +379,16 @@ with lib;
sort =
helpers.defaultNullOpts.mkListOf (with types; listOf str)
''
[
["type" "asc"]
["name" "asc"]
]
''
''
Sort order can be "asc" or "desc".
See `:help oil-columns` to see which columns are sortable.
'';
''
[
["type" "asc"]
["name" "asc"]
]
''
''
Sort order can be "asc" or "desc".
See `:help oil-columns` to see which columns are sortable.
'';
};
float = {
@ -325,15 +406,15 @@ with lib;
override =
helpers.defaultNullOpts.mkLuaFn
''
function(conf)
return conf
end
''
''
This is the config that will be passed to `nvim_open_win`.
Change values here to customize the layout.
'';
''
function(conf)
return conf
end
''
''
This is the config that will be passed to `nvim_open_win`.
Change values here to customize the layout.
'';
};
preview = {
@ -349,15 +430,9 @@ with lib;
`min_width = [40 0.4]` means "the greater of 40 columns or 40% of total".
'';
width =
helpers.mkNullOrOption
(
with types;
either
int
(numbers.between 0.0 1.0)
)
"Optionally define an integer/float for the exact width of the preview window.";
width = helpers.mkNullOrOption (
with types; either int (numbers.between 0.0 1.0)
) "Optionally define an integer/float for the exact width of the preview window.";
max_height = helpers.defaultNullOpts.mkNullable dimensionType "0.9" ''
Height dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%).
@ -371,15 +446,9 @@ with lib;
`min_height = [5 0.1]` means "the greater of 5 columns or 10% of total".
'';
height =
helpers.mkNullOrOption
(
with types;
either
int
(numbers.between 0.0 1.0)
)
"Optionally define an integer/float for the exact height of the preview window.";
height = helpers.mkNullOrOption (
with types; either int (numbers.between 0.0 1.0)
) "Optionally define an integer/float for the exact height of the preview window.";
border = helpers.defaultNullOpts.mkStr "rounded" "";
@ -405,15 +474,9 @@ with lib;
`min_width = [40 0.4]` means "the greater of 40 columns or 40% of total".
'';
width =
helpers.mkNullOrOption
(
with types;
either
int
(numbers.between 0.0 1.0)
)
"Optionally define an integer/float for the exact width of the preview window.";
width = helpers.mkNullOrOption (
with types; either int (numbers.between 0.0 1.0)
) "Optionally define an integer/float for the exact width of the preview window.";
max_height = helpers.defaultNullOpts.mkNullable dimensionType "0.9" ''
Height dimensions can be integers or a float between 0 and 1 (e.g. 0.4 for 40%).
@ -427,15 +490,9 @@ with lib;
`min_height = [5 0.1]` means "the greater of 5 columns or 10% of total".
'';
height =
helpers.mkNullOrOption
(
with types;
either
int
(numbers.between 0.0 1.0)
)
"Optionally define an integer/float for the exact height of the preview window.";
height = helpers.mkNullOrOption (
with types; either int (numbers.between 0.0 1.0)
) "Optionally define an integer/float for the exact height of the preview window.";
border = helpers.defaultNullOpts.mkStr "rounded" "";
@ -453,26 +510,26 @@ with lib;
};
};
settingsExample = {
columns = ["icon"];
view_options.show_hidden = false;
win_options = {
wrap = false;
signcolumn = "no";
cursorcolumn = false;
foldcolumn = "0";
spell = false;
list = false;
conceallevel = 3;
concealcursor = "ncv";
};
keymaps = {
"<C-c>" = false;
"<leader>qq" = "actions.close";
"<C-l>" = false;
"<C-r>" = "actions.refresh";
"y." = "actions.copy_entry_path";
};
skip_confirm_for_simple_edits = true;
settingsExample = {
columns = [ "icon" ];
view_options.show_hidden = false;
win_options = {
wrap = false;
signcolumn = "no";
cursorcolumn = false;
foldcolumn = "0";
spell = false;
list = false;
conceallevel = 3;
concealcursor = "ncv";
};
}
keymaps = {
"<C-c>" = false;
"<leader>qq" = "actions.close";
"<C-l>" = false;
"<C-r>" = "actions.refresh";
"y." = "actions.copy_entry_path";
};
skip_confirm_for_simple_edits = true;
};
}

View file

@ -5,10 +5,12 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.ollama;
actionOptionType = with helpers.nixvimTypes;
actionOptionType =
with helpers.nixvimTypes;
oneOf [
rawLua
(enum [
@ -21,7 +23,7 @@ with lib; let
])
(submodule {
options = {
fn = helpers.mkNullOrStrLuaFnOr (enum [false]) ''
fn = helpers.mkNullOrStrLuaFnOr (enum [ false ]) ''
fun(prompt: table): Ollama.PromptActionResponseCallback
Example:
@ -54,21 +56,21 @@ with lib; let
};
})
];
in {
meta.maintainers = [maintainers.GaetanLepage];
in
{
meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.ollama =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "ollama.nvim";
options.plugins.ollama = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "ollama.nvim";
package = helpers.mkPackageOption "ollama.nvim" pkgs.vimPlugins.ollama-nvim;
package = helpers.mkPackageOption "ollama.nvim" pkgs.vimPlugins.ollama-nvim;
model = helpers.defaultNullOpts.mkStr "mistral" ''
The default model to use.
'';
model = helpers.defaultNullOpts.mkStr "mistral" ''
The default model to use.
'';
prompts = let
prompts =
let
promptOptions = {
prompt = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
@ -106,20 +108,12 @@ in {
extract =
helpers.defaultNullOpts.mkNullable
(
with helpers.nixvimTypes;
maybeRaw
(
either
str
(enum [false])
)
)
"```$ftype\n(.-)```"
''
A `string.match` pattern to use for an Action to extract the output from the response
(Insert/Replace).
'';
(with helpers.nixvimTypes; maybeRaw (either str (enum [ false ])))
"```$ftype\n(.-)```"
''
A `string.match` pattern to use for an Action to extract the output from the response
(Insert/Replace).
'';
options = helpers.mkNullOrOption (with types; attrsOf anything) ''
Additional model parameters, such as temperature, listed in the documentation for the [Modelfile](https://github.com/jmorganca/ollama/blob/main/docs/modelfile.md#valid-parameters-and-values).
@ -131,104 +125,98 @@ in {
(overrides what's in the Modelfile).
'';
format = helpers.defaultNullOpts.mkEnumFirstDefault ["json"] ''
format = helpers.defaultNullOpts.mkEnumFirstDefault [ "json" ] ''
The format to return a response in.
Currently the only accepted value is `"json"`.
'';
};
processPrompt = prompt:
if isAttrs prompt
then {
inherit (prompt) prompt;
input_label = prompt.inputLabel;
inherit
(prompt)
action
model
extract
options
system
format
;
}
else prompt;
processPrompt =
prompt:
if isAttrs prompt then
{
inherit (prompt) prompt;
input_label = prompt.inputLabel;
inherit (prompt)
action
model
extract
options
system
format
;
}
else
prompt;
in
mkOption {
type = with types;
attrsOf (
either
(submodule {
options = promptOptions;
})
(enum [false])
);
default = {};
apply = v: mapAttrs (_: processPrompt) v;
description = ''
A table of prompts to use for each model.
Default prompts are defined [here](https://github.com/nomnivore/ollama.nvim/blob/main/lua/ollama/prompts.lua).
'';
};
action = helpers.defaultNullOpts.mkNullable actionOptionType "display" ''
How to handle prompt outputs when not specified by prompt.
See [here](https://github.com/nomnivore/ollama.nvim/tree/main#actions) for more details.
'';
url = helpers.defaultNullOpts.mkStr "http://127.0.0.1:11434" ''
The url to use to connect to the ollama server.
'';
serve = {
onStart = helpers.defaultNullOpts.mkBool false ''
Whether to start the ollama server on startup.
'';
command = helpers.defaultNullOpts.mkStr "ollama" ''
The command to use to start the ollama server.
'';
args = helpers.defaultNullOpts.mkListOf types.str ''["serve"]'' ''
The arguments to pass to the serve command.
'';
stopCommand = helpers.defaultNullOpts.mkStr "pkill" ''
The command to use to stop the ollama server.
'';
stopArgs = helpers.defaultNullOpts.mkListOf types.str ''["-SIGTERM" "ollama"]'' ''
The arguments to pass to the stop command.
mkOption {
type = with types; attrsOf (either (submodule { options = promptOptions; }) (enum [ false ]));
default = { };
apply = v: mapAttrs (_: processPrompt) v;
description = ''
A table of prompts to use for each model.
Default prompts are defined [here](https://github.com/nomnivore/ollama.nvim/blob/main/lua/ollama/prompts.lua).
'';
};
action = helpers.defaultNullOpts.mkNullable actionOptionType "display" ''
How to handle prompt outputs when not specified by prompt.
See [here](https://github.com/nomnivore/ollama.nvim/tree/main#actions) for more details.
'';
url = helpers.defaultNullOpts.mkStr "http://127.0.0.1:11434" ''
The url to use to connect to the ollama server.
'';
serve = {
onStart = helpers.defaultNullOpts.mkBool false ''
Whether to start the ollama server on startup.
'';
command = helpers.defaultNullOpts.mkStr "ollama" ''
The command to use to start the ollama server.
'';
args = helpers.defaultNullOpts.mkListOf types.str ''["serve"]'' ''
The arguments to pass to the serve command.
'';
stopCommand = helpers.defaultNullOpts.mkStr "pkill" ''
The command to use to stop the ollama server.
'';
stopArgs = helpers.defaultNullOpts.mkListOf types.str ''["-SIGTERM" "ollama"]'' ''
The arguments to pass to the stop command.
'';
};
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = let
setupOptions = with cfg;
{
inherit
model
prompts
action
url
;
serve = with serve; {
on_start = onStart;
extraConfigLua =
let
setupOptions =
with cfg;
{
inherit
command
args
model
prompts
action
url
;
stop_command = stopCommand;
stop_args = stopArgs;
};
}
// cfg.extraOptions;
in ''
require('ollama').setup(${helpers.toLuaObject setupOptions})
'';
serve = with serve; {
on_start = onStart;
inherit command args;
stop_command = stopCommand;
stop_args = stopArgs;
};
}
// cfg.extraOptions;
in
''
require('ollama').setup(${helpers.toLuaObject setupOptions})
'';
};
}

View file

@ -5,20 +5,20 @@
pkgs,
...
}:
with lib; {
options.plugins.persistence =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "persistence.nvim";
with lib;
{
options.plugins.persistence = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "persistence.nvim";
package = helpers.mkPackageOption "persistence.nvim" pkgs.vimPlugins.persistence-nvim;
package = helpers.mkPackageOption "persistence.nvim" pkgs.vimPlugins.persistence-nvim;
dir =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua)
dir =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua)
''vim.fn.expand(vim.fn.stdpath("state") .. "/sessions/")''
"directory where session files are saved";
options = let
options =
let
# https://neovim.io/doc/user/options.html#'sessionoptions'
sessionOpts = [
"blank"
@ -38,30 +38,34 @@ with lib; {
"winsize"
];
in
helpers.defaultNullOpts.mkNullable (with types; listOf (enum sessionOpts))
''["buffers" "curdir" "tabpages" "winsize" "skiprtp"]'' "sessionoptions used for saving";
helpers.defaultNullOpts.mkNullable (
with types; listOf (enum sessionOpts)
) ''["buffers" "curdir" "tabpages" "winsize" "skiprtp"]'' "sessionoptions used for saving";
preSave = helpers.defaultNullOpts.mkLuaFn "nil" "a function to call before saving the session";
preSave = helpers.defaultNullOpts.mkLuaFn "nil" "a function to call before saving the session";
saveEmpty = helpers.defaultNullOpts.mkBool false ''
don't save if there are no open file buffers
'';
};
saveEmpty = helpers.defaultNullOpts.mkBool false ''
don't save if there are no open file buffers
'';
};
config = let
cfg = config.plugins.persistence;
in
config =
let
cfg = config.plugins.persistence;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = let
opts = {
inherit (cfg) dir options;
pre_save = cfg.preSave;
save_empty = cfg.saveEmpty;
};
in ''
require('persistence').setup(${helpers.toLuaObject opts})
'';
extraConfigLua =
let
opts = {
inherit (cfg) dir options;
pre_save = cfg.preSave;
save_empty = cfg.saveEmpty;
};
in
''
require('persistence').setup(${helpers.toLuaObject opts})
'';
};
}

View file

@ -5,62 +5,81 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.presence-nvim;
in {
in
{
options = {
plugins.presence-nvim =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "presence-nvim";
package = helpers.mkPackageOption "presence-nvim" pkgs.vimPlugins.presence-nvim;
plugins.presence-nvim = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "presence-nvim";
package = helpers.mkPackageOption "presence-nvim" pkgs.vimPlugins.presence-nvim;
# General options.
autoUpdate = helpers.defaultNullOpts.mkBool true ''
Update activity based on autocmd events.
If `false`, map or manually execute
`:lua package.loaded.presence:update()`
'';
# General options.
autoUpdate = helpers.defaultNullOpts.mkBool true ''
Update activity based on autocmd events.
If `false`, map or manually execute
`:lua package.loaded.presence:update()`
'';
neovimImageText = helpers.defaultNullOpts.mkStr "The One True Text Editor" ''
Text displayed when hovered over the Neovim image.
'';
neovimImageText = helpers.defaultNullOpts.mkStr "The One True Text Editor" ''
Text displayed when hovered over the Neovim image.
'';
mainImage = helpers.defaultNullOpts.mkEnum ["neovim" "file"] "neovim" ''
Main image display.
'';
mainImage =
helpers.defaultNullOpts.mkEnum
[
"neovim"
"file"
]
"neovim"
''
Main image display.
'';
clientId = helpers.defaultNullOpts.mkStr "793271441293967371" ''
Use your own Discord application client id. (not recommended)
'';
clientId = helpers.defaultNullOpts.mkStr "793271441293967371" ''
Use your own Discord application client id. (not recommended)
'';
logLevel = helpers.defaultNullOpts.mkEnum ["debug" "info" "warn" "error"] "null" ''
Log messages at or above this level.
'';
logLevel =
helpers.defaultNullOpts.mkEnum
[
"debug"
"info"
"warn"
"error"
]
"null"
''
Log messages at or above this level.
'';
debounceTimeout = helpers.defaultNullOpts.mkInt 10 ''
Number of seconds to debounce events.
(or calls to `:lua package.loaded.presence:update(<filename>, true)`)
'';
debounceTimeout = helpers.defaultNullOpts.mkInt 10 ''
Number of seconds to debounce events.
(or calls to `:lua package.loaded.presence:update(<filename>, true)`)
'';
enableLineNumber = helpers.defaultNullOpts.mkBool false ''
Displays the current line number instead of the current project.
'';
enableLineNumber = helpers.defaultNullOpts.mkBool false ''
Displays the current line number instead of the current project.
'';
blacklist = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
A list of strings or Lua patterns that disable Rich Presence if the
current file name, path, or workspace matches.
'';
blacklist = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
A list of strings or Lua patterns that disable Rich Presence if the
current file name, path, or workspace matches.
'';
buttons =
helpers.defaultNullOpts.mkNullable
(types.either helpers.nixvimTypes.rawLua
(types.listOf (types.submodule {
options = {
label = helpers.mkNullOrOption types.str "";
url = helpers.mkNullOrOption types.str "";
};
})))
buttons =
helpers.defaultNullOpts.mkNullable
(types.either helpers.nixvimTypes.rawLua (
types.listOf (
types.submodule {
options = {
label = helpers.mkNullOrOption types.str "";
url = helpers.mkNullOrOption types.str "";
};
}
)
))
"[]"
''
Button configurations which will always appear in Rich Presence.
@ -74,85 +93,103 @@ in {
Can also be a lua function: `function(buffer: string, repo_url: string|nil): table)`
'';
fileAssets = helpers.mkNullOrOption (with types; attrsOf (listOf str)) ''
Custom file asset definitions keyed by file names and extensions.
fileAssets = helpers.mkNullOrOption (with types; attrsOf (listOf str)) ''
Custom file asset definitions keyed by file names and extensions.
List elements for each attribute (filetype):
List elements for each attribute (filetype):
`name`: The name of the asset shown as the title of the file in Discord.
`name`: The name of the asset shown as the title of the file in Discord.
`source`: The source of the asset, either an art asset key or the URL of an image asset.
`source`: The source of the asset, either an art asset key or the URL of an image asset.
Example:
```nix
{
# Use art assets uploaded in Discord application for the configured client id
js = [ "JavaScript" "javascript" ];
ts = [ "TypeScript" "typescript" ];
# Use image URLs
rs = [ "Rust" "https://www.rust-lang.org/logos/rust-logo-512x512.png" ];
go = [ "Go" "https://go.dev/blog/go-brand/Go-Logo/PNG/Go-Logo_Aqua.png" ];
};
```
'';
Example:
```nix
{
# Use art assets uploaded in Discord application for the configured client id
js = [ "JavaScript" "javascript" ];
ts = [ "TypeScript" "typescript" ];
# Use image URLs
rs = [ "Rust" "https://www.rust-lang.org/logos/rust-logo-512x512.png" ];
go = [ "Go" "https://go.dev/blog/go-brand/Go-Logo/PNG/Go-Logo_Aqua.png" ];
};
```
'';
showTime = helpers.defaultNullOpts.mkBool true "Show the timer.";
showTime = helpers.defaultNullOpts.mkBool true "Show the timer.";
# Rich presence text options.
editingText = helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "Editing %s" ''
String rendered when an editable file is loaded in the buffer.
# Rich presence text options.
editingText =
helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "Editing %s"
''
String rendered when an editable file is loaded in the buffer.
Can also be a lua function:
`function(filename: string): string`
'';
Can also be a lua function:
`function(filename: string): string`
'';
fileExplorerText = helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "Browsing %s" ''
String rendered when browsing a file explorer.
fileExplorerText =
helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "Browsing %s"
''
String rendered when browsing a file explorer.
Can also be a lua function:
`function(file_explorer_name: string): string`
'';
Can also be a lua function:
`function(file_explorer_name: string): string`
'';
gitCommitText = helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "Committing changes" ''
String rendered when committing changes in git.
gitCommitText =
helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua)
"Committing changes"
''
String rendered when committing changes in git.
Can also be a lua function:
`function(filename: string): string`
'';
Can also be a lua function:
`function(filename: string): string`
'';
pluginManagerText = helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "Managing plugins" ''
String rendered when managing plugins.
pluginManagerText =
helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua)
"Managing plugins"
''
String rendered when managing plugins.
Can also be a lua function:
`function(plugin_manager_name: string): string`
'';
Can also be a lua function:
`function(plugin_manager_name: string): string`
'';
readingText = helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "Reading %s" ''
String rendered when a read-only/unmodifiable file is loaded into the buffer.
readingText =
helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "Reading %s"
''
String rendered when a read-only/unmodifiable file is loaded into the buffer.
Can also be a lua function:
`function(filename: string): string`
'';
Can also be a lua function:
`function(filename: string): string`
'';
workspaceText = helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "Working on %s" ''
String rendered when in a git repository.
workspaceText =
helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua)
"Working on %s"
''
String rendered when in a git repository.
Can also be a lua function:
`function(project_name: string|nil, filename: string): string`
'';
Can also be a lua function:
`function(project_name: string|nil, filename: string): string`
'';
lineNumberText = helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua) "Line %s out of %s" ''
String rendered when `enableLineNumber` is set to `true` to display the current line number.
lineNumberText =
helpers.defaultNullOpts.mkNullable (types.either types.str helpers.nixvimTypes.rawLua)
"Line %s out of %s"
''
String rendered when `enableLineNumber` is set to `true` to display the current line number.
Can also be a lua function:
`function(line_number: number, line_count: number): string`
'';
};
Can also be a lua function:
`function(line_number: number, line_count: number): string`
'';
};
};
config = let
setupOptions =
{
config =
let
setupOptions = {
# General options.
auto_update = cfg.autoUpdate;
neovim_image_text = cfg.neovimImageText;
@ -174,11 +211,10 @@ in {
reading_text = cfg.readingText;
workspace_text = cfg.workspaceText;
line_number_text = cfg.lineNumberText;
}
// cfg.extraOptions;
in
} // cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
require("presence").setup${helpers.toLuaObject setupOptions}
'';

View file

@ -5,31 +5,40 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.project-nvim;
in {
in
{
imports = [
(lib.mkRenamedOptionModule
["plugins" "telescope" "extensions" "project-nvim" "enable"]
["plugins" "project-nvim" "enableTelescope"])
[
"plugins"
"telescope"
"extensions"
"project-nvim"
"enable"
]
[
"plugins"
"project-nvim"
"enableTelescope"
]
)
];
options.plugins.project-nvim =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "project.nvim";
options.plugins.project-nvim = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "project.nvim";
package = helpers.mkPackageOption "project-nvim" pkgs.vimPlugins.project-nvim;
package = helpers.mkPackageOption "project-nvim" pkgs.vimPlugins.project-nvim;
manualMode = helpers.defaultNullOpts.mkBool false ''
Manual mode doesn't automatically change your root directory, so you have the option to
manually do so using `:ProjectRoot` command.
'';
manualMode = helpers.defaultNullOpts.mkBool false ''
Manual mode doesn't automatically change your root directory, so you have the option to
manually do so using `:ProjectRoot` command.
'';
detectionMethods =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
''["lsp" "pattern"]''
detectionMethods =
helpers.defaultNullOpts.mkNullable (with types; listOf str) ''["lsp" "pattern"]''
''
Methods of detecting the root directory.
**"lsp"** uses the native neovim lsp, while **"pattern"** uses vim-rooter like glob pattern
@ -38,75 +47,76 @@ in {
You can also delete or rearangne the detection methods.
'';
patterns =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
patterns =
helpers.defaultNullOpts.mkNullable (with types; listOf str)
''[".git" "_darcs" ".hg" ".bzr" ".svn" "Makefile" "package.json"]''
''
All the patterns used to detect root dir, when **"pattern"** is in `detectionMethods`.
'';
ignoreLsp =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
"[]"
"Table of lsp clients to ignore by name.";
ignoreLsp = helpers.defaultNullOpts.mkNullable (
with types; listOf str
) "[]" "Table of lsp clients to ignore by name.";
excludeDirs =
helpers.defaultNullOpts.mkNullable
(with types; listOf str)
"[]"
"Don't calculate root dir on specific directories.";
excludeDirs = helpers.defaultNullOpts.mkNullable (
with types; listOf str
) "[]" "Don't calculate root dir on specific directories.";
showHidden = helpers.defaultNullOpts.mkBool false "Show hidden files in telescope.";
showHidden = helpers.defaultNullOpts.mkBool false "Show hidden files in telescope.";
silentChdir = helpers.defaultNullOpts.mkBool true ''
When set to false, you will get a message when `project.nvim` changes your directory.
'';
silentChdir = helpers.defaultNullOpts.mkBool true ''
When set to false, you will get a message when `project.nvim` changes your directory.
'';
scopeChdir = helpers.defaultNullOpts.mkEnumFirstDefault ["global" "tab" "win"] ''
What scope to change the directory.
'';
scopeChdir =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"global"
"tab"
"win"
]
''
What scope to change the directory.
'';
dataPath =
helpers.defaultNullOpts.mkNullable
(with types; either str helpers.nixvimTypes.rawLua)
dataPath =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua)
''{__raw = "vim.fn.stdpath('data')";}''
"Path where project.nvim will store the project history for use in telescope.";
enableTelescope = mkEnableOption ''
When set to true, enabled project-nvim telescope integration.
'';
};
enableTelescope = mkEnableOption ''
When set to true, enabled project-nvim telescope integration.
'';
};
config = mkIf cfg.enable {
warnings =
optional
(cfg.enableTelescope && (!config.plugins.telescope.enable))
''
Telescope support for project-nvim is enabled but the telescope plugin is not.
'';
extraPlugins = [cfg.package];
extraConfigLua = let
setupOptions = with cfg;
{
manual_mode = manualMode;
detection_methods = detectionMethods;
inherit patterns;
ignore_lsp = ignoreLsp;
exclude_dirs = excludeDirs;
show_hidden = showHidden;
silent_chdir = silentChdir;
scope_schdir = scopeChdir;
data_path = dataPath;
}
// cfg.extraOptions;
in ''
require('project_nvim').setup(${helpers.toLuaObject setupOptions})
warnings = optional (cfg.enableTelescope && (!config.plugins.telescope.enable)) ''
Telescope support for project-nvim is enabled but the telescope plugin is not.
'';
plugins.telescope.enabledExtensions = mkIf cfg.enableTelescope ["projects"];
extraPlugins = [ cfg.package ];
extraConfigLua =
let
setupOptions =
with cfg;
{
manual_mode = manualMode;
detection_methods = detectionMethods;
inherit patterns;
ignore_lsp = ignoreLsp;
exclude_dirs = excludeDirs;
show_hidden = showHidden;
silent_chdir = silentChdir;
scope_schdir = scopeChdir;
data_path = dataPath;
}
// cfg.extraOptions;
in
''
require('project_nvim').setup(${helpers.toLuaObject setupOptions})
'';
plugins.telescope.enabledExtensions = mkIf cfg.enableTelescope [ "projects" ];
};
}

View file

@ -5,9 +5,11 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.quickmath;
in {
in
{
options.plugins.quickmath = {
enable = mkEnableOption "quickmath.nvim";
@ -25,11 +27,11 @@ in {
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
keymaps = with cfg.keymap;
optional (key != null)
{
keymaps =
with cfg.keymap;
optional (key != null) {
mode = "n";
inherit key;
action = ":Quickmath<CR>";

View file

@ -5,20 +5,15 @@
pkgs,
...
}:
with lib; {
options.plugins.refactoring =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "refactoring.nvim";
with lib;
{
options.plugins.refactoring = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "refactoring.nvim";
package = helpers.mkPackageOption "refactoring.nvim" pkgs.vimPlugins.refactoring-nvim;
package = helpers.mkPackageOption "refactoring.nvim" pkgs.vimPlugins.refactoring-nvim;
promptFuncReturnType =
helpers.defaultNullOpts.mkNullable
(
with types;
attrsOf bool
)
promptFuncReturnType =
helpers.defaultNullOpts.mkNullable (with types; attrsOf bool)
''
{
"go" = false;
@ -36,12 +31,8 @@ with lib; {
we want to provide a way to input a type instead of inserting a placeholder value.
'';
promptFuncParamType =
helpers.defaultNullOpts.mkNullable
(
with types;
attrsOf bool
)
promptFuncParamType =
helpers.defaultNullOpts.mkNullable (with types; attrsOf bool)
''
{
"go" = false;
@ -59,12 +50,8 @@ with lib; {
we want to provide a way to input a type instead of inserting a placeholder value.
'';
printVarStatements =
helpers.defaultNullOpts.mkNullable
(
with types;
attrsOf (listOf str)
)
printVarStatements =
helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str))
''
{
"go" = [];
@ -89,12 +76,8 @@ with lib; {
]
'';
printfStatements =
helpers.defaultNullOpts.mkNullable
(
with types;
attrsOf (listOf str)
)
printfStatements =
helpers.defaultNullOpts.mkNullable (with types; attrsOf (listOf str))
''
{
"go" = [];
@ -116,12 +99,8 @@ with lib; {
]
'';
extractVarStatements =
helpers.defaultNullOpts.mkNullable
(
with types;
attrsOf str
)
extractVarStatements =
helpers.defaultNullOpts.mkNullable (with types; attrsOf str)
''
{
"go" = "";
@ -140,24 +119,27 @@ with lib; {
Example:
go = "%s := %s // poggers"
'';
};
};
config = let
cfg = config.plugins.refactoring;
in
config =
let
cfg = config.plugins.refactoring;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = let
opts = with cfg; {
prompt_func_return_type = promptFuncReturnType;
prompt_func_param_type = promptFuncParamType;
print_var_statements = printVarStatements;
printf_statements = printfStatements;
extract_var_statements = extractVarStatements;
};
in ''
require('refactoring').setup(${helpers.toLuaObject opts})
'';
extraConfigLua =
let
opts = with cfg; {
prompt_func_return_type = promptFuncReturnType;
prompt_func_param_type = promptFuncParamType;
print_var_statements = printVarStatements;
printf_statements = printfStatements;
extract_var_statements = extractVarStatements;
};
in
''
require('refactoring').setup(${helpers.toLuaObject opts})
'';
};
}

View file

@ -6,288 +6,359 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "rest";
originalName = "rest.nvim";
luaName = "rest-nvim";
defaultPackage = pkgs.vimPlugins.rest-nvim;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "rest";
originalName = "rest.nvim";
luaName = "rest-nvim";
defaultPackage = pkgs.vimPlugins.rest-nvim;
extraPackages = [pkgs.curl];
extraPackages = [ pkgs.curl ];
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-04-07: remove 2024-06-07
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"envFile"
"encodeUrl"
"skipSslVerification"
"customDynamicVariables"
["highlight" "timeout"]
];
imports = let
basePluginPath = ["plugins" "rest"];
settingsPath = basePluginPath ++ ["settings"];
in [
(
mkRenamedOptionModule
(basePluginPath ++ ["resultSplitHorizontal"])
(settingsPath ++ ["result" "split" "horizontal"])
# TODO introduced 2024-04-07: remove 2024-06-07
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"envFile"
"encodeUrl"
"skipSslVerification"
"customDynamicVariables"
[
"highlight"
"timeout"
]
];
imports =
let
basePluginPath = [
"plugins"
"rest"
];
settingsPath = basePluginPath ++ [ "settings" ];
in
[
(mkRenamedOptionModule (basePluginPath ++ [ "resultSplitHorizontal" ]) (
settingsPath
++ [
"result"
"split"
"horizontal"
]
))
(mkRenamedOptionModule (basePluginPath ++ [ "resultSplitInPlace" ]) (
settingsPath
++ [
"result"
"split"
"in_place"
]
))
(mkRenamedOptionModule (basePluginPath ++ [ "stayInCurrentWindowAfterSplit" ]) (
settingsPath
++ [
"result"
"split"
"stay_in_current_window_after_split"
]
))
(mkRenamedOptionModule
(
basePluginPath
++ [
"result"
"showUrl"
]
)
(
settingsPath
++ [
"result"
"behavior"
"show_info"
"url"
]
)
)
(
mkRenamedOptionModule
(basePluginPath ++ ["resultSplitInPlace"])
(settingsPath ++ ["result" "split" "in_place"])
(mkRenamedOptionModule
(
basePluginPath
++ [
"result"
"showHeaders"
]
)
(
settingsPath
++ [
"result"
"behavior"
"show_info"
"headers"
]
)
)
(
mkRenamedOptionModule
(basePluginPath ++ ["stayInCurrentWindowAfterSplit"])
(settingsPath ++ ["result" "split" "stay_in_current_window_after_split"])
(mkRenamedOptionModule
(
basePluginPath
++ [
"result"
"showHttpInfo"
]
)
(
settingsPath
++ [
"result"
"behavior"
"show_info"
"http_info"
]
)
)
(
mkRenamedOptionModule
(basePluginPath ++ ["result" "showUrl"])
(settingsPath ++ ["result" "behavior" "show_info" "url"])
(mkRenamedOptionModule
(
basePluginPath
++ [
"result"
"showCurlCommand"
]
)
(
settingsPath
++ [
"result"
"behavior"
"show_info"
"curl_command"
]
)
)
(
mkRenamedOptionModule
(basePluginPath ++ ["result" "showHeaders"])
(settingsPath ++ ["result" "behavior" "show_info" "headers"])
)
(
mkRenamedOptionModule
(basePluginPath ++ ["result" "showHttpInfo"])
(settingsPath ++ ["result" "behavior" "show_info" "http_info"])
)
(
mkRenamedOptionModule
(basePluginPath ++ ["result" "showCurlCommand"])
(settingsPath ++ ["result" "behavior" "show_info" "curl_command"])
)
(
mkRemovedOptionModule
(basePluginPath ++ ["result" "showStatistics"])
(mkRemovedOptionModule
(
basePluginPath
++ [
"result"
"showStatistics"
]
)
''
Use `plugins.rest.settings.result.behavior.statistics.{enable,stats}` instead.
Refer to the documentation for more information.
''
)
(
mkRenamedOptionModule
(basePluginPath ++ ["result" "formatters"])
(settingsPath ++ ["result" "behavior" "formatters"])
(mkRenamedOptionModule
(
basePluginPath
++ [
"result"
"formatters"
]
)
(
settingsPath
++ [
"result"
"behavior"
"formatters"
]
)
)
(
mkRenamedOptionModule
(basePluginPath ++ ["highlight" "enabled"])
(settingsPath ++ ["highlight" "enable"])
)
(
mkRemovedOptionModule
(basePluginPath ++ ["jumpToRequest"])
''
This option has been deprecated upstream.
''
)
(
mkRemovedOptionModule
(basePluginPath ++ ["yankDryRun"])
''
This option has been deprecated upstream.
''
)
(
mkRemovedOptionModule
(basePluginPath ++ ["searchBack"])
''
This option has been deprecated upstream.
''
(mkRenamedOptionModule
(
basePluginPath
++ [
"highlight"
"enabled"
]
)
(
settingsPath
++ [
"highlight"
"enable"
]
)
)
(mkRemovedOptionModule (basePluginPath ++ [ "jumpToRequest" ]) ''
This option has been deprecated upstream.
'')
(mkRemovedOptionModule (basePluginPath ++ [ "yankDryRun" ]) ''
This option has been deprecated upstream.
'')
(mkRemovedOptionModule (basePluginPath ++ [ "searchBack" ]) ''
This option has been deprecated upstream.
'')
];
settingsOptions = {
client = helpers.defaultNullOpts.mkStr "curl" ''
The HTTP client to be used when running requests.
'';
settingsOptions = {
client = helpers.defaultNullOpts.mkStr "curl" ''
The HTTP client to be used when running requests.
'';
env_file = helpers.defaultNullOpts.mkStr ".env" ''
Environment variables file to be used for the request variables in the document.
'';
env_file = helpers.defaultNullOpts.mkStr ".env" ''
Environment variables file to be used for the request variables in the document.
'';
env_pattern = helpers.defaultNullOpts.mkStr "\\.env$" ''
Environment variables file pattern for `telescope.nvim`.
'';
env_pattern = helpers.defaultNullOpts.mkStr "\\.env$" ''
Environment variables file pattern for `telescope.nvim`.
'';
env_edit_command = helpers.defaultNullOpts.mkStr "tabedit" ''
Neovim command to edit an environment file.
'';
env_edit_command = helpers.defaultNullOpts.mkStr "tabedit" ''
Neovim command to edit an environment file.
'';
encode_url = helpers.defaultNullOpts.mkBool true ''
Encode URL before making request.
'';
encode_url = helpers.defaultNullOpts.mkBool true ''
Encode URL before making request.
'';
skip_ssl_verification = helpers.defaultNullOpts.mkBool false ''
Skip SSL verification, useful for unknown certificates.
'';
skip_ssl_verification = helpers.defaultNullOpts.mkBool false ''
Skip SSL verification, useful for unknown certificates.
'';
custom_dynamic_variables = mkOption {
type = with helpers.nixvimTypes;
nullOr (
maybeRaw (
attrsOf strLuaFn
)
);
default = null;
example = {
"$timestamp" = "os.time";
"$randomInt" = ''
function()
return math.random(0, 1000)
end
'';
};
description = ''
Custom dynamic variables. Keys are variable names and values are lua functions.
default: `{}`
custom_dynamic_variables = mkOption {
type = with helpers.nixvimTypes; nullOr (maybeRaw (attrsOf strLuaFn));
default = null;
example = {
"$timestamp" = "os.time";
"$randomInt" = ''
function()
return math.random(0, 1000)
end
'';
apply = v:
if isAttrs v
then mapAttrs (_: helpers.mkRaw) v
else v;
};
description = ''
Custom dynamic variables. Keys are variable names and values are lua functions.
logs = {
level = helpers.defaultNullOpts.mkNullable helpers.nixvimTypes.logLevel "info" ''
The logging level name, see `:h vim.log.levels`.
default: `{}`
'';
apply = v: if isAttrs v then mapAttrs (_: helpers.mkRaw) v else v;
};
logs = {
level = helpers.defaultNullOpts.mkNullable helpers.nixvimTypes.logLevel "info" ''
The logging level name, see `:h vim.log.levels`.
'';
save = helpers.defaultNullOpts.mkBool true ''
Whether to save log messages into a `.log` file.
'';
};
result = {
split = {
horizontal = helpers.defaultNullOpts.mkBool false ''
Open request results in a horizontal split.
'';
save = helpers.defaultNullOpts.mkBool true ''
Whether to save log messages into a `.log` file.
in_place = helpers.defaultNullOpts.mkBool false ''
Keep the HTTP file buffer above|left when split horizontal|vertical.
'';
stay_in_current_window_after_split = helpers.defaultNullOpts.mkBool true ''
Stay in the current window (HTTP file) or change the focus to the results window.
'';
};
result = {
split = {
horizontal = helpers.defaultNullOpts.mkBool false ''
Open request results in a horizontal split.
behavior = {
show_info = {
url = helpers.defaultNullOpts.mkBool true ''
Display the request URL.
'';
in_place = helpers.defaultNullOpts.mkBool false ''
Keep the HTTP file buffer above|left when split horizontal|vertical.
headers = helpers.defaultNullOpts.mkBool true ''
Display the request headers.
'';
stay_in_current_window_after_split = helpers.defaultNullOpts.mkBool true ''
Stay in the current window (HTTP file) or change the focus to the results window.
http_info = helpers.defaultNullOpts.mkBool true ''
Display the request HTTP information.
'';
curl_command = helpers.defaultNullOpts.mkBool true ''
Display the cURL command that was used for the request.
'';
};
behavior = {
show_info = {
url = helpers.defaultNullOpts.mkBool true ''
Display the request URL.
'';
decode_url = helpers.defaultNullOpts.mkBool true ''
Whether to decode the request URL query parameters to improve readability.
'';
headers = helpers.defaultNullOpts.mkBool true ''
Display the request headers.
'';
http_info = helpers.defaultNullOpts.mkBool true ''
Display the request HTTP information.
'';
curl_command = helpers.defaultNullOpts.mkBool true ''
Display the cURL command that was used for the request.
'';
};
decode_url = helpers.defaultNullOpts.mkBool true ''
Whether to decode the request URL query parameters to improve readability.
statistics = {
enable = helpers.defaultNullOpts.mkBool true ''
Whether to enable statistics or not.
'';
statistics = {
enable = helpers.defaultNullOpts.mkBool true ''
Whether to enable statistics or not.
'';
stats =
helpers.defaultNullOpts.mkListOf (with types; attrsOf str)
''
[
{
__unkeyed = "total_time";
title = "Time taken:";
}
{
__unkeyed = "size_download_t";
title = "Download size:";
}
]
''
"See https://curl.se/libcurl/c/curl_easy_getinfo.html.";
};
formatters = {
json = helpers.defaultNullOpts.mkStr "jq" ''
JSON formatter.
'';
html =
helpers.defaultNullOpts.mkStr
''
{
__raw = \'\'
function(body)
if vim.fn.executable("tidy") == 0 then
return body, { found = false, name = "tidy" }
end
local fmt_body = vim.fn.system({
"tidy",
"-i",
"-q",
"--tidy-mark", "no",
"--show-body-only", "auto",
"--show-errors", "0",
"--show-warnings", "0",
"-",
}, body):gsub("\n$", "")
return fmt_body, { found = true, name = "tidy" }
end
\'\';
}
''
"HTML formatter.";
};
stats = helpers.defaultNullOpts.mkListOf (with types; attrsOf str) ''
[
{
__unkeyed = "total_time";
title = "Time taken:";
}
{
__unkeyed = "size_download_t";
title = "Download size:";
}
]
'' "See https://curl.se/libcurl/c/curl_easy_getinfo.html.";
};
keybinds = {
buffer_local = helpers.defaultNullOpts.mkBool false ''
Enable keybinds only in request result buffer.
formatters = {
json = helpers.defaultNullOpts.mkStr "jq" ''
JSON formatter.
'';
prev = helpers.defaultNullOpts.mkStr "H" ''
Mapping for cycle to previous result pane.
'';
html = helpers.defaultNullOpts.mkStr ''
{
__raw = \'\'
function(body)
if vim.fn.executable("tidy") == 0 then
return body, { found = false, name = "tidy" }
end
local fmt_body = vim.fn.system({
"tidy",
"-i",
"-q",
"--tidy-mark", "no",
"--show-body-only", "auto",
"--show-errors", "0",
"--show-warnings", "0",
"-",
}, body):gsub("\n$", "")
next = helpers.defaultNullOpts.mkStr "L" ''
Mapping for cycle to next result pane.
'';
return fmt_body, { found = true, name = "tidy" }
end
\'\';
}
'' "HTML formatter.";
};
};
highlight = {
enable = helpers.defaultNullOpts.mkBool true ''
Whether current request highlighting is enabled or not.
keybinds = {
buffer_local = helpers.defaultNullOpts.mkBool false ''
Enable keybinds only in request result buffer.
'';
timeout = helpers.defaultNullOpts.mkUnsignedInt 750 ''
Duration time of the request highlighting in milliseconds.
prev = helpers.defaultNullOpts.mkStr "H" ''
Mapping for cycle to previous result pane.
'';
next = helpers.defaultNullOpts.mkStr "L" ''
Mapping for cycle to next result pane.
'';
};
};
keybinds =
helpers.defaultNullOpts.mkListOf (with types; listOf str)
highlight = {
enable = helpers.defaultNullOpts.mkBool true ''
Whether current request highlighting is enabled or not.
'';
timeout = helpers.defaultNullOpts.mkUnsignedInt 750 ''
Duration time of the request highlighting in milliseconds.
'';
};
keybinds =
helpers.defaultNullOpts.mkListOf (with types; listOf str)
''
[
[
@ -306,33 +377,33 @@ with lib;
Declare some keybindings.
Format: list of 3 strings lists: key, action and description.
'';
};
};
settingsExample = {
client = "curl";
env_file = ".env";
logs = {
level = "info";
save = true;
};
result = {
split = {
horizontal = false;
in_place = false;
stay_in_current_window_after_split = true;
};
};
keybinds = [
[
"<localleader>rr"
"<cmd>Rest run<cr>"
"Run request under the cursor"
]
[
"<localleader>rl"
"<cmd>Rest run last<cr>"
"Re-run latest request"
]
];
settingsExample = {
client = "curl";
env_file = ".env";
logs = {
level = "info";
save = true;
};
}
result = {
split = {
horizontal = false;
in_place = false;
stay_in_current_window_after_split = true;
};
};
keybinds = [
[
"<localleader>rr"
"<cmd>Rest run<cr>"
"Run request under the cursor"
]
[
"<localleader>rl"
"<cmd>Rest run last<cr>"
"Re-run latest request"
]
];
};
}

View file

@ -6,38 +6,38 @@
...
}:
with lib;
helpers.vim-plugin.mkVimPlugin config {
name = "sandwich";
originalName = "vim-sandwich";
defaultPackage = pkgs.vimPlugins.vim-sandwich;
globalPrefix = "sandwich_";
helpers.vim-plugin.mkVimPlugin config {
name = "sandwich";
originalName = "vim-sandwich";
defaultPackage = pkgs.vimPlugins.vim-sandwich;
globalPrefix = "sandwich_";
description = ''
The `settings` option will not let you define the options starting with `sandwich#`.
For those, you can directly use the `globals` option:
```nix
globals."sandwich#magicchar#f#patterns" = [
{
header.__raw = "[[\<\%(\h\k*\.\)*\h\k*]]";
bra = "(";
ket = ")";
footer = "";
}
];
```
description = ''
The `settings` option will not let you define the options starting with `sandwich#`.
For those, you can directly use the `globals` option:
```nix
globals."sandwich#magicchar#f#patterns" = [
{
header.__raw = "[[\<\%(\h\k*\.\)*\h\k*]]";
bra = "(";
ket = ")";
footer = "";
}
];
```
'';
maintainers = [ maintainers.GaetanLepage ];
settingsOptions = {
no_default_key_mappings = helpers.defaultNullOpts.mkBool false ''
Whether to disable the default mappings.
'';
};
maintainers = [maintainers.GaetanLepage];
settingsOptions = {
no_default_key_mappings = helpers.defaultNullOpts.mkBool false ''
Whether to disable the default mappings.
'';
};
settingsExample = {
no_default_key_mappings = true;
no_tex_ftplugin = true;
no_vim_ftplugin = true;
};
}
settingsExample = {
no_default_key_mappings = true;
no_tex_ftplugin = true;
no_vim_ftplugin = true;
};
}

View file

@ -11,7 +11,7 @@ helpers.vim-plugin.mkVimPlugin config {
defaultPackage = pkgs.vimPlugins.vim-sleuth;
globalPrefix = "sleuth_";
maintainers = [lib.maintainers.GaetanLepage];
maintainers = [ lib.maintainers.GaetanLepage ];
settingsOptions = {
heuristics = helpers.defaultNullOpts.mkBool true ''

View file

@ -10,14 +10,22 @@ helpers.neovim-plugin.mkNeovimPlugin config {
originalName = "smart-splits.nvim";
defaultPackage = pkgs.vimPlugins.smart-splits-nvim;
maintainers = [lib.maintainers.foo-dogsquared];
maintainers = [ lib.maintainers.foo-dogsquared ];
settingsExample = {
resize_mode = {
quit_key = "<ESC>";
resize_keys = ["h" "j" "k" "l"];
resize_keys = [
"h"
"j"
"k"
"l"
];
silent = true;
};
ignored_events = ["BufEnter" "WinEnter"];
ignored_events = [
"BufEnter"
"WinEnter"
];
};
}

View file

@ -5,9 +5,11 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.specs;
in {
in
{
options.plugins.specs = {
enable = mkEnableOption "specs-nvim";
@ -54,12 +56,14 @@ in {
type = types.submodule {
options = {
builtin = mkOption {
type = types.nullOr (types.enum [
"linear_fader"
"exp_fader"
"pulse_fader"
"empty_fader"
]);
type = types.nullOr (
types.enum [
"linear_fader"
"exp_fader"
"pulse_fader"
"empty_fader"
]
);
default = "linear_fader";
};
@ -76,16 +80,22 @@ in {
};
};
};
default = {builtin = "linear_fader";};
default = {
builtin = "linear_fader";
};
};
resizer = mkOption {
type = types.submodule {
options = {
builtin = mkOption {
type =
types.nullOr
(types.enum ["shrink_resizer" "slide_resizer" "empty_resizer"]);
type = types.nullOr (
types.enum [
"shrink_resizer"
"slide_resizer"
"empty_resizer"
]
);
default = "shrink_resizer";
};
@ -102,53 +112,50 @@ in {
};
};
};
default = {builtin = "shrink_resizer";};
default = {
builtin = "shrink_resizer";
};
};
ignored_filetypes = mkOption {
type = with types; listOf str;
default = [];
default = [ ];
};
ignored_buffertypes = mkOption {
type = with types; listOf str;
default = ["nofile"];
default = [ "nofile" ];
};
};
config = let
setup = helpers.toLuaObject {
inherit (cfg) show_jumps min_jump;
ignore_filetypes =
attrsets.listToAttrs
(lib.lists.map (x: attrsets.nameValuePair x true)
cfg.ignored_filetypes);
ignore_buftypes =
attrsets.listToAttrs
(lib.lists.map (x: attrsets.nameValuePair x true)
cfg.ignored_buffertypes);
popup = {
inherit (cfg) blend width;
winhl =
if (cfg.color != null)
then "SpecsPopColor"
else "PMenu";
delay_ms = cfg.delay;
inc_ms = cfg.increment;
fader = helpers.mkRaw (
if cfg.fader.builtin == null
then cfg.fader.custom
else ''require("specs").${cfg.fader.builtin}''
config =
let
setup = helpers.toLuaObject {
inherit (cfg) show_jumps min_jump;
ignore_filetypes = attrsets.listToAttrs (
lib.lists.map (x: attrsets.nameValuePair x true) cfg.ignored_filetypes
);
resizer = helpers.mkRaw (
if cfg.resizer.builtin == null
then cfg.resizer.custom
else ''require("specs").${cfg.resizer.builtin}''
ignore_buftypes = attrsets.listToAttrs (
lib.lists.map (x: attrsets.nameValuePair x true) cfg.ignored_buffertypes
);
popup = {
inherit (cfg) blend width;
winhl = if (cfg.color != null) then "SpecsPopColor" else "PMenu";
delay_ms = cfg.delay;
inc_ms = cfg.increment;
fader = helpers.mkRaw (
if cfg.fader.builtin == null then cfg.fader.custom else ''require("specs").${cfg.fader.builtin}''
);
resizer = helpers.mkRaw (
if cfg.resizer.builtin == null then
cfg.resizer.custom
else
''require("specs").${cfg.resizer.builtin}''
);
};
};
};
in
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
highlight.SpecsPopColor.bg = mkIf (cfg.color != null) cfg.color;

View file

@ -6,27 +6,29 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "spectre";
originalName = "nvim-spectre";
defaultPackage = pkgs.vimPlugins.nvim-spectre;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "spectre";
originalName = "nvim-spectre";
defaultPackage = pkgs.vimPlugins.nvim-spectre;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
description = ''
You may want to set the package for your find/replace tool(s) like shown below:
description = ''
You may want to set the package for your find/replace tool(s) like shown below:
```nix
plugins.spectre.findPackage = pkgs.rg;
plugins.spectre.replacePackage = pkgs.gnused;
```
'';
```nix
plugins.spectre.findPackage = pkgs.rg;
plugins.spectre.replacePackage = pkgs.gnused;
```
'';
settingsOptions = let
mkEngineOption = type:
settingsOptions =
let
mkEngineOption =
type:
helpers.mkNullOrOption
(
with types;
(
with types;
attrsOf (submodule {
options = {
cmd = mkOption {
@ -38,38 +40,35 @@ with lib;
List of arguments to provide to the engine.
'';
options =
helpers.defaultNullOpts.mkAttrsOf
(types.submodule {
options = {
value = mkOption {
type = types.str;
example = "-i";
description = "The option flag.";
};
icon = mkOption {
type = types.str;
example = "[I]";
description = "The option icon.";
};
desc = helpers.mkNullOrStr ''
The description for this option.
'';
options = helpers.defaultNullOpts.mkAttrsOf (types.submodule {
options = {
value = mkOption {
type = types.str;
example = "-i";
description = "The option flag.";
};
})
"{}"
"The options for this engine.";
icon = mkOption {
type = types.str;
example = "[I]";
description = "The option icon.";
};
desc = helpers.mkNullOrStr ''
The description for this option.
'';
};
}) "{}" "The options for this engine.";
};
})
)
''
Definition of the ${type} engines.
)
''
Definition of the ${type} engines.
default: see [here](https://github.com/nvim-pack/nvim-spectre/blob/master/lua/spectre/config.lua)
'';
in {
default: see [here](https://github.com/nvim-pack/nvim-spectre/blob/master/lua/spectre/config.lua)
'';
in
{
color_devicons = helpers.defaultNullOpts.mkBool true ''
Whether to enable color devicons.
'';
@ -86,39 +85,30 @@ with lib;
Show line number for search/replace results.
'';
line_sep_start =
helpers.defaultNullOpts.mkStr
""
"Start of the line separator";
line_sep_start = helpers.defaultNullOpts.mkStr "" "Start of the line separator";
result_padding = helpers.defaultNullOpts.mkStr " " ''
Result padding string.
'';
line_sep =
helpers.defaultNullOpts.mkStr
""
"Line separator.";
line_sep = helpers.defaultNullOpts.mkStr "" "Line separator.";
highlight =
helpers.defaultNullOpts.mkAttrsOf types.str
''
{
headers = "SpectreHeader";
ui = "SpectreBody";
filename = "SpectreFile";
filedirectory = "SpectreDir";
search = "SpectreSearch";
border = "SpectreBorder";
replace = "SpectreReplace";
}
''
"Highlight groups.";
highlight = helpers.defaultNullOpts.mkAttrsOf types.str ''
{
headers = "SpectreHeader";
ui = "SpectreBody";
filename = "SpectreFile";
filedirectory = "SpectreDir";
search = "SpectreSearch";
border = "SpectreBorder";
replace = "SpectreReplace";
}
'' "Highlight groups.";
mapping =
helpers.mkNullOrOption
(
with types;
(
with types;
attrsOf (submodule {
options = {
map = mkOption {
@ -137,12 +127,12 @@ with lib;
'';
};
})
)
''
Keymaps declaration.
)
''
Keymaps declaration.
default: see [here](https://github.com/nvim-pack/nvim-spectre/blob/master/lua/spectre/config.lua)
'';
default: see [here](https://github.com/nvim-pack/nvim-spectre/blob/master/lua/spectre/config.lua)
'';
find_engine = mkEngineOption "find";
@ -187,55 +177,59 @@ with lib;
'';
};
settingsExample = {
live_update = true;
is_insert_mode = false;
find_engine = {
rg = {
cmd = "rg";
args = [
"--color=never"
"--no-heading"
"--with-filename"
"--line-number"
"--column"
];
options = {
ignore-case = {
value = "--ignore-case";
icon = "[I]";
desc = "ignore case";
};
hidden = {
value = "--hidden";
desc = "hidden file";
icon = "[H]";
};
line = {
value = "-x";
icon = "[L]";
desc = "match in line";
};
word = {
value = "-w";
icon = "[W]";
desc = "match in word";
};
settingsExample = {
live_update = true;
is_insert_mode = false;
find_engine = {
rg = {
cmd = "rg";
args = [
"--color=never"
"--no-heading"
"--with-filename"
"--line-number"
"--column"
];
options = {
ignore-case = {
value = "--ignore-case";
icon = "[I]";
desc = "ignore case";
};
hidden = {
value = "--hidden";
desc = "hidden file";
icon = "[H]";
};
line = {
value = "-x";
icon = "[L]";
desc = "match in line";
};
word = {
value = "-w";
icon = "[W]";
desc = "match in word";
};
};
};
default = {
find = {
cmd = "rg";
options = ["word" "hidden"];
};
replace = {
cmd = "sed";
};
};
default = {
find = {
cmd = "rg";
options = [
"word"
"hidden"
];
};
replace = {
cmd = "sed";
};
};
};
extraOptions = let
extraOptions =
let
userCommandSettings = config.plugins.spectre.settings.default;
findPackages = {
@ -250,7 +244,8 @@ with lib;
# `toString` will turn `null` into `"null"` to allow for the attrs indexation.
findDefaultPackage = findPackages.${toString userCommandSettings.find.cmd} or null;
replaceDefaultPackage = replacePackages.${toString userCommandSettings.replace.cmd} or null;
in {
in
{
findPackage = mkOption {
type = with types; nullOr package;
default = findDefaultPackage;
@ -274,10 +269,10 @@ with lib;
};
};
extraConfig = cfg: {
extraPackages = [
cfg.findPackage
cfg.replacePackage
];
};
}
extraConfig = cfg: {
extraPackages = [
cfg.findPackage
cfg.replacePackage
];
};
}

View file

@ -5,69 +5,66 @@
pkgs,
...
}:
with lib; let
with lib;
let
pluginName = "spider";
cfg = config.plugins.${pluginName};
in {
options.plugins.${pluginName} =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption pluginName;
in
{
options.plugins.${pluginName} = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption pluginName;
package = helpers.mkPackageOption pluginName pkgs.vimPlugins.nvim-spider;
package = helpers.mkPackageOption pluginName pkgs.vimPlugins.nvim-spider;
skipInsignificantPunctuation =
helpers.defaultNullOpts.mkBool true "Whether to skip insignificant punctuation.";
skipInsignificantPunctuation = helpers.defaultNullOpts.mkBool true "Whether to skip insignificant punctuation.";
keymaps = {
silent = mkOption {
type = types.bool;
description = "Whether ${pluginName} keymaps should be silent.";
default = false;
};
keymaps = {
silent = mkOption {
type = types.bool;
description = "Whether ${pluginName} keymaps should be silent.";
default = false;
};
motions = mkOption {
type = types.attrsOf types.str;
description = ''
Mappings for spider motions.
The keys are the motion and the values are the keyboard shortcuts.
The shortcut might not necessarily be the same as the motion name.
'';
default = {};
example = {
w = "w";
e = "e";
b = "b";
ge = "ge";
};
motions = mkOption {
type = types.attrsOf types.str;
description = ''
Mappings for spider motions.
The keys are the motion and the values are the keyboard shortcuts.
The shortcut might not necessarily be the same as the motion name.
'';
default = { };
example = {
w = "w";
e = "e";
b = "b";
ge = "ge";
};
};
};
};
config = let
setupOptions =
{
config =
let
setupOptions = {
inherit (cfg) skipInsignificantPunctuation;
}
// cfg.extraOptions;
} // cfg.extraOptions;
mappings =
mapAttrsToList
(
motion: key: {
mode = ["n" "o" "x"];
inherit key;
action.__raw = "function() require('spider').motion('${motion}') end";
options = {
inherit (cfg.keymaps) silent;
desc = "Spider-${motion}";
};
}
)
cfg.keymaps.motions;
in
mappings = mapAttrsToList (motion: key: {
mode = [
"n"
"o"
"x"
];
inherit key;
action.__raw = "function() require('spider').motion('${motion}') end";
options = {
inherit (cfg.keymaps) silent;
desc = "Spider-${motion}";
};
}) cfg.keymaps.motions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
keymaps = mappings;

View file

@ -7,48 +7,57 @@
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
name = "startify";
originalName = "vim-startify";
defaultPackage = pkgs.vimPlugins.vim-startify;
globalPrefix = "startify_";
mkVimPlugin config {
name = "startify";
originalName = "vim-startify";
defaultPackage = pkgs.vimPlugins.vim-startify;
globalPrefix = "startify_";
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-03-01: remove 2024-05-01
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"sessionDir"
"lists"
"bookmarks"
"commands"
"filesNumber"
"sessionAutoload"
"sessionBeforeSave"
"sessionPersistence"
"sessionDeleteBuffers"
"changeToDir"
"changeToVcsRoot"
"changeCmd"
"paddingLeft"
"enableSpecial"
"enableUnsafe"
"sessionRemoveLines"
"sessionNumber"
"sessionSort"
"customIndices"
"customHeader"
"customFooter"
"relativePath"
"useEnv"
];
imports =
map
# TODO introduced 2024-03-01: remove 2024-05-01
deprecateExtraConfig = true;
optionsRenamedToSettings = [
"sessionDir"
"lists"
"bookmarks"
"commands"
"filesNumber"
"sessionAutoload"
"sessionBeforeSave"
"sessionPersistence"
"sessionDeleteBuffers"
"changeToDir"
"changeToVcsRoot"
"changeCmd"
"paddingLeft"
"enableSpecial"
"enableUnsafe"
"sessionRemoveLines"
"sessionNumber"
"sessionSort"
"customIndices"
"customHeader"
"customFooter"
"relativePath"
"useEnv"
];
imports =
map
(
option:
mkRenamedOptionModule
["plugins" "startify" option.old]
["plugins" "startify" "settings" option.new]
mkRenamedOptionModule
[
"plugins"
"startify"
option.old
]
[
"plugins"
"startify"
"settings"
option.new
]
)
[
{
@ -85,20 +94,20 @@ with helpers.vim-plugin;
}
];
settingsOptions = import ./options.nix {inherit lib helpers;};
settingsOptions = import ./options.nix { inherit lib helpers; };
# TODO
settingsExample = {
custom_header = [
""
" "
" "
" "
" "
" "
" "
];
change_to_dir = false;
fortune_use_unicode = true;
};
}
# TODO
settingsExample = {
custom_header = [
""
" "
" "
" "
" "
" "
" "
];
change_to_dir = false;
fortune_use_unicode = true;
};
}

View file

@ -1,19 +1,15 @@
{ lib, helpers }:
with lib;
{
lib,
helpers,
}:
with lib; {
session_dir = helpers.defaultNullOpts.mkStr "~/.vim/session" ''
The directory to save/load sessions to/from.
'';
lists = mkOption {
type = with helpers.nixvimTypes;
listOf
(
either
strLua
(submodule {
type =
with helpers.nixvimTypes;
listOf (
either strLua (submodule {
freeformType = with types; attrsOf anything;
options = {
type = mkOption {
@ -34,13 +30,8 @@ with lib; {
};
})
);
apply = v:
map (listElem:
if isString listElem
then helpers.mkRaw listElem
else listElem)
v;
default = [];
apply = v: map (listElem: if isString listElem then helpers.mkRaw listElem else listElem) v;
default = [ ];
description = ''
Startify displays lists. Each list consists of a `type` and optionally a `header` and
custom `indices`.
@ -75,44 +66,47 @@ with lib; {
bookmarks =
helpers.defaultNullOpts.mkListOf
(
with helpers.nixvimTypes;
oneOf [str rawLua attrs]
)
"[]"
''
A list of files or directories to bookmark.
The list can contain two kinds of types.
Either a path (str) or an attrs where the key is the custom index and the value is the path.
'';
(
with helpers.nixvimTypes;
oneOf [
str
rawLua
attrs
]
)
"[]"
''
A list of files or directories to bookmark.
The list can contain two kinds of types.
Either a path (str) or an attrs where the key is the custom index and the value is the path.
'';
commands =
helpers.defaultNullOpts.mkListOf
(
with types;
oneOf
[
(
with types;
oneOf [
str
(attrsOf (either str (listOf str)))
(listOf str)
]
)
"[]"
''
A list of commands to execute on selection.
Leading colons are optional.
It supports optional custom indices and/or command descriptions.
)
"[]"
''
A list of commands to execute on selection.
Leading colons are optional.
It supports optional custom indices and/or command descriptions.
Example:
```nix
[
":help reference"
["Vim Reference" "h ref"]
{h = "h ref";}
{m = ["My magical function" "call Magic()"];}
]
```
'';
Example:
```nix
[
":help reference"
["Vim Reference" "h ref"]
{h = "h ref";}
{m = ["My magical function" "call Magic()"];}
]
```
'';
files_number = helpers.defaultNullOpts.mkUnsignedInt 10 ''
The number of files to list.
@ -233,16 +227,12 @@ with lib; {
The number of spaces used for left padding.
'';
skiplist_server =
helpers.defaultNullOpts.mkListOf
(with helpers.nixvimTypes; maybeRaw str)
"[]"
''
Do not create the startify buffer, if this is a Vim server instance with a name contained in
this list.
skiplist_server = helpers.defaultNullOpts.mkListOf (with helpers.nixvimTypes; maybeRaw str) "[]" ''
Do not create the startify buffer, if this is a Vim server instance with a name contained in
this list.
Example: `["GVIM"]`
'';
Example: `["GVIM"]`
'';
enable_special = helpers.defaultNullOpts.mkBool true ''
Show `<empty buffer>` and `<quit>`.
@ -318,51 +308,42 @@ with lib; {
'';
custom_indices =
helpers.defaultNullOpts.mkNullable
(
with helpers.nixvimTypes;
maybeRaw (listOf str)
)
"[]"
''
Use any list of strings as indices instead of increasing numbers. If there are more startify
entries than actual items in the custom list, the remaining entries will be filled using the
default numbering scheme starting from 0.
helpers.defaultNullOpts.mkNullable (with helpers.nixvimTypes; maybeRaw (listOf str)) "[]"
''
Use any list of strings as indices instead of increasing numbers. If there are more startify
entries than actual items in the custom list, the remaining entries will be filled using the
default numbering scheme starting from 0.
Thus you can create your own indexing scheme that fits your keyboard layout.
You don't want to leave the home row, do you?!
Thus you can create your own indexing scheme that fits your keyboard layout.
You don't want to leave the home row, do you?!
Example:
```nix
["f" "g" "h"]
```
'';
Example:
```nix
["f" "g" "h"]
```
'';
custom_header =
helpers.mkNullOrOption
(
with helpers.nixvimTypes;
maybeRaw (listOf (maybeRaw str))
)
''
Define your own header.
helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (listOf (maybeRaw str)))
''
Define your own header.
This option takes a `list of strings`, whereas each string will be put on its own line.
If it is a simple `string`, it should evaluate to a list of strings.
This option takes a `list of strings`, whereas each string will be put on its own line.
If it is a simple `string`, it should evaluate to a list of strings.
Example:
```nix
[
""
" "
" "
" "
" "
" "
" "
]
```
'';
Example:
```nix
[
""
" "
" "
" "
" "
" "
" "
]
```
'';
custom_header_quotes = helpers.defaultNullOpts.mkListOf (with types; listOf str) "[]" ''
Example:
@ -375,14 +356,10 @@ with lib; {
'';
custom_footer =
helpers.mkNullOrOption
(
with helpers.nixvimTypes;
maybeRaw (listOf (maybeRaw str))
)
''
Same as the custom header, but shown at the bottom of the startify buffer.
'';
helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (listOf (maybeRaw str)))
''
Same as the custom header, but shown at the bottom of the startify buffer.
'';
disable_at_vimenter = helpers.defaultNullOpts.mkBool false ''
Don't run Startify at Vim startup.

View file

@ -5,40 +5,56 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.startup;
in {
meta.maintainers = [maintainers.GaetanLepage];
in
{
meta.maintainers = [ maintainers.GaetanLepage ];
options.plugins.startup =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "startup.nvim";
options.plugins.startup = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "startup.nvim";
package = helpers.mkPackageOption "startup.nvim" pkgs.vimPlugins.startup-nvim;
package = helpers.mkPackageOption "startup.nvim" pkgs.vimPlugins.startup-nvim;
theme = helpers.defaultNullOpts.mkStr "dashboard" ''
Use a pre-defined theme.
'';
theme = helpers.defaultNullOpts.mkStr "dashboard" ''
Use a pre-defined theme.
'';
sections = let
sectionType = with types;
sections =
let
sectionType =
with types;
submodule {
options = {
type = helpers.defaultNullOpts.mkEnumFirstDefault ["text" "mapping" "oldfiles"] ''
- "text" -> text that will be displayed
- "mapping" -> create mappings for commands that can be used.
use `mappings.executeCommand` on the commands to execute.
- "oldfiles" -> display oldfiles (can be opened with `mappings.openFile`/`openFileSplit`)
'';
type =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"text"
"mapping"
"oldfiles"
]
''
- "text" -> text that will be displayed
- "mapping" -> create mappings for commands that can be used.
use `mappings.executeCommand` on the commands to execute.
- "oldfiles" -> display oldfiles (can be opened with `mappings.openFile`/`openFileSplit`)
'';
oldfilesDirectory = helpers.defaultNullOpts.mkBool false ''
if the oldfiles of the current directory should be displayed.
'';
align = helpers.defaultNullOpts.mkEnumFirstDefault ["center" "left" "right"] ''
How to align the section.
'';
align =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"center"
"left"
"right"
]
''
How to align the section.
'';
foldSection = helpers.defaultNullOpts.mkBool false ''
Whether to fold or not.
@ -49,52 +65,38 @@ in {
'';
margin =
helpers.defaultNullOpts.mkNullable
(
with types;
either
(numbers.between 0.0 1.0)
ints.positive
)
"5"
''
The margin for left or right alignment.
- if < 1 fraction of screen width
- if > 1 numbers of column
'';
helpers.defaultNullOpts.mkNullable (with types; either (numbers.between 0.0 1.0) ints.positive) "5"
''
The margin for left or right alignment.
- if < 1 fraction of screen width
- if > 1 numbers of column
'';
content =
helpers.mkNullOrOption
(
with types;
(
with types;
oneOf [
# for "text" "mapping"
(
listOf
(
either
str
(listOf str)
)
)
(listOf (either str (listOf str)))
helpers.nixvimTypes.rawLua
# for "oldfiles" sections
(enum [""])
(enum [ "" ])
]
)
''
The type of `content` depends on the section `type`:
- "text" -> a list of strings or a function (`rawLua`) that requires a function that returns a table of strings
- "mapping" -> a list of list of strings in the format:
```nix
[
[<displayed_command_name> <command> <mapping>]
[<displayed_command_name> <command> <mapping>]
]
```
Example: `[" Find File" "Telescope find_files" "<leader>ff"]`
- "oldfiles" -> `""`
'';
)
''
The type of `content` depends on the section `type`:
- "text" -> a list of strings or a function (`rawLua`) that requires a function that returns a table of strings
- "mapping" -> a list of list of strings in the format:
```nix
[
[<displayed_command_name> <command> <mapping>]
[<displayed_command_name> <command> <mapping>]
]
```
Example: `[" Find File" "Telescope find_files" "<leader>ff"]`
- "oldfiles" -> `""`
'';
highlight = helpers.mkNullOrOption types.str ''
Highlight group in which the section text should be highlighted.
@ -110,217 +112,207 @@ in {
};
};
in
mkOption {
type = with types; attrsOf sectionType;
default = {};
description = ''
'';
example = {
header = {
type = "text";
align = "center";
foldSection = false;
title = "Header";
margin = 5;
content.__raw = "require('startup.headers').hydra_header";
highlight = "Statement";
defaultColor = "";
oldfilesAmount = 0;
};
body = {
type = "mapping";
align = "center";
foldSection = true;
title = "Basic Commands";
margin = 5;
content = [
[
" Find File"
"Telescope find_files"
"<leader>ff"
]
[
"󰍉 Find Word"
"Telescope live_grep"
"<leader>lg"
]
[
" Recent Files"
"Telescope oldfiles"
"<leader>of"
]
[
" File Browser"
"Telescope file_browser"
"<leader>fb"
]
[
" Colorschemes"
"Telescope colorscheme"
"<leader>cs"
]
[
" New File"
"lua require'startup'.new_file()"
"<leader>nf"
]
];
highlight = "String";
defaultColor = "";
oldfilesAmount = 0;
};
mkOption {
type = with types; attrsOf sectionType;
default = { };
description = '''';
example = {
header = {
type = "text";
align = "center";
foldSection = false;
title = "Header";
margin = 5;
content.__raw = "require('startup.headers').hydra_header";
highlight = "Statement";
defaultColor = "";
oldfilesAmount = 0;
};
body = {
type = "mapping";
align = "center";
foldSection = true;
title = "Basic Commands";
margin = 5;
content = [
[
" Find File"
"Telescope find_files"
"<leader>ff"
]
[
"󰍉 Find Word"
"Telescope live_grep"
"<leader>lg"
]
[
" Recent Files"
"Telescope oldfiles"
"<leader>of"
]
[
" File Browser"
"Telescope file_browser"
"<leader>fb"
]
[
" Colorschemes"
"Telescope colorscheme"
"<leader>cs"
]
[
" New File"
"lua require'startup'.new_file()"
"<leader>nf"
]
];
highlight = "String";
defaultColor = "";
oldfilesAmount = 0;
};
};
};
options = {
mappingKeys = helpers.defaultNullOpts.mkBool true ''
Display mapping (e.g. `<leader>ff`).
'';
options = {
mappingKeys = helpers.defaultNullOpts.mkBool true ''
Display mapping (e.g. `<leader>ff`).
'';
cursorColumn =
helpers.defaultNullOpts.mkNullable
(
with types;
either
(numbers.between 0.0 1.0)
ints.positive
)
cursorColumn =
helpers.defaultNullOpts.mkNullable (with types; either (numbers.between 0.0 1.0) ints.positive)
"0.5"
''
- if < 1, fraction of screen width
- if > 1 numbers of column
'';
after = helpers.defaultNullOpts.mkLuaFn "nil" ''
A function that gets executed at the end.
'';
after = helpers.defaultNullOpts.mkLuaFn "nil" ''
A function that gets executed at the end.
'';
emptyLinesBetweenMappings = helpers.defaultNullOpts.mkBool true ''
Add an empty line between mapping/commands.
'';
emptyLinesBetweenMappings = helpers.defaultNullOpts.mkBool true ''
Add an empty line between mapping/commands.
'';
disableStatuslines = helpers.defaultNullOpts.mkBool true ''
Disable status-, buffer- and tablines.
'';
disableStatuslines = helpers.defaultNullOpts.mkBool true ''
Disable status-, buffer- and tablines.
'';
paddings = helpers.defaultNullOpts.mkNullable (with types; listOf ints.unsigned) "[]" ''
Amount of empty lines before each section (must be equal to amount of sections).
'';
};
mappings = {
executeCommand = helpers.defaultNullOpts.mkStr "<CR>" ''
Keymapping to execute a command.
'';
openFile = helpers.defaultNullOpts.mkStr "o" ''
Keymapping to open a file.
'';
openFileSplit = helpers.defaultNullOpts.mkStr "<c-o>" ''
Keymapping to open a file in a split.
'';
openSection = helpers.defaultNullOpts.mkStr "<TAB>" ''
Keymapping to open a section.
'';
openHelp = helpers.defaultNullOpts.mkStr "?" ''
Keymapping to open help.
'';
};
colors = {
background = helpers.defaultNullOpts.mkStr "#1f2227" ''
The background color.
'';
foldedSection = helpers.defaultNullOpts.mkStr "#56b6c2" ''
The color of folded sections.
This can also be changed with the `StartupFoldedSection` highlight group.
'';
};
parts = mkOption {
type = with types; listOf str;
default = [];
description = "List all sections in order.";
example = ["section_1" "section_2"];
};
userMappings = mkOption {
type = with types; attrsOf str;
description = "Add your own mappings as key-command pairs.";
default = {};
example = {
"<leader>ff" = "<cmd>Telescope find_files<CR>";
"<leader>lg" = "<cmd>Telescope live_grep<CR>";
};
};
paddings = helpers.defaultNullOpts.mkNullable (with types; listOf ints.unsigned) "[]" ''
Amount of empty lines before each section (must be equal to amount of sections).
'';
};
mappings = {
executeCommand = helpers.defaultNullOpts.mkStr "<CR>" ''
Keymapping to execute a command.
'';
openFile = helpers.defaultNullOpts.mkStr "o" ''
Keymapping to open a file.
'';
openFileSplit = helpers.defaultNullOpts.mkStr "<c-o>" ''
Keymapping to open a file in a split.
'';
openSection = helpers.defaultNullOpts.mkStr "<TAB>" ''
Keymapping to open a section.
'';
openHelp = helpers.defaultNullOpts.mkStr "?" ''
Keymapping to open help.
'';
};
colors = {
background = helpers.defaultNullOpts.mkStr "#1f2227" ''
The background color.
'';
foldedSection = helpers.defaultNullOpts.mkStr "#56b6c2" ''
The color of folded sections.
This can also be changed with the `StartupFoldedSection` highlight group.
'';
};
parts = mkOption {
type = with types; listOf str;
default = [ ];
description = "List all sections in order.";
example = [
"section_1"
"section_2"
];
};
userMappings = mkOption {
type = with types; attrsOf str;
description = "Add your own mappings as key-command pairs.";
default = { };
example = {
"<leader>ff" = "<cmd>Telescope find_files<CR>";
"<leader>lg" = "<cmd>Telescope live_grep<CR>";
};
};
};
config = mkIf cfg.enable {
assertions = let
sectionNames = attrNames cfg.sections;
numSections = length sectionNames;
in [
{
assertion = (cfg.options.paddings == null) || (length cfg.options.paddings) == numSections;
message = ''
Nixvim (plugins.startup): Make sure that `plugins.startup.options.paddings` has the same
number of elements as there are sections.
'';
}
{
assertion =
((length cfg.parts) <= numSections)
&& (
all
(part: hasAttr part cfg.sections)
cfg.parts
);
message = ''
Nixvim (plugins.startup): You should not have more section names in `plugins.startup.parts` than you have sections defined.
'';
}
];
extraPlugins = [cfg.package];
extraConfigLua = let
sections =
mapAttrs
(
name: sectionAttrs:
with sectionAttrs; {
inherit type;
oldfiles_directory = oldfilesDirectory;
inherit align;
fold_section = foldSection;
inherit
title
margin
content
highlight
;
default_color = defaultColor;
oldfiles_amount = oldfilesAmount;
}
)
cfg.sections;
options = with cfg.options;
assertions =
let
sectionNames = attrNames cfg.sections;
numSections = length sectionNames;
in
[
{
mapping_keys = mappingKeys;
cursor_column = cursorColumn;
inherit after;
empty_lines_between_mappings = emptyLinesBetweenMappings;
disable_statuslines = disableStatuslines;
inherit paddings;
assertion = (cfg.options.paddings == null) || (length cfg.options.paddings) == numSections;
message = ''
Nixvim (plugins.startup): Make sure that `plugins.startup.options.paddings` has the same
number of elements as there are sections.
'';
}
// cfg.extraOptions;
setupOptions =
{
assertion =
((length cfg.parts) <= numSections) && (all (part: hasAttr part cfg.sections) cfg.parts);
message = ''
Nixvim (plugins.startup): You should not have more section names in `plugins.startup.parts` than you have sections defined.
'';
}
];
extraPlugins = [ cfg.package ];
extraConfigLua =
let
sections = mapAttrs (
name: sectionAttrs: with sectionAttrs; {
inherit type;
oldfiles_directory = oldfilesDirectory;
inherit align;
fold_section = foldSection;
inherit
title
margin
content
highlight
;
default_color = defaultColor;
oldfiles_amount = oldfilesAmount;
}
) cfg.sections;
options =
with cfg.options;
{
mapping_keys = mappingKeys;
cursor_column = cursorColumn;
inherit after;
empty_lines_between_mappings = emptyLinesBetweenMappings;
disable_statuslines = disableStatuslines;
inherit paddings;
}
// cfg.extraOptions;
setupOptions = {
inherit (cfg) theme;
inherit options;
mappings = with cfg.mappings; {
@ -335,16 +327,13 @@ in {
folded_section = foldedSection;
};
inherit (cfg) parts;
}
// sections;
in
} // sections;
in
''
require('startup').setup(${helpers.toLuaObject setupOptions})
''
+ (
optionalString
(cfg.userMappings != {})
"require('startup').create_mappings(${helpers.toLuaObject cfg.userMappings})"
);
+ (optionalString (
cfg.userMappings != { }
) "require('startup').create_mappings(${helpers.toLuaObject cfg.userMappings})");
};
}

View file

@ -10,5 +10,5 @@ helpers.vim-plugin.mkVimPlugin config {
originalName = "surround.vim";
defaultPackage = pkgs.vimPlugins.surround;
maintainers = [lib.maintainers.GaetanLepage];
maintainers = [ lib.maintainers.GaetanLepage ];
}

View file

@ -5,174 +5,180 @@
pkgs,
...
}:
with lib; let
with lib;
let
# TODO: Introduced 2024-03-19, remove on 2024-05-19
deprecations = let
pluginPath = ["plugins" "tmux-navigator"];
option = s: pluginPath ++ [s];
setting = s: pluginPath ++ ["settings" s];
settingStr = s: concatStringsSep "." (setting s);
in [
(
mkRenamedOptionModule
(option "tmuxNavigatorSaveOnSwitch")
(setting "save_on_switch")
)
(
mkRemovedOptionModule
(option "tmuxNavigatorDisableWhenZoomed")
"Use `${settingStr "disable_when_zoomed"}` option."
)
(
mkRemovedOptionModule
(option "tmuxNavigatorNoWrap")
"Use `${settingStr "no_wrap"}` option."
)
];
deprecations =
let
pluginPath = [
"plugins"
"tmux-navigator"
];
option = s: pluginPath ++ [ s ];
setting =
s:
pluginPath
++ [
"settings"
s
];
settingStr = s: concatStringsSep "." (setting s);
in
[
(mkRenamedOptionModule (option "tmuxNavigatorSaveOnSwitch") (setting "save_on_switch"))
(mkRemovedOptionModule (option "tmuxNavigatorDisableWhenZoomed") "Use `${settingStr "disable_when_zoomed"}` option.")
(mkRemovedOptionModule (option "tmuxNavigatorNoWrap") "Use `${settingStr "no_wrap"}` option.")
];
in
helpers.vim-plugin.mkVimPlugin config {
name = "tmux-navigator";
originalName = "vim-tmux-navigator";
defaultPackage = pkgs.vimPlugins.vim-tmux-navigator;
globalPrefix = "tmux_navigator_";
helpers.vim-plugin.mkVimPlugin config {
name = "tmux-navigator";
originalName = "vim-tmux-navigator";
defaultPackage = pkgs.vimPlugins.vim-tmux-navigator;
globalPrefix = "tmux_navigator_";
maintainers = [helpers.maintainers.MattSturgeon];
maintainers = [ helpers.maintainers.MattSturgeon ];
description = ''
When combined with a set of tmux key bindings, the plugin will allow you to navigate seamlessly between vim splits and tmux panes using a consistent set of hotkeys.
description = ''
When combined with a set of tmux key bindings, the plugin will allow you to navigate seamlessly between vim splits and tmux panes using a consistent set of hotkeys.
**WARNING:** to work correctly, you must configure tmux separately.
**WARNING:** to work correctly, you must configure tmux separately.
## Usage
## Usage
This plugin provides the following mappings which allow you to move between vim splits and tmux panes seamlessly.
This plugin provides the following mappings which allow you to move between vim splits and tmux panes seamlessly.
- `<ctrl-h>` => Left
- `<ctrl-j>` => Down
- `<ctrl-k>` => Up
- `<ctrl-l>` => Right
- `<ctrl-\>` => Previous split
- `<ctrl-h>` => Left
- `<ctrl-j>` => Down
- `<ctrl-k>` => Up
- `<ctrl-l>` => Right
- `<ctrl-\>` => Previous split
To use alternative key mappings, see [`plugins.tmux-navigator.settings.no_mappings`][no_mappings].
To use alternative key mappings, see [`plugins.tmux-navigator.settings.no_mappings`][no_mappings].
## Configure tmux
## Configure tmux
There are two main ways to configure tmux. Either install the `tmuxPlugins.vim-tmux-navigator` plugin or add a snippet to your tmux config:
There are two main ways to configure tmux. Either install the `tmuxPlugins.vim-tmux-navigator` plugin or add a snippet to your tmux config:
```shell
# Smart pane switching with awareness of vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
# Forwarding <C-\\> needs different syntax, depending on tmux version
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
```
See the [upstream docs] for more info.
[no_mappings]: ./settings.html#pluginstmux-navigatorsettingsno_mappings
[upstream docs]: https://github.com/christoomey/vim-tmux-navigator#installation
'';
imports = deprecations;
settingsOptions = {
save_on_switch =
helpers.mkNullOrOption
(types.enum [
1
2
])
''
You can configure the plugin to write the current buffer, or all buffers, when navigating from vim to tmux.
null: don't save on switch (default value)
1: `:update` (write the current buffer, but only if changed)
2: `:wall` (write all buffers)
'';
disable_when_zoomed = helpers.defaultNullOpts.mkBool false ''
By default, if you zoom the tmux pane running vim and then attempt to navigate "past" the edge of the vim session, tmux will unzoom the pane.
This is the default tmux behavior, but may be confusing if you've become accustomed to navigation "wrapping" around the sides due to this plugin.
This option disables the unzooming behavior, keeping all navigation within vim until the tmux pane is explicitly unzoomed.
'';
preserve_zoom = helpers.defaultNullOpts.mkBool false ''
As noted in `disable_when_zoomed`, navigating from a vim pane to another tmux pane normally causes the window to be unzoomed.
Some users may prefer the behavior of tmux's `-Z` option to `select-pane`, which keeps the window zoomed if it was zoomed.
This option enables that behavior.
Naturally, if `disable_when_zoomed` is enabled, this option will have no effect.
'';
no_wrap = helpers.defaultNullOpts.mkBool false ''
By default, if you try to move past the edge of the screen, tmux/vim will "wrap" around to the opposite side.
This option disables "wrapping" in vim, but tmux will need to be configured separately.
Tmux doesn't have a "no_wrap" option, so whatever key bindings you have need to conditionally wrap based on position on screen:
```shell
# Smart pane switching with awareness of vim splits.
# See: https://github.com/christoomey/vim-tmux-navigator
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
bind-key -n 'C-h' if-shell "$is_vim" { send-keys C-h } { if-shell -F '#{pane_at_left}' {} { select-pane -L } }
bind-key -n 'C-j' if-shell "$is_vim" { send-keys C-j } { if-shell -F '#{pane_at_bottom}' {} { select-pane -D } }
bind-key -n 'C-k' if-shell "$is_vim" { send-keys C-k } { if-shell -F '#{pane_at_top}' {} { select-pane -U } }
bind-key -n 'C-l' if-shell "$is_vim" { send-keys C-l } { if-shell -F '#{pane_at_right}' {} { select-pane -R } }
# Forwarding <C-\\> needs different syntax, depending on tmux version
tmux_version='$(tmux -V | sed -En "s/^tmux ([0-9]+(.[0-9]+)?).*/\1/p")'
if-shell -b '[ "$(echo "$tmux_version < 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\' 'select-pane -l'"
if-shell -b '[ "$(echo "$tmux_version >= 3.0" | bc)" = 1 ]' \
"bind-key -n 'C-\\' if-shell \"$is_vim\" 'send-keys C-\\\\' 'select-pane -l'"
bind-key -T copy-mode-vi 'C-h' select-pane -L
bind-key -T copy-mode-vi 'C-j' select-pane -D
bind-key -T copy-mode-vi 'C-k' select-pane -U
bind-key -T copy-mode-vi 'C-l' select-pane -R
bind-key -T copy-mode-vi 'C-\' select-pane -l
bind-key -T copy-mode-vi 'C-h' if-shell -F '#{pane_at_left}' {} { select-pane -L }
bind-key -T copy-mode-vi 'C-j' if-shell -F '#{pane_at_bottom}' {} { select-pane -D }
bind-key -T copy-mode-vi 'C-k' if-shell -F '#{pane_at_top}' {} { select-pane -U }
bind-key -T copy-mode-vi 'C-l' if-shell -F '#{pane_at_right}' {} { select-pane -R }
```
See the [upstream docs] for more info.
[no_mappings]: ./settings.html#pluginstmux-navigatorsettingsno_mappings
[upstream docs]: https://github.com/christoomey/vim-tmux-navigator#installation
'';
imports = deprecations;
no_mappings = helpers.defaultNullOpts.mkBool false ''
By default `<C-h>`, `<C-j>`, `<C-k>`, `<C-l>`, & `<C-\\>` are mapped to navigating left, down, up, right, & previous, respectively.
settingsOptions = {
save_on_switch = helpers.mkNullOrOption (types.enum [1 2]) ''
You can configure the plugin to write the current buffer, or all buffers, when navigating from vim to tmux.
This option disables those default mappings being created.
null: don't save on switch (default value)
1: `:update` (write the current buffer, but only if changed)
2: `:wall` (write all buffers)
'';
You can use the plugin's five commands to define your own custom mappings:
disable_when_zoomed = helpers.defaultNullOpts.mkBool false ''
By default, if you zoom the tmux pane running vim and then attempt to navigate "past" the edge of the vim session, tmux will unzoom the pane.
This is the default tmux behavior, but may be confusing if you've become accustomed to navigation "wrapping" around the sides due to this plugin.
```nix
keymaps = [
{
key = "<C-w>h";
action = "<cmd>TmuxNavigateLeft<cr>";
}
{
key = "<C-w>j";
action = "<cmd>TmuxNavigateDown<cr>";
}
{
key = "<C-w>k";
action = "<cmd>TmuxNavigateUp<cr>";
}
{
key = "<C-w>l";
action = "<cmd>TmuxNavigateRight<cr>";
}
{
key = "<C-w>\\";
action = "<cmd>TmuxNavigatePrevious<cr>";
}
];
```
This option disables the unzooming behavior, keeping all navigation within vim until the tmux pane is explicitly unzoomed.
'';
preserve_zoom = helpers.defaultNullOpts.mkBool false ''
As noted in `disable_when_zoomed`, navigating from a vim pane to another tmux pane normally causes the window to be unzoomed.
Some users may prefer the behavior of tmux's `-Z` option to `select-pane`, which keeps the window zoomed if it was zoomed.
This option enables that behavior.
Naturally, if `disable_when_zoomed` is enabled, this option will have no effect.
'';
no_wrap = helpers.defaultNullOpts.mkBool false ''
By default, if you try to move past the edge of the screen, tmux/vim will "wrap" around to the opposite side.
This option disables "wrapping" in vim, but tmux will need to be configured separately.
Tmux doesn't have a "no_wrap" option, so whatever key bindings you have need to conditionally wrap based on position on screen:
```shell
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" { send-keys C-h } { if-shell -F '#{pane_at_left}' {} { select-pane -L } }
bind-key -n 'C-j' if-shell "$is_vim" { send-keys C-j } { if-shell -F '#{pane_at_bottom}' {} { select-pane -D } }
bind-key -n 'C-k' if-shell "$is_vim" { send-keys C-k } { if-shell -F '#{pane_at_top}' {} { select-pane -U } }
bind-key -n 'C-l' if-shell "$is_vim" { send-keys C-l } { if-shell -F '#{pane_at_right}' {} { select-pane -R } }
bind-key -T copy-mode-vi 'C-h' if-shell -F '#{pane_at_left}' {} { select-pane -L }
bind-key -T copy-mode-vi 'C-j' if-shell -F '#{pane_at_bottom}' {} { select-pane -D }
bind-key -T copy-mode-vi 'C-k' if-shell -F '#{pane_at_top}' {} { select-pane -U }
bind-key -T copy-mode-vi 'C-l' if-shell -F '#{pane_at_right}' {} { select-pane -R }
```
'';
no_mappings = helpers.defaultNullOpts.mkBool false ''
By default `<C-h>`, `<C-j>`, `<C-k>`, `<C-l>`, & `<C-\\>` are mapped to navigating left, down, up, right, & previous, respectively.
This option disables those default mappings being created.
You can use the plugin's five commands to define your own custom mappings:
```nix
keymaps = [
{
key = "<C-w>h";
action = "<cmd>TmuxNavigateLeft<cr>";
}
{
key = "<C-w>j";
action = "<cmd>TmuxNavigateDown<cr>";
}
{
key = "<C-w>k";
action = "<cmd>TmuxNavigateUp<cr>";
}
{
key = "<C-w>l";
action = "<cmd>TmuxNavigateRight<cr>";
}
{
key = "<C-w>\\";
action = "<cmd>TmuxNavigatePrevious<cr>";
}
];
```
You will also need to update your tmux bindings to match.
'';
};
}
You will also need to update your tmux bindings to match.
'';
};
}

View file

@ -5,7 +5,8 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.todo-comments;
commands = {
@ -14,57 +15,55 @@ with lib; let
todoTrouble = "TodoTrouble";
todoTelescope = "TodoTelescope";
};
in {
in
{
imports = [
(
mkRemovedOptionModule
["plugins" "todo-comments" "keymapsSilent"]
"Use `plugins.todo-comments.keymaps.<COMMAND>.options.silent`."
)
(mkRemovedOptionModule [
"plugins"
"todo-comments"
"keymapsSilent"
] "Use `plugins.todo-comments.keymaps.<COMMAND>.options.silent`.")
];
options = {
plugins.todo-comments =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "todo-comments";
plugins.todo-comments = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "todo-comments";
package =
helpers.mkPackageOption
"todo-comments"
pkgs.vimPlugins.todo-comments-nvim;
package = helpers.mkPackageOption "todo-comments" pkgs.vimPlugins.todo-comments-nvim;
ripgrepPackage = mkOption {
type = with types; nullOr package;
default = pkgs.ripgrep;
example = null;
description = "Which package (if any) to be added for file search support in todo-comments.";
};
ripgrepPackage = mkOption {
type = with types; nullOr package;
default = pkgs.ripgrep;
example = null;
description = "Which package (if any) to be added for file search support in todo-comments.";
};
signs = helpers.defaultNullOpts.mkBool true "Show icons in the signs column.";
signs = helpers.defaultNullOpts.mkBool true "Show icons in the signs column.";
signPriority = helpers.defaultNullOpts.mkInt 8 "Sign priority.";
signPriority = helpers.defaultNullOpts.mkInt 8 "Sign priority.";
keywords =
helpers.mkNullOrOption
(types.attrsOf (types.submodule {
options = {
icon = helpers.mkNullOrOption types.str ''
Icon used for the sign, and in search results.
'';
keywords =
helpers.mkNullOrOption
(types.attrsOf (
types.submodule {
options = {
icon = helpers.mkNullOrOption types.str ''
Icon used for the sign, and in search results.
'';
color = helpers.mkNullOrOption types.str ''
Can be a hex color, or a named color.
'';
color = helpers.mkNullOrOption types.str ''
Can be a hex color, or a named color.
'';
alt = helpers.mkNullOrOption (types.listOf types.str) ''
A set of other keywords that all map to this FIX keywords.
'';
alt = helpers.mkNullOrOption (types.listOf types.str) ''
A set of other keywords that all map to this FIX keywords.
'';
signs = helpers.mkNullOrOption types.bool ''
Configure signs for some keywords individually.
'';
};
}))
signs = helpers.mkNullOrOption types.bool ''
Configure signs for some keywords individually.
'';
};
}
))
''
Configurations for keywords to be recognized as todo comments.
@ -86,121 +85,117 @@ in {
```
'';
guiStyle = {
fg = helpers.defaultNullOpts.mkStr "NONE" ''
The gui style to use for the fg highlight group.
'';
bg = helpers.defaultNullOpts.mkStr "BOLD" ''
The gui style to use for the bg highlight group.
'';
};
mergeKeywords = helpers.defaultNullOpts.mkBool true ''
When true, custom keywords will be merged with the default
guiStyle = {
fg = helpers.defaultNullOpts.mkStr "NONE" ''
The gui style to use for the fg highlight group.
'';
highlight = {
multiline = helpers.defaultNullOpts.mkBool true ''
Enable multiline todo comments.
'';
bg = helpers.defaultNullOpts.mkStr "BOLD" ''
The gui style to use for the bg highlight group.
'';
};
multilinePattern = helpers.defaultNullOpts.mkStr "^." ''
Lua pattern to match the next multiline from the start of the
matched keyword.
'';
mergeKeywords = helpers.defaultNullOpts.mkBool true ''
When true, custom keywords will be merged with the default
'';
multilineContext = helpers.defaultNullOpts.mkInt 10 ''
Extra lines that will be re-evaluated when changing a line.
'';
highlight = {
multiline = helpers.defaultNullOpts.mkBool true ''
Enable multiline todo comments.
'';
before = helpers.defaultNullOpts.mkStr "" ''
"fg" or "bg" or empty.
'';
multilinePattern = helpers.defaultNullOpts.mkStr "^." ''
Lua pattern to match the next multiline from the start of the
matched keyword.
'';
keyword = helpers.defaultNullOpts.mkStr "wide" ''
"fg", "bg", "wide", "wide_bg", "wide_fg" or empty.
(wide and wide_bg is the same as bg, but will also highlight
surrounding characters, wide_fg acts accordingly but with fg).
'';
multilineContext = helpers.defaultNullOpts.mkInt 10 ''
Extra lines that will be re-evaluated when changing a line.
'';
after = helpers.defaultNullOpts.mkStr "fg" ''
"fg" or "bg" or empty.
'';
before = helpers.defaultNullOpts.mkStr "" ''
"fg" or "bg" or empty.
'';
pattern =
helpers.defaultNullOpts.mkNullable
(with types; either str (listOf str))
".*<(KEYWORDS)\\s*:"
keyword = helpers.defaultNullOpts.mkStr "wide" ''
"fg", "bg", "wide", "wide_bg", "wide_fg" or empty.
(wide and wide_bg is the same as bg, but will also highlight
surrounding characters, wide_fg acts accordingly but with fg).
'';
after = helpers.defaultNullOpts.mkStr "fg" ''
"fg" or "bg" or empty.
'';
pattern =
helpers.defaultNullOpts.mkNullable (with types; either str (listOf str)) ".*<(KEYWORDS)\\s*:"
''
Pattern or list of patterns, used for highlighting (vim regex)
Note: the provided pattern will be embedded as such: `[[PATTERN]]`.
'';
commentsOnly = helpers.defaultNullOpts.mkBool true ''
Uses treesitter to match keywords in comments only.
'';
commentsOnly = helpers.defaultNullOpts.mkBool true ''
Uses treesitter to match keywords in comments only.
'';
maxLineLen = helpers.defaultNullOpts.mkInt 400 ''
Ignore lines longer than this.
'';
maxLineLen = helpers.defaultNullOpts.mkInt 400 ''
Ignore lines longer than this.
'';
exclude = helpers.mkNullOrOption (types.listOf types.str) ''
List of file types to exclude highlighting.
'';
exclude = helpers.mkNullOrOption (types.listOf types.str) ''
List of file types to exclude highlighting.
'';
};
colors = helpers.mkNullOrOption (types.attrsOf (types.listOf types.str)) ''
List of named colors where we try to extract the guifg from the list
of highlight groups or use the hex color if hl not found as a fallback.
Default:
```nix
{
error = [ "DiagnosticError" "ErrorMsg" "#DC2626" ];
warning = [ "DiagnosticWarn" "WarningMsg" "#FBBF24" ];
info = [ "DiagnosticInfo" "#2563EB" ];
hint = [ "DiagnosticHint" "#10B981" ];
default = [ "Identifier" "#7C3AED" ];
test = [ "Identifier" "#FF00FF" ];
};
```
'';
colors =
helpers.mkNullOrOption
(types.attrsOf (types.listOf types.str)) ''
List of named colors where we try to extract the guifg from the list
of highlight groups or use the hex color if hl not found as a fallback.
search = {
command = helpers.defaultNullOpts.mkStr "rg" "Command to use for searching for keywords.";
Default:
```nix
{
error = [ "DiagnosticError" "ErrorMsg" "#DC2626" ];
warning = [ "DiagnosticWarn" "WarningMsg" "#FBBF24" ];
info = [ "DiagnosticInfo" "#2563EB" ];
hint = [ "DiagnosticHint" "#10B981" ];
default = [ "Identifier" "#7C3AED" ];
test = [ "Identifier" "#FF00FF" ];
};
```
'';
args = helpers.mkNullOrOption (types.listOf types.str) ''
Arguments to use for the search command in list form.
search = {
command = helpers.defaultNullOpts.mkStr "rg" "Command to use for searching for keywords.";
Default:
```nix
[
"--color=never"
"--no-heading"
"--with-filename"
"--line-number"
"--column"
];
```
'';
args = helpers.mkNullOrOption (types.listOf types.str) ''
Arguments to use for the search command in list form.
pattern = helpers.defaultNullOpts.mkStr "\\b(KEYWORDS):" ''
Regex that will be used to match keywords.
Don't replace the (KEYWORDS) placeholder.
Default:
```nix
[
"--color=never"
"--no-heading"
"--with-filename"
"--line-number"
"--column"
];
```
'';
Note: the provided pattern will be embedded as such: `[[PATTERN]]`.
'';
};
pattern = helpers.defaultNullOpts.mkStr "\\b(KEYWORDS):" ''
Regex that will be used to match keywords.
Don't replace the (KEYWORDS) placeholder.
Note: the provided pattern will be embedded as such: `[[PATTERN]]`.
'';
};
keymaps = let
mkKeymapOption = optionName: funcName:
helpers.mkCompositeOption
"Keymap settings for the `:${funcName}` function."
{
keymaps =
let
mkKeymapOption =
optionName: funcName:
helpers.mkCompositeOption "Keymap settings for the `:${funcName}` function." {
key = mkOption {
type = types.str;
description = "Key for the `${funcName}` function.";
@ -226,30 +221,27 @@ in {
options = helpers.keymaps.mapConfigOptions;
};
in
mapAttrs mkKeymapOption commands;
};
mapAttrs mkKeymapOption commands;
};
};
config = let
setupOptions =
{
config =
let
setupOptions = {
inherit (cfg) signs;
sign_priority = cfg.signPriority;
inherit (cfg) keywords;
gui_style = cfg.guiStyle;
merge_keywords = cfg.mergeKeywords;
highlight = {
inherit
(cfg.highlight)
inherit (cfg.highlight)
multiline
before
keyword
after
exclude
;
pattern =
helpers.ifNonNull' cfg.highlight.pattern
(helpers.mkRaw "[[${cfg.highlight.pattern}]]");
pattern = helpers.ifNonNull' cfg.highlight.pattern (helpers.mkRaw "[[${cfg.highlight.pattern}]]");
multiline_pattern = cfg.highlight.multilinePattern;
multiline_context = cfg.highlight.multilineContext;
comments_only = cfg.highlight.commentsOnly;
@ -258,54 +250,43 @@ in {
inherit (cfg) colors;
search = {
inherit (cfg.search) command args;
pattern =
helpers.ifNonNull' cfg.search.pattern
(
if isList cfg.search.pattern
then (map helpers.mkRaw cfg.search.pattern)
else helpers.mkRaw "[[${cfg.search.pattern}]]"
);
pattern = helpers.ifNonNull' cfg.search.pattern (
if isList cfg.search.pattern then
(map helpers.mkRaw cfg.search.pattern)
else
helpers.mkRaw "[[${cfg.search.pattern}]]"
);
};
}
// cfg.extraOptions;
in
} // cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPackages = [cfg.ripgrepPackage];
extraPlugins = [ cfg.package ];
extraPackages = [ cfg.ripgrepPackage ];
extraConfigLua = ''
require("todo-comments").setup${helpers.toLuaObject setupOptions}
'';
keymaps =
flatten
(
mapAttrsToList
(
optionName: funcName: let
keymap = cfg.keymaps.${optionName};
keymaps = flatten (
mapAttrsToList (
optionName: funcName:
let
keymap = cfg.keymaps.${optionName};
cwd = optionalString (keymap.cwd != null) " cwd=${keymap.cwd}";
keywords = optionalString (keymap.keywords != null) " keywords=${keymap.keywords}";
in
optional
(keymap != null)
{
mode = "n";
inherit
(keymap)
key
options
;
action = ":${funcName}${cwd}${keywords}<CR>";
}
)
commands
);
cwd = optionalString (keymap.cwd != null) " cwd=${keymap.cwd}";
keywords = optionalString (keymap.keywords != null) " keywords=${keymap.keywords}";
in
optional (keymap != null) {
mode = "n";
inherit (keymap) key options;
action = ":${funcName}${cwd}${keywords}<CR>";
}
) commands
);
# Automatically enable plugins if keymaps have been set
plugins = mkMerge [
(mkIf (cfg.keymaps.todoTrouble != null) {trouble.enable = true;})
(mkIf (cfg.keymaps.todoTelescope != null) {telescope.enable = true;})
(mkIf (cfg.keymaps.todoTrouble != null) { trouble.enable = true; })
(mkIf (cfg.keymaps.todoTelescope != null) { telescope.enable = true; })
];
};
}

View file

@ -6,227 +6,250 @@
...
}:
with lib;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "toggleterm";
originalName = "toggleterm.nvim";
defaultPackage = pkgs.vimPlugins.toggleterm-nvim;
helpers.neovim-plugin.mkNeovimPlugin config {
name = "toggleterm";
originalName = "toggleterm.nvim";
defaultPackage = pkgs.vimPlugins.toggleterm-nvim;
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO: introduced 2024-04-07, remove on 2024-06-07
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"size"
"onCreate"
"onOpen"
"onClose"
"onStdout"
"onStderr"
"onExit"
"hideNumbers"
"shadeFiletypes"
"autochdir"
"highlights"
"shadeTerminals"
"shadingFactor"
"startInInsert"
"insertMappings"
"terminalMappings"
"persistSize"
"persistMode"
"direction"
"closeOnExit"
"shell"
"autoScroll"
["floatOpts" "border"]
["floatOpts" "width"]
["floatOpts" "height"]
["floatOpts" "winblend"]
["floatOpts" "zindex"]
["winbar" "enabled"]
["winbar" "nameFormatter"]
];
imports = [
(
mkRemovedOptionModule
["plugins" "toggleterm" "openMapping"]
''
Please use `plugins.toggleterm.settings.open_mapping` instead but beware, you have to provide the value in this form: `"[[<c-\>]]"`.
''
)
];
# TODO: introduced 2024-04-07, remove on 2024-06-07
deprecateExtraOptions = true;
optionsRenamedToSettings = [
"size"
"onCreate"
"onOpen"
"onClose"
"onStdout"
"onStderr"
"onExit"
"hideNumbers"
"shadeFiletypes"
"autochdir"
"highlights"
"shadeTerminals"
"shadingFactor"
"startInInsert"
"insertMappings"
"terminalMappings"
"persistSize"
"persistMode"
"direction"
"closeOnExit"
"shell"
"autoScroll"
[
"floatOpts"
"border"
]
[
"floatOpts"
"width"
]
[
"floatOpts"
"height"
]
[
"floatOpts"
"winblend"
]
[
"floatOpts"
"zindex"
]
[
"winbar"
"enabled"
]
[
"winbar"
"nameFormatter"
]
];
imports = [
(mkRemovedOptionModule
[
"plugins"
"toggleterm"
"openMapping"
]
''
Please use `plugins.toggleterm.settings.open_mapping` instead but beware, you have to provide the value in this form: `"[[<c-\>]]"`.
''
)
];
settingsOptions = {
size = helpers.defaultNullOpts.mkStrLuaFnOr types.number "12" ''
Size of the terminal.
`size` can be a number or a function.
settingsOptions = {
size = helpers.defaultNullOpts.mkStrLuaFnOr types.number "12" ''
Size of the terminal.
`size` can be a number or a function.
Example:
```nix
size = 20
```
OR
Example:
```nix
size = 20
```
OR
```nix
size = \'\'
function(term)
if term.direction == "horizontal" then
return 15
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
```nix
size = \'\'
function(term)
if term.direction == "horizontal" then
return 15
elseif term.direction == "vertical" then
return vim.o.columns * 0.4
end
\'\';
```
end
\'\';
```
'';
open_mapping = helpers.mkNullOrLua ''
Setting the `open_mapping` key to use for toggling the terminal(s) will set up mappings for
normal mode.
'';
on_create = helpers.mkNullOrLuaFn ''
Function to run when the terminal is first created.
`fun(t: Terminal)`
'';
on_open = helpers.mkNullOrLuaFn ''
Function to run when the terminal opens.
`fun(t: Terminal)`
'';
on_close = helpers.mkNullOrLuaFn ''
Function to run when the terminal closes.
`fun(t: Terminal)`
'';
on_stdout = helpers.mkNullOrLuaFn ''
Callback for processing output on stdout.
`fun(t: Terminal, job: number, data: string[], name: string)`
'';
on_stderr = helpers.mkNullOrLuaFn ''
Callback for processing output on stderr.
`fun(t: Terminal, job: number, data: string[], name: string)`
'';
on_exit = helpers.mkNullOrLuaFn ''
Function to run when terminal process exits.
`fun(t: Terminal, job: number, exit_code: number, name: string)`
'';
hide_numbers = helpers.defaultNullOpts.mkBool true ''
Hide the number column in toggleterm buffers.
'';
shade_filetypes = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Shade filetypes.
'';
autochdir = helpers.defaultNullOpts.mkBool false ''
When neovim changes it current directory the terminal will change it's own when next it's
opened.
'';
highlights = helpers.defaultNullOpts.mkAttrsOf helpers.nixvimTypes.highlight ''
{
NormalFloat.link = "Normal";
FloatBorder.link = "Normal";
StatusLine.gui = "NONE";
StatusLineNC = {
cterm = "italic";
gui = "NONE";
};
}
'' "Highlights which map a highlight group name to an attrs of it's values.";
shade_terminals = helpers.defaultNullOpts.mkBool true ''
NOTE: This option takes priority over highlights specified so if you specify Normal
highlights you should set this to `false`.
'';
shading_factor = helpers.mkNullOrOption types.int ''
The percentage by which to lighten terminal background.
default: -30 (gets multiplied by -3 if background is light).
'';
start_in_insert = helpers.defaultNullOpts.mkBool true ''
Whether to start toggleterm in insert mode.
'';
insert_mappings = helpers.defaultNullOpts.mkBool true ''
Whether or not the open mapping applies in insert mode.
'';
terminal_mappings = helpers.defaultNullOpts.mkBool true ''
Whether or not the open mapping applies in the opened terminals.
'';
persist_size = helpers.defaultNullOpts.mkBool true ''
Whether the terminal size should persist.
'';
persist_mode = helpers.defaultNullOpts.mkBool true ''
If set to true (default) the previous terminal mode will be remembered.
'';
direction = helpers.defaultNullOpts.mkEnum [
"vertical"
"horizontal"
"tab"
"float"
] "horizontal" "The direction the terminal should be opened in.";
close_on_exit = helpers.defaultNullOpts.mkBool true ''
Close the terminal window when the process exits.
'';
shell = helpers.defaultNullOpts.mkStr ''{__raw = "vim.o.shell";}'' ''
Change the default shell.
'';
auto_scroll = helpers.defaultNullOpts.mkBool true ''
Automatically scroll to the bottom on terminal output.
'';
float_opts = {
border = helpers.mkNullOrOption helpers.nixvimTypes.border ''
`border` = "single" | "double" | "shadow" | "curved" | ... other options supported by
`win open`.
The border key is *almost* the same as 'nvim_open_win'.
The 'curved' border is a custom border type not natively supported but implemented in this plugin.
'';
open_mapping = helpers.mkNullOrLua ''
Setting the `open_mapping` key to use for toggling the terminal(s) will set up mappings for
normal mode.
width = helpers.mkNullOrOption types.ints.unsigned "";
height = helpers.mkNullOrOption types.ints.unsigned "";
row = helpers.mkNullOrOption types.ints.unsigned "";
col = helpers.mkNullOrOption types.ints.unsigned "";
winblend = helpers.defaultNullOpts.mkUnsignedInt 0 "";
zindex = helpers.mkNullOrOption types.ints.unsigned "";
title_pos = helpers.defaultNullOpts.mkStr "left" "";
};
winbar = {
enabled = helpers.defaultNullOpts.mkBool false ''
Whether to enable winbar.
'';
on_create = helpers.mkNullOrLuaFn ''
Function to run when the terminal is first created.
`fun(t: Terminal)`
'';
on_open = helpers.mkNullOrLuaFn ''
Function to run when the terminal opens.
`fun(t: Terminal)`
'';
on_close = helpers.mkNullOrLuaFn ''
Function to run when the terminal closes.
`fun(t: Terminal)`
'';
on_stdout = helpers.mkNullOrLuaFn ''
Callback for processing output on stdout.
`fun(t: Terminal, job: number, data: string[], name: string)`
'';
on_stderr = helpers.mkNullOrLuaFn ''
Callback for processing output on stderr.
`fun(t: Terminal, job: number, data: string[], name: string)`
'';
on_exit = helpers.mkNullOrLuaFn ''
Function to run when terminal process exits.
`fun(t: Terminal, job: number, exit_code: number, name: string)`
'';
hide_numbers = helpers.defaultNullOpts.mkBool true ''
Hide the number column in toggleterm buffers.
'';
shade_filetypes = helpers.defaultNullOpts.mkListOf types.str "[]" ''
Shade filetypes.
'';
autochdir = helpers.defaultNullOpts.mkBool false ''
When neovim changes it current directory the terminal will change it's own when next it's
opened.
'';
highlights =
helpers.defaultNullOpts.mkAttrsOf helpers.nixvimTypes.highlight
''
{
NormalFloat.link = "Normal";
FloatBorder.link = "Normal";
StatusLine.gui = "NONE";
StatusLineNC = {
cterm = "italic";
gui = "NONE";
};
}
''
"Highlights which map a highlight group name to an attrs of it's values.";
shade_terminals = helpers.defaultNullOpts.mkBool true ''
NOTE: This option takes priority over highlights specified so if you specify Normal
highlights you should set this to `false`.
'';
shading_factor = helpers.mkNullOrOption types.int ''
The percentage by which to lighten terminal background.
default: -30 (gets multiplied by -3 if background is light).
'';
start_in_insert = helpers.defaultNullOpts.mkBool true ''
Whether to start toggleterm in insert mode.
'';
insert_mappings = helpers.defaultNullOpts.mkBool true ''
Whether or not the open mapping applies in insert mode.
'';
terminal_mappings = helpers.defaultNullOpts.mkBool true ''
Whether or not the open mapping applies in the opened terminals.
'';
persist_size = helpers.defaultNullOpts.mkBool true ''
Whether the terminal size should persist.
'';
persist_mode = helpers.defaultNullOpts.mkBool true ''
If set to true (default) the previous terminal mode will be remembered.
'';
direction =
helpers.defaultNullOpts.mkEnum
["vertical" "horizontal" "tab" "float"] "horizontal"
"The direction the terminal should be opened in.";
close_on_exit = helpers.defaultNullOpts.mkBool true ''
Close the terminal window when the process exits.
'';
shell = helpers.defaultNullOpts.mkStr ''{__raw = "vim.o.shell";}'' ''
Change the default shell.
'';
auto_scroll = helpers.defaultNullOpts.mkBool true ''
Automatically scroll to the bottom on terminal output.
'';
float_opts = {
border = helpers.mkNullOrOption helpers.nixvimTypes.border ''
`border` = "single" | "double" | "shadow" | "curved" | ... other options supported by
`win open`.
The border key is *almost* the same as 'nvim_open_win'.
The 'curved' border is a custom border type not natively supported but implemented in this plugin.
'';
width = helpers.mkNullOrOption types.ints.unsigned "";
height = helpers.mkNullOrOption types.ints.unsigned "";
row = helpers.mkNullOrOption types.ints.unsigned "";
col = helpers.mkNullOrOption types.ints.unsigned "";
winblend = helpers.defaultNullOpts.mkUnsignedInt 0 "";
zindex = helpers.mkNullOrOption types.ints.unsigned "";
title_pos = helpers.defaultNullOpts.mkStr "left" "";
};
winbar = {
enabled = helpers.defaultNullOpts.mkBool false ''
Whether to enable winbar.
'';
name_formatter =
helpers.defaultNullOpts.mkLuaFn
name_formatter =
helpers.defaultNullOpts.mkLuaFn
''
function(term)
return term.name
@ -242,16 +265,16 @@ with lib;
end
```
'';
};
};
};
settingsExample = {
open_mapping = "[[<c-\>]]";
direction = "float";
float_opts = {
border = "curved";
width = 130;
height = 30;
};
settingsExample = {
open_mapping = "[[<c-\>]]";
direction = "float";
float_opts = {
border = "curved";
width = 130;
height = 30;
};
}
};
}

View file

@ -7,24 +7,32 @@
}:
with lib;
with helpers.vim-plugin;
mkVimPlugin config {
name = "undotree";
defaultPackage = pkgs.vimPlugins.undotree;
globalPrefix = "undotree_";
mkVimPlugin config {
name = "undotree";
defaultPackage = pkgs.vimPlugins.undotree;
globalPrefix = "undotree_";
maintainers = [maintainers.GaetanLepage];
maintainers = [ maintainers.GaetanLepage ];
# TODO introduced 2024-02-22: remove 2024-04-22
deprecateExtraConfig = true;
imports = let
basePluginPath = ["plugins" "undotree"];
# TODO introduced 2024-02-22: remove 2024-04-22
deprecateExtraConfig = true;
imports =
let
basePluginPath = [
"plugins"
"undotree"
];
in
mapAttrsToList
mapAttrsToList
(
old: new:
mkRenamedOptionModule
(basePluginPath ++ [old])
(basePluginPath ++ ["settings" new])
mkRenamedOptionModule (basePluginPath ++ [ old ]) (
basePluginPath
++ [
"settings"
new
]
)
)
{
windowLayout = "WindowLayout";
@ -45,25 +53,25 @@ with helpers.vim-plugin;
showCursorLine = "ShowCursorLine";
};
settingsExample = {
WindowLayout = 4;
ShortIndicators = false;
DiffpanelHeight = 10;
DiffAutoOpen = true;
SetFocusWhenToggle = true;
SplitWidth = 40;
TreeNodeShape = "*";
TreeVertShape = "|";
TreeSplitShape = "/";
TreeReturnShape = "\\";
DiffCommand = "diff";
RelativeTimestamp = true;
HighlightChangedText = true;
HighlightChangedWithSign = true;
HighlightSyntaxAdd = "DiffAdd";
HighlightSyntaxChange = "DiffChange";
HighlightSyntaxDel = "DiffDelete";
HelpLine = true;
CursorLine = true;
};
}
settingsExample = {
WindowLayout = 4;
ShortIndicators = false;
DiffpanelHeight = 10;
DiffAutoOpen = true;
SetFocusWhenToggle = true;
SplitWidth = 40;
TreeNodeShape = "*";
TreeVertShape = "|";
TreeSplitShape = "/";
TreeReturnShape = "\\";
DiffCommand = "diff";
RelativeTimestamp = true;
HighlightChangedText = true;
HighlightChangedWithSign = true;
HighlightSyntaxAdd = "DiffAdd";
HighlightSyntaxChange = "DiffChange";
HighlightSyntaxDel = "DiffDelete";
HelpLine = true;
CursorLine = true;
};
}

View file

@ -5,9 +5,11 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.vim-bbye;
in {
in
{
options.plugins.vim-bbye = {
enable = mkEnableOption "vim-bbye";
@ -31,31 +33,24 @@ in {
};
config = mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
keymaps = with cfg.keymaps;
keymaps =
with cfg.keymaps;
helpers.keymaps.mkKeymaps
{
mode = "n";
options.silent = cfg.keymapsSilent;
}
(
{
mode = "n";
options.silent = cfg.keymapsSilent;
}
(
optional
(bdelete != null)
{
(optional (bdelete != null) {
key = bdelete;
action = ":Bdelete<CR>";
}
)
++ (
optional
(bwipeout != null)
{
})
++ (optional (bwipeout != null) {
key = bwipeout;
action = ":Bwipeout<CR>";
}
)
);
})
);
};
}

View file

@ -8,5 +8,5 @@ helpers.vim-plugin.mkVimPlugin config {
name = "vim-css-color";
defaultPackage = pkgs.vimPlugins.vim-css-color;
maintainers = [helpers.maintainers.DanielLaing];
maintainers = [ helpers.maintainers.DanielLaing ];
}

View file

@ -5,7 +5,8 @@
config,
...
}:
with lib; {
with lib;
{
options.plugins.vim-matchup = {
enable = mkEnableOption "vim-matchup";
@ -15,7 +16,7 @@ with lib; {
enable = mkEnableOption "treesitter integration";
disable =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]"
"Languages for each to disable this module";
"Languages for each to disable this module";
disableVirtualText = helpers.defaultNullOpts.mkBool false ''
Do not use virtual text to highlight the virtual end of a block, for languages without
@ -34,36 +35,38 @@ with lib; {
If matchParen is not enabled fallback to the standard vim matchparen.
'';
singleton =
helpers.defaultNullOpts.mkBool false
"Whether to highlight known words even if there is no match";
singleton = helpers.defaultNullOpts.mkBool false "Whether to highlight known words even if there is no match";
offscreen =
helpers.defaultNullOpts.mkNullable
(types.submodule {
options = {
method = helpers.defaultNullOpts.mkEnumFirstDefault ["status" "popup" "status_manual"] ''
'status': Replace the status-line for off-screen matches.
offscreen = helpers.defaultNullOpts.mkNullable (types.submodule {
options = {
method =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"status"
"popup"
"status_manual"
]
''
'status': Replace the status-line for off-screen matches.
If a match is off of the screen, the line belonging to that match will be displayed
syntax-highlighted in the status line along with the line number (if line numbers
are enabled). If the match is above the screen border, an additional Δ symbol will
be shown to indicate that the matching line is really above the cursor line.
If a match is off of the screen, the line belonging to that match will be displayed
syntax-highlighted in the status line along with the line number (if line numbers
are enabled). If the match is above the screen border, an additional Δ symbol will
be shown to indicate that the matching line is really above the cursor line.
'popup': Show off-screen matches in a popup (vim) or floating (neovim) window.
'popup': Show off-screen matches in a popup (vim) or floating (neovim) window.
'status_manual': Compute the string which would be displayed in the status-line or
popup, but do not display it. The function MatchupStatusOffscreen() can be used to
get the text.
'';
scrolloff = helpers.defaultNullOpts.mkBool false ''
When enabled, off-screen matches will not be shown in the statusline while the
cursor is at the screen edge (respects the value of 'scrolloff').
This is intended to prevent flickering while scrolling with j and k.
'';
};
})
''{method = "status";}'' "Dictionary controlling the behavior with off-screen matches.";
'status_manual': Compute the string which would be displayed in the status-line or
popup, but do not display it. The function MatchupStatusOffscreen() can be used to
get the text.
'';
scrolloff = helpers.defaultNullOpts.mkBool false ''
When enabled, off-screen matches will not be shown in the statusline while the
cursor is at the screen edge (respects the value of 'scrolloff').
This is intended to prevent flickering while scrolling with j and k.
'';
};
}) ''{method = "status";}'' "Dictionary controlling the behavior with off-screen matches.";
stopline = helpers.defaultNullOpts.mkInt 400 ''
The number of lines to search in either direction while highlighting matches.
@ -72,11 +75,11 @@ with lib; {
timeout =
helpers.defaultNullOpts.mkInt 300
"Adjust timeouts in milliseconds for matchparen highlighting";
"Adjust timeouts in milliseconds for matchparen highlighting";
insertTimeout =
helpers.defaultNullOpts.mkInt 60
"Adjust timeouts in milliseconds for matchparen highlighting";
"Adjust timeouts in milliseconds for matchparen highlighting";
deferred = {
enable = helpers.defaultNullOpts.mkBool false ''
@ -121,44 +124,59 @@ with lib; {
enable = helpers.defaultNullOpts.mkBool true "Controls text objects";
linewiseOperators =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
''["d" "y"]'' "Modify the set of operators which may operate line-wise";
helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["d" "y"]''
"Modify the set of operators which may operate line-wise";
};
enableSurround =
helpers.defaultNullOpts.mkBool false
"To enable the delete surrounding (ds%) and change surrounding (cs%) maps";
enableSurround = helpers.defaultNullOpts.mkBool false "To enable the delete surrounding (ds%) and change surrounding (cs%) maps";
enableTransmute =
helpers.defaultNullOpts.mkBool false "To enable the experimental transmute module";
enableTransmute = helpers.defaultNullOpts.mkBool false "To enable the experimental transmute module";
delimStopline = helpers.defaultNullOpts.mkInt 1500 ''
To configure the number of lines to search in either direction while using motions and text
objects. Does not apply to match highlighting (see matchParenStopline instead)
'';
delimNoSkips = helpers.defaultNullOpts.mkNullable (types.enum [0 1 2]) "0" ''
To disable matching within strings and comments:
- 0: matching is enabled within strings and comments
- 1: recognize symbols within comments
- 2: don't recognize anything in comments
'';
delimNoSkips =
helpers.defaultNullOpts.mkNullable
(types.enum [
0
1
2
])
"0"
''
To disable matching within strings and comments:
- 0: matching is enabled within strings and comments
- 1: recognize symbols within comments
- 2: don't recognize anything in comments
'';
};
# TODO introduced 2024-03-07: remove 2024-05-07
imports = [
(
mkRenamedOptionModule
["plugins" "vim-matchup" "matchParen" "deffered"]
["plugins" "vim-matchup" "matchParen" "deferred"]
(mkRenamedOptionModule
[
"plugins"
"vim-matchup"
"matchParen"
"deffered"
]
[
"plugins"
"vim-matchup"
"matchParen"
"deferred"
]
)
];
config = let
cfg = config.plugins.vim-matchup;
in
config =
let
cfg = config.plugins.vim-matchup;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
plugins.treesitter.moduleConfig.matchup = mkIf cfg.treesitterIntegration.enable {
inherit (cfg.treesitterIntegration) enable disable;

View file

@ -5,17 +5,16 @@
config,
...
}:
with lib; {
with lib;
{
options.plugins.which-key = {
enable =
mkEnableOption
"which-key.nvim, a plugin that popup with possible key bindings of the command you started typing";
enable = mkEnableOption "which-key.nvim, a plugin that popup with possible key bindings of the command you started typing";
package = helpers.mkPackageOption "which-key-nvim" pkgs.vimPlugins.which-key-nvim;
registrations = mkOption {
type = with types; attrsOf anything;
default = {};
default = { };
description = "Manually register the description of mappings.";
example = {
"<leader>p" = "Find git files with telescope";
@ -25,30 +24,20 @@ with lib; {
plugins = {
marks = helpers.defaultNullOpts.mkBool true "shows a list of your marks on ' and `";
registers =
helpers.defaultNullOpts.mkBool true
''shows your registers on " in NORMAL or <C-r> in INSERT mode'';
registers = helpers.defaultNullOpts.mkBool true ''shows your registers on " in NORMAL or <C-r> in INSERT mode'';
spelling = {
enabled =
helpers.defaultNullOpts.mkBool true
"enabling this will show WhichKey when pressing z= to select spelling suggestions";
suggestions =
helpers.defaultNullOpts.mkInt 20
"how many suggestions should be shown in the list?";
enabled = helpers.defaultNullOpts.mkBool true "enabling this will show WhichKey when pressing z= to select spelling suggestions";
suggestions = helpers.defaultNullOpts.mkInt 20 "how many suggestions should be shown in the list?";
};
presets = {
operators = helpers.defaultNullOpts.mkBool true "adds help for operators like d, y, ...";
motions = helpers.defaultNullOpts.mkBool true "adds help for motions";
textObjects =
helpers.defaultNullOpts.mkBool true
"help for text objects triggered after entering an operator";
textObjects = helpers.defaultNullOpts.mkBool true "help for text objects triggered after entering an operator";
windows = helpers.defaultNullOpts.mkBool true "default bindings on <c-w>";
nav = helpers.defaultNullOpts.mkBool true "misc bindings to work with windows";
z =
helpers.defaultNullOpts.mkBool true
"bindings for folds, spelling and others prefixed with z";
z = helpers.defaultNullOpts.mkBool true "bindings for folds, spelling and others prefixed with z";
g = helpers.defaultNullOpts.mkBool true "bindings for prefixed with g";
};
};
@ -67,9 +56,7 @@ with lib; {
};
icons = {
breadcrumb =
helpers.defaultNullOpts.mkStr "»"
"symbol used in the command line area that shows your active key combo";
breadcrumb = helpers.defaultNullOpts.mkStr "»" "symbol used in the command line area that shows your active key combo";
separator = helpers.defaultNullOpts.mkStr "" "symbol used between a key and it's label";
group = helpers.defaultNullOpts.mkStr "+" "symbol prepended to a group";
};
@ -79,137 +66,156 @@ with lib; {
scrollUp = helpers.defaultNullOpts.mkStr "<c-u>" "binding to scroll up inside the popup";
};
window = let
spacingOptions = types.submodule {
options = {
top = mkOption {type = types.int;};
right = mkOption {type = types.int;};
bottom = mkOption {type = types.int;};
left = mkOption {type = types.int;};
window =
let
spacingOptions = types.submodule {
options = {
top = mkOption { type = types.int; };
right = mkOption { type = types.int; };
bottom = mkOption { type = types.int; };
left = mkOption { type = types.int; };
};
};
in
{
border = helpers.defaultNullOpts.mkBorder "none" "which-key" "";
position = helpers.defaultNullOpts.mkEnumFirstDefault [
"bottom"
"top"
] "";
margin =
helpers.defaultNullOpts.mkNullable spacingOptions ''{top = 1; right = 0; bottom = 1; left = 0;}''
"extra window margin";
padding =
helpers.defaultNullOpts.mkNullable spacingOptions ''{top = 1; right = 2; bottom = 1; left = 2;}''
"extra window padding";
winblend = helpers.defaultNullOpts.mkNullable (types.ints.between 0
100
) "0" "0 for fully opaque and 100 for fully transparent";
};
in {
border = helpers.defaultNullOpts.mkBorder "none" "which-key" "";
position = helpers.defaultNullOpts.mkEnumFirstDefault ["bottom" "top"] "";
margin =
helpers.defaultNullOpts.mkNullable spacingOptions
''{top = 1; right = 0; bottom = 1; left = 0;}'' "extra window margin";
padding =
helpers.defaultNullOpts.mkNullable spacingOptions
''{top = 1; right = 2; bottom = 1; left = 2;}'' "extra window padding";
winblend =
helpers.defaultNullOpts.mkNullable (types.ints.between 0 100) "0"
"0 for fully opaque and 100 for fully transparent";
};
layout = let
rangeOption = types.submodule {
options = {
min = mkOption {type = types.int;};
max = mkOption {type = types.int;};
layout =
let
rangeOption = types.submodule {
options = {
min = mkOption { type = types.int; };
max = mkOption { type = types.int; };
};
};
in
{
height =
helpers.defaultNullOpts.mkNullable rangeOption "{min = 4; max = 25;}"
"min and max height of the columns";
width =
helpers.defaultNullOpts.mkNullable rangeOption "{min = 20; max = 50;}"
"min and max width of the columns";
spacing = helpers.defaultNullOpts.mkInt 3 "spacing between columns";
align = helpers.defaultNullOpts.mkEnumFirstDefault [
"left"
"center"
"right"
] "";
};
in {
height =
helpers.defaultNullOpts.mkNullable rangeOption "{min = 4; max = 25;}"
"min and max height of the columns";
width =
helpers.defaultNullOpts.mkNullable rangeOption "{min = 20; max = 50;}"
"min and max width of the columns";
spacing = helpers.defaultNullOpts.mkInt 3 "spacing between columns";
align = helpers.defaultNullOpts.mkEnumFirstDefault ["left" "center" "right"] "";
};
ignoreMissing =
helpers.defaultNullOpts.mkBool false
"enable this to hide mappings for which you didn't specify a label";
ignoreMissing = helpers.defaultNullOpts.mkBool false "enable this to hide mappings for which you didn't specify a label";
hidden = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''
["<silent>" "<cmd>" "<Cmd>" "<CR>" "^:" "^ " "^call " "^lua "]
'' "hide mapping boilerplate";
showHelp =
helpers.defaultNullOpts.mkBool true
"show a help message in the command line for using WhichKey";
showHelp = helpers.defaultNullOpts.mkBool true "show a help message in the command line for using WhichKey";
showKeys =
helpers.defaultNullOpts.mkBool true
"show the currently pressed key and its label as a message in the command line";
showKeys = helpers.defaultNullOpts.mkBool true "show the currently pressed key and its label as a message in the command line";
triggers =
helpers.defaultNullOpts.mkNullable
(types.either (types.enum ["auto"]) (types.listOf types.str))
''"auto"'' "automatically setup triggers, or specify a list manually";
triggers = helpers.defaultNullOpts.mkNullable (types.either (types.enum [ "auto" ]) (
types.listOf types.str
)) ''"auto"'' "automatically setup triggers, or specify a list manually";
triggersNoWait =
helpers.defaultNullOpts.mkNullable (types.listOf types.str)
''["`" "'" "g`" "g'" "\"" "<c-r>" "z="]'' ''
list of triggers, where WhichKey should not wait for timeoutlen and show immediately
'';
''["`" "'" "g`" "g'" "\"" "<c-r>" "z="]''
''
list of triggers, where WhichKey should not wait for timeoutlen and show immediately
'';
triggersBlackList =
helpers.defaultNullOpts.mkNullable (types.attrsOf (types.listOf types.str))
''{ i = ["j" "k"]; v = ["j" "k"]}}'' ''
list of mode / prefixes that should never be hooked by WhichKey
this is mostly relevant for keymaps that start with a native binding
'';
''{ i = ["j" "k"]; v = ["j" "k"]}}''
''
list of mode / prefixes that should never be hooked by WhichKey
this is mostly relevant for keymaps that start with a native binding
'';
disable = {
buftypes =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]"
"Disabled by default for Telescope";
"Disabled by default for Telescope";
filetypes = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "";
};
};
config = let
cfg = config.plugins.which-key;
setupOptions = {
plugins = {
inherit (cfg.plugins) marks registers spelling;
presets = {
inherit (cfg.plugins.presets) operators motions;
text_objects = cfg.plugins.presets.textObjects;
inherit (cfg.plugins.presets) windows nav z g;
config =
let
cfg = config.plugins.which-key;
setupOptions = {
plugins = {
inherit (cfg.plugins) marks registers spelling;
presets = {
inherit (cfg.plugins.presets) operators motions;
text_objects = cfg.plugins.presets.textObjects;
inherit (cfg.plugins.presets)
windows
nav
z
g
;
};
};
inherit (cfg) operators;
key_labels = cfg.keyLabels;
inherit (cfg) motions icons;
popup_mappings = {
scroll_down = cfg.popupMappings.scrollDown;
scroll_up = cfg.popupMappings.scrollUp;
};
window =
let
mkSpacing =
opt:
helpers.ifNonNull' opt [
opt.top
opt.right
opt.bottom
opt.top
];
in
{
inherit (cfg.window) border position;
margin = mkSpacing cfg.window.margin;
padding = mkSpacing cfg.window.padding;
inherit (cfg.window) winblend;
};
inherit (cfg) layout;
ignore_missing = cfg.ignoreMissing;
inherit (cfg) hidden;
show_help = cfg.showHelp;
show_keys = cfg.showKeys;
inherit (cfg) triggers;
triggers_nowait = cfg.triggersNoWait;
triggers_blacklist = cfg.triggersBlackList;
inherit (cfg) disable;
};
inherit (cfg) operators;
key_labels = cfg.keyLabels;
inherit (cfg) motions icons;
popup_mappings = {
scroll_down = cfg.popupMappings.scrollDown;
scroll_up = cfg.popupMappings.scrollUp;
};
window = let
mkSpacing = opt: helpers.ifNonNull' opt [opt.top opt.right opt.bottom opt.top];
in {
inherit (cfg.window) border position;
margin = mkSpacing cfg.window.margin;
padding = mkSpacing cfg.window.padding;
inherit (cfg.window) winblend;
};
inherit (cfg) layout;
ignore_missing = cfg.ignoreMissing;
inherit (cfg) hidden;
show_help = cfg.showHelp;
show_keys = cfg.showKeys;
inherit (cfg) triggers;
triggers_nowait = cfg.triggersNoWait;
triggers_blacklist = cfg.triggersBlackList;
inherit (cfg) disable;
};
in
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua =
''
require("which-key").setup(${helpers.toLuaObject setupOptions})
''
+ (
optionalString (cfg.registrations != {}) ''
require("which-key").register(${helpers.toLuaObject cfg.registrations})
''
);
+ (optionalString (cfg.registrations != { }) ''
require("which-key").register(${helpers.toLuaObject cfg.registrations})
'');
};
}

View file

@ -5,16 +5,16 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.wilder;
mkKeyOption = default: desc:
mkKeyOption =
default: desc:
helpers.defaultNullOpts.mkNullable
(
with types;
either
str
(submodule {
(
with types;
either str (submodule {
options = {
key = mkOption {
type = str;
@ -22,7 +22,7 @@ with lib; let
};
fallback = mkOption {
type = either str (enum [false]);
type = either str (enum [ false ]);
description = ''
For a no-op, set <fallback> to "".
@ -35,47 +35,55 @@ with lib; let
};
};
})
)
default
''
${desc}
)
default
''
${desc}
NOTE:
A string or an attrs (with keys `key` and `fallback`) representing the mapping to bind to
`|wilder#next()|`.
If a string is provided, it is automatically converted to `{key = <KEY>; fallback = <KEY>;}`.
NOTE:
A string or an attrs (with keys `key` and `fallback`) representing the mapping to bind to
`|wilder#next()|`.
If a string is provided, it is automatically converted to `{key = <KEY>; fallback = <KEY>;}`.
- `mapping` is the `|cmap|` used to bind to `|wilder#next()|`.
- `fallback` is the mapping used if `|wilder#in_context()|` is false.
'';
in {
- `mapping` is the `|cmap|` used to bind to `|wilder#next()|`.
- `fallback` is the mapping used if `|wilder#in_context()|` is false.
'';
in
{
imports = [
(
mkRenamedOptionModule
["plugins" "wilder-nvim"]
["plugins" "wilder"]
(mkRenamedOptionModule
[
"plugins"
"wilder-nvim"
]
[
"plugins"
"wilder"
]
)
];
options.plugins.wilder =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "wilder-nvim";
options.plugins.wilder = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "wilder-nvim";
package = helpers.mkPackageOption "wilder-nvim" pkgs.vimPlugins.wilder-nvim;
package = helpers.mkPackageOption "wilder-nvim" pkgs.vimPlugins.wilder-nvim;
### Setup options ###
enableCmdlineEnter = helpers.defaultNullOpts.mkBool true ''
If true calls `wilder#enable_cmdline_enter()`.
Creates a new `|CmdlineEnter|` autocmd to which will start wilder when the cmdline is
entered.
'';
### Setup options ###
enableCmdlineEnter = helpers.defaultNullOpts.mkBool true ''
If true calls `wilder#enable_cmdline_enter()`.
Creates a new `|CmdlineEnter|` autocmd to which will start wilder when the cmdline is
entered.
'';
modes =
helpers.defaultNullOpts.mkNullable
modes =
helpers.defaultNullOpts.mkNullable
(
with types;
listOf (enum ["/" "?" ":"])
listOf (enum [
"/"
"?"
":"
])
)
''["/" "?"]''
''
@ -83,168 +91,170 @@ in {
Possible elements: '/', '?' and ':'
'';
wildcharm =
helpers.defaultNullOpts.mkNullable
(
with types;
either str (enum [false])
)
"&wildchar"
wildcharm =
helpers.defaultNullOpts.mkNullable (with types; either str (enum [ false ])) "&wildchar"
''
Key to set the 'wildcharm' option to.
Can be set to v:false to skip the setting.
'';
nextKey = mkKeyOption "<Tab>" ''
A key to map to `wilder#next()` providing next suggestion.
'';
nextKey = mkKeyOption "<Tab>" ''
A key to map to `wilder#next()` providing next suggestion.
'';
prevKey = mkKeyOption "<S-Tab>" ''
A key to map to `wilder#prev()` providing previous suggestion.
'';
prevKey = mkKeyOption "<S-Tab>" ''
A key to map to `wilder#prev()` providing previous suggestion.
'';
acceptKey = mkKeyOption "<Down>" ''
Mapping to bind to `wilder#accept_completion()`.
'';
acceptKey = mkKeyOption "<Down>" ''
Mapping to bind to `wilder#accept_completion()`.
'';
rejectKey = mkKeyOption "<Up>" ''
Mapping to bind to `wilder#reject_completion()`.
'';
rejectKey = mkKeyOption "<Up>" ''
Mapping to bind to `wilder#reject_completion()`.
'';
acceptCompletionAutoSelect = helpers.defaultNullOpts.mkBool true ''
The `auto_select` option passed to `wilder#accept_completion()`, if mapped.
'';
acceptCompletionAutoSelect = helpers.defaultNullOpts.mkBool true ''
The `auto_select` option passed to `wilder#accept_completion()`, if mapped.
'';
### Other options ###
useCmdlinechanged = helpers.mkNullOrOption types.bool ''
If true, wilder will refresh queries when the `|CmdlineChanged|` autocommand is triggered.
Otherwise it will use a `|timer|` to check whether the cmdline has changed.
Using a timer will be more resource intensive.
### Other options ###
useCmdlinechanged = helpers.mkNullOrOption types.bool ''
If true, wilder will refresh queries when the `|CmdlineChanged|` autocommand is triggered.
Otherwise it will use a `|timer|` to check whether the cmdline has changed.
Using a timer will be more resource intensive.
Default: `exists('##CmdlineChanged')`
'';
Default: `exists('##CmdlineChanged')`
'';
interval = helpers.defaultNullOpts.mkUnsignedInt 100 ''
Interval of the `|timer|` used to check whether the cmdline has changed, in milliseconds.
Only applicable if `useCmdlinechanged` is false.
'';
interval = helpers.defaultNullOpts.mkUnsignedInt 100 ''
Interval of the `|timer|` used to check whether the cmdline has changed, in milliseconds.
Only applicable if `useCmdlinechanged` is false.
'';
beforeCursor = helpers.defaultNullOpts.mkBool false ''
If true, wilder will look only at the part of the cmdline before the cursor, and when
selecting a completion, the entire cmdline will be replaced.
Only applicable if `useCmdlinechanged` is false.
'';
beforeCursor = helpers.defaultNullOpts.mkBool false ''
If true, wilder will look only at the part of the cmdline before the cursor, and when
selecting a completion, the entire cmdline will be replaced.
Only applicable if `useCmdlinechanged` is false.
'';
usePythonRemotePlugin = helpers.mkNullOrOption types.bool ''
If true, uses the Python remote plugin.
This option can be set to false to disable the Python remote plugin.
usePythonRemotePlugin = helpers.mkNullOrOption types.bool ''
If true, uses the Python remote plugin.
This option can be set to false to disable the Python remote plugin.
This option has to be set before setting the `pipeline` option and before wilder is first
run.
This option has to be set before setting the `pipeline` option and before wilder is first
run.
Default: `has('python3') && (has('nvim') || exists('*yarp#py3'))`
'';
Default: `has('python3') && (has('nvim') || exists('*yarp#py3'))`
'';
numWorkers = helpers.defaultNullOpts.mkUnsignedInt 2 ''
Number of workers for the Python 3 `|remote-plugin|`.
Has to be set at startup, before wilder is first run.
Setting the option after the first run has no effect.
'';
numWorkers = helpers.defaultNullOpts.mkUnsignedInt 2 ''
Number of workers for the Python 3 `|remote-plugin|`.
Has to be set at startup, before wilder is first run.
Setting the option after the first run has no effect.
'';
pipeline = helpers.mkNullOrOption (with helpers.nixvimTypes; listOf strLua) ''
Sets the pipeline to use to get completions.
See `|wilder-pipeline|`.
pipeline = helpers.mkNullOrOption (with helpers.nixvimTypes; listOf strLua) ''
Sets the pipeline to use to get completions.
See `|wilder-pipeline|`.
Example:
```lua
[
\'\'
wilder.branch(
wilder.cmdline_pipeline({
language = 'python',
fuzzy = 1,
}),
wilder.python_search_pipeline({
pattern = wilder.python_fuzzy_pattern(),
sorter = wilder.python_difflib_sorter(),
engine = 're',
})
)
\'\'
]
```
'';
renderer = helpers.defaultNullOpts.mkLuaFn "nil" ''
Sets the renderer to used to display the completions.
See `|wilder-renderer|`.
Example:
```lua
Example:
```lua
[
\'\'
wilder.wildmenu_renderer({
-- highlighter applies highlighting to the candidates
highlighter = wilder.basic_highlighter(),
})
wilder.branch(
wilder.cmdline_pipeline({
language = 'python',
fuzzy = 1,
}),
wilder.python_search_pipeline({
pattern = wilder.python_fuzzy_pattern(),
sorter = wilder.python_difflib_sorter(),
engine = 're',
})
)
\'\'
```
'';
]
```
'';
preHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
A function which takes a `ctx`.
This function is called when wilder starts, or when wilder becomes unhidden.
See `|wilder-hidden|`.
renderer = helpers.defaultNullOpts.mkLuaFn "nil" ''
Sets the renderer to used to display the completions.
See `|wilder-renderer|`.
`ctx` contains no keys.
'';
Example:
```lua
\'\'
wilder.wildmenu_renderer({
-- highlighter applies highlighting to the candidates
highlighter = wilder.basic_highlighter(),
})
\'\'
```
'';
postHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
A function which takes a `ctx`.
This function is called when wilder stops, or when wilder becomes hidden.
See `|wilder-hidden|`.
preHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
A function which takes a `ctx`.
This function is called when wilder starts, or when wilder becomes unhidden.
See `|wilder-hidden|`.
`ctx` contains no keys.
'';
};
`ctx` contains no keys.
'';
config = let
setupOptions = with cfg; let
processKeyOpt = key:
helpers.ifNonNull' key
(
if isString key
then key
else [key.key key.fallback]
);
in {
enable_cmdline_enter = enableCmdlineEnter;
inherit modes;
inherit wildcharm;
next_key = processKeyOpt nextKey;
previous_key = processKeyOpt prevKey;
accept_key = processKeyOpt acceptKey;
reject_key = processKeyOpt rejectKey;
accept_completion_auto_select = acceptCompletionAutoSelect;
};
postHook = helpers.defaultNullOpts.mkLuaFn "nil" ''
A function which takes a `ctx`.
This function is called when wilder stops, or when wilder becomes hidden.
See `|wilder-hidden|`.
options = with cfg;
{
use_cmdlinechanged = useCmdlinechanged;
inherit interval;
before_cursor = beforeCursor;
use_python_remote_plugin = usePythonRemotePlugin;
num_workers = numWorkers;
pipeline =
helpers.ifNonNull' pipeline
(map helpers.mkRaw pipeline);
inherit renderer;
pre_hook = preHook;
post_hook = postHook;
}
// cfg.extraOptions;
in
`ctx` contains no keys.
'';
};
config =
let
setupOptions =
with cfg;
let
processKeyOpt =
key:
helpers.ifNonNull' key (
if isString key then
key
else
[
key.key
key.fallback
]
);
in
{
enable_cmdline_enter = enableCmdlineEnter;
inherit modes;
inherit wildcharm;
next_key = processKeyOpt nextKey;
previous_key = processKeyOpt prevKey;
accept_key = processKeyOpt acceptKey;
reject_key = processKeyOpt rejectKey;
accept_completion_auto_select = acceptCompletionAutoSelect;
};
options =
with cfg;
{
use_cmdlinechanged = useCmdlinechanged;
inherit interval;
before_cursor = beforeCursor;
use_python_remote_plugin = usePythonRemotePlugin;
num_workers = numWorkers;
pipeline = helpers.ifNonNull' pipeline (map helpers.mkRaw pipeline);
inherit renderer;
pre_hook = preHook;
post_hook = postHook;
}
// cfg.extraOptions;
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPlugins = [ cfg.package ];
extraConfigLua = ''
wilder = require("wilder")

View file

@ -5,169 +5,180 @@
pkgs,
...
}:
with lib; let
with lib;
let
cfg = config.plugins.yanky;
in {
options.plugins.yanky =
helpers.neovim-plugin.extraOptionsOptions
// {
enable = mkEnableOption "yanky.nvim";
in
{
options.plugins.yanky = helpers.neovim-plugin.extraOptionsOptions // {
enable = mkEnableOption "yanky.nvim";
package = helpers.mkPackageOption "yanky.nvim" pkgs.vimPlugins.yanky-nvim;
package = helpers.mkPackageOption "yanky.nvim" pkgs.vimPlugins.yanky-nvim;
ring = {
historyLength = helpers.defaultNullOpts.mkUnsignedInt 100 ''
Define the number of yanked items that will be saved and used for ring.
'';
ring = {
historyLength = helpers.defaultNullOpts.mkUnsignedInt 100 ''
Define the number of yanked items that will be saved and used for ring.
'';
storage = helpers.defaultNullOpts.mkEnumFirstDefault ["shada" "sqlite" "memory"] ''
Define the storage mode for ring values.
storage =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"shada"
"sqlite"
"memory"
]
''
Define the storage mode for ring values.
Using `shada`, this will save pesistantly using Neovim ShaDa feature.
This means that history will be persisted between each session of Neovim.
Using `shada`, this will save pesistantly using Neovim ShaDa feature.
This means that history will be persisted between each session of Neovim.
You can also use this feature to sync the yank history across multiple running instances
of Neovim by updating shada file.
If you execute `:wshada` in the first instance and then `:rshada` in the second instance,
the second instance will be synced with the yank history in the first instance.
You can also use this feature to sync the yank history across multiple running instances
of Neovim by updating shada file.
If you execute `:wshada` in the first instance and then `:rshada` in the second instance,
the second instance will be synced with the yank history in the first instance.
Using `memory`, each Neovim instance will have his own history and il will be lost between
sessions.
Using `memory`, each Neovim instance will have his own history and il will be lost between
sessions.
Sqlite is more reliable than ShaDa but requires more dependencies.
You can change the storage path using `ring.storagePath` option.
'';
storagePath =
helpers.defaultNullOpts.mkNullable
(with types; either str helpers.nixvimTypes.rawLua)
''{__raw = "vim.fn.stdpath('data') .. '/databases/yanky.db'";}''
"Only for sqlite storage.";
syncWithNumberedRegisters = helpers.defaultNullOpts.mkBool true ''
History can also be synchronized with numbered registers.
Every time the yank history changes the numbered registers 1 - 9 will be updated to sync
with the first 9 entries in the yank history.
See [here](http://vimcasts.org/blog/2013/11/registers-the-good-the-bad-and-the-ugly-parts/) for an explanation of why we would want do do this.
'';
cancelEvent = helpers.defaultNullOpts.mkEnumFirstDefault ["update" "move"] ''
Define the event used to cancel ring activation.
`update` will cancel ring on next buffer update, `move` will cancel ring when moving
cursor or content changed.
'';
ignoreRegisters = helpers.defaultNullOpts.mkNullable (with types; listOf str) ''["_"]'' ''
Define registers to be ignored.
By default the black hole register is ignored.
'';
updateRegisterOnCycle = helpers.defaultNullOpts.mkBool false ''
If true, when you cycle through the ring, the contents of the register used to update will
be updated with the last content cycled.
'';
};
picker = {
select = {
action = helpers.mkNullOrOption (with types; either helpers.nixvimTypes.rawLua str) ''
This define the action that should be done when selecting an item in the
`vim.ui.select` prompt.
If you let this option to `null`, this will use the default action: put selected item
after cursor.
This is either:
- a `rawLua` value (`action.__raw = "function() foo end";`).
- a string. In this case, Nixvim will automatically interpret it as a builtin yanky
action.
Example: `action = "put('p')";` will translate to
`action = require('yanky.picker').actions.put('p')` in lua.
'';
};
telescope = {
enable = mkEnableOption "the `yank_history` telescope picker.";
useDefaultMappings = helpers.defaultNullOpts.mkBool true ''
This define if default Telescope mappings should be used.
Sqlite is more reliable than ShaDa but requires more dependencies.
You can change the storage path using `ring.storagePath` option.
'';
mappings = helpers.mkNullOrOption (with types; attrsOf (attrsOf str)) ''
This define or overrides the mappings available in Telescope.
storagePath = helpers.defaultNullOpts.mkNullable (
with types; either str helpers.nixvimTypes.rawLua
) ''{__raw = "vim.fn.stdpath('data') .. '/databases/yanky.db'";}'' "Only for sqlite storage.";
If you set `useDefaultMappings` to `true`, mappings will be merged with default
mappings.
syncWithNumberedRegisters = helpers.defaultNullOpts.mkBool true ''
History can also be synchronized with numbered registers.
Every time the yank history changes the numbered registers 1 - 9 will be updated to sync
with the first 9 entries in the yank history.
See [here](http://vimcasts.org/blog/2013/11/registers-the-good-the-bad-and-the-ugly-parts/) for an explanation of why we would want do do this.
'';
Example:
```nix
{
i = {
"<c-g>" = "put('p')";
"<c-k>" = "put('P')";
"<c-x>" = "delete()";
"<c-r>" = "set_register(require('yanky.utils').get_default_register())";
};
n = {
p = "put('p')";
P = "put('P')";
d = "delete()";
r = "set_register(require('yanky.utils').get_default_register())";
};
}
```
cancelEvent =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"update"
"move"
]
''
Define the event used to cancel ring activation.
`update` will cancel ring on next buffer update, `move` will cancel ring when moving
cursor or content changed.
'';
};
};
systemClipboard = {
syncWithRing = helpers.defaultNullOpts.mkBool true ''
Yanky can automatically adds to ring history yanks that occurs outside of Neovim.
This works regardless to your `&clipboard` setting.
ignoreRegisters = helpers.defaultNullOpts.mkNullable (with types; listOf str) ''["_"]'' ''
Define registers to be ignored.
By default the black hole register is ignored.
'';
This means, if `&clipboard` is set to `unnamed` and/or `unnamedplus`, if you yank
something outside of Neovim, you can put it immediately using `p` and it will be added to
your yank ring.
updateRegisterOnCycle = helpers.defaultNullOpts.mkBool false ''
If true, when you cycle through the ring, the contents of the register used to update will
be updated with the last content cycled.
'';
};
If `&clipboard` is empty, if you yank something outside of Neovim, this will be the first
value you'll have when cycling through the ring.
Basically, you can do `p` and then `<c-p>` to paste yanked text.
picker = {
select = {
action = helpers.mkNullOrOption (with types; either helpers.nixvimTypes.rawLua str) ''
This define the action that should be done when selecting an item in the
`vim.ui.select` prompt.
If you let this option to `null`, this will use the default action: put selected item
after cursor.
This is either:
- a `rawLua` value (`action.__raw = "function() foo end";`).
- a string. In this case, Nixvim will automatically interpret it as a builtin yanky
action.
Example: `action = "put('p')";` will translate to
`action = require('yanky.picker').actions.put('p')` in lua.
'';
};
highlight = {
onPut = helpers.defaultNullOpts.mkBool true ''
Define if highlight put text feature is enabled.
telescope = {
enable = mkEnableOption "the `yank_history` telescope picker.";
useDefaultMappings = helpers.defaultNullOpts.mkBool true ''
This define if default Telescope mappings should be used.
'';
onYank = helpers.defaultNullOpts.mkBool true ''
Define if highlight yanked text feature is enabled.
'';
mappings = helpers.mkNullOrOption (with types; attrsOf (attrsOf str)) ''
This define or overrides the mappings available in Telescope.
timer = helpers.defaultNullOpts.mkUnsignedInt 500 ''
Define the duration of highlight.
'';
};
If you set `useDefaultMappings` to `true`, mappings will be merged with default
mappings.
preserveCursorPosition = {
enabled = helpers.defaultNullOpts.mkBool true ''
Whether cursor position should be preserved on yank.
This works only if mappings has been defined.
'';
};
textobj = {
enabled = helpers.defaultNullOpts.mkBool true ''
Yanky comes with a text object corresponding to last put text.
To use it, you have to enable it and set a keymap.
Example:
```nix
{
i = {
"<c-g>" = "put('p')";
"<c-k>" = "put('P')";
"<c-x>" = "delete()";
"<c-r>" = "set_register(require('yanky.utils').get_default_register())";
};
n = {
p = "put('p')";
P = "put('P')";
d = "delete()";
r = "set_register(require('yanky.utils').get_default_register())";
};
}
```
'';
};
};
config = let
thereAreSomeTelescopeMappings =
(cfg.picker.telescope.mappings != null)
&& (cfg.picker.telescope.mappings != {});
in
systemClipboard = {
syncWithRing = helpers.defaultNullOpts.mkBool true ''
Yanky can automatically adds to ring history yanks that occurs outside of Neovim.
This works regardless to your `&clipboard` setting.
This means, if `&clipboard` is set to `unnamed` and/or `unnamedplus`, if you yank
something outside of Neovim, you can put it immediately using `p` and it will be added to
your yank ring.
If `&clipboard` is empty, if you yank something outside of Neovim, this will be the first
value you'll have when cycling through the ring.
Basically, you can do `p` and then `<c-p>` to paste yanked text.
'';
};
highlight = {
onPut = helpers.defaultNullOpts.mkBool true ''
Define if highlight put text feature is enabled.
'';
onYank = helpers.defaultNullOpts.mkBool true ''
Define if highlight yanked text feature is enabled.
'';
timer = helpers.defaultNullOpts.mkUnsignedInt 500 ''
Define the duration of highlight.
'';
};
preserveCursorPosition = {
enabled = helpers.defaultNullOpts.mkBool true ''
Whether cursor position should be preserved on yank.
This works only if mappings has been defined.
'';
};
textobj = {
enabled = helpers.defaultNullOpts.mkBool true ''
Yanky comes with a text object corresponding to last put text.
To use it, you have to enable it and set a keymap.
'';
};
};
config =
let
thereAreSomeTelescopeMappings =
(cfg.picker.telescope.mappings != null) && (cfg.picker.telescope.mappings != { });
in
mkIf cfg.enable {
assertions = [
{
@ -182,74 +193,59 @@ in {
plugins.telescope.enable = true;
plugins.telescope.enabledExtensions = optional cfg.picker.telescope.enable "yank_history";
extraPlugins =
[
cfg.package
]
++ (
optional (cfg.ring.storage == "sqlite") pkgs.vimPlugins.sqlite-lua
);
extraPlugins = [
cfg.package
] ++ (optional (cfg.ring.storage == "sqlite") pkgs.vimPlugins.sqlite-lua);
extraConfigLua = let
setupOptions = with cfg;
{
ring = {
history_length = ring.historyLength;
inherit (ring) storage;
storage_path = ring.storagePath;
sync_with_numbered_registers = ring.syncWithNumberedRegisters;
cancel_event = ring.cancelEvent;
ignore_registers = ring.ignoreRegisters;
update_register_on_cycle = ring.updateRegisterOnCycle;
};
picker = {
select = {
action =
if isString picker.select.action
then helpers.mkRaw "require('yanky.picker').actions.${picker.select.action}"
else picker.select.action;
extraConfigLua =
let
setupOptions =
with cfg;
{
ring = {
history_length = ring.historyLength;
inherit (ring) storage;
storage_path = ring.storagePath;
sync_with_numbered_registers = ring.syncWithNumberedRegisters;
cancel_event = ring.cancelEvent;
ignore_registers = ring.ignoreRegisters;
update_register_on_cycle = ring.updateRegisterOnCycle;
};
telescope = {
use_default_mappings = picker.telescope.useDefaultMappings;
mappings =
helpers.ifNonNull' picker.telescope.mappings
(
mapAttrs
(
mode: mappings:
mapAttrs
(
key: action:
helpers.mkRaw "__yanky_telescope_mapping.${action}"
)
mappings
)
picker.telescope.mappings
picker = {
select = {
action =
if isString picker.select.action then
helpers.mkRaw "require('yanky.picker').actions.${picker.select.action}"
else
picker.select.action;
};
telescope = {
use_default_mappings = picker.telescope.useDefaultMappings;
mappings = helpers.ifNonNull' picker.telescope.mappings (
mapAttrs (
mode: mappings: mapAttrs (key: action: helpers.mkRaw "__yanky_telescope_mapping.${action}") mappings
) picker.telescope.mappings
);
};
};
};
system_clipboard = {
sync_with_ring = systemClipboard.syncWithRing;
};
highlight = {
on_put = highlight.onPut;
on_yank = highlight.onYank;
inherit (highlight) timer;
};
preserve_cursor_position = {
inherit (preserveCursorPosition) enabled;
};
textobj = {
inherit (textobj) enabled;
};
}
// cfg.extraOptions;
in
(
optionalString
thereAreSomeTelescopeMappings
"local __yanky_telescope_mapping = require('yanky.telescope.mapping')"
)
system_clipboard = {
sync_with_ring = systemClipboard.syncWithRing;
};
highlight = {
on_put = highlight.onPut;
on_yank = highlight.onYank;
inherit (highlight) timer;
};
preserve_cursor_position = {
inherit (preserveCursorPosition) enabled;
};
textobj = {
inherit (textobj) enabled;
};
}
// cfg.extraOptions;
in
(optionalString thereAreSomeTelescopeMappings "local __yanky_telescope_mapping = require('yanky.telescope.mapping')")
+ ''
require('yanky').setup(${helpers.toLuaObject setupOptions})
'';

View file

@ -10,7 +10,7 @@ helpers.neovim-plugin.mkNeovimPlugin config {
originalName = "zellij.nvim";
defaultPackage = pkgs.vimPlugins.zellij-nvim;
maintainers = [lib.maintainers.hmajid2301];
maintainers = [ lib.maintainers.hmajid2301 ];
settingsOptions = {
path = helpers.defaultNullOpts.mkStr "zellij" ''

View file

@ -5,47 +5,54 @@
pkgs,
...
}:
with lib; {
with lib;
{
options.plugins.zk = {
enable = mkEnableOption "zk.nvim, a plugin to integrate with zk";
package = helpers.mkPackageOption "zk.nvim" pkgs.vimPlugins.zk-nvim;
picker = helpers.defaultNullOpts.mkEnumFirstDefault ["select" "fzf" "telescope"] ''
it's recommended to use "telescope" or "fzf"
'';
picker =
helpers.defaultNullOpts.mkEnumFirstDefault
[
"select"
"fzf"
"telescope"
]
''
it's recommended to use "telescope" or "fzf"
'';
lsp = {
config =
helpers.neovim-plugin.extraOptionsOptions
// {
cmd = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["zk" "lsp"]'' "";
name = helpers.defaultNullOpts.mkStr "zk" "";
};
config = helpers.neovim-plugin.extraOptionsOptions // {
cmd = helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["zk" "lsp"]'' "";
name = helpers.defaultNullOpts.mkStr "zk" "";
};
autoAttach = {
enabled = helpers.defaultNullOpts.mkBool true "automatically attach buffers in a zk notebook";
filetypes =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["markdown"]''
"matching the given filetypes";
"matching the given filetypes";
};
};
};
config = let
cfg = config.plugins.zk;
setupOptions = {
inherit (cfg) picker;
lsp = {
inherit (cfg.lsp) config;
auto_attach = {
inherit (cfg.lsp.autoAttach) enabled filetypes;
config =
let
cfg = config.plugins.zk;
setupOptions = {
inherit (cfg) picker;
lsp = {
inherit (cfg.lsp) config;
auto_attach = {
inherit (cfg.lsp.autoAttach) enabled filetypes;
};
};
};
};
in
in
mkIf cfg.enable {
extraPlugins = [cfg.package];
extraPackages = [pkgs.zk];
extraPlugins = [ cfg.package ];
extraPackages = [ pkgs.zk ];
extraConfigLua = ''
require("zk").setup(${helpers.toLuaObject setupOptions})