Merge pull request #241 from FrothyMarrow/lib-calls-explicit

treewide: make lib calls explicit
This commit is contained in:
raf 2024-03-24 14:52:23 +03:00 committed by GitHub
commit dbe7baee15
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 589 additions and 496 deletions

View file

@ -8,13 +8,16 @@
# - the addition of the function `entryBefore` indicating a "wanted # - the addition of the function `entryBefore` indicating a "wanted
# by" relationship. # by" relationship.
{lib}: let {lib}: let
inherit (lib) all filterAttrs nvim mapAttrs toposort; inherit (builtins) isAttrs attrValues attrNames elem all;
inherit (lib.attrsets) filterAttrs mapAttrs;
inherit (lib.lists) toposort;
inherit (lib.nvim.dag) isEntry entryBetween;
in { in {
empty = {}; empty = {};
isEntry = e: e ? data && e ? after && e ? before; isEntry = e: e ? data && e ? after && e ? before;
isDag = dag: isDag = dag:
builtins.isAttrs dag && all nvim.dag.isEntry (builtins.attrValues dag); isAttrs dag && all isEntry (attrValues dag);
/* /*
Takes an attribute set containing entries built by entryAnywhere, Takes an attribute set containing entries built by entryAnywhere,
@ -76,8 +79,8 @@ in {
*/ */
topoSort = dag: let topoSort = dag: let
dagBefore = dag: name: dagBefore = dag: name:
builtins.attrNames attrNames
(filterAttrs (_n: v: builtins.elem name v.before) dag); (filterAttrs (_n: v: elem name v.before) dag);
normalizedDag = normalizedDag =
mapAttrs (n: v: { mapAttrs (n: v: {
name = n; name = n;
@ -85,8 +88,8 @@ in {
after = v.after ++ dagBefore dag n; after = v.after ++ dagBefore dag n;
}) })
dag; dag;
before = a: b: builtins.elem a.name b.after; before = a: b: elem a.name b.after;
sorted = toposort before (builtins.attrValues normalizedDag); sorted = toposort before (attrValues normalizedDag);
in in
if sorted ? result if sorted ? result
then { then {
@ -100,8 +103,8 @@ in {
entryBetween = before: after: data: {inherit data before after;}; entryBetween = before: after: data: {inherit data before after;};
# Create a DAG entry with no particular dependency information. # Create a DAG entry with no particular dependency information.
entryAnywhere = nvim.dag.entryBetween [] []; entryAnywhere = entryBetween [] [];
entryAfter = nvim.dag.entryBetween []; entryAfter = entryBetween [];
entryBefore = before: nvim.dag.entryBetween before []; entryBefore = before: entryBetween before [];
} }

View file

@ -1,32 +1,37 @@
# From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/booleans.nix # From home-manager: https://github.com/nix-community/home-manager/blob/master/modules/lib/booleans.nix
{lib}: { {lib}: let
inherit (builtins) isString getAttr;
inherit (lib.options) mkOption;
inherit (lib.attrsets) listToAttrs;
inherit (lib.types) bool;
in {
# Converts a boolean to a yes/no string. This is used in lots of # Converts a boolean to a yes/no string. This is used in lots of
# configuration formats. # configuration formats.
diagnosticsToLua = { diagnosticsToLua = {
lang, lang,
config, config,
diagnostics, diagnosticsProviders,
}: }:
lib.listToAttrs listToAttrs
(map (v: let (map (v: let
type = type =
if builtins.isString v if isString v
then v then v
else builtins.getAttr v.type; else getAttr v.type;
package = package =
if builtins.isString v if isString v
then diagnostics.${type}.package then diagnosticsProviders.${type}.package
else v.package; else v.package;
in { in {
name = "${lang}-diagnostics-${type}"; name = "${lang}-diagnostics-${type}";
value = diagnostics.${type}.nullConfig package; value = diagnosticsProviders.${type}.nullConfig package;
}) })
config); config);
mkEnable = desc: mkEnable = desc:
lib.mkOption { mkOption {
description = "Turn on ${desc} for enabled languages by default"; description = "Turn on ${desc} for enabled languages by default";
type = lib.types.bool; type = bool;
default = false; default = false;
}; };
} }

View file

@ -1,7 +1,9 @@
# Helpers for converting values to lua # Helpers for converting values to lua
{lib}: let {lib}: let
inherit (lib) mapAttrsToList filterAttrs concatStringsSep concatMapStringsSep stringToCharacters boolToString; inherit (builtins) hasAttr head throw typeOf isList isAttrs isBool isInt isString isPath isFloat toJSON;
inherit (builtins) hasAttr head throw typeOf; inherit (lib.attrsets) mapAttrsToList filterAttrs;
inherit (lib.strings) concatStringsSep concatMapStringsSep stringToCharacters;
inherit (lib.trivial) boolToString;
in rec { in rec {
# Convert a null value to lua's nil # Convert a null value to lua's nil
nullString = value: nullString = value:
@ -11,29 +13,29 @@ in rec {
# convert an expression to lua # convert an expression to lua
expToLua = exp: expToLua = exp:
if builtins.isList exp if isList exp
then listToLuaTable exp # if list, convert to lua table then listToLuaTable exp # if list, convert to lua table
else if builtins.isAttrs exp else if isAttrs exp
then attrsetToLuaTable exp # if attrs, convert to table then attrsetToLuaTable exp # if attrs, convert to table
else if builtins.isBool exp else if isBool exp
then lib.boolToString exp # if bool, convert to string then boolToString exp # if bool, convert to string
else if builtins.isInt exp else if isInt exp
then builtins.toString exp # if int, convert to string then toString exp # if int, convert to string
else if exp == null else if exp == null
then "nil" then "nil"
else (builtins.toJSON exp); # otherwise jsonify the value and print as is else (toJSON exp); # otherwise jsonify the value and print as is
# convert list to a lua table # convert list to a lua table
listToLuaTable = list: listToLuaTable = list:
"{ " + (builtins.concatStringsSep ", " (map expToLua list)) + " }"; "{ " + (concatStringsSep ", " (map expToLua list)) + " }";
# convert attrset to a lua table # convert attrset to a lua table
attrsetToLuaTable = attrset: attrsetToLuaTable = attrset:
"{ " "{ "
+ ( + (
builtins.concatStringsSep ", " concatStringsSep ", "
( (
lib.mapAttrsToList ( mapAttrsToList (
name: value: name: value:
name name
+ " = " + " = "
@ -44,10 +46,10 @@ in rec {
) )
+ " }"; + " }";
# Convert a list of lua expressions to a lua table. The difference to listToLuaTable is that the elements here are expected to be lua expressions already, whereas listToLuaTable converts from nix types to lua first # Convert a list of lua expressions to a lua table. The difference to listToLuaTable is that the elements here are expected to be lua expressions already, whereas listToLuaTable converts from nix types to lua first
luaTable = items: ''{${builtins.concatStringsSep "," items}}''; luaTable = items: ''{${concatStringsSep "," items}}'';
toLuaObject = args: toLuaObject = args:
if builtins.isAttrs args if isAttrs args
then then
if hasAttr "__raw" args if hasAttr "__raw" args
then args.__raw then args.__raw
@ -68,19 +70,19 @@ in rec {
) )
args))) args)))
+ "}" + "}"
else if builtins.isList args else if isList args
then "{" + concatMapStringsSep "," toLuaObject args + "}" then "{" + concatMapStringsSep "," toLuaObject args + "}"
else if builtins.isString args else if isString args
then then
# This should be enough! # This should be enough!
builtins.toJSON args toJSON args
else if builtins.isPath args else if isPath args
then builtins.toJSON (toString args) then toJSON (toString args)
else if builtins.isBool args else if isBool args
then "${boolToString args}" then "${boolToString args}"
else if builtins.isFloat args else if isFloat args
then "${toString args}" then "${toString args}"
else if builtins.isInt args else if isInt args
then "${toString args}" then "${toString args}"
else if (args == null) else if (args == null)
then "nil" then "nil"

View file

@ -15,13 +15,13 @@ with lib; let
in { in {
diagnostics = { diagnostics = {
langDesc, langDesc,
diagnostics, diagnosticsProviders,
defaultDiagnostics, defaultDiagnosticsProvider,
}: }:
mkOption { mkOption {
description = "List of ${langDesc} diagnostics to enable"; description = "List of ${langDesc} diagnostics to enable";
type = with types; listOf (either (enum (attrNames diagnostics)) (submodule diagnosticSubmodule)); type = with types; listOf (either (enum (attrNames diagnosticsProviders)) (submodule diagnosticSubmodule));
default = defaultDiagnostics; default = defaultDiagnosticsProvider;
}; };
mkGrammarOption = pkgs: grammar: mkGrammarOption = pkgs: grammar:

View file

@ -1,5 +1,5 @@
let let
inherit (builtins) isInt isBool toJSON; inherit (builtins) isInt isBool toJSON toString;
in rec { in rec {
# yes? no. # yes? no.
yesNo = value: yesNo = value:
@ -16,7 +16,7 @@ in rec {
# convert a literal value to a vim compliant value # convert a literal value to a vim compliant value
valToVim = val: valToVim = val:
if (isInt val) if (isInt val)
then (builtins.toString val) then (toString val)
else else
( (
if (isBool val) if (isBool val)

View file

@ -4,12 +4,15 @@
... ...
}: let }: let
inherit (builtins) concatStringsSep; inherit (builtins) concatStringsSep;
inherit (lib) optionalString mkIf nvim; inherit (lib.modules) mkIf;
inherit (lib.lists) optionals;
inherit (lib.strings) optionalString;
inherit (lib.nvim.dag) entryAfter;
cfg = config.vim; cfg = config.vim;
in { in {
config = { config = {
vim.startPlugins = ["plenary-nvim"] ++ lib.optionals (cfg.spellChecking.enableProgrammingWordList) ["vim-dirtytalk"]; vim.startPlugins = ["plenary-nvim"] ++ optionals (cfg.spellChecking.enableProgrammingWordList) ["vim-dirtytalk"];
vim.maps.normal = vim.maps.normal =
mkIf cfg.disableArrows { mkIf cfg.disableArrows {
@ -57,7 +60,7 @@ in {
}; };
}; };
vim.configRC.basic = nvim.dag.entryAfter ["globalsScript"] '' vim.configRC.basic = entryAfter ["globalsScript"] ''
" Settings that are set for everything " Settings that are set for everything
set encoding=utf-8 set encoding=utf-8
set mouse=${cfg.mouseSupport} set mouse=${cfg.mouseSupport}

View file

@ -3,12 +3,12 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) types; inherit (lib.types) package path str bool int listOf enum nullOr;
in { in {
options.vim = { options.vim = {
package = mkOption { package = mkOption {
type = types.package; type = package;
default = pkgs.neovim-unwrapped; default = pkgs.neovim-unwrapped;
description = '' description = ''
The neovim package to use. You will need to use an unwrapped package for this option to work as intended. The neovim package to use. You will need to use an unwrapped package for this option to work as intended.
@ -18,13 +18,13 @@ in {
debugMode = { debugMode = {
enable = mkEnableOption "debug mode"; enable = mkEnableOption "debug mode";
level = mkOption { level = mkOption {
type = types.int; type = int;
default = 20; default = 20;
description = "Set the debug level"; description = "Set the debug level";
}; };
logFile = mkOption { logFile = mkOption {
type = types.path; type = path;
default = "/tmp/nvim.log"; default = "/tmp/nvim.log";
description = "Set the log file"; description = "Set the log file";
}; };
@ -33,7 +33,7 @@ in {
enableLuaLoader = mkEnableOption "experimental Lua module loader to speed up the start up process"; enableLuaLoader = mkEnableOption "experimental Lua module loader to speed up the start up process";
leaderKey = mkOption { leaderKey = mkOption {
type = with types; nullOr str; type = nullOr str;
default = null; default = null;
description = "The leader key to be used internally"; description = "The leader key to be used internally";
}; };
@ -42,7 +42,7 @@ in {
enable = mkEnableOption "neovim's built-in spellchecking"; enable = mkEnableOption "neovim's built-in spellchecking";
enableProgrammingWordList = mkEnableOption "vim-dirtytalk, a wordlist for programmers, that includes programming words"; enableProgrammingWordList = mkEnableOption "vim-dirtytalk, a wordlist for programmers, that includes programming words";
languages = mkOption { languages = mkOption {
type = with types; listOf str; type = listOf str;
description = "The languages to be used for spellchecking"; description = "The languages to be used for spellchecking";
default = ["en"]; default = ["en"];
example = ["en" "de"]; example = ["en" "de"];
@ -50,55 +50,55 @@ in {
}; };
colourTerm = mkOption { colourTerm = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Set terminal up for 256 colours"; description = "Set terminal up for 256 colours";
}; };
disableArrows = mkOption { disableArrows = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Set to prevent arrow keys from moving cursor"; description = "Set to prevent arrow keys from moving cursor";
}; };
hideSearchHighlight = mkOption { hideSearchHighlight = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Hide search highlight so it doesn't stay highlighted"; description = "Hide search highlight so it doesn't stay highlighted";
}; };
scrollOffset = mkOption { scrollOffset = mkOption {
type = types.int; type = int;
default = 8; default = 8;
description = "Start scrolling this number of lines from the top or bottom of the page."; description = "Start scrolling this number of lines from the top or bottom of the page.";
}; };
wordWrap = mkOption { wordWrap = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Enable word wrapping."; description = "Enable word wrapping.";
}; };
syntaxHighlighting = mkOption { syntaxHighlighting = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Enable syntax highlighting"; description = "Enable syntax highlighting";
}; };
mapLeaderSpace = mkOption { mapLeaderSpace = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Map the space key to leader key"; description = "Map the space key to leader key";
}; };
useSystemClipboard = mkOption { useSystemClipboard = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Make use of the clipboard for default yank and paste operations. Don't use * and +"; description = "Make use of the clipboard for default yank and paste operations. Don't use * and +";
}; };
mouseSupport = mkOption { mouseSupport = mkOption {
type = with types; enum ["a" "n" "v" "i" "c"]; type = enum ["a" "n" "v" "i" "c"];
default = "a"; default = "a";
description = '' description = ''
Set modes for mouse support. Set modes for mouse support.
@ -112,7 +112,7 @@ in {
}; };
lineNumberMode = mkOption { lineNumberMode = mkOption {
type = with types; enum ["relative" "number" "relNumber" "none"]; type = enum ["relative" "number" "relNumber" "none"];
default = "relNumber"; default = "relNumber";
description = '' description = ''
How line numbers are displayed. Available options are How line numbers are displayed. Available options are
@ -121,78 +121,78 @@ in {
}; };
preventJunkFiles = mkOption { preventJunkFiles = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Prevent swapfile, backupfile from being created"; description = "Prevent swapfile, backupfile from being created";
}; };
tabWidth = mkOption { tabWidth = mkOption {
type = types.int; type = int;
default = 4; default = 4;
description = "Set the width of tabs"; description = "Set the width of tabs";
}; };
autoIndent = mkOption { autoIndent = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Enable auto indent"; description = "Enable auto indent";
}; };
cmdHeight = mkOption { cmdHeight = mkOption {
type = types.int; type = int;
default = 1; default = 1;
description = "Height of the command pane"; description = "Height of the command pane";
}; };
updateTime = mkOption { updateTime = mkOption {
type = types.int; type = int;
default = 300; default = 300;
description = "The number of milliseconds till Cursor Hold event is fired"; description = "The number of milliseconds till Cursor Hold event is fired";
}; };
showSignColumn = mkOption { showSignColumn = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Show the sign column"; description = "Show the sign column";
}; };
bell = mkOption { bell = mkOption {
type = types.enum ["none" "visual" "on"]; type = enum ["none" "visual" "on"];
default = "none"; default = "none";
description = "Set how bells are handled. Options: on, visual or none"; description = "Set how bells are handled. Options: on, visual or none";
}; };
mapTimeout = mkOption { mapTimeout = mkOption {
type = types.int; type = int;
default = 500; default = 500;
description = "Timeout in ms that neovim will wait for mapped action to complete"; description = "Timeout in ms that neovim will wait for mapped action to complete";
}; };
splitBelow = mkOption { splitBelow = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "New splits will open below instead of on top"; description = "New splits will open below instead of on top";
}; };
splitRight = mkOption { splitRight = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "New splits will open to the right"; description = "New splits will open to the right";
}; };
enableEditorconfig = mkOption { enableEditorconfig = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Follow editorconfig rules in current directory"; description = "Follow editorconfig rules in current directory";
}; };
cursorlineOpt = mkOption { cursorlineOpt = mkOption {
type = types.enum ["line" "screenline" "number" "both"]; type = enum ["line" "screenline" "number" "both"];
default = "line"; default = "line";
description = "Highlight the text line of the cursor with CursorLine hl-CursorLine"; description = "Highlight the text line of the cursor with CursorLine hl-CursorLine";
}; };
searchCase = mkOption { searchCase = mkOption {
type = types.enum ["ignore" "smart" "sensitive"]; type = enum ["ignore" "smart" "sensitive"];
default = "sensitive"; default = "sensitive";
description = "Set the case sensitivity of search"; description = "Set the case sensitivity of search";
}; };

View file

@ -1,5 +1,5 @@
{lib, ...}: let {lib, ...}: let
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption literalMD;
inherit (lib.nvim.binds) mkMappingOption; inherit (lib.nvim.binds) mkMappingOption;
inherit (lib.types) enum attrsOf nullOr str; inherit (lib.types) enum attrsOf nullOr str;
in { in {
@ -52,7 +52,7 @@ in {
''; '';
type = str; type = str;
default = "nvim_cmp_menu_map"; default = "nvim_cmp_menu_map";
example = lib.literalMD '' example = literalMD ''
```lua ```lua
function(entry, vim_item) function(entry, vim_item)
return vim_item return vim_item

View file

@ -4,10 +4,16 @@
... ...
}: let }: let
inherit (builtins) attrValues attrNames map mapAttrs toJSON isString concatStringsSep filter; inherit (builtins) attrValues attrNames map mapAttrs toJSON isString concatStringsSep filter;
inherit (lib) mkOption types mapAttrsFlatten filterAttrs optionalString getAttrs literalExpression; inherit (lib.options) mkOption literalExpression mdDoc;
inherit (lib) nvim; inherit (lib.attrsets) filterAttrs getAttrs;
inherit (nvim.lua) toLuaObject; inherit (lib.strings) optionalString;
inherit (nvim.vim) valToVim; inherit (lib.misc) mapAttrsFlatten;
inherit (lib.trivial) showWarnings;
inherit (lib.types) bool str listOf oneOf attrsOf nullOr attrs submodule unspecified lines;
inherit (lib.nvim.types) dagOf pluginsOpt extraPluginType;
inherit (lib.nvim.dag) entryAnywhere entryAfter topoSort;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.vim) valToVim;
cfg = config.vim; cfg = config.vim;
@ -22,7 +28,7 @@
mkBool = value: description: mkBool = value: description:
mkOption { mkOption {
type = types.bool; type = bool;
default = value; default = value;
inherit description; inherit description;
}; };
@ -54,7 +60,7 @@
"Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default."; "Whether to use the 'noremap' variant of the command, ignoring any custom mappings on the defined action. It is highly advised to keep this on, which is the default.";
desc = mkOption { desc = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = null; default = null;
description = "A description of this keybind, to be shown in which-key, if you have it enabled."; description = "A description of this keybind, to be shown in which-key, if you have it enabled.";
}; };
@ -94,17 +100,17 @@
}) })
maps); maps);
mapOption = types.submodule { mapOption = submodule {
options = options =
mapConfigOptions mapConfigOptions
// { // {
action = mkOption { action = mkOption {
type = types.str; type = str;
description = "The action to execute."; description = "The action to execute.";
}; };
lua = mkOption { lua = mkOption {
type = types.bool; type = bool;
description = '' description = ''
If true, `action` is considered to be lua code. If true, `action` is considered to be lua code.
Thus, it will not be wrapped in `""`. Thus, it will not be wrapped in `""`.
@ -117,13 +123,13 @@
mapOptions = mode: mapOptions = mode:
mkOption { mkOption {
description = "Mappings for ${mode} mode"; description = "Mappings for ${mode} mode";
type = types.attrsOf mapOption; type = attrsOf mapOption;
default = {}; default = {};
}; };
in { in {
options = { options = {
assertions = lib.mkOption { assertions = mkOption {
type = with types; listOf unspecified; type = listOf unspecified;
internal = true; internal = true;
default = []; default = [];
example = literalExpression '' example = literalExpression ''
@ -139,9 +145,9 @@ in {
warnings = mkOption { warnings = mkOption {
internal = true; internal = true;
default = []; default = [];
type = with types; listOf str; type = listOf str;
example = ["The `foo' service is deprecated and will go away soon!"]; example = ["The `foo' service is deprecated and will go away soon!"];
description = lib.mdDoc '' description = mdDoc ''
This option allows modules to show warnings to users during This option allows modules to show warnings to users during
the evaluation of the system configuration. the evaluation of the system configuration.
''; '';
@ -150,46 +156,46 @@ in {
vim = { vim = {
viAlias = mkOption { viAlias = mkOption {
description = "Enable vi alias"; description = "Enable vi alias";
type = types.bool; type = bool;
default = true; default = true;
}; };
vimAlias = mkOption { vimAlias = mkOption {
description = "Enable vim alias"; description = "Enable vim alias";
type = types.bool; type = bool;
default = true; default = true;
}; };
configRC = mkOption { configRC = mkOption {
description = "vimrc contents"; description = "vimrc contents";
type = types.oneOf [(nvim.types.dagOf types.lines) types.str]; type = oneOf [(dagOf lines) str];
default = {}; default = {};
}; };
luaConfigRC = mkOption { luaConfigRC = mkOption {
description = "vim lua config"; description = "vim lua config";
type = types.oneOf [(nvim.types.dagOf types.lines) types.str]; type = oneOf [(dagOf lines) str];
default = {}; default = {};
}; };
builtConfigRC = mkOption { builtConfigRC = mkOption {
internal = true; internal = true;
type = types.lines; type = lines;
description = "The built config for neovim after resolving the DAG"; description = "The built config for neovim after resolving the DAG";
}; };
startPlugins = nvim.types.pluginsOpt { startPlugins = pluginsOpt {
default = []; default = [];
description = "List of plugins to startup."; description = "List of plugins to startup.";
}; };
optPlugins = nvim.types.pluginsOpt { optPlugins = pluginsOpt {
default = []; default = [];
description = "List of plugins to optionally load"; description = "List of plugins to optionally load";
}; };
extraPlugins = mkOption { extraPlugins = mkOption {
type = types.attrsOf nvim.types.extraPluginType; type = attrsOf extraPluginType;
default = {}; default = {};
description = '' description = ''
List of plugins and related config. List of plugins and related config.
@ -210,7 +216,7 @@ in {
}; };
luaPackages = mkOption { luaPackages = mkOption {
type = types.listOf types.str; type = listOf str;
default = []; default = [];
description = '' description = ''
List of lua packages to install. List of lua packages to install.
@ -220,11 +226,11 @@ in {
globals = mkOption { globals = mkOption {
default = {}; default = {};
description = "Set containing global variable values"; description = "Set containing global variable values";
type = types.attrs; type = attrs;
}; };
maps = mkOption { maps = mkOption {
type = types.submodule { type = submodule {
options = { options = {
normal = mapOptions "normal"; normal = mapOptions "normal";
insert = mapOptions "insert"; insert = mapOptions "insert";
@ -289,12 +295,12 @@ in {
mapResult, mapResult,
}: let }: let
# When the value is a string, default it to dag.entryAnywhere # When the value is a string, default it to dag.entryAnywhere
finalDag = lib.mapAttrs (_: value: finalDag = mapAttrs (_: value:
if isString value if isString value
then nvim.dag.entryAnywhere value then entryAnywhere value
else value) else value)
dag; dag;
sortedDag = nvim.dag.topoSort finalDag; sortedDag = topoSort finalDag;
result = result =
if sortedDag ? result if sortedDag ? result
then mapResult sortedDag.result then mapResult sortedDag.result
@ -305,7 +311,7 @@ in {
vim = { vim = {
startPlugins = map (x: x.package) (attrValues cfg.extraPlugins); startPlugins = map (x: x.package) (attrValues cfg.extraPlugins);
configRC = { configRC = {
globalsScript = nvim.dag.entryAnywhere (concatStringsSep "\n" globalsScript); globalsScript = entryAnywhere (concatStringsSep "\n" globalsScript);
luaScript = let luaScript = let
mkSection = r: '' mkSection = r: ''
@ -319,7 +325,7 @@ in {
inherit mapResult; inherit mapResult;
}; };
in in
nvim.dag.entryAfter ["globalsScript"] luaConfig; entryAfter ["globalsScript"] luaConfig;
extraPluginConfigs = let extraPluginConfigs = let
mkSection = r: '' mkSection = r: ''
@ -332,7 +338,7 @@ in {
setup, setup,
... ...
}: }:
nvim.dag.entryAfter after setup) entryAfter after setup)
cfg.extraPlugins; cfg.extraPlugins;
pluginConfig = resolveDag { pluginConfig = resolveDag {
name = "extra plugins config"; name = "extra plugins config";
@ -340,7 +346,7 @@ in {
inherit mapResult; inherit mapResult;
}; };
in in
nvim.dag.entryAfter ["luaScript"] pluginConfig; entryAfter ["luaScript"] pluginConfig;
# This is probably not the right way to set the config. I'm not sure how it should look like. # This is probably not the right way to set the config. I'm not sure how it should look like.
mappings = let mappings = let
@ -359,7 +365,7 @@ in {
]; ];
mapConfig = wrapLuaConfig (concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps)); mapConfig = wrapLuaConfig (concatStringsSep "\n" (map (v: concatStringsSep "\n" v) maps));
in in
nvim.dag.entryAfter ["globalsScript"] mapConfig; entryAfter ["globalsScript"] mapConfig;
}; };
builtConfigRC = let builtConfigRC = let
@ -368,7 +374,7 @@ in {
baseSystemAssertWarn = baseSystemAssertWarn =
if failedAssertions != [] if failedAssertions != []
then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}" then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}"
else lib.showWarnings config.warnings; else showWarnings config.warnings;
mkSection = r: '' mkSection = r: ''
" SECTION: ${r.name} " SECTION: ${r.name}

View file

@ -1,5 +1,5 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption; inherit (lib.options) mkEnableOption;
in { in {
options.vim.dashboard.dashboard-nvim = { options.vim.dashboard.dashboard-nvim = {
enable = mkEnableOption "Fancy and Blazing Fast start screen plugin of neovim [dashboard.nvim]"; enable = mkEnableOption "Fancy and Blazing Fast start screen plugin of neovim [dashboard.nvim]";

View file

@ -33,7 +33,7 @@ in {
vim.luaConfigRC.nvimtreelua = entryAnywhere '' vim.luaConfigRC.nvimtreelua = entryAnywhere ''
${ ${
lib.optionalString cfg.disableNetrw '' optionalString cfg.disableNetrw ''
-- disable netrew completely -- disable netrew completely
vim.g.loaded_netrw = 1 vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1 vim.g.loaded_netrwPlugin = 1

View file

@ -3,29 +3,30 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkEnableOption mkOption types literalExpression; inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.types) nullOr str bool int listOf enum attrs oneOf addCheck submodule;
in { in {
options.vim.filetree.nvimTree = { options.vim.filetree.nvimTree = {
enable = mkEnableOption "filetree via nvim-tree.lua"; enable = mkEnableOption "filetree via nvim-tree.lua";
mappings = { mappings = {
toggle = mkOption { toggle = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<leader>t"; default = "<leader>t";
description = "Toggle NvimTree"; description = "Toggle NvimTree";
}; };
refresh = mkOption { refresh = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<leader>tr"; default = "<leader>tr";
description = "Refresh NvimTree"; description = "Refresh NvimTree";
}; };
findFile = mkOption { findFile = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<leader>tg"; default = "<leader>tg";
description = "Find file in NvimTree"; description = "Find file in NvimTree";
}; };
focus = mkOption { focus = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<leader>tf"; default = "<leader>tf";
description = "Focus NvimTree"; description = "Focus NvimTree";
}; };
@ -34,19 +35,19 @@ in {
disableNetrw = mkOption { disableNetrw = mkOption {
default = false; default = false;
description = "Disables netrw and replaces it with tree"; description = "Disables netrw and replaces it with tree";
type = types.bool; type = bool;
}; };
hijackNetrw = mkOption { hijackNetrw = mkOption {
default = true; default = true;
description = "Prevents netrw from automatically opening when opening directories"; description = "Prevents netrw from automatically opening when opening directories";
type = types.bool; type = bool;
}; };
autoreloadOnWrite = mkOption { autoreloadOnWrite = mkOption {
default = true; default = true;
description = "Auto reload tree on write"; description = "Auto reload tree on write";
type = types.bool; type = bool;
}; };
updateFocusedFile = mkOption { updateFocusedFile = mkOption {
@ -55,16 +56,16 @@ in {
until it finds the file. until it finds the file.
''; '';
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
enable = mkOption { enable = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "update focused file"; description = "update focused file";
}; };
updateRoot = mkOption { updateRoot = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = '' description = ''
Update the root directory of the tree if the file is not under current Update the root directory of the tree if the file is not under current
@ -75,7 +76,7 @@ in {
}; };
ignoreList = mkOption { ignoreList = mkOption {
type = with types; listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
List of buffer names and filetypes that will not update the root dir List of buffer names and filetypes that will not update the root dir
@ -93,26 +94,26 @@ in {
sorter = mkOption { sorter = mkOption {
default = "name"; default = "name";
description = "How files within the same directory are sorted."; description = "How files within the same directory are sorted.";
type = types.enum ["name" "extension" "modification_time" "case_sensitive" "suffix" "filetype"]; type = enum ["name" "extension" "modification_time" "case_sensitive" "suffix" "filetype"];
}; };
foldersFirst = mkOption { foldersFirst = mkOption {
default = true; default = true;
description = "Sort folders before files. Has no effect when `sort.sorter` is a function."; description = "Sort folders before files. Has no effect when `sort.sorter` is a function.";
type = types.bool; type = bool;
}; };
}; };
hijackCursor = mkOption { hijackCursor = mkOption {
default = false; default = false;
description = "Hijack the cursor in the tree to put it at the start of the filename"; description = "Hijack the cursor in the tree to put it at the start of the filename";
type = types.bool; type = bool;
}; };
hijackUnnamedBufferWhenOpening = mkOption { hijackUnnamedBufferWhenOpening = mkOption {
default = false; default = false;
description = "Open nvimtree in place of the unnamed buffer if it's empty."; description = "Open nvimtree in place of the unnamed buffer if it's empty.";
type = types.bool; type = bool;
}; };
rootDirs = mkOption { rootDirs = mkOption {
@ -120,7 +121,7 @@ in {
description = '' description = ''
Preferred root directories. Only relevant when `updateFocusedFile.updateRoot` is `true` Preferred root directories. Only relevant when `updateFocusedFile.updateRoot` is `true`
''; '';
type = with types; listOf str; type = listOf str;
}; };
preferStartupRoot = mkOption { preferStartupRoot = mkOption {
@ -129,11 +130,11 @@ in {
Prefer startup root directory when updating root directory of the tree. Prefer startup root directory when updating root directory of the tree.
Only relevant when `update_focused_file.update_root` is `true` Only relevant when `update_focused_file.update_root` is `true`
''; '';
type = types.bool; type = bool;
}; };
syncRootWithCwd = mkOption { syncRootWithCwd = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = '' description = ''
Changes the tree root directory on `DirChanged` and refreshes the tree. Changes the tree root directory on `DirChanged` and refreshes the tree.
@ -145,13 +146,13 @@ in {
reloadOnBufEnter = mkOption { reloadOnBufEnter = mkOption {
default = false; default = false;
type = types.bool; type = bool;
description = "Automatically reloads the tree on `BufEnter` nvim-tree."; description = "Automatically reloads the tree on `BufEnter` nvim-tree.";
}; };
respectBufCwd = mkOption { respectBufCwd = mkOption {
default = false; default = false;
type = types.bool; type = bool;
description = "Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree."; description = "Will change cwd of nvim-tree to that of new buffer's when opening nvim-tree.";
}; };
@ -163,10 +164,10 @@ in {
autoOpen = false; autoOpen = false;
}; };
type = types.submodule { type = submodule {
options = { options = {
enable = mkOption { enable = mkOption {
type = types.bool; type = bool;
description = '' description = ''
Enable the `hijack_directories` feature. Disable this option if you use vim-dirvish or dirbuf.nvim. Enable the `hijack_directories` feature. Disable this option if you use vim-dirvish or dirbuf.nvim.
If `hijack_netrw` and `disable_netrw` are `false`, this feature will be disabled. If `hijack_netrw` and `disable_netrw` are `false`, this feature will be disabled.
@ -174,7 +175,7 @@ in {
}; };
autoOpen = mkOption { autoOpen = mkOption {
type = types.bool; type = bool;
description = '' description = ''
Opens the tree if the tree was previously closed. Opens the tree if the tree was previously closed.
''; '';
@ -187,7 +188,7 @@ in {
args = mkOption { args = mkOption {
default = []; default = [];
description = "Optional argument list."; description = "Optional argument list.";
type = with types; listOf str; type = listOf str;
}; };
cmd = mkOption { cmd = mkOption {
@ -198,7 +199,7 @@ in {
then "${pkgs.xdg-utils}/bin/xdg-open" then "${pkgs.xdg-utils}/bin/xdg-open"
else throw "NvimTree: No default system open command for this platform, please set `vim.filetree.nvimTree.systemOpen.cmd`"; else throw "NvimTree: No default system open command for this platform, please set `vim.filetree.nvimTree.systemOpen.cmd`";
description = "The open command itself"; description = "The open command itself";
type = types.str; type = str;
}; };
}; };
@ -210,13 +211,13 @@ in {
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
enable = mkEnableOption "diagnostics view in the signcolumn."; enable = mkEnableOption "diagnostics view in the signcolumn.";
debounceDelay = mkOption { debounceDelay = mkOption {
description = "Idle milliseconds between diagnostic event and update."; description = "Idle milliseconds between diagnostic event and update.";
type = types.int; type = int;
default = 50; default = 50;
}; };
@ -226,7 +227,7 @@ in {
}; };
showOnOpenDirs = mkOption { showOnOpenDirs = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = '' description = ''
Show diagnostics icons on directories that are open. Show diagnostics icons on directories that are open.
@ -237,26 +238,26 @@ in {
icons = mkOption { icons = mkOption {
description = "Icons for diagnostic severity."; description = "Icons for diagnostic severity.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
hint = mkOption { hint = mkOption {
description = "Icon used for `hint` diagnostic."; description = "Icon used for `hint` diagnostic.";
type = types.str; type = str;
default = ""; default = "";
}; };
info = mkOption { info = mkOption {
description = "Icon used for `info` diagnostic."; description = "Icon used for `info` diagnostic.";
type = types.str; type = str;
default = ""; default = "";
}; };
warning = mkOption { warning = mkOption {
description = "Icon used for `warning` diagnostic."; description = "Icon used for `warning` diagnostic.";
type = types.str; type = str;
default = ""; default = "";
}; };
error = mkOption { error = mkOption {
description = "Icon used for `error` diagnostic."; description = "Icon used for `error` diagnostic.";
type = types.str; type = str;
default = ""; default = "";
}; };
}; };
@ -266,17 +267,17 @@ in {
severity = mkOption { severity = mkOption {
description = "Severity for which the diagnostics will be displayed. See `:help diagnostic-severity`"; description = "Severity for which the diagnostics will be displayed. See `:help diagnostic-severity`";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
min = mkOption { min = mkOption {
description = "Minimum severity."; description = "Minimum severity.";
type = types.enum ["HINT" "INFO" "WARNING" "ERROR"]; type = enum ["HINT" "INFO" "WARNING" "ERROR"];
default = "HINT"; default = "HINT";
}; };
max = mkOption { max = mkOption {
description = "Maximum severity."; description = "Maximum severity.";
type = types.enum ["HINT" "INFO" "WARNING" "ERROR"]; type = enum ["HINT" "INFO" "WARNING" "ERROR"];
default = "ERROR"; default = "ERROR";
}; };
}; };
@ -290,19 +291,19 @@ in {
enable = mkEnableOption "Git integration with icons and colors."; enable = mkEnableOption "Git integration with icons and colors.";
showOnDirs = mkOption { showOnDirs = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Show git icons on parent directories."; description = "Show git icons on parent directories.";
}; };
showOnOpenDirs = mkOption { showOnOpenDirs = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Show git icons on directories that are open."; description = "Show git icons on directories that are open.";
}; };
disableForDirs = mkOption { disableForDirs = mkOption {
type = with types; listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
Disable git integration when git top-level matches these paths. Disable git integration when git top-level matches these paths.
@ -311,7 +312,7 @@ in {
}; };
timeout = mkOption { timeout = mkOption {
type = types.int; type = int;
default = 400; default = 400;
description = '' description = ''
Kills the git process after some time if it takes too long. Kills the git process after some time if it takes too long.
@ -323,18 +324,18 @@ in {
modified = mkOption { modified = mkOption {
description = "Indicate which file have unsaved modification."; description = "Indicate which file have unsaved modification.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
enable = mkEnableOption "Modified files with icons and color highlight."; enable = mkEnableOption "Modified files with icons and color highlight.";
showOnDirs = mkOption { showOnDirs = mkOption {
type = types.bool; type = bool;
description = "Show modified icons on parent directories."; description = "Show modified icons on parent directories.";
default = true; default = true;
}; };
showOnOpenDirs = mkOption { showOnOpenDirs = mkOption {
type = types.bool; type = bool;
description = "Show modified icons on directories that are open."; description = "Show modified icons on directories that are open.";
default = true; default = true;
}; };
@ -351,22 +352,22 @@ in {
performance. performance.
''; '';
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
enable = mkOption { enable = mkOption {
description = "Enable filesystem watchers."; description = "Enable filesystem watchers.";
type = types.bool; type = bool;
default = true; default = true;
}; };
debounceDelay = mkOption { debounceDelay = mkOption {
description = "Idle milliseconds between filesystem change and action."; description = "Idle milliseconds between filesystem change and action.";
type = types.int; type = int;
default = 50; default = 50;
}; };
ignoreDirs = mkOption { ignoreDirs = mkOption {
type = with types; listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
List of vim regex for absolute directory paths that will not be watched. List of vim regex for absolute directory paths that will not be watched.
@ -385,22 +386,22 @@ in {
view = mkOption { view = mkOption {
description = "Window / buffer setup."; description = "Window / buffer setup.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
centralizeSelection = mkOption { centralizeSelection = mkOption {
description = "If true, reposition the view so that the current node is initially centralized when entering nvim-tree."; description = "If true, reposition the view so that the current node is initially centralized when entering nvim-tree.";
type = types.bool; type = bool;
default = false; default = false;
}; };
cursorline = mkOption { cursorline = mkOption {
description = "Enable cursorline in nvim-tree window."; description = "Enable cursorline in nvim-tree window.";
type = types.bool; type = bool;
default = true; default = true;
}; };
debounceDelay = mkOption { debounceDelay = mkOption {
type = types.int; type = int;
default = 15; default = 15;
description = '' description = ''
Idle milliseconds before some reload / refresh operations. Idle milliseconds before some reload / refresh operations.
@ -416,7 +417,7 @@ in {
A table (an attribute set in our case, see example) indicates that the view should be dynamically sized based on the A table (an attribute set in our case, see example) indicates that the view should be dynamically sized based on the
longest line. longest line.
''; '';
type = with types; oneOf [int attrs]; type = oneOf [int attrs];
default = 30; default = 30;
example = literalExpression '' example = literalExpression ''
{ {
@ -429,7 +430,7 @@ in {
side = mkOption { side = mkOption {
description = "Side of the tree."; description = "Side of the tree.";
type = types.enum ["left" "right"]; type = enum ["left" "right"];
default = "left"; default = "left";
}; };
@ -438,13 +439,13 @@ in {
Preserves window proportions when opening a file. Preserves window proportions when opening a file.
If `false`, the height and width of windows other than nvim-tree will be equalized. If `false`, the height and width of windows other than nvim-tree will be equalized.
''; '';
type = types.bool; type = bool;
default = false; default = false;
}; };
number = mkOption { number = mkOption {
description = "Print the line number in front of each line."; description = "Print the line number in front of each line.";
type = types.bool; type = bool;
default = false; default = false;
}; };
@ -454,13 +455,13 @@ in {
If the option `view.number` is also `true`, the number on the cursor line If the option `view.number` is also `true`, the number on the cursor line
will be the line number instead of `0`. will be the line number instead of `0`.
''; '';
type = types.bool; type = bool;
default = false; default = false;
}; };
signcolumn = mkOption { signcolumn = mkOption {
description = ''Show diagnostic sign column. Value can be `"yes"`, `"auto"` or`"no"`.''; description = ''Show diagnostic sign column. Value can be `"yes"`, `"auto"` or`"no"`.'';
type = types.enum ["yes" "auto" "no"]; type = enum ["yes" "auto" "no"];
default = "yes"; default = "yes";
}; };
@ -468,23 +469,23 @@ in {
description = "Configuration options for floating window."; description = "Configuration options for floating window.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
enable = mkOption { enable = mkOption {
description = "If true, tree window will be floating."; description = "If true, tree window will be floating.";
type = types.bool; type = bool;
default = false; default = false;
}; };
quitOnFocusLoss = mkOption { quitOnFocusLoss = mkOption {
description = "Close the floating tree window when it loses focus."; description = "Close the floating tree window when it loses focus.";
type = types.bool; type = bool;
default = true; default = true;
}; };
openWinConfig = mkOption { openWinConfig = mkOption {
description = "Floating window config. See `:h nvim_open_win()` for more details."; description = "Floating window config. See `:h nvim_open_win()` for more details.";
type = types.attrs; type = attrs;
default = { default = {
relative = "editor"; relative = "editor";
border = "rounded"; border = "rounded";
@ -505,23 +506,23 @@ in {
addTrailing = mkOption { addTrailing = mkOption {
default = false; default = false;
description = "Appends a trailing slash to folder names."; description = "Appends a trailing slash to folder names.";
type = types.bool; type = bool;
}; };
groupEmpty = mkOption { groupEmpty = mkOption {
default = false; default = false;
description = "Compact folders that only contain a single folder into one node in the file tree."; description = "Compact folders that only contain a single folder into one node in the file tree.";
type = types.bool; type = bool;
}; };
fullName = mkOption { fullName = mkOption {
default = false; default = false;
description = "Display node whose name length is wider than the width of nvim-tree window in floating window."; description = "Display node whose name length is wider than the width of nvim-tree window in floating window.";
type = types.bool; type = bool;
}; };
highlightGit = mkOption { highlightGit = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = '' description = ''
Enable file highlight for git attributes using `NvimTreeGit` highlight groups. Enable file highlight for git attributes using `NvimTreeGit` highlight groups.
@ -531,7 +532,7 @@ in {
}; };
highlightOpenedFiles = mkOption { highlightOpenedFiles = mkOption {
type = types.enum ["none" "icon" "name" "all"]; type = enum ["none" "icon" "name" "all"];
default = "none"; default = "none";
description = '' description = ''
Highlight icons and/or names for bufloaded() files using the Highlight icons and/or names for bufloaded() files using the
@ -540,7 +541,7 @@ in {
}; };
highlightModified = mkOption { highlightModified = mkOption {
type = types.enum ["none" "icon" "name" "all"]; type = enum ["none" "icon" "name" "all"];
default = "none"; default = "none";
description = '' description = ''
Highlight modified files in the tree using `NvimTreeNormal` highlight group. Highlight modified files in the tree using `NvimTreeNormal` highlight group.
@ -549,7 +550,7 @@ in {
}; };
rootFolderLabel = mkOption { rootFolderLabel = mkOption {
type = with types; oneOf [str bool]; type = oneOf [str bool];
default = false; default = false;
example = ''"":~:s?$?/..?"''; example = ''"":~:s?$?/..?"'';
description = '' description = ''
@ -566,7 +567,7 @@ in {
}; };
indentWidth = mkOption { indentWidth = mkOption {
type = with types; addCheck int (x: x >= 1); type = addCheck int (x: x >= 1);
default = 2; default = 2;
description = "Number of spaces for an each tree nesting level. Minimum 1."; description = "Number of spaces for an each tree nesting level. Minimum 1.";
}; };
@ -574,17 +575,17 @@ in {
indentMarkers = mkOption { indentMarkers = mkOption {
description = "Configuration options for tree indent markers."; description = "Configuration options for tree indent markers.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
enable = mkEnableOption "Display indent markers when folders are open."; enable = mkEnableOption "Display indent markers when folders are open.";
inlineArrows = mkOption { inlineArrows = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Display folder arrows in the same column as indent marker when using `renderer.icons.show.folder_arrow`"; description = "Display folder arrows in the same column as indent marker when using `renderer.icons.show.folder_arrow`";
}; };
icons = mkOption { icons = mkOption {
type = types.attrs; type = attrs;
description = "Individual elements of the indent markers"; description = "Individual elements of the indent markers";
default = { default = {
corner = ""; corner = "";
@ -599,13 +600,13 @@ in {
}; };
specialFiles = mkOption { specialFiles = mkOption {
type = with types; listOf str; type = listOf str;
default = ["Cargo.toml" "README.md" "readme.md" "Makefile" "MAKEFILE" "flake.nix"]; # ;) default = ["Cargo.toml" "README.md" "readme.md" "Makefile" "MAKEFILE" "flake.nix"]; # ;)
description = "A list of filenames that gets highlighted with `NvimTreeSpecialFile"; description = "A list of filenames that gets highlighted with `NvimTreeSpecialFile";
}; };
symlinkDestination = mkOption { symlinkDestination = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Whether to show the destination of the symlink."; description = "Whether to show the destination of the symlink.";
}; };
@ -613,53 +614,53 @@ in {
icons = mkOption { icons = mkOption {
description = "Configuration options for icons."; description = "Configuration options for icons.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
webdevColors = mkOption { webdevColors = mkOption {
type = types.bool; type = bool;
description = " Use the webdev icon colors, otherwise `NvimTreeFileIcon`"; description = " Use the webdev icon colors, otherwise `NvimTreeFileIcon`";
default = true; default = true;
}; };
gitPlacement = mkOption { gitPlacement = mkOption {
type = types.enum ["before" "after" "signcolumn"]; type = enum ["before" "after" "signcolumn"];
description = "Place where the git icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled."; description = "Place where the git icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled.";
default = "before"; default = "before";
}; };
modifiedPlacement = mkOption { modifiedPlacement = mkOption {
type = types.enum ["before" "after" "signcolumn"]; type = enum ["before" "after" "signcolumn"];
description = "Place where the modified icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled."; description = "Place where the modified icons will be rendered. `signcolumn` requires `view.signcolumn` to be enabled.";
default = "after"; default = "after";
}; };
padding = mkOption { padding = mkOption {
type = types.str; type = str;
description = "Inserted between icon and filename"; description = "Inserted between icon and filename";
default = " "; default = " ";
}; };
symlinkArrow = mkOption { symlinkArrow = mkOption {
type = types.str; type = str;
description = "Used as a separator between symlinks' source and target."; description = "Used as a separator between symlinks' source and target.";
default = " "; default = " ";
}; };
show = { show = {
file = mkOption { file = mkOption {
type = types.bool; type = bool;
description = "Show an icon before the file name. `nvim-web-devicons` will be used if available."; description = "Show an icon before the file name. `nvim-web-devicons` will be used if available.";
default = true; default = true;
}; };
folder = mkOption { folder = mkOption {
type = types.bool; type = bool;
description = "Show an icon before the folder name."; description = "Show an icon before the folder name.";
default = true; default = true;
}; };
folderArrow = mkOption { folderArrow = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = '' description = ''
Show a small arrow before the folder node. Arrow will be a part of the Show a small arrow before the folder node. Arrow will be a part of the
@ -668,7 +669,7 @@ in {
}; };
git = mkOption { git = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = '' description = ''
Show a git status icon, see `renderer.icons.gitPlacement` Show a git status icon, see `renderer.icons.gitPlacement`
@ -677,7 +678,7 @@ in {
}; };
modified = mkOption { modified = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = '' description = ''
Show a modified icon, see `renderer.icons.modifiedPlacement` Show a modified icon, see `renderer.icons.modifiedPlacement`
@ -692,29 +693,29 @@ in {
to appear in the signcolumn. to appear in the signcolumn.
''; '';
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
default = mkOption { default = mkOption {
type = types.str; type = str;
description = "Glyph for files. Will be overridden by `nvim-web-devicons` if available."; description = "Glyph for files. Will be overridden by `nvim-web-devicons` if available.";
default = ""; default = "";
}; };
symlink = mkOption { symlink = mkOption {
type = types.str; type = str;
description = "Glyph for symlinks."; description = "Glyph for symlinks.";
default = ""; default = "";
}; };
modified = mkOption { modified = mkOption {
type = types.str; type = str;
description = "Icon to display for modified files."; description = "Icon to display for modified files.";
default = ""; default = "";
}; };
# TODO: hardcode each attribute # TODO: hardcode each attribute
folder = mkOption { folder = mkOption {
type = types.attrs; type = attrs;
description = "Glyphs for directories. Recommended to use the defaults unless you know what you are doing."; description = "Glyphs for directories. Recommended to use the defaults unless you know what you are doing.";
default = { default = {
default = ""; default = "";
@ -729,7 +730,7 @@ in {
}; };
git = mkOption { git = mkOption {
type = types.attrs; type = attrs;
description = "Glyphs for git status."; description = "Glyphs for git status.";
default = { default = {
unstaged = ""; unstaged = "";
@ -759,22 +760,22 @@ in {
noBuffer = false; noBuffer = false;
exclude = []; exclude = [];
}; };
type = types.submodule { type = submodule {
options = { options = {
gitIgnored = mkOption { gitIgnored = mkOption {
type = types.bool; type = bool;
description = "Ignore files based on `.gitignore`. Requires git.enable` to be `true`"; description = "Ignore files based on `.gitignore`. Requires git.enable` to be `true`";
default = false; default = false;
}; };
dotfiles = mkOption { dotfiles = mkOption {
type = types.bool; type = bool;
description = "Do not show dotfiles: files starting with a `.`"; description = "Do not show dotfiles: files starting with a `.`";
default = false; default = false;
}; };
gitClean = mkOption { gitClean = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = '' description = ''
@ -784,13 +785,13 @@ in {
}; };
noBuffer = mkOption { noBuffer = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Do not show files that have no `buflisted()` buffer."; description = "Do not show files that have no `buflisted()` buffer.";
}; };
exclude = mkOption { exclude = mkOption {
type = with types; listOf str; type = listOf str;
default = []; default = [];
description = "List of directories or files to exclude from filtering: always show them."; description = "List of directories or files to exclude from filtering: always show them.";
}; };
@ -804,10 +805,10 @@ in {
cmd = "${pkgs.glib}/bin/gio trash"; cmd = "${pkgs.glib}/bin/gio trash";
}; };
type = types.submodule { type = submodule {
options = { options = {
cmd = mkOption { cmd = mkOption {
type = types.str; type = str;
description = "The command used to trash items"; description = "The command used to trash items";
}; };
}; };
@ -817,10 +818,10 @@ in {
actions = mkOption { actions = mkOption {
description = "Configuration for various actions."; description = "Configuration for various actions.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
useSystemClipboard = mkOption { useSystemClipboard = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = '' description = ''
A boolean value that toggle the use of system clipboard when copy/paste A boolean value that toggle the use of system clipboard when copy/paste
@ -833,16 +834,16 @@ in {
changeDir = mkOption { changeDir = mkOption {
description = "vim `change-directory` behaviour"; description = "vim `change-directory` behaviour";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
enable = mkOption { enable = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Change the working directory when changing directories in the tree."; description = "Change the working directory when changing directories in the tree.";
}; };
global = mkOption { global = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = '' description = ''
Use `:cd` instead of `:lcd` when changing directories. Use `:cd` instead of `:lcd` when changing directories.
@ -851,7 +852,7 @@ in {
}; };
restrictAboveCwd = mkOption { restrictAboveCwd = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = '' description = ''
Restrict changing to a directory above the global current working directory. Restrict changing to a directory above the global current working directory.
@ -865,10 +866,10 @@ in {
expandAll = mkOption { expandAll = mkOption {
description = "Configuration for expand_all behaviour."; description = "Configuration for expand_all behaviour.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
maxFolderDiscovery = mkOption { maxFolderDiscovery = mkOption {
type = types.int; type = int;
default = 300; default = 300;
description = '' description = ''
Limit the number of folders being explored when expanding every folders. Limit the number of folders being explored when expanding every folders.
@ -876,7 +877,7 @@ in {
''; '';
}; };
exclude = mkOption { exclude = mkOption {
type = with types; listOf str; type = listOf str;
description = "A list of directories that should not be expanded automatically."; description = "A list of directories that should not be expanded automatically.";
default = [".git" "target" "build" "result"]; default = [".git" "target" "build" "result"];
}; };
@ -888,10 +889,10 @@ in {
filePopup = mkOption { filePopup = mkOption {
description = "Configuration for file_popup behaviour."; description = "Configuration for file_popup behaviour.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
openWinConfig = mkOption { openWinConfig = mkOption {
type = types.attrs; type = attrs;
default = { default = {
col = 1; col = 1;
row = 1; row = 1;
@ -909,22 +910,22 @@ in {
openFile = mkOption { openFile = mkOption {
description = "Configuration options for opening a file from nvim-tree."; description = "Configuration options for opening a file from nvim-tree.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
quitOnOpen = mkOption { quitOnOpen = mkOption {
type = types.bool; type = bool;
description = "Closes the explorer when opening a file."; description = "Closes the explorer when opening a file.";
default = false; default = false;
}; };
eject = mkOption { eject = mkOption {
type = types.bool; type = bool;
description = "Prevent new opened file from opening in the same window as the tree."; description = "Prevent new opened file from opening in the same window as the tree.";
default = false; default = false;
}; };
resizeWindow = mkOption { resizeWindow = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Resizes the tree when opening a file. Previously `view.auto_resize`"; description = "Resizes the tree when opening a file. Previously `view.auto_resize`";
@ -933,16 +934,16 @@ in {
windowPicker = mkOption { windowPicker = mkOption {
description = "window_picker"; description = "window_picker";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
enable = mkOption { enable = mkOption {
type = types.bool; type = bool;
description = "Enable the window picker. If this feature is not enabled, files will open in window from which you last opened the tree."; description = "Enable the window picker. If this feature is not enabled, files will open in window from which you last opened the tree.";
default = false; default = false;
}; };
picker = mkOption { picker = mkOption {
type = types.str; type = str;
default = "default"; default = "default";
description = '' description = ''
Change the default window picker, can be a string `"default"` or a function. Change the default window picker, can be a string `"default"` or a function.
@ -959,20 +960,20 @@ in {
}; };
chars = mkOption { chars = mkOption {
type = types.str; type = str;
description = "A string of chars used as identifiers by the window picker."; description = "A string of chars used as identifiers by the window picker.";
default = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; default = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
}; };
exclude = { exclude = {
filetype = mkOption { filetype = mkOption {
type = with types; listOf str; type = listOf str;
description = "A list of filetypes to exclude from the window picker."; description = "A list of filetypes to exclude from the window picker.";
default = ["notify" "packer" "qf" "diff" "fugitive" "fugitiveblame"]; default = ["notify" "packer" "qf" "diff" "fugitive" "fugitiveblame"];
}; };
buftype = mkOption { buftype = mkOption {
type = with types; listOf str; type = listOf str;
description = "A list of buftypes to exclude from the window picker."; description = "A list of buftypes to exclude from the window picker.";
default = ["nofile" "terminal" "help"]; default = ["nofile" "terminal" "help"];
}; };
@ -986,7 +987,7 @@ in {
removeFile = { removeFile = {
closeWindow = mkOption { closeWindow = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Close any window displaying a file when removing the file from the tree"; description = "Close any window displaying a file when removing the file from the tree";
}; };
@ -1004,16 +1005,16 @@ in {
The filter can be cleared with the `F` key by default. The filter can be cleared with the `F` key by default.
''; '';
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
prefix = mkOption { prefix = mkOption {
type = types.str; type = str;
description = "Prefix of the filter displayed in the buffer."; description = "Prefix of the filter displayed in the buffer.";
default = "[FILTER]: "; default = "[FILTER]: ";
}; };
alwaysShowFolders = mkOption { alwaysShowFolders = mkOption {
type = types.bool; type = bool;
description = "Whether to filter folders or not."; description = "Whether to filter folders or not.";
default = true; default = true;
}; };
@ -1024,15 +1025,15 @@ in {
tab = mkOption { tab = mkOption {
description = "Configuration for tab behaviour."; description = "Configuration for tab behaviour.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
sync = mkOption { sync = mkOption {
description = "Configuration for syncing nvim-tree across tabs."; description = "Configuration for syncing nvim-tree across tabs.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
open = mkOption { open = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = '' description = ''
Opens the tree automatically when switching tabpage or opening a new Opens the tree automatically when switching tabpage or opening a new
@ -1041,7 +1042,7 @@ in {
}; };
close = mkOption { close = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = '' description = ''
Closes the tree across all tabpages when the tree is closed. Closes the tree across all tabpages when the tree is closed.
@ -1049,7 +1050,7 @@ in {
}; };
ignore = mkOption { ignore = mkOption {
type = with types; listOf str; type = listOf str;
default = []; default = [];
description = '' description = ''
List of filetypes or buffer names on new tab that will prevent List of filetypes or buffer names on new tab that will prevent
@ -1066,16 +1067,16 @@ in {
notify = mkOption { notify = mkOption {
description = "Configuration for notifications."; description = "Configuration for notifications.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
threshold = mkOption { threshold = mkOption {
type = types.enum ["ERROR" "WARNING" "INFO" "DEBUG"]; type = enum ["ERROR" "WARNING" "INFO" "DEBUG"];
description = "Specify minimum notification level, uses the values from `vim.log.levels`"; description = "Specify minimum notification level, uses the values from `vim.log.levels`";
default = "INFO"; default = "INFO";
}; };
absolutePath = mkOption { absolutePath = mkOption {
type = types.bool; type = bool;
description = "Whether to use absolute paths or item names in fs action notifications."; description = "Whether to use absolute paths or item names in fs action notifications.";
default = true; default = true;
}; };
@ -1086,17 +1087,17 @@ in {
ui = mkOption { ui = mkOption {
description = "General UI configuration."; description = "General UI configuration.";
default = {}; default = {};
type = types.submodule { type = submodule {
options = { options = {
confirm = { confirm = {
remove = mkOption { remove = mkOption {
type = types.bool; type = bool;
description = "Prompt before removing."; description = "Prompt before removing.";
default = true; default = true;
}; };
trash = mkOption { trash = mkOption {
type = types.bool; type = bool;
description = "Prompt before trash."; description = "Prompt before trash.";
default = true; default = true;
}; };
@ -1109,7 +1110,7 @@ in {
openOnSetup = mkOption { openOnSetup = mkOption {
default = true; default = true;
description = "Open when vim is started on a directory"; description = "Open when vim is started on a directory";
type = types.bool; type = bool;
}; };
}; };
} }

View file

@ -9,6 +9,7 @@
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.types) enum either package listOf str bool; inherit (lib.types) enum either package listOf str bool;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) diagnostics mkGrammarOption;
cfg = config.vim.languages.bash; cfg = config.vim.languages.bash;
@ -45,8 +46,8 @@
}; };
}; };
defaultDiagnostics = ["shellcheck"]; defaultDiagnosticsProvider = ["shellcheck"];
diagnostics = { diagnosticsProviders = {
shellcheck = { shellcheck = {
package = pkgs.shellcheck; package = pkgs.shellcheck;
nullConfig = pkg: '' nullConfig = pkg: ''
@ -65,7 +66,7 @@ in {
treesitter = { treesitter = {
enable = mkEnableOption "Bash treesitter" // {default = config.vim.languages.enableTreesitter;}; enable = mkEnableOption "Bash treesitter" // {default = config.vim.languages.enableTreesitter;};
package = lib.nvim.types.mkGrammarOption pkgs "bash"; package = mkGrammarOption pkgs "bash";
}; };
lsp = { lsp = {
@ -106,10 +107,10 @@ in {
extraDiagnostics = { extraDiagnostics = {
enable = mkEnableOption "extra Bash diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; enable = mkEnableOption "extra Bash diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = lib.nvim.types.diagnostics { types = diagnostics {
langDesc = "Bash"; langDesc = "Bash";
inherit diagnostics; inherit diagnosticsProviders;
inherit defaultDiagnostics; inherit defaultDiagnosticsProvider;
}; };
}; };
}; };

View file

@ -7,9 +7,10 @@
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) diagnosticsToLua;
cfg = config.vim.languages.bash; cfg = config.vim.languages.bash;
diagnostics = { diagnosticsProviders = {
shellcheck = { shellcheck = {
package = pkgs.shellcheck; package = pkgs.shellcheck;
nullConfig = pkg: '' nullConfig = pkg: ''
@ -72,10 +73,10 @@ in {
(mkIf cfg.extraDiagnostics.enable { (mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true; vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua { vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "bash"; lang = "bash";
config = cfg.extraDiagnostics.types; config = cfg.extraDiagnostics.types;
inherit diagnostics; inherit diagnosticsProviders;
}; };
}) })
]); ]);

View file

@ -6,15 +6,17 @@
}: let }: let
inherit (builtins) attrNames; inherit (builtins) attrNames;
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib) nvim;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool enum package either listOf str nullOr; inherit (lib.types) bool enum package either listOf str nullOr;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.dag) entryAnywhere;
packageToCmd = package: defaultCmd: packageToCmd = package: defaultCmd:
if isList cfg.lsp.package if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package then expToLua cfg.lsp.package
else ''{ "${cfg.lsp.package}/bin/${defaultCmd}" }''; else ''{ "${cfg.lsp.package}/bin/${defaultCmd}" }'';
cfg = config.vim.languages.clang; cfg = config.vim.languages.clang;
@ -91,8 +93,8 @@ in {
treesitter = { treesitter = {
enable = mkEnableOption "C/C++ treesitter" // {default = config.vim.languages.enableTreesitter;}; enable = mkEnableOption "C/C++ treesitter" // {default = config.vim.languages.enableTreesitter;};
cPackage = nvim.types.mkGrammarOption pkgs "c"; cPackage = mkGrammarOption pkgs "c";
cppPackage = nvim.types.mkGrammarOption pkgs "cpp"; cppPackage = mkGrammarOption pkgs "cpp";
}; };
lsp = { lsp = {
@ -139,7 +141,7 @@ in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
(mkIf cfg.cHeader { (mkIf cfg.cHeader {
vim.configRC.c-header = nvim.dag.entryAnywhere "let g:c_syntax_for_h = 1"; vim.configRC.c-header = entryAnywhere "let g:c_syntax_for_h = 1";
}) })
(mkIf cfg.treesitter.enable { (mkIf cfg.treesitter.enable {

View file

@ -10,8 +10,10 @@
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.strings) optionalString; inherit (lib.strings) optionalString;
inherit (lib.types) enum either listOf package str; inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.dag) entryAnywhere; inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) diagnosticsToLua;
cfg = config.vim.languages.nix; cfg = config.vim.languages.nix;
@ -21,7 +23,7 @@
defaultServer = "nil"; defaultServer = "nil";
packageToCmd = package: defaultCmd: packageToCmd = package: defaultCmd:
if isList package if isList package
then lib.nvim.lua.expToLua package then expToLua package
else ''{"${package}/bin/${defaultCmd}"}''; else ''{"${package}/bin/${defaultCmd}"}'';
servers = { servers = {
rnix = { rnix = {
@ -95,8 +97,8 @@
}; };
}; };
defaultDiagnostics = ["statix" "deadnix"]; defaultDiagnosticsProvider = ["statix" "deadnix"];
diagnostics = { diagnosticsProviders = {
statix = { statix = {
package = pkgs.statix; package = pkgs.statix;
nullConfig = pkg: '' nullConfig = pkg: ''
@ -164,10 +166,10 @@ in {
extraDiagnostics = { extraDiagnostics = {
enable = mkEnableOption "extra Nix diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; enable = mkEnableOption "extra Nix diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = lib.nvim.types.diagnostics { types = diagnostics {
langDesc = "Nix"; langDesc = "Nix";
inherit diagnostics; inherit diagnosticsProviders;
inherit defaultDiagnostics; inherit defaultDiagnosticsProvider;
}; };
}; };
}; };
@ -196,10 +198,10 @@ in {
(mkIf cfg.extraDiagnostics.enable { (mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true; vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua { vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "nix"; lang = "nix";
config = cfg.extraDiagnostics.types; config = cfg.extraDiagnostics.types;
inherit diagnostics; inherit diagnosticsProviders;
}; };
}) })
]); ]);

View file

@ -4,7 +4,15 @@
lib, lib,
... ...
}: let }: let
inherit (lib) isList nvim mkEnableOption mkOption types mkIf mkMerge optionalString boolToString optionals; inherit (lib.modules) mkIf mkMerge;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
inherit (lib.lists) isList optionals;
inherit (lib.types) bool package str listOf either;
inherit (lib.nvim.types) mkGrammarOption;
inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.languages.rust; cfg = config.vim.languages.rust;
in { in {
@ -13,14 +21,14 @@ in {
treesitter = { treesitter = {
enable = mkEnableOption "Rust treesitter" // {default = config.vim.languages.enableTreesitter;}; enable = mkEnableOption "Rust treesitter" // {default = config.vim.languages.enableTreesitter;};
package = nvim.types.mkGrammarOption pkgs "rust"; package = mkGrammarOption pkgs "rust";
}; };
crates = { crates = {
enable = mkEnableOption "crates-nvim, tools for managing dependencies"; enable = mkEnableOption "crates-nvim, tools for managing dependencies";
codeActions = mkOption { codeActions = mkOption {
description = "Enable code actions through null-ls"; description = "Enable code actions through null-ls";
type = types.bool; type = bool;
default = true; default = true;
}; };
}; };
@ -30,13 +38,13 @@ in {
package = mkOption { package = mkOption {
description = "rust-analyzer package, or the command to run as a list of strings"; description = "rust-analyzer package, or the command to run as a list of strings";
example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]''; example = ''[lib.getExe pkgs.jdt-language-server "-data" "~/.cache/jdtls/workspace"]'';
type = with types; either package (listOf str); type = either package (listOf str);
default = pkgs.rust-analyzer; default = pkgs.rust-analyzer;
}; };
opts = mkOption { opts = mkOption {
description = "Options to pass to rust analyzer"; description = "Options to pass to rust analyzer";
type = types.str; type = str;
default = ""; default = "";
}; };
}; };
@ -44,13 +52,13 @@ in {
dap = { dap = {
enable = mkOption { enable = mkOption {
description = "Rust Debug Adapter support"; description = "Rust Debug Adapter support";
type = types.bool; type = bool;
default = config.vim.languages.enableDAP; default = config.vim.languages.enableDAP;
}; };
package = mkOption { package = mkOption {
description = "lldb pacakge"; description = "lldb pacakge";
type = types.package; type = package;
default = pkgs.lldb; default = pkgs.lldb;
}; };
}; };
@ -62,7 +70,7 @@ in {
startPlugins = ["crates-nvim"]; startPlugins = ["crates-nvim"];
lsp.null-ls.enable = mkIf cfg.crates.codeActions true; lsp.null-ls.enable = mkIf cfg.crates.codeActions true;
autocomplete.sources = {"crates" = "[Crates]";}; autocomplete.sources = {"crates" = "[Crates]";};
luaConfigRC.rust-crates = nvim.dag.entryAnywhere '' luaConfigRC.rust-crates = entryAnywhere ''
require('crates').setup { require('crates').setup {
null_ls = { null_ls = {
enabled = ${boolToString cfg.crates.codeActions}, enabled = ${boolToString cfg.crates.codeActions},
@ -125,7 +133,7 @@ in {
on_attach = rust_on_attach, on_attach = rust_on_attach,
cmd = ${ cmd = ${
if isList cfg.lsp.package if isList cfg.lsp.package
then nvim.lua.expToLua cfg.lsp.package then expToLua cfg.lsp.package
else ''{"${cfg.lsp.package}/bin/rust-analyzer"}'' else ''{"${cfg.lsp.package}/bin/rust-analyzer"}''
}, },
settings = { settings = {

View file

@ -10,6 +10,8 @@
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.types) enum either listOf package str; inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.nvim.types) diagnostics;
cfg = config.vim.languages.sql; cfg = config.vim.languages.sql;
sqlfluffDefault = pkgs.sqlfluff; sqlfluffDefault = pkgs.sqlfluff;
@ -51,8 +53,8 @@
}; };
}; };
defaultDiagnostics = ["sqlfluff"]; defaultDiagnosticsProvider = ["sqlfluff"];
diagnostics = { diagnosticsProviders = {
sqlfluff = { sqlfluff = {
package = sqlfluffDefault; package = sqlfluffDefault;
nullConfig = pkg: '' nullConfig = pkg: ''
@ -122,10 +124,10 @@ in {
extraDiagnostics = { extraDiagnostics = {
enable = mkEnableOption "extra SQL diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; enable = mkEnableOption "extra SQL diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = lib.nvim.types.diagnostics { types = diagnostics {
langDesc = "SQL"; langDesc = "SQL";
inherit diagnostics; inherit diagnosticsProviders;
inherit defaultDiagnostics; inherit defaultDiagnosticsProvider;
}; };
}; };
}; };
@ -154,10 +156,10 @@ in {
(mkIf cfg.extraDiagnostics.enable { (mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true; vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua { vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "sql"; lang = "sql";
config = cfg.extraDiagnostics.types; config = cfg.extraDiagnostics.types;
inherit diagnostics; inherit diagnosticsProviders;
}; };
}) })
]); ]);

View file

@ -8,9 +8,11 @@
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.meta) getExe;
inherit (lib.types) enum either listOf package str; inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.languages) diagnosticsToLua;
inherit (lib.nvim.types) mkGrammarOption diagnostics;
cfg = config.vim.languages.svelte; cfg = config.vim.languages.svelte;
@ -49,15 +51,15 @@
}; };
# TODO: specify packages # TODO: specify packages
defaultDiagnostics = ["eslint_d"]; defaultDiagnosticsProvider = ["eslint_d"];
diagnostics = { diagnosticsProviders = {
eslint_d = { eslint_d = {
package = pkgs.nodePackages.eslint_d; package = pkgs.nodePackages.eslint_d;
nullConfig = pkg: '' nullConfig = pkg: ''
table.insert( table.insert(
ls_sources, ls_sources,
null_ls.builtins.diagnostics.eslint_d.with({ null_ls.builtins.diagnostics.eslint_d.with({
command = "${lib.getExe pkg}", command = "${getExe pkg}",
}) })
) )
''; '';
@ -109,10 +111,10 @@ in {
extraDiagnostics = { extraDiagnostics = {
enable = mkEnableOption "extra Svelte diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; enable = mkEnableOption "extra Svelte diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = lib.nvim.types.diagnostics { types = diagnostics {
langDesc = "Svelte"; langDesc = "Svelte";
inherit diagnostics; inherit diagnosticsProviders;
inherit defaultDiagnostics; inherit defaultDiagnosticsProvider;
}; };
}; };
}; };
@ -135,10 +137,10 @@ in {
(mkIf cfg.extraDiagnostics.enable { (mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true; vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua { vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "svelte"; lang = "svelte";
config = cfg.extraDiagnostics.types; config = cfg.extraDiagnostics.types;
inherit diagnostics; inherit diagnosticsProviders;
}; };
}) })
]); ]);

View file

@ -4,7 +4,7 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf; inherit (lib.modules) mkIf;
cfg = config.vim.tidal; cfg = config.vim.tidal;
in { in {

View file

@ -3,20 +3,21 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkEnableOption mkOption types; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) int bool;
in { in {
options.vim.tidal = { options.vim.tidal = {
enable = mkEnableOption "tidalcycles tools and plugins"; enable = mkEnableOption "tidalcycles tools and plugins";
flash = mkOption { flash = mkOption {
description = ''When sending a paragraph or a single line, vim-tidal will "flash" the selection for some milliseconds''; description = ''When sending a paragraph or a single line, vim-tidal will "flash" the selection for some milliseconds'';
type = types.int; type = int;
default = 150; default = 150;
}; };
openSC = mkOption { openSC = mkOption {
description = "Automatically run the supercollider CLI, sclang, alongside the Tidal GHCI terminal."; description = "Automatically run the supercollider CLI, sclang, alongside the Tidal GHCI terminal.";
type = types.bool; type = bool;
default = true; default = true;
}; };
}; };

View file

@ -8,9 +8,11 @@
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.lists) isList; inherit (lib.lists) isList;
inherit (lib.meta) getExe;
inherit (lib.types) enum either listOf package str; inherit (lib.types) enum either listOf package str;
inherit (lib.nvim.lua) expToLua; inherit (lib.nvim.lua) expToLua;
inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.types) mkGrammarOption diagnostics;
inherit (lib.nvim.languages) diagnosticsToLua;
cfg = config.vim.languages.ts; cfg = config.vim.languages.ts;
@ -75,15 +77,15 @@
}; };
# TODO: specify packages # TODO: specify packages
defaultDiagnostics = ["eslint_d"]; defaultDiagnosticsProvider = ["eslint_d"];
diagnostics = { diagnosticsProviders = {
eslint_d = { eslint_d = {
package = pkgs.nodePackages.eslint_d; package = pkgs.nodePackages.eslint_d;
nullConfig = pkg: '' nullConfig = pkg: ''
table.insert( table.insert(
ls_sources, ls_sources,
null_ls.builtins.diagnostics.eslint_d.with({ null_ls.builtins.diagnostics.eslint_d.with({
command = "${lib.getExe pkg}", command = "${getExe pkg}",
}) })
) )
''; '';
@ -135,10 +137,10 @@ in {
extraDiagnostics = { extraDiagnostics = {
enable = mkEnableOption "extra Typescript/Javascript diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;}; enable = mkEnableOption "extra Typescript/Javascript diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
types = lib.nvim.types.diagnostics { types = diagnostics {
langDesc = "Typescript/Javascript"; langDesc = "Typescript/Javascript";
inherit diagnostics; inherit diagnosticsProviders;
inherit defaultDiagnostics; inherit defaultDiagnosticsProvider;
}; };
}; };
}; };
@ -161,10 +163,10 @@ in {
(mkIf cfg.extraDiagnostics.enable { (mkIf cfg.extraDiagnostics.enable {
vim.lsp.null-ls.enable = true; vim.lsp.null-ls.enable = true;
vim.lsp.null-ls.sources = lib.nvim.languages.diagnosticsToLua { vim.lsp.null-ls.sources = diagnosticsToLua {
lang = "ts"; lang = "ts";
config = cfg.extraDiagnostics.types; config = cfg.extraDiagnostics.types;
inherit diagnostics; inherit diagnosticsProviders;
}; };
}) })
]); ]);

View file

@ -4,7 +4,11 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) addDescriptionsToMappings mkIf optional boolToString optionalString; inherit (lib.modules) mkIf;
inherit (lib.lists) optional;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) addDescriptionsToMappings;
cfg = config.vim.lsp; cfg = config.vim.lsp;
usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp"; usingNvimCmp = config.vim.autocomplete.enable && config.vim.autocomplete.type == "nvim-cmp";

View file

@ -3,7 +3,9 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf mkMerge nvim mapAttrs; inherit (lib.modules) mkIf mkMerge;
inherit (lib.attrsets) mapAttrs;
inherit (lib.nvim.dag) entryAnywhere entryAfter entryBetween;
cfg = config.vim.lsp; cfg = config.vim.lsp;
in { in {
@ -13,14 +15,14 @@ in {
lsp.enable = true; lsp.enable = true;
startPlugins = ["none-ls"]; startPlugins = ["none-ls"];
luaConfigRC.null_ls-setup = nvim.dag.entryAnywhere '' luaConfigRC.null_ls-setup = entryAnywhere ''
local null_ls = require("null-ls") local null_ls = require("null-ls")
local null_helpers = require("null-ls.helpers") local null_helpers = require("null-ls.helpers")
local null_methods = require("null-ls.methods") local null_methods = require("null-ls.methods")
local ls_sources = {} local ls_sources = {}
''; '';
luaConfigRC.null_ls = nvim.dag.entryAfter ["null_ls-setup" "lsp-setup"] '' luaConfigRC.null_ls = entryAfter ["null_ls-setup" "lsp-setup"] ''
require('null-ls').setup({ require('null-ls').setup({
debug = false, debug = false,
diagnostics_format = "[#{m}] #{s} (#{c})", diagnostics_format = "[#{m}] #{s} (#{c})",
@ -33,7 +35,7 @@ in {
}; };
} }
{ {
vim.luaConfigRC = mapAttrs (_: v: (nvim.dag.entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources; vim.luaConfigRC = mapAttrs (_: v: (entryBetween ["null_ls"] ["null_ls-setup"] v)) cfg.null-ls.sources;
} }
]); ]);
} }

View file

@ -3,17 +3,19 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf nvim boolToString;
inherit (lib.nvim.lua) listToLuaTable;
inherit (lib.strings) escapeNixString;
inherit (builtins) toString; inherit (builtins) toString;
inherit (lib.modules) mkIf;
inherit (lib.trivial) boolToString;
inherit (lib.strings) escapeNixString;
inherit (lib.nvim.lua) listToLuaTable;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.presence.neocord; cfg = config.vim.presence.neocord;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["neocord"]; vim.startPlugins = ["neocord"];
vim.luaConfigRC.neocord = nvim.dag.entryAnywhere '' vim.luaConfigRC.neocord = entryAnywhere ''
-- Description of each option can be found in https://github.com/IogaMaster/neocord#lua -- Description of each option can be found in https://github.com/IogaMaster/neocord#lua
require("neocord").setup({ require("neocord").setup({
-- General options -- General options

View file

@ -1,5 +1,7 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption mkOption types literalExpression mkRemovedOptionModule; inherit (lib.modules) mkRemovedOptionModule;
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.types) bool int str enum nullOr listOf;
in { in {
imports = [ imports = [
(mkRemovedOptionModule ["vim" "presence" "presence-nvim"] '' (mkRemovedOptionModule ["vim" "presence" "presence-nvim"] ''
@ -14,7 +16,7 @@ in {
enable = mkEnableOption "neocord plugin for discord rich presence"; enable = mkEnableOption "neocord plugin for discord rich presence";
logo = mkOption { logo = mkOption {
type = types.str; # TODO: can the default be documented better, maybe with an enum? type = str; # TODO: can the default be documented better, maybe with an enum?
default = "auto"; default = "auto";
description = '' description = ''
Logo to be displayed on the RPC item Logo to be displayed on the RPC item
@ -24,55 +26,55 @@ in {
}; };
logo_tooltip = mkOption { logo_tooltip = mkOption {
type = types.str; type = str;
default = "The One True Text Editor"; default = "The One True Text Editor";
description = "Text displayed when hovering over the Neovim image"; description = "Text displayed when hovering over the Neovim image";
}; };
main_image = mkOption { main_image = mkOption {
type = types.enum ["language" "logo"]; type = enum ["language" "logo"];
default = "language"; default = "language";
description = "Main image to be displayed"; description = "Main image to be displayed";
}; };
client_id = mkOption { client_id = mkOption {
type = types.str; type = str;
default = "1157438221865717891"; default = "1157438221865717891";
description = "Client ID of the application"; description = "Client ID of the application";
}; };
log_level = mkOption { log_level = mkOption {
type = with types; nullOr (enum ["debug" "info" "warn" "error"]); type = nullOr (enum ["debug" "info" "warn" "error"]);
default = null; default = null;
description = "Log level to be used by the plugin"; description = "Log level to be used by the plugin";
}; };
debounce_timeout = mkOption { debounce_timeout = mkOption {
type = types.int; type = int;
default = 10; default = 10;
description = "Number of seconds to debounce events"; description = "Number of seconds to debounce events";
}; };
auto_update = mkOption { auto_update = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Automatically update the presence"; description = "Automatically update the presence";
}; };
enable_line_number = mkOption { enable_line_number = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Show line number on the RPC item"; description = "Show line number on the RPC item";
}; };
show_time = mkOption { show_time = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Show time on the RPC item"; description = "Show time on the RPC item";
}; };
blacklist = mkOption { blacklist = mkOption {
type = with types; listOf str; type = listOf str;
default = []; default = [];
example = literalExpression ''["Alpha"]''; example = literalExpression ''["Alpha"]'';
description = "List of filetypes to ignore"; description = "List of filetypes to ignore";
@ -80,49 +82,49 @@ in {
rich_presence = { rich_presence = {
editing_text = mkOption { editing_text = mkOption {
type = types.str; type = str;
default = "Editing %s"; default = "Editing %s";
description = "Text displayed when editing a file"; description = "Text displayed when editing a file";
}; };
file_explorer_text = mkOption { file_explorer_text = mkOption {
type = types.str; type = str;
default = "Browsing %s"; default = "Browsing %s";
description = "Text displayed when browsing files"; description = "Text displayed when browsing files";
}; };
git_commit_text = mkOption { git_commit_text = mkOption {
type = types.str; type = str;
default = "Committing changes"; default = "Committing changes";
description = "Text displayed when committing changes"; description = "Text displayed when committing changes";
}; };
plugin_manager_text = mkOption { plugin_manager_text = mkOption {
type = types.str; type = str;
default = "Managing plugins"; default = "Managing plugins";
description = "Text displayed when managing plugins"; description = "Text displayed when managing plugins";
}; };
reading_text = mkOption { reading_text = mkOption {
type = types.str; type = str;
default = "Reading %s"; default = "Reading %s";
description = "Text displayed when reading a file"; description = "Text displayed when reading a file";
}; };
workspace_text = mkOption { workspace_text = mkOption {
type = types.str; type = str;
default = "Working on %s"; default = "Working on %s";
description = "Text displayed when working on a project"; description = "Text displayed when working on a project";
}; };
line_number_text = mkOption { line_number_text = mkOption {
type = types.str; type = str;
default = "Line %s out of %s"; default = "Line %s out of %s";
description = "Text displayed when showing line number"; description = "Text displayed when showing line number";
}; };
terminal_text = mkOption { terminal_text = mkOption {
type = types.str; type = str;
default = "Working on the terminal"; default = "Working on the terminal";
description = "Text displayed when working on the terminal"; description = "Text displayed when working on the terminal";
}; };

View file

@ -4,6 +4,7 @@
... ...
}: let }: let
inherit (lib.options) mkOption mkEnableOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.lists) optionals;
inherit (lib.types) enum; inherit (lib.types) enum;
cfg = config.vim.ui.borders; cfg = config.vim.ui.borders;
@ -27,7 +28,7 @@ in {
enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;}; enable = mkEnableOption "borders for the ${name} plugin" // {default = cfg.enable;};
style = mkOption { style = mkOption {
type = enum (defaultStyles ++ lib.optionals (name != "which-key") ["shadow"]); type = enum (defaultStyles ++ optionals (name != "which-key") ["shadow"]);
default = cfg.globalStyle; default = cfg.globalStyle;
description = "The border style to use for the ${name} plugin"; description = "The border style to use for the ${name} plugin";
}; };

View file

@ -1,5 +1,5 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption; inherit (lib.options) mkEnableOption;
in { in {
options.vim.ui.noice = { options.vim.ui.noice = {
enable = mkEnableOption "UI modification library [noice.nvim]"; enable = mkEnableOption "UI modification library [noice.nvim]";

View file

@ -3,7 +3,7 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkEnableOption; inherit (lib.options) mkEnableOption;
in { in {
options.vim.binds.cheatsheet = { options.vim.binds.cheatsheet = {
enable = mkEnableOption "cheatsheet-nvim: searchable cheatsheet for nvim using telescope"; enable = mkEnableOption "cheatsheet-nvim: searchable cheatsheet for nvim using telescope";

View file

@ -3,14 +3,15 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf nvim; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.binds.cheatsheet; cfg = config.vim.binds.cheatsheet;
in { in {
config = mkIf (cfg.enable) { config = mkIf (cfg.enable) {
vim.startPlugins = ["cheatsheet-nvim"]; vim.startPlugins = ["cheatsheet-nvim"];
vim.luaConfigRC.cheaetsheet-nvim = nvim.dag.entryAnywhere '' vim.luaConfigRC.cheaetsheet-nvim = entryAnywhere ''
require('cheatsheet').setup({}) require('cheatsheet').setup({})
''; '';
}; };

View file

@ -1,5 +1,6 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption mkMappingOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in { in {
options.vim.utility.ccc = { options.vim.utility.ccc = {
enable = mkEnableOption "ccc color picker for neovim"; enable = mkEnableOption "ccc color picker for neovim";

View file

@ -3,20 +3,17 @@
lib, lib,
... ...
}: let }: let
inherit (lib) addDescriptionsToMappings mkIf nvim; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.ccc; cfg = config.vim.utility.ccc;
self = import ./ccc.nix {inherit lib;};
mappingDefinitions = self.options.vim.utility.ccc.mappings;
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
in { in {
config = mkIf (cfg.enable) { config = mkIf (cfg.enable) {
vim.startPlugins = [ vim.startPlugins = [
"ccc" "ccc"
]; ];
vim.luaConfigRC.ccc = nvim.dag.entryAnywhere '' vim.luaConfigRC.ccc = entryAnywhere ''
local ccc = require("ccc") local ccc = require("ccc")
ccc.setup { ccc.setup {
highlighter = { highlighter = {

View file

@ -3,7 +3,7 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf nvim; inherit (lib.modules) mkIf;
cfg = config.vim.utility.diffview-nvim; cfg = config.vim.utility.diffview-nvim;
in { in {
@ -12,9 +12,5 @@ in {
"diffview-nvim" "diffview-nvim"
"plenary-nvim" "plenary-nvim"
]; ];
vim.luaConfigRC.diffview-nvim =
nvim.dag.entryAnywhere ''
'';
}; };
} }

View file

@ -1,5 +1,5 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption; inherit (lib.options) mkEnableOption;
in { in {
options.vim.utility.diffview-nvim = { options.vim.utility.diffview-nvim = {
enable = mkEnableOption "diffview-nvim: cycle through diffs for all modified files for any git rev"; enable = mkEnableOption "diffview-nvim: cycle through diffs for all modified files for any git rev";

View file

@ -3,7 +3,9 @@
lib, lib,
... ...
}: let }: let
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetLuaBinding nvim; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLuaBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.gestures.gesture-nvim; cfg = config.vim.gestures.gesture-nvim;
@ -23,7 +25,7 @@ in {
}) })
]; ];
vim.luaConfigRC.gesture-nvim = nvim.dag.entryAnywhere '' vim.luaConfigRC.gesture-nvim = entryAnywhere ''
vim.opt.mouse = "a" vim.opt.mouse = "a"
local gesture = require("gesture") local gesture = require("gesture")

View file

@ -1,5 +1,6 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption mkMappingOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in { in {
options.vim.gestures.gesture-nvim = { options.vim.gestures.gesture-nvim = {
enable = mkEnableOption "gesture-nvim: mouse gestures"; enable = mkEnableOption "gesture-nvim: mouse gestures";

View file

@ -3,7 +3,8 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf nvim; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.icon-picker; cfg = config.vim.utility.icon-picker;
in { in {
@ -13,7 +14,7 @@ in {
"dressing-nvim" "dressing-nvim"
]; ];
vim.luaConfigRC.icon-picker = nvim.dag.entryAnywhere '' vim.luaConfigRC.icon-picker = entryAnywhere ''
require("icon-picker").setup({ require("icon-picker").setup({
disable_legacy_commands = true disable_legacy_commands = true
}) })

View file

@ -1,5 +1,5 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption; inherit (lib.options) mkEnableOption;
in { in {
options.vim.utility.icon-picker = { options.vim.utility.icon-picker = {
enable = mkEnableOption "nerdfonts icon picker for nvim"; enable = mkEnableOption "nerdfonts icon picker for nvim";

View file

@ -3,7 +3,9 @@
lib, lib,
... ...
}: let }: let
inherit (lib) addDescriptionsToMappings mkIf mkSetBinding nvim; inherit (lib.modules) mkIf;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.motion.hop; cfg = config.vim.utility.motion.hop;
@ -17,7 +19,7 @@ in {
vim.maps.normal = mkSetBinding mappings.hop "<cmd> HopPattern<CR>"; vim.maps.normal = mkSetBinding mappings.hop "<cmd> HopPattern<CR>";
vim.luaConfigRC.hop-nvim = nvim.dag.entryAnywhere '' vim.luaConfigRC.hop-nvim = entryAnywhere ''
require('hop').setup() require('hop').setup()
''; '';
}; };

View file

@ -1,5 +1,6 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkMappingOption mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in { in {
options.vim.utility.motion.hop = { options.vim.utility.motion.hop = {
mappings = { mappings = {

View file

@ -3,7 +3,9 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf mkMerge mkBinding nvim; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.motion.leap; cfg = config.vim.utility.motion.leap;
in { in {
@ -35,7 +37,7 @@ in {
(mkBinding cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window") (mkBinding cfg.mappings.leapFromWindow "<Plug>(leap-from-window)" "Leap from window")
]; ];
vim.luaConfigRC.leap-nvim = nvim.dag.entryAnywhere '' vim.luaConfigRC.leap-nvim = entryAnywhere ''
require('leap').opts = { require('leap').opts = {
max_phase_one_targets = nil, max_phase_one_targets = nil,
highlight_unlabeled_phase_one_targets = false, highlight_unlabeled_phase_one_targets = false,

View file

@ -1,32 +1,33 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption mkOption types; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) nullOr str;
in { in {
options.vim.utility.motion.leap = { options.vim.utility.motion.leap = {
enable = mkEnableOption "leap.nvim plugin (easy motion)"; enable = mkEnableOption "leap.nvim plugin (easy motion)";
mappings = { mappings = {
leapForwardTo = mkOption { leapForwardTo = mkOption {
type = types.nullOr types.str; type = nullOr str;
description = "Leap forward to"; description = "Leap forward to";
default = "s"; default = "s";
}; };
leapBackwardTo = mkOption { leapBackwardTo = mkOption {
type = types.nullOr types.str; type = nullOr str;
description = "Leap backward to"; description = "Leap backward to";
default = "S"; default = "S";
}; };
leapForwardTill = mkOption { leapForwardTill = mkOption {
type = types.nullOr types.str; type = nullOr str;
description = "Leap forward till"; description = "Leap forward till";
default = "x"; default = "x";
}; };
leapBackwardTill = mkOption { leapBackwardTill = mkOption {
type = types.nullOr types.str; type = nullOr str;
description = "Leap backward till"; description = "Leap backward till";
default = "X"; default = "X";
}; };
leapFromWindow = mkOption { leapFromWindow = mkOption {
type = types.nullOr types.str; type = nullOr str;
description = "Leap from window"; description = "Leap from window";
default = "gs"; default = "gs";
}; };

View file

@ -4,7 +4,11 @@
lib, lib,
... ...
}: let }: let
inherit (lib) nvim mkIf mkMerge mkBinding pushDownDefault; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
# TODO: move this to its own module
inherit (lib) pushDownDefault;
cfg = config.vim.utility.preview.glow; cfg = config.vim.utility.preview.glow;
self = import ./glow.nix { self = import ./glow.nix {
@ -23,7 +27,7 @@ in {
"<leader>pm" = "+Preview Markdown"; "<leader>pm" = "+Preview Markdown";
}; };
vim.luaConfigRC.glow = nvim.dag.entryAnywhere '' vim.luaConfigRC.glow = entryAnywhere ''
require('glow').setup({ require('glow').setup({
glow_path = "${pkgs.glow}/bin/glow" glow_path = "${pkgs.glow}/bin/glow"
}); });

View file

@ -1,5 +1,7 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkEnableOption mkMappingOption mkRenamedOptionModule; inherit (lib.modules) mkRenamedOptionModule;
inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in { in {
imports = [ imports = [
(mkRenamedOptionModule ["vim" "languages" "markdown" "glow" "enable"] ["vim" "utility" "preview" "glow" "enable"]) (mkRenamedOptionModule ["vim" "languages" "markdown" "glow" "enable"] ["vim" "utility" "preview" "glow" "enable"])

View file

@ -4,15 +4,17 @@
lib, lib,
... ...
}: let }: let
inherit (lib) nvim mkIf concatMapStringsSep optionalString stringLength; inherit (lib.strings) optionalString stringLength concatMapStringsSep;
inherit (nvim.vim) mkVimBool; inherit (lib.modules) mkIf;
inherit (lib.nvim.vim) mkVimBool;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.preview.markdownPreview; cfg = config.vim.utility.preview.markdownPreview;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = [pkgs.vimPlugins.markdown-preview-nvim]; vim.startPlugins = [pkgs.vimPlugins.markdown-preview-nvim];
vim.configRC.markdown-preview = nvim.dag.entryAnywhere '' vim.configRC.markdown-preview = entryAnywhere ''
let g:mkdp_auto_start = ${mkVimBool cfg.autoStart} let g:mkdp_auto_start = ${mkVimBool cfg.autoStart}
let g:mkdp_auto_close = ${mkVimBool cfg.autoClose} let g:mkdp_auto_close = ${mkVimBool cfg.autoClose}
let g:mkdp_refresh_slow = ${mkVimBool cfg.lazyRefresh} let g:mkdp_refresh_slow = ${mkVimBool cfg.lazyRefresh}

View file

@ -1,54 +1,55 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) types mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) bool str listOf;
in { in {
options.vim.utility.preview = { options.vim.utility.preview = {
markdownPreview = { markdownPreview = {
enable = mkEnableOption "Markdown preview in neovim with markdown-preview.nvim"; enable = mkEnableOption "Markdown preview in neovim with markdown-preview.nvim";
autoStart = mkOption { autoStart = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Automatically open the preview window after entering a Markdown buffer"; description = "Automatically open the preview window after entering a Markdown buffer";
}; };
autoClose = mkOption { autoClose = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Automatically close the preview window after leaving a Markdown buffer"; description = "Automatically close the preview window after leaving a Markdown buffer";
}; };
lazyRefresh = mkOption { lazyRefresh = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Only update preview when saving or leaving insert mode"; description = "Only update preview when saving or leaving insert mode";
}; };
filetypes = mkOption { filetypes = mkOption {
type = with types; listOf str; type = listOf str;
default = ["markdown"]; default = ["markdown"];
description = "Allowed filetypes"; description = "Allowed filetypes";
}; };
alwaysAllowPreview = mkOption { alwaysAllowPreview = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Allow preview on all filetypes"; description = "Allow preview on all filetypes";
}; };
broadcastServer = mkOption { broadcastServer = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "Allow for outside and network wide connections"; description = "Allow for outside and network wide connections";
}; };
customIP = mkOption { customIP = mkOption {
type = types.str; type = str;
default = ""; default = "";
description = "IP-address to use"; description = "IP-address to use";
}; };
customPort = mkOption { customPort = mkOption {
type = types.str; type = str;
default = ""; default = "";
description = "Port to use"; description = "Port to use";
}; };

View file

@ -3,7 +3,9 @@
lib, lib,
... ...
}: let }: let
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.surround; cfg = config.vim.utility.surround;
self = import ./surround.nix {inherit lib config;}; self = import ./surround.nix {inherit lib config;};
@ -16,7 +18,7 @@ in {
"nvim-surround" "nvim-surround"
]; ];
luaConfigRC.surround = nvim.dag.entryAnywhere '' luaConfigRC.surround = entryAnywhere ''
require('nvim-surround').setup() require('nvim-surround').setup()
''; '';

View file

@ -3,67 +3,69 @@
config, config,
... ...
}: let }: let
inherit (lib) mkOption types mkIf mkDefault; inherit (lib.modules) mkIf mkDefault;
inherit (lib.options) mkOption;
inherit (lib.types) bool nullOr str;
in { in {
options.vim.utility.surround = { options.vim.utility.surround = {
enable = mkOption { enable = mkOption {
type = types.bool; type = bool;
default = false; default = false;
description = "nvim-surround: add/change/delete surrounding delimiter pairs with ease. Note that the default mappings deviate from upstreeam to avoid conflicts with nvim-leap."; description = "nvim-surround: add/change/delete surrounding delimiter pairs with ease. Note that the default mappings deviate from upstreeam to avoid conflicts with nvim-leap.";
}; };
useVendoredKeybindings = mkOption { useVendoredKeybindings = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = "Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap"; description = "Use alternative set of keybindings that avoids conflicts with other popular plugins, e.g. nvim-leap";
}; };
mappings = { mappings = {
insert = mkOption { insert = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<C-g>z"; default = "<C-g>z";
description = "Add surround character around the cursor"; description = "Add surround character around the cursor";
}; };
insertLine = mkOption { insertLine = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "<C-g>Z"; default = "<C-g>Z";
description = "Add surround character around the cursor on new lines"; description = "Add surround character around the cursor on new lines";
}; };
normal = mkOption { normal = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "gz"; default = "gz";
description = "Surround motion with character"; description = "Surround motion with character";
}; };
normalCur = mkOption { normalCur = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "gZ"; default = "gZ";
description = "Surround motion with character on new lines"; description = "Surround motion with character on new lines";
}; };
normalLine = mkOption { normalLine = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "gzz"; default = "gzz";
description = "Surround line with character"; description = "Surround line with character";
}; };
normalCurLine = mkOption { normalCurLine = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "gZZ"; default = "gZZ";
description = "Surround line with character on new lines"; description = "Surround line with character on new lines";
}; };
visual = mkOption { visual = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "gz"; default = "gz";
description = "Surround selection with character"; description = "Surround selection with character";
}; };
visualLine = mkOption { visualLine = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "gZ"; default = "gZ";
description = "Surround selection with character on new lines"; description = "Surround selection with character on new lines";
}; };
delete = mkOption { delete = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "gzd"; default = "gzd";
description = "Delete surrounding character"; description = "Delete surrounding character";
}; };
change = mkOption { change = mkOption {
type = types.nullOr types.str; type = nullOr str;
default = "gzr"; default = "gzr";
description = "Change surrounding character"; description = "Change surrounding character";
}; };

View file

@ -4,7 +4,11 @@
lib, lib,
... ...
}: let }: let
inherit (lib) addDescriptionsToMappings mkIf mkMerge mkSetBinding nvim pushDownDefault; inherit (lib.modules) mkIf mkMerge;
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetBinding;
inherit (lib.nvim.dag) entryAnywhere;
# TODO: move this to its own module
inherit (lib) pushDownDefault;
cfg = config.vim.telescope; cfg = config.vim.telescope;
self = import ./telescope.nix {inherit lib;}; self = import ./telescope.nix {inherit lib;};
@ -60,7 +64,7 @@ in {
"<leader>fvc" = "Commits"; "<leader>fvc" = "Commits";
}; };
vim.luaConfigRC.telescope = nvim.dag.entryAnywhere '' vim.luaConfigRC.telescope = entryAnywhere ''
local telescope = require('telescope') local telescope = require('telescope')
telescope.setup { telescope.setup {
defaults = { defaults = {

View file

@ -1,5 +1,6 @@
{lib, ...}: let {lib, ...}: let
inherit (lib) mkMappingOption mkEnableOption; inherit (lib.options) mkEnableOption;
inherit (lib.nvim.binds) mkMappingOption;
in { in {
options.vim.telescope = { options.vim.telescope = {
mappings = { mappings = {

View file

@ -4,7 +4,8 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) mkIf nvim; inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.utility.vim-wakatime; cfg = config.vim.utility.vim-wakatime;
in { in {
@ -13,7 +14,7 @@ in {
pkgs.vimPlugins.vim-wakatime pkgs.vimPlugins.vim-wakatime
]; ];
vim.configRC.vim-wakatime = nvim.dag.entryAnywhere '' vim.configRC.vim-wakatime = entryAnywhere ''
${ ${
if cfg.cli-package == null if cfg.cli-package == null
then "" then ""

View file

@ -3,13 +3,14 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) mkEnableOption mkOption types; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.types) nullOr package;
in { in {
options.vim.utility.vim-wakatime = { options.vim.utility.vim-wakatime = {
enable = mkEnableOption "vim-wakatime: live code statistics"; enable = mkEnableOption "vim-wakatime: live code statistics";
cli-package = mkOption { cli-package = mkOption {
type = with types; nullOr package; type = nullOr package;
default = pkgs.wakatime; default = pkgs.wakatime;
description = "The package that should be used for wakatime-cli. Set as null to use the default path in `$XDG_DATA_HOME`"; description = "The package that should be used for wakatime-cli. Set as null to use the default path in `$XDG_DATA_HOME`";
}; };

View file

@ -3,14 +3,18 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf mkMerge nvim optionalString boolToString mkBinding; inherit (lib.modules) mkIf mkMerge;
inherit (lib.strings) optionalString;
inherit (lib.trivial) boolToString;
inherit (lib.nvim.binds) mkBinding;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.visuals; cfg = config.vim.visuals;
in { in {
config = mkIf cfg.enable (mkMerge [ config = mkIf cfg.enable (mkMerge [
(mkIf cfg.indentBlankline.enable { (mkIf cfg.indentBlankline.enable {
vim.startPlugins = ["indent-blankline"]; vim.startPlugins = ["indent-blankline"];
vim.luaConfigRC.indent-blankline = nvim.dag.entryAnywhere '' vim.luaConfigRC.indent-blankline = entryAnywhere ''
-- highlight error: https://github.com/lukas-reineke/indent-blankline.nvim/issues/59 -- highlight error: https://github.com/lukas-reineke/indent-blankline.nvim/issues/59
-- vim.wo.colorcolumn = "99999" -- vim.wo.colorcolumn = "99999"
vim.opt.list = true vim.opt.list = true
@ -42,7 +46,7 @@ in {
(mkIf cfg.cursorline.enable { (mkIf cfg.cursorline.enable {
vim.startPlugins = ["nvim-cursorline"]; vim.startPlugins = ["nvim-cursorline"];
vim.luaConfigRC.cursorline = nvim.dag.entryAnywhere '' vim.luaConfigRC.cursorline = entryAnywhere ''
require('nvim-cursorline').setup { require('nvim-cursorline').setup {
cursorline = { cursorline = {
timeout = ${toString cfg.cursorline.lineTimeout}, timeout = ${toString cfg.cursorline.lineTimeout},
@ -58,7 +62,7 @@ in {
(mkIf cfg.scrollBar.enable { (mkIf cfg.scrollBar.enable {
vim.startPlugins = ["scrollbar-nvim"]; vim.startPlugins = ["scrollbar-nvim"];
vim.luaConfigRC.scrollBar = nvim.dag.entryAnywhere '' vim.luaConfigRC.scrollBar = entryAnywhere ''
require('scrollbar').setup{ require('scrollbar').setup{
excluded_filetypes = { excluded_filetypes = {
'prompt', 'prompt',
@ -77,7 +81,7 @@ in {
(mkIf cfg.smoothScroll.enable { (mkIf cfg.smoothScroll.enable {
vim.startPlugins = ["cinnamon-nvim"]; vim.startPlugins = ["cinnamon-nvim"];
vim.luaConfigRC.smoothScroll = nvim.dag.entryAnywhere '' vim.luaConfigRC.smoothScroll = entryAnywhere ''
require('cinnamon').setup() require('cinnamon').setup()
''; '';
}) })
@ -87,7 +91,7 @@ in {
vim.maps.normal = mkBinding cfg.cellularAutomaton.mappings.makeItRain "<cmd>CellularAutomaton make_it_rain<CR>" "Make it rain"; vim.maps.normal = mkBinding cfg.cellularAutomaton.mappings.makeItRain "<cmd>CellularAutomaton make_it_rain<CR>" "Make it rain";
vim.luaConfigRC.cellularAUtomaton = nvim.dag.entryAnywhere '' vim.luaConfigRC.cellularAUtomaton = entryAnywhere ''
local config = { local config = {
fps = 50, fps = 50,
name = 'slide', name = 'slide',
@ -115,7 +119,7 @@ in {
(mkIf cfg.highlight-undo.enable { (mkIf cfg.highlight-undo.enable {
vim.startPlugins = ["highlight-undo"]; vim.startPlugins = ["highlight-undo"];
vim.luaConfigRC.highlight-undo = nvim.dag.entryAnywhere '' vim.luaConfigRC.highlight-undo = entryAnywhere ''
require('highlight-undo').setup({ require('highlight-undo').setup({
duration = ${toString cfg.highlight-undo.duration}, duration = ${toString cfg.highlight-undo.duration},
highlight_for_count = ${boolToString cfg.highlight-undo.highlightForCount}, highlight_for_count = ${boolToString cfg.highlight-undo.highlightForCount},

View file

@ -3,14 +3,17 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkIf nvim; inherit (lib.modules) mkIf;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.dag) entryAnywhere;
cfg = config.vim.visuals.fidget-nvim; cfg = config.vim.visuals.fidget-nvim;
in { in {
config = mkIf cfg.enable { config = mkIf cfg.enable {
vim.startPlugins = ["fidget-nvim"]; vim.startPlugins = ["fidget-nvim"];
vim.luaConfigRC.fidget-nvim = nvim.dag.entryAnywhere '' vim.luaConfigRC.fidget-nvim = entryAnywhere ''
require'fidget'.setup(${nvim.lua.toLuaObject cfg.setupOpts}) require'fidget'.setup(${toLuaObject cfg.setupOpts})
''; '';
}; };
} }

View file

@ -3,7 +3,13 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkRemovedOptionModule mkEnableOption mkOption mapAttrs toUpper nvim types mkRenamedOptionModule; inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule;
inherit (lib.options) mkEnableOption mkOption;
inherit (lib.attrsets) mapAttrs;
inherit (lib.strings) toUpper;
inherit (lib.types) int float bool str enum listOf attrsOf;
inherit (lib.nvim.types) mkPluginSetupOption;
rawLua = lua: {__raw = lua;}; rawLua = lua: {__raw = lua;};
in { in {
imports = [ imports = [
@ -15,31 +21,31 @@ in {
options.vim.visuals.fidget-nvim = { options.vim.visuals.fidget-nvim = {
enable = mkEnableOption "nvim LSP UI element [fidget-nvim]"; enable = mkEnableOption "nvim LSP UI element [fidget-nvim]";
setupOpts = nvim.types.mkPluginSetupOption "Fidget" { setupOpts = mkPluginSetupOption "Fidget" {
progress = { progress = {
poll_rate = mkOption { poll_rate = mkOption {
description = "How frequently to poll for LSP progress messages"; description = "How frequently to poll for LSP progress messages";
type = types.int; type = int;
default = 0; default = 0;
}; };
suppress_on_insert = mkOption { suppress_on_insert = mkOption {
description = "Suppress new messages when in insert mode"; description = "Suppress new messages when in insert mode";
type = types.bool; type = bool;
default = false; default = false;
}; };
ignore_done_already = mkOption { ignore_done_already = mkOption {
description = "Ignore new tasks that are already done"; description = "Ignore new tasks that are already done";
type = types.bool; type = bool;
default = false; default = false;
}; };
ignore_empty_message = mkOption { ignore_empty_message = mkOption {
description = "Ignore new tasks with empty messages"; description = "Ignore new tasks with empty messages";
type = types.bool; type = bool;
default = false; default = false;
}; };
clear_on_detach = mkOption { clear_on_detach = mkOption {
description = "Clear notification group when LSP server detaches"; description = "Clear notification group when LSP server detaches";
type = types.bool; type = bool;
default = true; default = true;
apply = clear: apply = clear:
if clear if clear
@ -54,7 +60,7 @@ in {
}; };
notification_group = mkOption { notification_group = mkOption {
description = "How to get a progress message's notification group key"; description = "How to get a progress message's notification group key";
type = types.str; type = str;
default = '' default = ''
function(msg) function(msg)
return msg.lsp_client.name return msg.lsp_client.name
@ -64,40 +70,40 @@ in {
}; };
ignore = mkOption { ignore = mkOption {
description = "Ignore LSP servers by name"; description = "Ignore LSP servers by name";
type = types.listOf types.str; type = listOf str;
default = []; default = [];
}; };
display = { display = {
render_limit = mkOption { render_limit = mkOption {
description = "Maximum number of messages to render"; description = "Maximum number of messages to render";
type = types.int; type = int;
default = 16; default = 16;
}; };
done_ttl = mkOption { done_ttl = mkOption {
description = "How long a message should persist when complete"; description = "How long a message should persist when complete";
type = types.int; type = int;
default = 3; default = 3;
}; };
done_icon = mkOption { done_icon = mkOption {
description = "Icon shown when LSP progress tasks are completed"; description = "Icon shown when LSP progress tasks are completed";
type = types.str; type = str;
default = ""; default = "";
}; };
done_style = mkOption { done_style = mkOption {
description = "Highlight group for completed LSP tasks"; description = "Highlight group for completed LSP tasks";
type = types.str; type = str;
default = "Constant"; default = "Constant";
}; };
progress_ttl = mkOption { progress_ttl = mkOption {
description = "How long a message should persist when in progress"; description = "How long a message should persist when in progress";
type = types.int; type = int;
default = 99999; default = 99999;
}; };
progress_icon = { progress_icon = {
pattern = mkOption { pattern = mkOption {
description = "Pattern shown when LSP progress tasks are in progress"; description = "Pattern shown when LSP progress tasks are in progress";
type = types.enum [ type = enum [
"dots" "dots"
"dots_negative" "dots_negative"
"dots_snake" "dots_snake"
@ -136,38 +142,38 @@ in {
}; };
period = mkOption { period = mkOption {
description = "Period of the pattern"; description = "Period of the pattern";
type = types.int; type = int;
default = 1; default = 1;
}; };
}; };
progress_style = mkOption { progress_style = mkOption {
description = "Highlight group for in-progress LSP tasks"; description = "Highlight group for in-progress LSP tasks";
type = types.str; type = str;
default = "WarningMsg"; default = "WarningMsg";
}; };
group_style = mkOption { group_style = mkOption {
description = "Highlight group for group name (LSP server name)"; description = "Highlight group for group name (LSP server name)";
type = types.str; type = str;
default = "Title"; default = "Title";
}; };
icon_style = mkOption { icon_style = mkOption {
description = "Highlight group for group icons"; description = "Highlight group for group icons";
type = types.str; type = str;
default = "Question"; default = "Question";
}; };
priority = mkOption { priority = mkOption {
description = "Priority of the progress notification"; description = "Priority of the progress notification";
type = types.int; type = int;
default = 30; default = 30;
}; };
skip_history = mkOption { skip_history = mkOption {
description = "Skip adding messages to history"; description = "Skip adding messages to history";
type = types.bool; type = bool;
default = true; default = true;
}; };
format_message = mkOption { format_message = mkOption {
description = "How to format a progress message"; description = "How to format a progress message";
type = types.str; type = str;
default = '' default = ''
require("fidget.progress.display").default_format_message require("fidget.progress.display").default_format_message
''; '';
@ -175,7 +181,7 @@ in {
}; };
format_annote = mkOption { format_annote = mkOption {
description = "How to format a progress annotation"; description = "How to format a progress annotation";
type = types.str; type = str;
default = '' default = ''
function(msg) return msg.title end function(msg) return msg.title end
''; '';
@ -183,7 +189,7 @@ in {
}; };
format_group_name = mkOption { format_group_name = mkOption {
description = "How to format a progress notification group's name"; description = "How to format a progress notification group's name";
type = types.str; type = str;
default = '' default = ''
function(group) return tostring(group) end function(group) return tostring(group) end
''; '';
@ -191,7 +197,7 @@ in {
}; };
overrides = mkOption { overrides = mkOption {
description = "Override options from the default notification config"; description = "Override options from the default notification config";
type = types.attrsOf types.str; type = attrsOf str;
default = {rust_analyzer = "{ name = 'rust-analyzer' }";}; default = {rust_analyzer = "{ name = 'rust-analyzer' }";};
apply = mapAttrs (key: lua: rawLua lua); apply = mapAttrs (key: lua: rawLua lua);
}; };
@ -200,12 +206,12 @@ in {
lsp = { lsp = {
progress_ringbuf_size = mkOption { progress_ringbuf_size = mkOption {
description = "Nvim's LSP client ring buffer size"; description = "Nvim's LSP client ring buffer size";
type = types.int; type = int;
default = 100; default = 100;
}; };
log_handler = mkOption { log_handler = mkOption {
description = "Log `$/progress` handler invocations"; description = "Log `$/progress` handler invocations";
type = types.bool; type = bool;
default = false; default = false;
}; };
}; };
@ -214,34 +220,34 @@ in {
notification = { notification = {
poll_rate = mkOption { poll_rate = mkOption {
description = "How frequently to update and render notifications"; description = "How frequently to update and render notifications";
type = types.int; type = int;
default = 10; default = 10;
}; };
filter = mkOption { filter = mkOption {
description = "Minimum notifications level"; description = "Minimum notifications level";
type = types.enum ["debug" "info" "warn" "error"]; type = enum ["debug" "info" "warn" "error"];
default = "info"; default = "info";
apply = filter: rawLua "vim.log.levels.${toUpper filter}"; apply = filter: rawLua "vim.log.levels.${toUpper filter}";
}; };
history_size = mkOption { history_size = mkOption {
description = "Number of removed messages to retain in history"; description = "Number of removed messages to retain in history";
type = types.int; type = int;
default = 128; default = 128;
}; };
override_vim_notify = mkOption { override_vim_notify = mkOption {
description = "Automatically override vim.notify() with Fidget"; description = "Automatically override vim.notify() with Fidget";
type = types.bool; type = bool;
default = false; default = false;
}; };
configs = mkOption { configs = mkOption {
description = "How to configure notification groups when instantiated"; description = "How to configure notification groups when instantiated";
type = types.attrsOf types.str; type = attrsOf str;
default = {default = "require('fidget.notification').default_config";}; default = {default = "require('fidget.notification').default_config";};
apply = mapAttrs (key: lua: rawLua lua); apply = mapAttrs (key: lua: rawLua lua);
}; };
redirect = mkOption { redirect = mkOption {
description = "Conditionally redirect notifications to another backend"; description = "Conditionally redirect notifications to another backend";
type = types.str; type = str;
default = '' default = ''
function(msg, level, opts) function(msg, level, opts)
if opts and opts.on_open then if opts and opts.on_open then
@ -255,27 +261,27 @@ in {
view = { view = {
stack_upwards = mkOption { stack_upwards = mkOption {
description = "Display notification items from bottom to top"; description = "Display notification items from bottom to top";
type = types.bool; type = bool;
default = true; default = true;
}; };
icon_separator = mkOption { icon_separator = mkOption {
description = "Separator between group name and icon"; description = "Separator between group name and icon";
type = types.str; type = str;
default = " "; default = " ";
}; };
group_separator = mkOption { group_separator = mkOption {
description = "Separator between notification groups"; description = "Separator between notification groups";
type = types.str; type = str;
default = "---"; default = "---";
}; };
group_separator_hl = mkOption { group_separator_hl = mkOption {
description = "Highlight group used for group separator"; description = "Highlight group used for group separator";
type = types.str; type = str;
default = "Comment"; default = "Comment";
}; };
render_message = mkOption { render_message = mkOption {
description = "How to render notification messages"; description = "How to render notification messages";
type = types.str; type = str;
default = '' default = ''
function(msg, cnt) function(msg, cnt)
return cnt == 1 and msg or string.format("(%dx) %s", cnt, msg) return cnt == 1 and msg or string.format("(%dx) %s", cnt, msg)
@ -288,17 +294,17 @@ in {
window = { window = {
normal_hl = mkOption { normal_hl = mkOption {
description = "Base highlight group in the notification window"; description = "Base highlight group in the notification window";
type = types.str; type = str;
default = "Comment"; default = "Comment";
}; };
winblend = mkOption { winblend = mkOption {
description = "Background color opacity in the notification window"; description = "Background color opacity in the notification window";
type = types.int; type = int;
default = 100; default = 100;
}; };
border = mkOption { border = mkOption {
description = "Border style of the notification window"; description = "Border style of the notification window";
type = types.enum ["none" "single" "double" "rounded" "solid" "shadow"]; type = enum ["none" "single" "double" "rounded" "solid" "shadow"];
default = default =
if config.vim.ui.borders.enable if config.vim.ui.borders.enable
then config.vim.ui.borders.globalStyle then config.vim.ui.borders.globalStyle
@ -306,37 +312,37 @@ in {
}; };
zindex = mkOption { zindex = mkOption {
description = "Stacking priority of the notification window"; description = "Stacking priority of the notification window";
type = types.int; type = int;
default = 45; default = 45;
}; };
max_width = mkOption { max_width = mkOption {
description = "Maximum width of the notification window"; description = "Maximum width of the notification window";
type = types.int; type = int;
default = 0; default = 0;
}; };
max_height = mkOption { max_height = mkOption {
description = "Maximum height of the notification window"; description = "Maximum height of the notification window";
type = types.int; type = int;
default = 0; default = 0;
}; };
x_padding = mkOption { x_padding = mkOption {
description = "Padding from right edge of window boundary"; description = "Padding from right edge of window boundary";
type = types.int; type = int;
default = 1; default = 1;
}; };
y_padding = mkOption { y_padding = mkOption {
description = "Padding from bottom edge of window boundary"; description = "Padding from bottom edge of window boundary";
type = types.int; type = int;
default = 0; default = 0;
}; };
align = mkOption { align = mkOption {
description = "How to align the notification window"; description = "How to align the notification window";
type = types.enum ["top" "bottom"]; type = enum ["top" "bottom"];
default = "bottom"; default = "bottom";
}; };
relative = mkOption { relative = mkOption {
description = "What the notification window position is relative to"; description = "What the notification window position is relative to";
type = types.enum ["editor" "win"]; type = enum ["editor" "win"];
default = "editor"; default = "editor";
}; };
}; };
@ -346,7 +352,7 @@ in {
nvim-tree = { nvim-tree = {
enable = mkOption { enable = mkOption {
description = "Integrate with nvim-tree/nvim-tree.lua (if enabled)"; description = "Integrate with nvim-tree/nvim-tree.lua (if enabled)";
type = types.bool; type = bool;
default = default =
if config.vim.filetree.nvimTree.enable if config.vim.filetree.nvimTree.enable
then true then true
@ -356,7 +362,7 @@ in {
xcodebuild-nvim = { xcodebuild-nvim = {
enable = mkOption { enable = mkOption {
description = "Integrate with wojciech-kulik/xcodebuild.nvim (if enabled)"; description = "Integrate with wojciech-kulik/xcodebuild.nvim (if enabled)";
type = types.bool; type = bool;
default = true; default = true;
}; };
}; };
@ -365,23 +371,23 @@ in {
logger = { logger = {
level = mkOption { level = mkOption {
description = "Minimum logging level"; description = "Minimum logging level";
type = types.enum ["debug" "error" "info" "trace" "warn" "off"]; type = enum ["debug" "error" "info" "trace" "warn" "off"];
default = "warn"; default = "warn";
apply = logLevel: rawLua "vim.log.levels.${toUpper logLevel}"; apply = logLevel: rawLua "vim.log.levels.${toUpper logLevel}";
}; };
max_size = mkOption { max_size = mkOption {
description = "Maximum log file size, in KB"; description = "Maximum log file size, in KB";
type = types.int; type = int;
default = 10000; default = 10000;
}; };
float_precision = mkOption { float_precision = mkOption {
description = "Limit the number of decimals displayed for floats"; description = "Limit the number of decimals displayed for floats";
type = types.float; type = float;
default = 0.01; default = 0.01;
}; };
path = mkOption { path = mkOption {
description = "Where Fidget writes its logs to"; description = "Where Fidget writes its logs to";
type = types.str; type = str;
default = '' default = ''
string.format("%s/fidget.nvim.log", vim.fn.stdpath("cache")) string.format("%s/fidget.nvim.log", vim.fn.stdpath("cache"))
''; '';

View file

@ -3,7 +3,10 @@
lib, lib,
... ...
}: let }: let
inherit (lib) mkEnableOption mkMappingOption mkOption types literalExpression mkRenamedOptionModule mkRemovedOptionModule; inherit (lib.modules) mkRemovedOptionModule mkRenamedOptionModule;
inherit (lib.options) mkEnableOption mkOption literalExpression;
inherit (lib.types) int bool str nullOr;
inherit (lib.nvim.binds) mkMappingOption;
cfg = config.vim.visuals; cfg = config.vim.visuals;
in { in {
@ -34,13 +37,13 @@ in {
enable = mkEnableOption "line hightlighting on the cursor [nvim-cursorline]"; enable = mkEnableOption "line hightlighting on the cursor [nvim-cursorline]";
lineTimeout = mkOption { lineTimeout = mkOption {
type = types.int; type = int;
description = "Time in milliseconds for cursorline to appear"; description = "Time in milliseconds for cursorline to appear";
default = 0; default = 0;
}; };
lineNumbersOnly = mkOption { lineNumbersOnly = mkOption {
type = types.bool; type = bool;
description = "Hightlight only in the presence of line numbers"; description = "Hightlight only in the presence of line numbers";
default = true; default = true;
}; };
@ -49,21 +52,21 @@ in {
indentBlankline = { indentBlankline = {
enable = mkEnableOption "indentation guides [indent-blankline]"; enable = mkEnableOption "indentation guides [indent-blankline]";
debounce = mkOption { debounce = mkOption {
type = types.int; type = int;
description = "Debounce time in milliseconds"; description = "Debounce time in milliseconds";
default = 200; default = 200;
}; };
viewportBuffer = { viewportBuffer = {
min = mkOption { min = mkOption {
type = types.int; type = int;
description = "Number of lines above and below of what is currently description = "Number of lines above and below of what is currently
visible in the window"; visible in the window";
default = 30; default = 30;
}; };
max = mkOption { max = mkOption {
type = types.int; type = int;
description = "Number of lines above and below of what is currently description = "Number of lines above and below of what is currently
visible in the window"; visible in the window";
default = 500; default = 500;
@ -72,34 +75,34 @@ in {
indent = { indent = {
char = mkOption { char = mkOption {
type = types.str; type = str;
description = "Character for indentation line"; description = "Character for indentation line";
default = ""; default = "";
}; };
}; };
listChar = mkOption { listChar = mkOption {
type = types.str; type = str;
description = "Character for indentation line"; description = "Character for indentation line";
default = ""; default = "";
}; };
fillChar = mkOption { fillChar = mkOption {
description = "Character to fill indents"; description = "Character to fill indents";
type = with types; nullOr types.str; type = nullOr str;
default = ""; default = "";
}; };
eolChar = mkOption { eolChar = mkOption {
description = "Character at end of line"; description = "Character at end of line";
type = with types; nullOr types.str; type = nullOr str;
default = ""; default = "";
}; };
scope = { scope = {
enabled = mkOption { enabled = mkOption {
description = "Highlight current scope from treesitter"; description = "Highlight current scope from treesitter";
type = types.bool; type = bool;
default = config.vim.treesitter.enable; default = config.vim.treesitter.enable;
defaultText = literalExpression "config.vim.treesitter.enable"; defaultText = literalExpression "config.vim.treesitter.enable";
}; };
@ -109,7 +112,7 @@ in {
Displays the end of line character set by [](#opt-vim.visuals.indentBlankline.eolChar) instead of the Displays the end of line character set by [](#opt-vim.visuals.indentBlankline.eolChar) instead of the
indent guide on line returns. indent guide on line returns.
''; '';
type = types.bool; type = bool;
default = cfg.indentBlankline.eolChar != null; default = cfg.indentBlankline.eolChar != null;
defaultText = literalExpression "config.vim.visuals.indentBlankline.eolChar != null"; defaultText = literalExpression "config.vim.visuals.indentBlankline.eolChar != null";
}; };
@ -120,7 +123,7 @@ in {
enable = mkEnableOption "highlight undo [highlight-undo]"; enable = mkEnableOption "highlight undo [highlight-undo]";
highlightForCount = mkOption { highlightForCount = mkOption {
type = types.bool; type = bool;
default = true; default = true;
description = '' description = ''
Enable support for highlighting when a <count> is provided before the key Enable support for highlighting when a <count> is provided before the key
@ -129,14 +132,14 @@ in {
}; };
duration = mkOption { duration = mkOption {
type = types.int; type = int;
description = "Duration of highlight"; description = "Duration of highlight";
default = 500; default = 500;
}; };
undo = { undo = {
hlGroup = mkOption { hlGroup = mkOption {
type = types.str; type = str;
description = "Highlight group for undo"; description = "Highlight group for undo";
default = "HighlightUndo"; default = "HighlightUndo";
}; };
@ -144,7 +147,7 @@ in {
redo = { redo = {
hlGroup = mkOption { hlGroup = mkOption {
type = types.str; type = str;
description = "Highlight group for redo"; description = "Highlight group for redo";
default = "HighlightUndo"; default = "HighlightUndo";
}; };