plugins: remove mkCompositeOptions from implementation

This commit is contained in:
Gaetan Lepage 2023-12-09 23:09:50 +01:00 committed by Gaétan Lepage
parent 70b4e2d981
commit d8cffe2ead
13 changed files with 607 additions and 681 deletions

View file

@ -23,17 +23,15 @@ with lib; let
"the button which is clicked to close / save a buffer, or indicate that it is pinned."; "the button which is clicked to close / save a buffer, or indicate that it is pinned.";
diagnostics = diagnostics =
helpers.mkCompositeOption "Diagnostics icons"
(
genAttrs genAttrs
["error" "warn" "info" "hint"] ["error" "warn" "info" "hint"]
( (
name: name:
helpers.mkCompositeOption "${name} diagnostic icon" { helpers.mkCompositeOption "${name} diagnostic icon." {
enable = helpers.defaultNullOpts.mkBool false "Enable the ${name} diagnostic symbol"; enable = helpers.defaultNullOpts.mkBool false "Enable the ${name} diagnostic symbol";
icon = helpers.mkNullOrOption types.str "${name} diagnostic symbol"; icon = helpers.mkNullOrOption types.str "${name} diagnostic symbol";
} }
)
); );
filetype = { filetype = {
@ -250,7 +248,7 @@ in {
buffer_index = bufferIndex; buffer_index = bufferIndex;
buffer_number = bufferNumber; buffer_number = bufferNumber;
inherit button; inherit button;
diagnostics = helpers.ifNonNull' bufferOption.diagnostics ( diagnostics =
/* /*
Because the keys of this lua table are not strings (but Because the keys of this lua table are not strings (but
`vim.diagnostic.severity.XXXX`), we have to manualy build a raw lua string here. `vim.diagnostic.severity.XXXX`), we have to manualy build a raw lua string here.
@ -277,7 +275,6 @@ in {
setIconsList setIconsList
) )
+ "}" + "}"
)
); );
filetype = with filetype; { filetype = with filetype; {
custom_color = customColors; custom_color = customColors;

View file

@ -240,19 +240,19 @@ in {
offsets = helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "null" "offsets"; offsets = helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "null" "offsets";
groups = helpers.mkCompositeOption "groups" { groups = {
items = items =
helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "[]" helpers.defaultNullOpts.mkNullable (types.listOf types.attrs) "[]"
"List of groups."; "List of groups.";
options = helpers.mkCompositeOption "Group options" { options = {
toggleHiddenOnEnter = toggleHiddenOnEnter =
helpers.defaultNullOpts.mkBool true helpers.defaultNullOpts.mkBool true
"Re-open hidden groups on bufenter."; "Re-open hidden groups on bufenter.";
}; };
}; };
hover = helpers.mkCompositeOption "Hover" { hover = {
enabled = mkEnableOption "hover"; enabled = mkEnableOption "hover";
reveal = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "reveal"; reveal = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "reveal";
@ -260,7 +260,7 @@ in {
delay = helpers.defaultNullOpts.mkInt 200 "delay"; delay = helpers.defaultNullOpts.mkInt 200 "delay";
}; };
debug = helpers.mkCompositeOption "Debug options" { debug = {
logging = helpers.defaultNullOpts.mkBool false "Whether to enable logging"; logging = helpers.defaultNullOpts.mkBool false "Whether to enable logging";
}; };
@ -319,14 +319,23 @@ in {
diagnostics_indicator = helpers.mkRaw diagnosticsIndicator; diagnostics_indicator = helpers.mkRaw diagnosticsIndicator;
diagnostics_update_in_insert = diagnosticsUpdateInInsert; diagnostics_update_in_insert = diagnosticsUpdateInInsert;
inherit offsets; inherit offsets;
groups = helpers.ifNonNull' groups { groups = {
inherit (groups) items; inherit (groups) items;
options = helpers.ifNonNull' groups.options { options = {
toggle_hidden_on_enter = groups.options.toggleHiddenOnEnter; toggle_hidden_on_enter = groups.options.toggleHiddenOnEnter;
}; };
}; };
inherit hover; hover = {
inherit debug; inherit
(hover)
enabled
reveal
delay
;
};
debug = {
inherit (debug) logging;
};
custom_filter = helpers.mkRaw customFilter; custom_filter = helpers.mkRaw customFilter;
} }
// cfg.extraOptions; // cfg.extraOptions;

View file

@ -58,7 +58,7 @@ in {
package = helpers.mkPackageOption "dap-ui" pkgs.vimPlugins.nvim-dap-ui; package = helpers.mkPackageOption "dap-ui" pkgs.vimPlugins.nvim-dap-ui;
controls = helpers.mkCompositeOption "Options for dap-ui controls." { controls = {
enabled = helpers.defaultNullOpts.mkBool true "Enable controls"; enabled = helpers.defaultNullOpts.mkBool true "Enable controls";
element = element =
@ -178,7 +178,7 @@ in {
}) })
"Keys to trigger actions in elements."; "Keys to trigger actions in elements.";
render = helpers.mkCompositeOption "Rendering options which can be updated after initial setup." { render = {
indent = helpers.defaultNullOpts.mkInt 1 "Default indentation size."; indent = helpers.defaultNullOpts.mkInt 1 "Default indentation size.";
maxTypeLength = helpers.mkNullOrOption types.int "Maximum number of characters to allow a type name to fill before trimming."; maxTypeLength = helpers.mkNullOrOption types.int "Maximum number of characters to allow a type name to fill before trimming.";
@ -206,11 +206,11 @@ in {
force_buffers = forceBuffers; force_buffers = forceBuffers;
render = helpers.ifNonNull' render (with render; { render = with render; {
inherit indent; inherit indent;
max_type_length = maxTypeLength; max_type_length = maxTypeLength;
max_value_lines = maxValueLines; max_value_lines = maxValueLines;
}); };
select_window = helpers.mkRaw selectWindow; select_window = helpers.mkRaw selectWindow;
} }

View file

@ -158,12 +158,10 @@ in {
Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree. Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.
''; '';
hijackDirectories = hijackDirectories = {
helpers.mkCompositeOption
"Hijacks new directory buffers when they are opened (`:e dir`)."
{
enable = helpers.defaultNullOpts.mkBool true '' enable = helpers.defaultNullOpts.mkBool true ''
Enable the feature. Hijacks new directory buffers when they are opened (`:e dir`).
Disable this option if you use vim-dirvish or dirbuf.nvim. Disable this option if you use vim-dirvish or dirbuf.nvim.
If `hijackNetrw` and `disableNetrw` are `false`, this feature will be disabled. If `hijackNetrw` and `disableNetrw` are `false`, this feature will be disabled.
''; '';
@ -173,14 +171,11 @@ in {
''; '';
}; };
updateFocusedFile = updateFocusedFile = {
helpers.mkCompositeOption enable = helpers.defaultNullOpts.mkBool false ''
''
Update the focused file on `BufEnter`, un-collapses the folders recursively until it finds Update the focused file on `BufEnter`, un-collapses the folders recursively until it finds
the file. the file.
'' '';
{
enable = helpers.defaultNullOpts.mkBool false "Enable this feature.";
updateRoot = helpers.defaultNullOpts.mkBool false '' updateRoot = helpers.defaultNullOpts.mkBool false ''
Update the root directory of the tree if the file is not under current root directory. Update the root directory of the tree if the file is not under current root directory.
@ -197,10 +192,7 @@ in {
''; '';
}; };
systemOpen = systemOpen = {
helpers.mkCompositeOption
"Open a file or directory in your preferred application."
{
cmd = helpers.defaultNullOpts.mkStr "" '' cmd = helpers.defaultNullOpts.mkStr "" ''
The open command itself. The open command itself.
@ -218,9 +210,8 @@ in {
''; '';
}; };
diagnostics = diagnostics = {
helpers.mkCompositeOption enable = helpers.defaultNullOpts.mkBool false ''
''
Show LSP and COC diagnostics in the signcolumn Show LSP and COC diagnostics in the signcolumn
Note that the modified sign will take precedence over the diagnostics signs. Note that the modified sign will take precedence over the diagnostics signs.
@ -230,9 +221,7 @@ in {
- `NvimTreeLspDiagnosticsWarning` - `NvimTreeLspDiagnosticsWarning`
- `NvimTreeLspDiagnosticsInformation` - `NvimTreeLspDiagnosticsInformation`
- `NvimTreeLspDiagnosticsHint` - `NvimTreeLspDiagnosticsHint`
'' '';
{
enable = helpers.defaultNullOpts.mkBool false "Enable/disable the feature.";
debounceDelay = helpers.defaultNullOpts.mkInt 50 '' debounceDelay = helpers.defaultNullOpts.mkInt 50 ''
Idle milliseconds between diagnostic event and update. Idle milliseconds between diagnostic event and update.
@ -247,7 +236,7 @@ in {
Only relevant when `diagnostics.showOnDirs` is `true Only relevant when `diagnostics.showOnDirs` is `true
''; '';
icons = helpers.mkCompositeOption "Icons for diagnostic severity." { icons = {
hint = helpers.defaultNullOpts.mkStr "" ""; hint = helpers.defaultNullOpts.mkStr "" "";
info = helpers.defaultNullOpts.mkStr "" ""; info = helpers.defaultNullOpts.mkStr "" "";
warning = helpers.defaultNullOpts.mkStr "" ""; warning = helpers.defaultNullOpts.mkStr "" "";
@ -256,20 +245,22 @@ in {
severity = let severity = let
severityEnum = ["error" "warn" "info" "hint"]; severityEnum = ["error" "warn" "info" "hint"];
in in {
helpers.mkCompositeOption min = helpers.defaultNullOpts.mkEnum severityEnum "hint" ''
'' Minimum severity for which the diagnostics will be displayed.
Severity for which the diagnostics will be displayed. See `|diagnostic-severity|`.
See |diagnostic-severity|. '';
'' max = helpers.defaultNullOpts.mkEnum severityEnum "error" ''
{ Maximum severity for which the diagnostics will be displayed.
min = helpers.defaultNullOpts.mkEnum severityEnum "hint" "Minimum severity."; See `|diagnostic-severity|`.
max = helpers.defaultNullOpts.mkEnum severityEnum "error" "Maximum severity."; '';
}; };
}; };
git = helpers.mkCompositeOption "Git integration with icons and colors." { git = {
enable = helpers.defaultNullOpts.mkBool true "Enable / disable the feature."; enable = helpers.defaultNullOpts.mkBool true ''
Git integration with icons and colors.
'';
ignore = helpers.defaultNullOpts.mkBool true '' ignore = helpers.defaultNullOpts.mkBool true ''
Ignore files based on `.gitignore`. Requires `git.enable` to be `true`. Ignore files based on `.gitignore`. Requires `git.enable` to be `true`.
@ -290,8 +281,10 @@ in {
''; '';
}; };
modified = helpers.mkCompositeOption "Indicate which file have unsaved modification." { modified = {
enable = helpers.defaultNullOpts.mkBool false "Enable / disable the feature."; enable = helpers.defaultNullOpts.mkBool false ''
Indicate which file have unsaved modification.
'';
showOnDirs = helpers.defaultNullOpts.mkBool true '' showOnDirs = helpers.defaultNullOpts.mkBool true ''
Show modified indication on directory whose children are modified. Show modified indication on directory whose children are modified.
@ -303,17 +296,14 @@ in {
''; '';
}; };
filesystemWatchers = filesystemWatchers = {
helpers.mkCompositeOption enable = helpers.defaultNullOpts.mkBool true ''
''
Will use file system watcher (libuv fs_event) to watch the filesystem for changes. Will use file system watcher (libuv fs_event) to watch the filesystem for changes.
Using this will disable BufEnter / BufWritePost events in nvim-tree which were used to Using this will disable BufEnter / BufWritePost events in nvim-tree which were used to
update the whole tree. update the whole tree.
With this feature, the tree will be updated only for the appropriate folder change, With this feature, the tree will be updated only for the appropriate folder change,
resulting in better performance. resulting in better performance.
'' '';
{
enable = helpers.defaultNullOpts.mkBool true "Enable / disable the feature.";
debounceDelay = helpers.defaultNullOpts.mkInt 50 '' debounceDelay = helpers.defaultNullOpts.mkInt 50 ''
Idle milliseconds between filesystem change and action. Idle milliseconds between filesystem change and action.
@ -425,7 +415,7 @@ in {
Show diagnostic sign column. Value can be `"yes"`, `"auto"`, `"no"`. Show diagnostic sign column. Value can be `"yes"`, `"auto"`, `"no"`.
''; '';
float = helpers.mkCompositeOption "Configuration options for floating window." { float = {
enable = helpers.defaultNullOpts.mkBool false '' enable = helpers.defaultNullOpts.mkBool false ''
Tree window will be floating. Tree window will be floating.
''; '';
@ -438,7 +428,7 @@ in {
}; };
}; };
renderer = helpers.mkCompositeOption "UI rendering setup" { renderer = {
addTrailing = helpers.defaultNullOpts.mkBool false '' addTrailing = helpers.defaultNullOpts.mkBool false ''
Appends a trailing slash to folder names. Appends a trailing slash to folder names.
''; '';
@ -505,7 +495,7 @@ in {
Number of spaces for an each tree nesting level. Minimum 1. Number of spaces for an each tree nesting level. Minimum 1.
''; '';
indentMarkers = helpers.mkCompositeOption "Configuration options for tree indent markers." { indentMarkers = {
enable = helpers.defaultNullOpts.mkBool false '' enable = helpers.defaultNullOpts.mkBool false ''
Display indent markers when folders are open Display indent markers when folders are open
''; '';
@ -515,7 +505,7 @@ in {
|renderer.icons.show.folder_arrow|. |renderer.icons.show.folder_arrow|.
''; '';
icons = helpers.mkCompositeOption "Icons shown before the file/directory. Length 1." { icons = {
corner = helpers.defaultNullOpts.mkStr "" ""; corner = helpers.defaultNullOpts.mkStr "" "";
edge = helpers.defaultNullOpts.mkStr "" ""; edge = helpers.defaultNullOpts.mkStr "" "";
item = helpers.defaultNullOpts.mkStr "" ""; item = helpers.defaultNullOpts.mkStr "" "";
@ -524,7 +514,7 @@ in {
}; };
}; };
icons = helpers.mkCompositeOption "Configuration options for icons." { icons = {
webdevColors = helpers.defaultNullOpts.mkBool true '' webdevColors = helpers.defaultNullOpts.mkBool true ''
Use the webdev icon colors, otherwise `NvimTreeFileIcon`. Use the webdev icon colors, otherwise `NvimTreeFileIcon`.
''; '';
@ -559,7 +549,7 @@ in {
Used as a separator between symlinks' source and target. Used as a separator between symlinks' source and target.
''; '';
show = helpers.mkCompositeOption "Configuration options for showing icon types." { show = {
file = helpers.defaultNullOpts.mkBool true '' file = helpers.defaultNullOpts.mkBool true ''
Show an icon before the file name. `nvim-web-devicons` will be used if available. Show an icon before the file name. `nvim-web-devicons` will be used if available.
''; '';
@ -584,7 +574,7 @@ in {
''; '';
}; };
glyphs = helpers.mkCompositeOption "Configuration options for icon glyphs." { glyphs = {
default = helpers.defaultNullOpts.mkStr "" '' default = helpers.defaultNullOpts.mkStr "" ''
Glyph for files. Will be overridden by `nvim-web-devicons` if available. Glyph for files. Will be overridden by `nvim-web-devicons` if available.
''; '';
@ -597,7 +587,7 @@ in {
Icon to display for modified files. Icon to display for modified files.
''; '';
folder = helpers.mkCompositeOption "Glyphs for directories." { folder = {
arrowClosed = helpers.defaultNullOpts.mkStr "" '' arrowClosed = helpers.defaultNullOpts.mkStr "" ''
Arrow glyphs for closed directories. Arrow glyphs for closed directories.
''; '';
@ -624,7 +614,7 @@ in {
''; '';
}; };
git = helpers.mkCompositeOption "Glyphs for git status." { git = {
unstaged = helpers.defaultNullOpts.mkStr "" '' unstaged = helpers.defaultNullOpts.mkStr "" ''
Glyph for unstaged nodes. Glyph for unstaged nodes.
''; '';
@ -661,7 +651,7 @@ in {
''; '';
}; };
filters = helpers.mkCompositeOption "Filtering options." { filters = {
dotfiles = helpers.defaultNullOpts.mkBool false '' dotfiles = helpers.defaultNullOpts.mkBool false ''
Do not show dotfiles: files starting with a `.` Do not show dotfiles: files starting with a `.`
Toggle via the `toggle_dotfiles` action, default mapping `H`. Toggle via the `toggle_dotfiles` action, default mapping `H`.
@ -692,7 +682,7 @@ in {
''; '';
}; };
trash = helpers.mkCompositeOption "Configuration options for trashing." { trash = {
cmd = helpers.defaultNullOpts.mkStr "gio trash" '' cmd = helpers.defaultNullOpts.mkStr "gio trash" ''
The command used to trash items (must be installed on your system). The command used to trash items (must be installed on your system).
The default is shipped with glib2 which is a common linux package. The default is shipped with glib2 which is a common linux package.
@ -700,8 +690,8 @@ in {
''; '';
}; };
actions = helpers.mkCompositeOption "Configuration for various actions." { actions = {
changeDir = helpers.mkCompositeOption "vim |current-directory| behaviour." { changeDir = {
enable = helpers.defaultNullOpts.mkBool true '' enable = helpers.defaultNullOpts.mkBool true ''
Change the working directory when changing directories in the tree. Change the working directory when changing directories in the tree.
''; '';
@ -716,7 +706,7 @@ in {
''; '';
}; };
expandAll = helpers.mkCompositeOption "Configuration for expand_all behaviour." { expandAll = {
maxFolderDiscovery = helpers.defaultNullOpts.mkInt 300 '' maxFolderDiscovery = helpers.defaultNullOpts.mkInt 300 ''
Limit the number of folders being explored when expanding every folders. Limit the number of folders being explored when expanding every folders.
Avoids hanging neovim when running this action on very large folders. Avoids hanging neovim when running this action on very large folders.
@ -728,14 +718,11 @@ in {
''; '';
}; };
filePopup = helpers.mkCompositeOption "Configuration for file_popup behaviour." { filePopup = {
openWinConfig = openWinConfigOption; openWinConfig = openWinConfigOption;
}; };
openFile = openFile = {
helpers.mkCompositeOption
"Configuration options for opening a file from nvim-tree."
{
quitOnOpen = helpers.defaultNullOpts.mkBool false '' quitOnOpen = helpers.defaultNullOpts.mkBool false ''
Closes the explorer when opening a file. Closes the explorer when opening a file.
It will also disable preventing a buffer overriding the tree. It will also disable preventing a buffer overriding the tree.
@ -746,10 +733,11 @@ in {
''; '';
}; };
windowPicker = helpers.mkCompositeOption "Window picker configuration." { windowPicker = {
enable = helpers.defaultNullOpts.mkBool true '' enable = helpers.defaultNullOpts.mkBool true ''
Enable the feature. If the feature is not enabled, files will open in window from Enable the window picker.
which you last opened the tree. If the feature is not enabled, files will open in window from which you last opened the
tree.
''; '';
picker = picker =
@ -783,7 +771,7 @@ in {
''; '';
}; };
removeFile = helpers.mkCompositeOption "" { removeFile = {
closeWindow = helpers.defaultNullOpts.mkBool true '' closeWindow = helpers.defaultNullOpts.mkBool true ''
Close any window displaying a file when removing the file from the tree. Close any window displaying a file when removing the file from the tree.
''; '';
@ -797,16 +785,7 @@ in {
''; '';
}; };
liveFilter = liveFilter = {
helpers.mkCompositeOption
''
Configurations for the live_filtering feature.
The live filter allows you to filter the tree nodes dynamically, based on regex matching
(see |vim.regex|).
This feature is bound to the `f` key by default.
The filter can be cleared with the `F` key by default.
''
{
prefix = helpers.defaultNullOpts.mkStr "[FILTER]: " '' prefix = helpers.defaultNullOpts.mkStr "[FILTER]: " ''
Prefix of the filter displayed in the buffer. Prefix of the filter displayed in the buffer.
''; '';
@ -816,8 +795,8 @@ in {
''; '';
}; };
tab = helpers.mkCompositeOption "Configuration for tab behaviour." { tab = {
sync = helpers.mkCompositeOption "Configuration for syncing nvim-tree across tabs." { sync = {
open = helpers.defaultNullOpts.mkBool false '' open = helpers.defaultNullOpts.mkBool false ''
Opens the tree automatically when switching tabpage or opening a new tabpage if the tree Opens the tree automatically when switching tabpage or opening a new tabpage if the tree
was previously open. was previously open.
@ -827,14 +806,14 @@ in {
Closes the tree across all tabpages when the tree is closed. Closes the tree across all tabpages when the tree is closed.
''; '';
ignore = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" '' ignore = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
List of filetypes or buffer names on new tab that will prevent List of filetypes or buffer names on new tab that will prevent
|nvim-tree.tab.sync.open| and |nvim-tree.tab.sync.close| |nvim-tree.tab.sync.open| and |nvim-tree.tab.sync.close|
''; '';
}; };
}; };
notify = helpers.mkCompositeOption "Configuration for notification." { notify = {
threshold = helpers.defaultNullOpts.mkEnum ["error" "warning" "info" "debug"] "info" '' threshold = helpers.defaultNullOpts.mkEnum ["error" "warning" "info" "debug"] "info" ''
Specify minimum notification level, uses the values from |vim.log.levels| Specify minimum notification level, uses the values from |vim.log.levels|
@ -845,8 +824,8 @@ in {
''; '';
}; };
ui = helpers.mkCompositeOption "General UI configuration." { ui = {
confirm = helpers.mkCompositeOption "Confirmation prompts." { confirm = {
remove = helpers.defaultNullOpts.mkBool true '' remove = helpers.defaultNullOpts.mkBool true ''
Prompt before removing. Prompt before removing.
''; '';
@ -857,7 +836,7 @@ in {
}; };
}; };
log = helpers.mkCompositeOption "Configuration for diagnostic logging." { log = {
enable = helpers.defaultNullOpts.mkBool false '' enable = helpers.defaultNullOpts.mkBool false ''
Enable logging to a file `$XDG_CACHE_HOME/nvim/nvim-tree.log` Enable logging to a file `$XDG_CACHE_HOME/nvim/nvim-tree.log`
''; '';
@ -866,7 +845,7 @@ in {
Remove existing log file at startup. Remove existing log file at startup.
''; '';
types = helpers.mkCompositeOption "Specify which information to log." { types = {
all = helpers.defaultNullOpts.mkBool false "Everything."; all = helpers.defaultNullOpts.mkBool false "Everything.";
profile = helpers.defaultNullOpts.mkBool false "Timing of some operations."; profile = helpers.defaultNullOpts.mkBool false "Timing of some operations.";
@ -904,50 +883,43 @@ in {
sync_root_with_cwd = syncRootWithCwd; sync_root_with_cwd = syncRootWithCwd;
reload_on_bufenter = reloadOnBufenter; reload_on_bufenter = reloadOnBufenter;
respect_buf_cwd = respectBufCwd; respect_buf_cwd = respectBufCwd;
hijack_directories = with hijackDirectories; hijack_directories = with hijackDirectories; {
ifNonNull' cfg.hijackDirectories {
inherit enable; inherit enable;
auto_open = autoOpenEnabled; auto_open = autoOpenEnabled;
}; };
update_focused_file = with updateFocusedFile; update_focused_file = with updateFocusedFile; {
ifNonNull' cfg.updateFocusedFile {
inherit enable; inherit enable;
update_root = updateRoot; update_root = updateRoot;
ignore_list = ignoreList; ignore_list = ignoreList;
}; };
system_open = systemOpen; system_open = systemOpen;
diagnostics = with diagnostics; diagnostics = with diagnostics; {
ifNonNull' cfg.diagnostics {
inherit enable; inherit enable;
debounce_delay = debounceDelay; debounce_delay = debounceDelay;
show_on_dirs = showOnDirs; show_on_dirs = showOnDirs;
show_on_open_dirs = showOnOpenDirs; show_on_open_dirs = showOnOpenDirs;
inherit icons; inherit icons;
severity = ifNonNull' cfg.diagnostics.severity ( severity =
mapAttrs ( mapAttrs (
name: value: name: value:
ifNonNull' value ifNonNull' value
(helpers.mkRaw "vim.diagnostic.severity.${strings.toUpper value}") (helpers.mkRaw "vim.diagnostic.severity.${strings.toUpper value}")
) )
severity severity;
);
}; };
git = with git; git = with git; {
ifNonNull' cfg.git {
inherit enable; inherit enable;
inherit ignore; inherit ignore;
show_on_dirs = showOnDirs; show_on_dirs = showOnDirs;
show_on_open_dirs = showOnOpenDirs; show_on_open_dirs = showOnOpenDirs;
inherit timeout; inherit timeout;
}; };
modified = with modified; modified = with modified; {
ifNonNull' cfg.modified {
inherit enable; inherit enable;
show_on_dirs = showOnDirs; show_on_dirs = showOnDirs;
show_on_open_dirs = showOnOpenDirs; show_on_open_dirs = showOnOpenDirs;
}; };
filesystem_watchers = with filesystemWatchers; filesystem_watchers = with filesystemWatchers; {
ifNonNull' cfg.filesystemWatchers {
inherit enable; inherit enable;
debounce_delay = debounceDelay; debounce_delay = debounceDelay;
ignore_dirs = ignoreDirs; ignore_dirs = ignoreDirs;
@ -964,15 +936,13 @@ in {
inherit number; inherit number;
inherit relativenumber; inherit relativenumber;
inherit signcolumn; inherit signcolumn;
float = with float; float = with float; {
ifNonNull' cfg.view.float {
inherit enable; inherit enable;
quit_on_focus_loss = quitOnFocusLoss; quit_on_focus_loss = quitOnFocusLoss;
open_win_config = openWinConfig; open_win_config = openWinConfig;
}; };
}; };
renderer = with renderer; renderer = with renderer; {
ifNonNull' cfg.renderer {
add_trailing = addTrailing; add_trailing = addTrailing;
group_empty = groupEmpty; group_empty = groupEmpty;
full_name = fullName; full_name = fullName;
@ -981,25 +951,21 @@ in {
highlight_modified = highlightModified; highlight_modified = highlightModified;
root_folder_label = rootFolderLabel; root_folder_label = rootFolderLabel;
indent_width = indentWidth; indent_width = indentWidth;
indent_markers = with indentMarkers; indent_markers = with indentMarkers; {
ifNonNull' cfg.renderer.indentMarkers {
inherit enable icons; inherit enable icons;
inline_arrows = inlineArrows; inline_arrows = inlineArrows;
}; };
icons = with icons; icons = with icons; {
ifNonNull' cfg.renderer.icons {
webdev_colors = webdevColors; webdev_colors = webdevColors;
git_placement = gitPlacement; git_placement = gitPlacement;
modified_placement = modifiedPlacement; modified_placement = modifiedPlacement;
inherit padding; inherit padding;
symlink_arrow = symlinkArrow; symlink_arrow = symlinkArrow;
show = with show; show = with show; {
ifNonNull' cfg.renderer.icons.show {
inherit file folder git modified; inherit file folder git modified;
folder_arrow = folderArrow; folder_arrow = folderArrow;
}; };
glyphs = with glyphs; glyphs = with glyphs; {
ifNonNull' cfg.renderer.icons.glyphs {
inherit default symlink modified git; inherit default symlink modified git;
folder = with folder; { folder = with folder; {
arrow_closed = arrowClosed; arrow_closed = arrowClosed;
@ -1013,64 +979,52 @@ in {
special_files = specialFiles; special_files = specialFiles;
symlink_destination = symlinkDestination; symlink_destination = symlinkDestination;
}; };
filters = with filters; filters = with filters; {
ifNonNull' cfg.filters {
inherit dotfiles custom exclude; inherit dotfiles custom exclude;
git_clean = gitClean; git_clean = gitClean;
no_buffer = noBuffer; no_buffer = noBuffer;
}; };
inherit trash; inherit trash;
actions = with actions; actions = with actions; {
ifNonNull' cfg.actions { change_dir = with changeDir; {
change_dir = with changeDir;
ifNonNull' cfg.actions.changeDir {
inherit enable global; inherit enable global;
restrict_above_cwd = restrictAboveCwd; restrict_above_cwd = restrictAboveCwd;
}; };
expand_all = with expandAll; expand_all = with expandAll; {
ifNonNull' cfg.actions.expandAll {
max_folder_discovery = maxFolderDiscovery; max_folder_discovery = maxFolderDiscovery;
inherit exclude; inherit exclude;
}; };
file_popup = with filePopup; file_popup = with filePopup; {
ifNonNull' cfg.actions.filePopup { open_win_config = openWinConfig;
open_win_config = filePopup.openWinConfig;
}; };
open_file = with openFile; open_file = with openFile; {
ifNonNull' cfg.actions.openFile {
quit_on_open = quitOnOpen; quit_on_open = quitOnOpen;
resize_window = resizeWindow; resize_window = resizeWindow;
window_picker = windowPicker; window_picker = windowPicker;
}; };
remove_file = with removeFile; remove_file = with removeFile; {
ifNonNull' cfg.actions.removeFile { close_window = closeWindow;
close_window = removeFile.closeWindow;
}; };
use_system_clipboard = useSystemClipboard; use_system_clipboard = useSystemClipboard;
}; };
live_filter = with liveFilter; live_filter = with liveFilter; {
ifNonNull' cfg.liveFilter {
inherit prefix; inherit prefix;
always_show_folders = alwaysShowFolders; always_show_folders = alwaysShowFolders;
}; };
inherit tab; inherit tab;
notify = with notify; notify = with notify; {
ifNonNull' cfg.notify {
threshold = threshold =
ifNonNull' cfg.notify.threshold ifNonNull' cfg.notify.threshold
(helpers.mkRaw "vim.log.levels.${strings.toUpper notify.threshold}"); (helpers.mkRaw "vim.log.levels.${strings.toUpper notify.threshold}");
}; };
inherit ui; inherit ui;
log = with log; log = with log; {
ifNonNull' cfg.log {
inherit enable truncate; inherit enable truncate;
types = ifNonNull' log.types ( types = with log.types; {
with log.types; {
inherit all profile dev diagnostics git watcher; inherit all profile dev diagnostics git watcher;
inherit (log.types) config; inherit (log.types) config;
copy_paste = copyPaste; copy_paste = copyPaste;
} };
);
}; };
} }
// cfg.extraOptions; // cfg.extraOptions;

View file

@ -51,7 +51,7 @@ in {
A custom vim function name to open preview page. This function will receive url as param. A custom vim function name to open preview page. This function will receive url as param.
''; '';
previewOptions = helpers.mkCompositeOption "Options for markdown render" { previewOptions = {
mkit = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "markdown-it options for render"; mkit = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "markdown-it options for render";
katex = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "katex options for math"; katex = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "katex options for math";
uml = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "markdown-it-plantuml options"; uml = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" "markdown-it-plantuml options";
@ -108,7 +108,7 @@ in {
mkdp_browser = mkIf (cfg.browser != null) cfg.browser; mkdp_browser = mkIf (cfg.browser != null) cfg.browser;
mkdp_echo_preview_url = mkIf (cfg.echoPreviewUrl != null) cfg.echoPreviewUrl; mkdp_echo_preview_url = mkIf (cfg.echoPreviewUrl != null) cfg.echoPreviewUrl;
mkdp_browserfunc = mkIf (cfg.browserFunc != null) cfg.browserFunc; mkdp_browserfunc = mkIf (cfg.browserFunc != null) cfg.browserFunc;
mkdp_preview_options = mkIf (cfg.previewOptions != null) cfg.previewOptions; mkdp_preview_options = cfg.previewOptions;
mkdp_markdown_css = mkIf (cfg.markdownCss != null) cfg.markdownCss; mkdp_markdown_css = mkIf (cfg.markdownCss != null) cfg.markdownCss;
mkdp_highlight_css = mkIf (cfg.highlightCss != null) cfg.highlightCss; mkdp_highlight_css = mkIf (cfg.highlightCss != null) cfg.highlightCss;
mkdp_port = mkIf (cfg.port != null) cfg.port; mkdp_port = mkIf (cfg.port != null) cfg.port;

View file

@ -35,7 +35,7 @@ in {
Automatically call RustReloadWorkspace when writing to a Cargo.toml file. Automatically call RustReloadWorkspace when writing to a Cargo.toml file.
''; '';
inlayHints = helpers.mkCompositeOption "inlay hints" { inlayHints = {
auto = helpers.defaultNullOpts.mkBool true "automatically set inlay hints (type hints)"; auto = helpers.defaultNullOpts.mkBool true "automatically set inlay hints (type hints)";
onlyCurrentLine = helpers.defaultNullOpts.mkBool false "Only show for current line"; onlyCurrentLine = helpers.defaultNullOpts.mkBool false "Only show for current line";
@ -71,7 +71,7 @@ in {
highlight = helpers.defaultNullOpts.mkStr "Comment" "The color of the hints"; highlight = helpers.defaultNullOpts.mkStr "Comment" "The color of the hints";
}; };
hoverActions = helpers.mkCompositeOption "hover actions" { hoverActions = {
border = border =
helpers.defaultNullOpts.mkBorder '' helpers.defaultNullOpts.mkBorder ''
[ [
@ -100,7 +100,7 @@ in {
"whether the hover action window gets automatically focused"; "whether the hover action window gets automatically focused";
}; };
crateGraph = helpers.mkCompositeOption "create graph" { crateGraph = {
backend = helpers.defaultNullOpts.mkStr "x11" '' backend = helpers.defaultNullOpts.mkStr "x11" ''
Backend used for displaying the graph Backend used for displaying the graph
see: https://graphviz.org/docs/outputs/ see: https://graphviz.org/docs/outputs/
@ -146,8 +146,7 @@ in {
on_initialized = helpers.mkRaw cfg.onInitialized; on_initialized = helpers.mkRaw cfg.onInitialized;
reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml; reload_workspace_from_cargo_toml = cfg.reloadWorkspaceFromCargoToml;
inlay_hints = with cfg.inlayHints; inlay_hints = with cfg.inlayHints; {
helpers.ifNonNull' cfg.inlayHints {
inherit auto; inherit auto;
only_current_line = onlyCurrentLine; only_current_line = onlyCurrentLine;
show_parameter_hints = showParameterHints; show_parameter_hints = showParameterHints;
@ -160,17 +159,14 @@ in {
inherit highlight; inherit highlight;
}; };
hover_actions = with cfg.hoverActions; hover_actions = with cfg.hoverActions; {
helpers.ifNonNull' cfg.hoverActions
{
inherit border; inherit border;
max_width = maxWidth; max_width = maxWidth;
max_height = maxHeight; max_height = maxHeight;
auto_focus = autoFocus; auto_focus = autoFocus;
}; };
crate_graph = with cfg.crateGraph; crate_graph = with cfg.crateGraph; {
helpers.ifNonNull' cfg.crateGraph {
inherit backend output full; inherit backend output full;
enabled_graphviz_backends = enabledGraphvizBackends; enabled_graphviz_backends = enabledGraphvizBackends;
}; };

View file

@ -56,7 +56,7 @@ in {
helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["VirtualTextOk"]'' helpers.defaultNullOpts.mkNullable (types.listOf types.str) ''["VirtualTextOk"]''
"Display modes used in live_mode"; "Display modes used in live_mode";
displayOptions = helpers.mkCompositeOption "Display options" { displayOptions = {
terminalWidth = terminalWidth =
helpers.defaultNullOpts.mkInt 45 helpers.defaultNullOpts.mkInt 45
"Change the terminal display option width."; "Change the terminal display option width.";
@ -77,17 +77,13 @@ in {
bg ? "", bg ? "",
ctermbg ? "", ctermbg ? "",
ctermfg ? "", ctermfg ? "",
}: }: {
helpers.mkCompositeOption "" {
bg = helpers.defaultNullOpts.mkStr fg "Background color"; bg = helpers.defaultNullOpts.mkStr fg "Background color";
fg = helpers.defaultNullOpts.mkStr bg "Foreground color"; fg = helpers.defaultNullOpts.mkStr bg "Foreground color";
ctermbg = helpers.defaultNullOpts.mkStr ctermbg "Foreground color"; ctermbg = helpers.defaultNullOpts.mkStr ctermbg "Foreground color";
ctermfg = helpers.defaultNullOpts.mkStr ctermfg "Foreground color"; ctermfg = helpers.defaultNullOpts.mkStr ctermfg "Foreground color";
}; };
in in
helpers.mkCompositeOption
"Customize highlight groups (setting this overrides colorscheme)"
(
mapAttrs mapAttrs
(optionName: colorOption) (optionName: colorOption)
{ {
@ -111,8 +107,7 @@ in {
fg = "#881515"; fg = "#881515";
ctermfg = "DarkRed"; ctermfg = "DarkRed";
}; };
} };
);
liveModeToggle = liveModeToggle =
helpers.defaultNullOpts.mkStr "off" helpers.defaultNullOpts.mkStr "off"
@ -144,8 +139,7 @@ in {
interpreter_options = cfg.interpreterOptions; interpreter_options = cfg.interpreterOptions;
inherit (cfg) display; inherit (cfg) display;
live_display = cfg.liveDisplay; live_display = cfg.liveDisplay;
display_options = with cfg.displayOptions; display_options = with cfg.displayOptions; {
helpers.ifNonNull' cfg.displayOptions {
terminal_width = terminalWidth; terminal_width = terminalWidth;
notification_timeout = notificationTimeout; notification_timeout = notificationTimeout;
}; };

View file

@ -16,7 +16,7 @@ in {
package = helpers.mkPackageOption "fidget" pkgs.vimPlugins.fidget-nvim; package = helpers.mkPackageOption "fidget" pkgs.vimPlugins.fidget-nvim;
text = helpers.mkCompositeOption "Fidget text options." { text = {
spinner = spinner =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
(types.either (types.either
@ -75,7 +75,7 @@ in {
''; '';
}; };
align = helpers.mkCompositeOption "Fidget alignment options." { align = {
bottom = helpers.defaultNullOpts.mkBool true '' bottom = helpers.defaultNullOpts.mkBool true ''
Whether to align fidgets along the bottom edge of each buffer. Whether to align fidgets along the bottom edge of each buffer.
''; '';
@ -88,7 +88,7 @@ in {
''; '';
}; };
timer = helpers.mkCompositeOption "Fidget timing options." { timer = {
spinnerRate = helpers.defaultNullOpts.mkNum 125 '' spinnerRate = helpers.defaultNullOpts.mkNum 125 ''
Duration of each frame of the spinner animation, in ms. Set to Duration of each frame of the spinner animation, in ms. Set to
`0` to only use the first frame of the spinner animation. `0` to only use the first frame of the spinner animation.
@ -109,7 +109,7 @@ in {
''; '';
}; };
window = helpers.mkCompositeOption "Windowing rules options." { window = {
relative = helpers.defaultNullOpts.mkEnum ["win" "editor"] "win" '' relative = helpers.defaultNullOpts.mkEnum ["win" "editor"] "win" ''
Whether to position the window relative to the current window, Whether to position the window relative to the current window,
or the editor. Valid values are `"win"` or `"editor"`. or the editor. Valid values are `"win"` or `"editor"`.
@ -129,7 +129,7 @@ in {
''; '';
}; };
fmt = helpers.mkCompositeOption "Fidget formatting options." { fmt = {
leftpad = helpers.defaultNullOpts.mkBool true '' leftpad = helpers.defaultNullOpts.mkBool true ''
Whether to right-justify the text in a fidget box by left-padding Whether to right-justify the text in a fidget box by left-padding
it with spaces. Recommended when `align.right` is `true`. it with spaces. Recommended when `align.right` is `true`.
@ -194,7 +194,7 @@ in {
List of options for fidget sources. List of options for fidget sources.
''; '';
debug = helpers.mkCompositeOption "Fidget debugging options." { debug = {
logging = helpers.defaultNullOpts.mkBool false '' logging = helpers.defaultNullOpts.mkBool false ''
Whether to enable logging, for debugging. The log is written to Whether to enable logging, for debugging. The log is written to
`~/.local/share/nvim/fidget.nvim.log`. `~/.local/share/nvim/fidget.nvim.log`.
@ -216,12 +216,12 @@ in {
setupOptions = setupOptions =
{ {
inherit (cfg) text align window sources; inherit (cfg) text align window sources;
timer = helpers.ifNonNull' cfg.timer { timer = {
spinner_rate = cfg.timer.spinnerRate; spinner_rate = cfg.timer.spinnerRate;
fidget_decay = cfg.timer.fidgetDecay; fidget_decay = cfg.timer.fidgetDecay;
task_decay = cfg.timer.taskDecay; task_decay = cfg.timer.taskDecay;
}; };
fmt = helpers.ifNonNull' cfg.fmt { fmt = {
inherit (cfg.fmt) leftpad fidget task; inherit (cfg.fmt) leftpad fidget task;
stack_upwards = cfg.fmt.stackUpwards; stack_upwards = cfg.fmt.stackUpwards;
max_width = cfg.fmt.maxWidth; max_width = cfg.fmt.maxWidth;

View file

@ -23,14 +23,14 @@ in {
}; };
plugins = { plugins = {
autopep8 = helpers.mkCompositeOption "autopep8 settings" { autopep8 = {
enabled = helpers.defaultNullOpts.mkBool true '' enabled = helpers.defaultNullOpts.mkBool true ''
Enable or disable the plugin. Enable or disable the plugin.
Setting this explicitely to `true` will install the dependency for this plugin (autopep8). Setting this explicitely to `true` will install the dependency for this plugin (autopep8).
''; '';
}; };
flake8 = helpers.mkCompositeOption "flake8 settings" { flake8 = {
config = helpers.mkNullOrOption types.str '' config = helpers.mkNullOrOption types.str ''
Path to the config file that will be the authoritative config source. Path to the config file that will be the authoritative config source.
''; '';
@ -84,7 +84,7 @@ in {
''; '';
}; };
jedi = helpers.mkCompositeOption "jedi settings" { jedi = {
auto_import_modules = auto_import_modules =
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
(types.listOf types.str) (types.listOf types.str)
@ -100,7 +100,7 @@ in {
''; '';
}; };
jedi_completion = helpers.mkCompositeOption "jedi_completion settings" { jedi_completion = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin."; enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
include_params = helpers.defaultNullOpts.mkBool true '' include_params = helpers.defaultNullOpts.mkBool true ''
@ -134,7 +134,7 @@ in {
"Modules for which labels and snippets should be cached."; "Modules for which labels and snippets should be cached.";
}; };
jedi_definition = helpers.mkCompositeOption "jedi_definition settings" { jedi_definition = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin."; enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
follow_imports = helpers.defaultNullOpts.mkBool true '' follow_imports = helpers.defaultNullOpts.mkBool true ''
@ -150,19 +150,19 @@ in {
''; '';
}; };
jedi_hover = helpers.mkCompositeOption "jedi_hover settings" { jedi_hover = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin."; enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
}; };
jedi_references = helpers.mkCompositeOption "jedi_references settings" { jedi_references = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin."; enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
}; };
jedi_signature_help = helpers.mkCompositeOption "jedi_signature_help settings" { jedi_signature_help = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin."; enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
}; };
jedi_symbols = helpers.mkCompositeOption "jedi_symbols settings" { jedi_symbols = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin."; enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
all_scopes = helpers.defaultNullOpts.mkBool true '' all_scopes = helpers.defaultNullOpts.mkBool true ''
@ -174,7 +174,7 @@ in {
''; '';
}; };
mccabe = helpers.mkCompositeOption "mccabe settings" { mccabe = {
enabled = helpers.defaultNullOpts.mkBool true '' enabled = helpers.defaultNullOpts.mkBool true ''
Enable or disable the plugin. Enable or disable the plugin.
Setting this explicitely to `true` will install the dependency for this plugin (mccabe). Setting this explicitely to `true` will install the dependency for this plugin (mccabe).
@ -185,7 +185,7 @@ in {
''; '';
}; };
preload = helpers.mkCompositeOption "preload settings" { preload = {
enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin."; enabled = helpers.defaultNullOpts.mkBool true "Enable or disable the plugin.";
modules = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" '' modules = helpers.defaultNullOpts.mkNullable (types.listOf types.str) "[]" ''
@ -193,7 +193,7 @@ in {
''; '';
}; };
pycodestyle = helpers.mkCompositeOption "pycodestyle settings" { pycodestyle = {
enabled = helpers.defaultNullOpts.mkBool true '' enabled = helpers.defaultNullOpts.mkBool true ''
Enable or disable the plugin. Enable or disable the plugin.
Setting this explicitely to `true` will install the dependency for this plugin Setting this explicitely to `true` will install the dependency for this plugin
@ -229,7 +229,7 @@ in {
''; '';
}; };
pydocstyle = helpers.mkCompositeOption "pydocstyle settings" { pydocstyle = {
enabled = helpers.defaultNullOpts.mkBool false '' enabled = helpers.defaultNullOpts.mkBool false ''
Enable or disable the plugin. Enable or disable the plugin.
Setting this explicitely to `true` will install the dependency for this plugin Setting this explicitely to `true` will install the dependency for this plugin
@ -273,14 +273,14 @@ in {
''; '';
}; };
pyflakes = helpers.mkCompositeOption "pyflakes settings" { pyflakes = {
enabled = helpers.defaultNullOpts.mkBool true '' enabled = helpers.defaultNullOpts.mkBool true ''
Enable or disable the plugin. Enable or disable the plugin.
Setting this explicitely to `true` will install the dependency for this plugin (pyflakes). Setting this explicitely to `true` will install the dependency for this plugin (pyflakes).
''; '';
}; };
pylint = helpers.mkCompositeOption "pylint settings" { pylint = {
enabled = helpers.defaultNullOpts.mkBool false '' enabled = helpers.defaultNullOpts.mkBool false ''
Enable or disable the plugin. Enable or disable the plugin.
Setting this explicitely to `true` will install the dependency for this plugin (pylint). Setting this explicitely to `true` will install the dependency for this plugin (pylint).
@ -297,7 +297,7 @@ in {
''; '';
}; };
rope_autoimport = helpers.mkCompositeOption "rope_autoimport settings" { rope_autoimport = {
enabled = helpers.defaultNullOpts.mkBool false '' enabled = helpers.defaultNullOpts.mkBool false ''
Enable or disable the plugin. Enable or disable the plugin.
Setting this explicitely to `true` will install the dependency for this plugin (rope). Setting this explicitely to `true` will install the dependency for this plugin (rope).
@ -309,7 +309,7 @@ in {
''; '';
}; };
rope_completion = helpers.mkCompositeOption "rope_completion settings" { rope_completion = {
enabled = helpers.defaultNullOpts.mkBool false '' enabled = helpers.defaultNullOpts.mkBool false ''
Enable or disable the plugin. Enable or disable the plugin.
Setting this explicitely to `true` will install the dependency for this plugin (rope). Setting this explicitely to `true` will install the dependency for this plugin (rope).
@ -320,7 +320,7 @@ in {
''; '';
}; };
yapf = helpers.mkCompositeOption "yapf settings" { yapf = {
enabled = helpers.defaultNullOpts.mkBool true '' enabled = helpers.defaultNullOpts.mkBool true ''
Enable or disable the plugin. Enable or disable the plugin.
Setting this explicitely to `true` will install the dependency for this plugin (yapf). Setting this explicitely to `true` will install the dependency for this plugin (yapf).
@ -328,7 +328,7 @@ in {
}; };
### THIRD-PARTY PLUGINS ### THIRD-PARTY PLUGINS
pylsp_mypy = helpers.mkCompositeOption "pylsp_mypy settings" { pylsp_mypy = {
enabled = helpers.defaultNullOpts.mkBool false '' enabled = helpers.defaultNullOpts.mkBool false ''
Enable or disable the plugin. Enable or disable the plugin.
Setting this explicitely to `true` will install the dependency for this plugin Setting this explicitely to `true` will install the dependency for this plugin
@ -484,7 +484,7 @@ in {
### END OF THIRD-PARTY PLUGINS ### END OF THIRD-PARTY PLUGINS
}; };
rope = helpers.mkCompositeOption "rope settings" { rope = {
extensionModules = helpers.mkNullOrOption types.str '' extensionModules = helpers.mkNullOrOption types.str ''
Builtin and c-extension modules that are allowed to be imported and inspected by rope. Builtin and c-extension modules that are allowed to be imported and inspected by rope.
''; '';
@ -504,7 +504,7 @@ in {
# plugins to its `propagatedBuildInputs`. # plugins to its `propagatedBuildInputs`.
# See https://github.com/NixOS/nixpkgs/issues/229337 # See https://github.com/NixOS/nixpkgs/issues/229337
plugins.lsp.servers.pylsp.package = let plugins.lsp.servers.pylsp.package = let
isEnabled = x: (x != null) && (x.enabled != null && x.enabled); isEnabled = x: (x.enabled != null && x.enabled);
inherit (cfg.settings) plugins; inherit (cfg.settings) plugins;
nativePlugins = nativePlugins =

View file

@ -48,13 +48,7 @@ in
padding = helpers.defaultNullOpts.mkBool true "Add an extra new line on top of the list"; padding = helpers.defaultNullOpts.mkBool true "Add an extra new line on top of the list";
actionKeys = actionKeys =
helpers.mkCompositeOption mapAttrs
''
Key mappings for actions in the trouble list.
Map to `{}` to remove a mapping, for example:
`close = {};`
''
(mapAttrs
( (
action: config: action: config:
helpers.defaultNullOpts.mkNullable helpers.defaultNullOpts.mkNullable
@ -131,7 +125,7 @@ in
default = "j"; default = "j";
description = "Next item"; description = "Next item";
}; };
}); };
indentLines = helpers.defaultNullOpts.mkBool true '' indentLines = helpers.defaultNullOpts.mkBool true ''
Add an indent guide below the fold icons. Add an indent guide below the fold icons.
@ -161,8 +155,6 @@ in
"For the given modes, automatically jump if there is only a single result."; "For the given modes, automatically jump if there is only a single result.";
signs = signs =
helpers.mkCompositeOption "Incons/text used for the different diagnostics."
(
mapAttrs mapAttrs
( (
diagnostic: default: diagnostic: default:
@ -174,8 +166,7 @@ in
hint = ""; hint = "";
information = ""; information = "";
other = ""; other = "";
} };
);
useDiagnosticSigns = helpers.defaultNullOpts.mkBool false '' useDiagnosticSigns = helpers.defaultNullOpts.mkBool false ''
Enabling this will use the signs defined in your lsp client Enabling this will use the signs defined in your lsp client
@ -197,22 +188,6 @@ in
fold_open = cfg.foldOpen; fold_open = cfg.foldOpen;
fold_closed = cfg.foldClosed; fold_closed = cfg.foldClosed;
inherit (cfg) group padding; inherit (cfg) group padding;
action_keys =
helpers.ifNonNull' cfg.actionKeys
(with cfg.actionKeys; {
inherit close cancel refresh jump;
open_split = openSplit;
open_vsplit = openVsplit;
open_tab = openTab;
jump_close = jumpClose;
toggle_mode = toggleMode;
toggle_preview = togglePreview;
inherit hover preview;
close_folds = closeFolds;
open_folds = openFolds;
toggle_fold = toggleFold;
inherit next;
});
indent_lines = cfg.indentLines; indent_lines = cfg.indentLines;
auto_open = cfg.autoOpen; auto_open = cfg.autoOpen;
auto_close = cfg.autoClose; auto_close = cfg.autoClose;
@ -220,6 +195,23 @@ in
auto_fold = cfg.autoFold; auto_fold = cfg.autoFold;
auto_jump = cfg.autoJump; auto_jump = cfg.autoJump;
inherit (cfg) signs; inherit (cfg) signs;
action_keys = with cfg.actionKeys; {
inherit close cancel refresh jump;
open_split = openSplit;
open_vsplit = openVsplit;
open_tab = openTab;
jump_close = jumpClose;
toggle_mode = toggleMode;
toggle_preview = togglePreview;
inherit
hover
preview
;
close_folds = closeFolds;
open_folds = openFolds;
toggle_fold = toggleFold;
inherit next;
};
use_diagnostic_signs = cfg.useDiagnosticSigns; use_diagnostic_signs = cfg.useDiagnosticSigns;
} }
// cfg.extraOptions; // cfg.extraOptions;

View file

@ -11,9 +11,7 @@ with lib; let
mkSeparatorsOption = { mkSeparatorsOption = {
leftDefault ? " ", leftDefault ? " ",
rightDefault ? " ", rightDefault ? " ",
name, }: {
}:
helpers.mkCompositeOption "${name} separtors." {
left = helpers.defaultNullOpts.mkStr leftDefault "Left separator"; left = helpers.defaultNullOpts.mkStr leftDefault "Left separator";
right = helpers.defaultNullOpts.mkStr rightDefault "Right separator"; right = helpers.defaultNullOpts.mkStr rightDefault "Right separator";
}; };
@ -55,7 +53,7 @@ with lib; let
) )
"Defines the icon to be displayed in front of the component."; "Defines the icon to be displayed in front of the component.";
separator = mkSeparatorsOption {name = "Component";}; separator = mkSeparatorsOption {};
color = helpers.mkNullOrOption (types.attrsOf types.str) '' color = helpers.mkNullOrOption (types.attrsOf types.str) ''
Defines a custom color for the component. Defines a custom color for the component.
@ -92,8 +90,7 @@ with lib; let
)) ))
""; "";
mkEmptySectionOption = name: mkEmptySectionOption = name: {
helpers.mkCompositeOption name {
lualine_a = mkComponentOptions ""; lualine_a = mkComponentOptions "";
lualine_b = mkComponentOptions ""; lualine_b = mkComponentOptions "";
lualine_c = mkComponentOptions ""; lualine_c = mkComponentOptions "";
@ -119,16 +116,14 @@ in {
componentSeparators = mkSeparatorsOption { componentSeparators = mkSeparatorsOption {
leftDefault = ""; leftDefault = "";
rightDefault = ""; rightDefault = "";
name = "component";
}; };
sectionSeparators = mkSeparatorsOption { sectionSeparators = mkSeparatorsOption {
leftDefault = ""; leftDefault = "";
rightDefault = ""; rightDefault = "";
name = "section";
}; };
disabledFiletypes = helpers.mkCompositeOption "Filetypes to disable lualine for." { disabledFiletypes = {
statusline = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" '' statusline = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
Only ignores the ft for statusline. Only ignores the ft for statusline.
''; '';
@ -157,15 +152,7 @@ in {
This feature is only available in neovim 0.7 and higher. This feature is only available in neovim 0.7 and higher.
''; '';
refresh = refresh = {
helpers.mkCompositeOption
''
Sets how often lualine should refresh it's contents (in ms).
The refresh option sets minimum time that lualine tries to maintain between refresh.
It's not guarantied if situation arises that lualine needs to refresh itself before this
time it'll do it.
''
{
statusline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the status line (ms)"; statusline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the status line (ms)";
tabline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the tabline (ms)"; tabline = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the tabline (ms)";
@ -173,7 +160,7 @@ in {
winbar = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the winbar (ms)"; winbar = helpers.defaultNullOpts.mkInt 1000 "Refresh time for the winbar (ms)";
}; };
sections = helpers.mkCompositeOption "Sections configuration" { sections = {
lualine_a = mkComponentOptions "mode"; lualine_a = mkComponentOptions "mode";
lualine_b = mkComponentOptions "branch"; lualine_b = mkComponentOptions "branch";
lualine_c = mkComponentOptions "filename"; lualine_c = mkComponentOptions "filename";
@ -183,7 +170,7 @@ in {
lualine_z = mkComponentOptions "location"; lualine_z = mkComponentOptions "location";
}; };
inactiveSections = helpers.mkCompositeOption "Inactive Sections configuration" { inactiveSections = {
lualine_a = mkComponentOptions ""; lualine_a = mkComponentOptions "";
lualine_b = mkComponentOptions ""; lualine_b = mkComponentOptions "";
lualine_c = mkComponentOptions "filename"; lualine_c = mkComponentOptions "filename";
@ -245,11 +232,11 @@ in {
always_divide_middle = cfg.alwaysDivideMiddle; always_divide_middle = cfg.alwaysDivideMiddle;
}; };
sections = mapNullable processSections cfg.sections; sections = processSections cfg.sections;
inactive_sections = mapNullable processSections cfg.inactiveSections; inactive_sections = processSections cfg.inactiveSections;
tabline = mapNullable processSections cfg.tabline; tabline = processSections cfg.tabline;
winbar = mapNullable processSections cfg.winbar; winbar = processSections cfg.winbar;
inactive_winbar = mapNullable processSections cfg.inactiveWinbar; inactive_winbar = processSections cfg.inactiveWinbar;
}; };
in in
mkIf cfg.enable { mkIf cfg.enable {

View file

@ -20,7 +20,7 @@ with lib; {
package = helpers.mkPackageOption "noice" pkgs.vimPlugins.noice-nvim; package = helpers.mkPackageOption "noice" pkgs.vimPlugins.noice-nvim;
cmdline = helpers.mkCompositeOption "" { cmdline = {
enabled = helpers.defaultNullOpts.mkBool true "enables Noice cmdline UI"; enabled = helpers.defaultNullOpts.mkBool true "enables Noice cmdline UI";
view = helpers.defaultNullOpts.mkStr "cmdline_popup" ""; view = helpers.defaultNullOpts.mkStr "cmdline_popup" "";
opts = helpers.defaultNullOpts.mkNullable types.anything "{}" ""; opts = helpers.defaultNullOpts.mkNullable types.anything "{}" "";
@ -45,10 +45,11 @@ with lib; {
''; '';
}; };
messages = messages = {
helpers.mkCompositeOption enabled = helpers.defaultNullOpts.mkBool true ''
"NOTE: If you enable messages, then the cmdline is enabled automatically" { Enables the messages UI.
enabled = helpers.defaultNullOpts.mkBool true "enables the messages UI"; NOTE: If you enable messages, then the cmdline is enabled automatically.
'';
view = helpers.defaultNullOpts.mkStr "notify" "default view for messages"; view = helpers.defaultNullOpts.mkStr "notify" "default view for messages";
viewError = helpers.defaultNullOpts.mkStr "notify" "default view for errors"; viewError = helpers.defaultNullOpts.mkStr "notify" "default view for errors";
viewWarn = helpers.defaultNullOpts.mkStr "notify" "default view for warnings"; viewWarn = helpers.defaultNullOpts.mkStr "notify" "default view for warnings";
@ -56,7 +57,7 @@ with lib; {
viewSearch = helpers.defaultNullOpts.mkStr "virtualtext" "view for search count messages"; viewSearch = helpers.defaultNullOpts.mkStr "virtualtext" "view for search count messages";
}; };
popupmenu = helpers.mkCompositeOption "" { popupmenu = {
enabled = helpers.defaultNullOpts.mkBool true "enables the Noice popupmenu UI"; enabled = helpers.defaultNullOpts.mkBool true "enables the Noice popupmenu UI";
backend = helpers.defaultNullOpts.mkEnumFirstDefault ["nui" "cmp"] ""; backend = helpers.defaultNullOpts.mkEnumFirstDefault ["nui" "cmp"] "";
kindIcons = kindIcons =
@ -110,20 +111,21 @@ with lib; {
} }
'' "You can add any custom commands that will be available with `:Noice command`"; '' "You can add any custom commands that will be available with `:Noice command`";
notify = notify = {
helpers.mkCompositeOption '' enabled = helpers.defaultNullOpts.mkBool true ''
Noice can be used as `vim.notify` so you can route any notification like other messages Enable notification handling.
Noice can be used as `vim.notify` so you can route any notification like other messages.
Notification messages have their level and other properties set. Notification messages have their level and other properties set.
event is always "notify" and kind can be any log level as a string event is always "notify" and kind can be any log level as a string.
The default routes will forward notifications to nvim-notify The default routes will forward notifications to nvim-notify.
Benefit of using Noice for this is the routing and consistent history view Benefit of using Noice for this is the routing and consistent history view.
'' { '';
enabled = helpers.defaultNullOpts.mkBool true "enable notification handling";
view = helpers.defaultNullOpts.mkStr "notify" ""; view = helpers.defaultNullOpts.mkStr "notify" "";
}; };
lsp = helpers.mkCompositeOption "" { lsp = {
progress = helpers.mkCompositeOption "" { progress = {
enabled = helpers.defaultNullOpts.mkBool true "enable LSP progress"; enabled = helpers.defaultNullOpts.mkBool true "enable LSP progress";
format = format =
@ -150,7 +152,7 @@ with lib; {
} }
'' ""; '' "";
hover = helpers.mkCompositeOption "" { hover = {
enabled = helpers.defaultNullOpts.mkBool true "enable hover UI"; enabled = helpers.defaultNullOpts.mkBool true "enable hover UI";
view = view =
helpers.defaultNullOpts.mkNullable types.str "null" helpers.defaultNullOpts.mkNullable types.str "null"
@ -160,10 +162,10 @@ with lib; {
"merged with defaults from documentation"; "merged with defaults from documentation";
}; };
signature = helpers.mkCompositeOption "" { signature = {
enabled = helpers.defaultNullOpts.mkBool true "enable signature UI"; enabled = helpers.defaultNullOpts.mkBool true "enable signature UI";
autoOpen = helpers.mkCompositeOption "" { autoOpen = {
enabled = helpers.defaultNullOpts.mkBool true ""; enabled = helpers.defaultNullOpts.mkBool true "";
trigger = trigger =
helpers.defaultNullOpts.mkBool true helpers.defaultNullOpts.mkBool true
@ -184,14 +186,14 @@ with lib; {
"merged with defaults from documentation"; "merged with defaults from documentation";
}; };
message = helpers.mkCompositeOption "Messages shown by lsp servers" { message = {
enabled = helpers.defaultNullOpts.mkBool true "enable display of messages"; enabled = helpers.defaultNullOpts.mkBool true "enable display of messages";
view = helpers.defaultNullOpts.mkStr "notify" ""; view = helpers.defaultNullOpts.mkStr "notify" "";
opts = helpers.defaultNullOpts.mkNullable types.anything "{}" ""; opts = helpers.defaultNullOpts.mkNullable types.anything "{}" "";
}; };
documentation = helpers.mkCompositeOption "defaults for hover and signature help" { documentation = {
view = helpers.defaultNullOpts.mkStr "hover" ""; view = helpers.defaultNullOpts.mkStr "hover" "";
opts = helpers.defaultNullOpts.mkNullable types.anything '' opts = helpers.defaultNullOpts.mkNullable types.anything ''
@ -206,7 +208,7 @@ with lib; {
}; };
}; };
markdown = helpers.mkCompositeOption "" { markdown = {
hover = helpers.defaultNullOpts.mkNullable (types.attrsOf types.str) '' hover = helpers.defaultNullOpts.mkNullable (types.attrsOf types.str) ''
{ {
"|(%S-)|" = helpers.mkRaw "vim.cmd.help"; // vim help links "|(%S-)|" = helpers.mkRaw "vim.cmd.help"; // vim help links
@ -226,16 +228,17 @@ with lib; {
'' "set highlight groups"; '' "set highlight groups";
}; };
health = helpers.mkCompositeOption "" { health = {
checker = checker =
helpers.defaultNullOpts.mkBool true helpers.defaultNullOpts.mkBool true
"Disable if you don't want health checks to run"; "Disable if you don't want health checks to run";
}; };
smartMove = smartMove = {
helpers.mkCompositeOption enabled = helpers.defaultNullOpts.mkBool true ''
"noice tries to move out of the way of existing floating windows." { Noice tries to move out of the way of existing floating windows.
enabled = helpers.defaultNullOpts.mkBool true "you can disable this behaviour here"; You can disable this behaviour here
'';
excludedFiletypes = excludedFiletypes =
helpers.defaultNullOpts.mkNullable (types.listOf types.str) helpers.defaultNullOpts.mkNullable (types.listOf types.str)
''[ "cmp_menu" "cmp_docs" "notify"]'' '' ''[ "cmp_menu" "cmp_docs" "notify"]'' ''
@ -272,13 +275,12 @@ with lib; {
cfg = config.plugins.noice; cfg = config.plugins.noice;
setupOptions = { setupOptions = {
inherit (cfg) presets views routes status format; inherit (cfg) presets views routes status format;
cmdline = helpers.ifNonNull' cfg.cmdline { cmdline = {
inherit (cfg.cmdline) enabled view opts format; inherit (cfg.cmdline) enabled view opts format;
}; };
messages = let messages = let
cfgM = cfg.messages; cfgM = cfg.messages;
in in {
helpers.ifNonNull' cfgM {
inherit (cfgM) enabled view; inherit (cfgM) enabled view;
view_error = cfgM.viewError; view_error = cfgM.viewError;
view_warn = cfgM.viewWarn; view_warn = cfgM.viewWarn;
@ -287,56 +289,51 @@ with lib; {
}; };
popupmenu = let popupmenu = let
cfgP = cfg.popupmenu; cfgP = cfg.popupmenu;
in in {
helpers.ifNonNull' cfgP {
inherit (cfgP) enabled backend; inherit (cfgP) enabled backend;
kind_icons = cfgP.kindIcons; kind_icons = cfgP.kindIcons;
}; };
inherit (cfg) redirect commands; inherit (cfg) redirect commands;
notify = helpers.ifNonNull' cfg.notify { notify = {
inherit (cfg.notify) enabled view; inherit (cfg.notify) enabled view;
}; };
lsp = let lsp = let
cfgL = cfg.lsp; cfgL = cfg.lsp;
in in {
helpers.ifNonNull' cfgL {
progress = let progress = let
cfgLP = cfgL.progress; cfgLP = cfgL.progress;
in in {
helpers.ifNonNull' cfgLP {
inherit (cfgLP) enabled format throttle view; inherit (cfgLP) enabled format throttle view;
format_done = cfgLP.formatDone; format_done = cfgLP.formatDone;
}; };
inherit (cfgL) override; inherit (cfgL) override;
hover = helpers.ifNonNull' cfgL.hover { hover = {
inherit (cfgL.hover) enabled view opts; inherit (cfgL.hover) enabled view opts;
}; };
signature = let signature = let
cfgLS = cfgL.signature; cfgLS = cfgL.signature;
in in {
helpers.ifNonNull' cfgLS {
inherit (cfgLS) enabled view opts; inherit (cfgLS) enabled view opts;
auto_open = helpers.ifNonNull' cfgLS.autoOpen { auto_open = {
inherit (cfgLS.autoOpen) enabled trigger luasnip throttle; inherit (cfgLS.autoOpen) enabled trigger luasnip throttle;
}; };
}; };
message = helpers.ifNonNull' cfgL.message { message = {
inherit (cfgL.message) enabled view opts; inherit (cfgL.message) enabled view opts;
}; };
documentation = helpers.ifNonNull' cfgL.documentation { documentation = {
inherit (cfgL.documentation) view opts; inherit (cfgL.documentation) view opts;
}; };
}; };
markdown = helpers.ifNonNull' cfg.markdown { markdown = {
inherit (cfg.markdown) hover highlights; inherit (cfg.markdown) hover highlights;
}; };
health = helpers.ifNonNull' cfg.health { health = {
inherit (cfg.health) checker; inherit (cfg.health) checker;
}; };
smart_move = let smart_move = let
cfgS = cfg.smartMove; cfgS = cfg.smartMove;
in in {
helpers.ifNonNull' cfgS {
inherit (cfgS) enabled; inherit (cfgS) enabled;
excluded_filetypes = cfgS.excludedFiletypes; excluded_filetypes = cfgS.excludedFiletypes;
}; };

View file

@ -79,7 +79,7 @@ in {
``` ```
''; '';
guiStyle = helpers.mkCompositeOption "The gui style for highlight groups." { guiStyle = {
fg = helpers.defaultNullOpts.mkStr "NONE" '' fg = helpers.defaultNullOpts.mkStr "NONE" ''
The gui style to use for the fg highlight group. The gui style to use for the fg highlight group.
''; '';
@ -93,7 +93,7 @@ in {
When true, custom keywords will be merged with the default When true, custom keywords will be merged with the default
''; '';
highlight = helpers.mkCompositeOption "Highlight options." { highlight = {
multiline = helpers.defaultNullOpts.mkBool true '' multiline = helpers.defaultNullOpts.mkBool true ''
Enable multiline todo comments. Enable multiline todo comments.
''; '';
@ -163,7 +163,7 @@ in {
``` ```
''; '';
search = helpers.mkCompositeOption "Search options." { search = {
command = helpers.defaultNullOpts.mkStr "rg" "Command to use for searching for keywords."; command = helpers.defaultNullOpts.mkStr "rg" "Command to use for searching for keywords.";
args = helpers.mkNullOrOption (types.listOf types.str) '' args = helpers.mkNullOrOption (types.listOf types.str) ''
@ -231,7 +231,7 @@ in {
inherit (cfg) keywords; inherit (cfg) keywords;
gui_style = cfg.guiStyle; gui_style = cfg.guiStyle;
merge_keywords = cfg.mergeKeywords; merge_keywords = cfg.mergeKeywords;
highlight = helpers.ifNonNull' cfg.highlight { highlight = {
inherit inherit
(cfg.highlight) (cfg.highlight)
multiline multiline
@ -249,7 +249,7 @@ in {
max_line_len = cfg.highlight.maxLineLen; max_line_len = cfg.highlight.maxLineLen;
}; };
inherit (cfg) colors; inherit (cfg) colors;
search = helpers.ifNonNull' cfg.search { search = {
inherit (cfg.search) command args; inherit (cfg.search) command args;
pattern = pattern =
helpers.ifNonNull' cfg.search.pattern helpers.ifNonNull' cfg.search.pattern