mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-06-23 21:13:28 +00:00
lib: format nixdoc values
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Treewide Checks / Validate flake (push) Waiting to run
Treewide Checks / Check formatting (push) Waiting to run
Treewide Checks / Check source tree for typos (push) Waiting to run
Treewide Checks / Validate documentation builds (push) Waiting to run
Treewide Checks / Validate documentation builds-1 (push) Waiting to run
Treewide Checks / Validate documentation builds-2 (push) Waiting to run
Treewide Checks / Validate documentation builds-3 (push) Waiting to run
Treewide Checks / Validate hyperlinks in documentation sources (push) Waiting to run
Treewide Checks / Validate Editorconfig conformance (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Treewide Checks / Validate flake (push) Waiting to run
Treewide Checks / Check formatting (push) Waiting to run
Treewide Checks / Check source tree for typos (push) Waiting to run
Treewide Checks / Validate documentation builds (push) Waiting to run
Treewide Checks / Validate documentation builds-1 (push) Waiting to run
Treewide Checks / Validate documentation builds-2 (push) Waiting to run
Treewide Checks / Validate documentation builds-3 (push) Waiting to run
Treewide Checks / Validate hyperlinks in documentation sources (push) Waiting to run
Treewide Checks / Validate Editorconfig conformance (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ia6dcbf5c44ff6d29e5760111179341226a6a6964
This commit is contained in:
parent
733c182e17
commit
56e20dd9c8
7 changed files with 322 additions and 322 deletions
|
|
@ -2,25 +2,25 @@
|
||||||
inherit (builtins) listToAttrs;
|
inherit (builtins) listToAttrs;
|
||||||
in {
|
in {
|
||||||
/**
|
/**
|
||||||
Map over a list and convert the result to an attribute set.
|
Map over a list and convert the result to an attribute set.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mapListToAttrs :: (a -> { name :: String; value :: b }) -> [a] -> AttrSet
|
mapListToAttrs :: (a -> { name :: String; value :: b }) -> [a] -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `f`: Function mapping each list element to a `{ name; value }` pair.
|
- `f`: Function mapping each list element to a `{ name; value }` pair.
|
||||||
- `list`: The list to map over.
|
- `list`: The list to map over.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mapListToAttrs (x: { name = x; value = x; }) ["a" "b"]
|
mapListToAttrs (x: { name = x; value = x; }) ["a" "b"]
|
||||||
=> { a = "a"; b = "b"; }
|
=> { a = "a"; b = "b"; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mapListToAttrs = f: list: listToAttrs (map f list);
|
mapListToAttrs = f: list: listToAttrs (map f list);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
278
lib/binds.nix
278
lib/binds.nix
|
|
@ -6,26 +6,26 @@
|
||||||
|
|
||||||
binds = rec {
|
binds = rec {
|
||||||
/**
|
/**
|
||||||
Create a silent Lua keybinding wrapped in `mkIf` to guard against null keys.
|
Create a silent Lua keybinding wrapped in `mkIf` to guard against null keys.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkLuaBinding :: String | Null -> String -> String -> AttrSet
|
mkLuaBinding :: String | Null -> String -> String -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `key`: The key sequence to bind, or `null` to disable.
|
- `key`: The key sequence to bind, or `null` to disable.
|
||||||
- `action`: Lua expression to execute on keypress.
|
- `action`: Lua expression to execute on keypress.
|
||||||
- `desc`: Human-readable description of the binding.
|
- `desc`: Human-readable description of the binding.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkLuaBinding "<leader>f" "require('telescope').find_files" "Find files"
|
mkLuaBinding "<leader>f" "require('telescope').find_files" "Find files"
|
||||||
=> { "<leader>f" = { action = "require('telescope').find_files"; desc = "Find files"; lua = true; silent = true; }; }
|
=> { "<leader>f" = { action = "require('telescope').find_files"; desc = "Find files"; lua = true; silent = true; }; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkLuaBinding = key: action: desc:
|
mkLuaBinding = key: action: desc:
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
|
|
@ -37,26 +37,26 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a silent expression-mode Lua keybinding wrapped in `mkIf`.
|
Create a silent expression-mode Lua keybinding wrapped in `mkIf`.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkExprBinding :: String | Null -> String -> String -> AttrSet
|
mkExprBinding :: String | Null -> String -> String -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `key`: The key sequence to bind, or `null` to disable.
|
- `key`: The key sequence to bind, or `null` to disable.
|
||||||
- `action`: Lua expression evaluated as a Vim expression.
|
- `action`: Lua expression evaluated as a Vim expression.
|
||||||
- `desc`: Human-readable description of the binding.
|
- `desc`: Human-readable description of the binding.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkExprBinding "<C-n>" "v:count == 0 ? 'j' : 'gj'" "Smart down"
|
mkExprBinding "<C-n>" "v:count == 0 ? 'j' : 'gj'" "Smart down"
|
||||||
=> { "<C-n>" = { action = "v:count == 0 ? 'j' : 'gj'"; desc = "Smart down"; lua = true; silent = true; expr = true; }; }
|
=> { "<C-n>" = { action = "v:count == 0 ? 'j' : 'gj'"; desc = "Smart down"; lua = true; silent = true; expr = true; }; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkExprBinding = key: action: desc:
|
mkExprBinding = key: action: desc:
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
|
|
@ -69,26 +69,26 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a silent (non-Lua) keybinding wrapped in `mkIf` to guard against null keys.
|
Create a silent (non-Lua) keybinding wrapped in `mkIf` to guard against null keys.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkBinding :: String | Null -> String -> String -> AttrSet
|
mkBinding :: String | Null -> String -> String -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `key`: The key sequence to bind, or `null` to disable.
|
- `key`: The key sequence to bind, or `null` to disable.
|
||||||
- `action`: Vimscript command or mapping string to execute.
|
- `action`: Vimscript command or mapping string to execute.
|
||||||
- `desc`: Human-readable description of the binding.
|
- `desc`: Human-readable description of the binding.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkBinding "<leader>w" ":w<CR>" "Save file"
|
mkBinding "<leader>w" ":w<CR>" "Save file"
|
||||||
=> { "<leader>w" = { action = ":w<CR>"; desc = "Save file"; silent = true; }; }
|
=> { "<leader>w" = { action = ":w<CR>"; desc = "Save file"; silent = true; }; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkBinding = key: action: desc:
|
mkBinding = key: action: desc:
|
||||||
mkIf (key != null) {
|
mkIf (key != null) {
|
||||||
|
|
@ -99,25 +99,25 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Build a nullable string NixOS option suitable for storing a keybinding value.
|
Build a nullable string NixOS option suitable for storing a keybinding value.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkMappingOption :: String -> String | Null -> Option
|
mkMappingOption :: String -> String | Null -> Option
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `description`: Documentation string for the option.
|
- `description`: Documentation string for the option.
|
||||||
- `default`: Default key value, or `null` for no binding.
|
- `default`: Default key value, or `null` for no binding.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkMappingOption "Toggle file tree" "<leader>e"
|
mkMappingOption "Toggle file tree" "<leader>e"
|
||||||
=> mkOption { type = nullOr str; default = "<leader>e"; description = "Toggle file tree"; }
|
=> mkOption { type = nullOr str; default = "<leader>e"; description = "Toggle file tree"; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkMappingOption = description: default:
|
mkMappingOption = description: default:
|
||||||
mkOption {
|
mkOption {
|
||||||
|
|
@ -126,29 +126,29 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Merge actual mapping values with their description metadata.
|
Merge actual mapping values with their description metadata.
|
||||||
|
|
||||||
Takes two attribute sets: one mapping keys to values and another mapping
|
Takes two attribute sets: one mapping keys to values and another mapping
|
||||||
keys to `{ description }` records. Produces an attribute set mapping
|
keys to `{ description }` records. Produces an attribute set mapping
|
||||||
keys to `{ value; description }` records. Nesting is handled recursively.
|
keys to `{ value; description }` records. Nesting is handled recursively.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
addDescriptionsToMappings :: AttrSet -> AttrSet -> AttrSet
|
addDescriptionsToMappings :: AttrSet -> AttrSet -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `actualMappings`: Attribute set of key → value pairs.
|
- `actualMappings`: Attribute set of key → value pairs.
|
||||||
- `mappingDefinitions`: Attribute set of key → `{ description }` pairs.
|
- `mappingDefinitions`: Attribute set of key → `{ description }` pairs.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
addDescriptionsToMappings { someKey = "some_value"; } { someKey = { description = "Some Description"; }; }
|
addDescriptionsToMappings { someKey = "some_value"; } { someKey = { description = "Some Description"; }; }
|
||||||
=> { someKey = { value = "some_value"; description = "Some Description"; }; }
|
=> { someKey = { value = "some_value"; description = "Some Description"; }; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
addDescriptionsToMappings = actualMappings: mappingDefinitions:
|
addDescriptionsToMappings = actualMappings: mappingDefinitions:
|
||||||
mapAttrs (name: value: let
|
mapAttrs (name: value: let
|
||||||
|
|
@ -165,124 +165,124 @@
|
||||||
actualMappings;
|
actualMappings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a non-Lua keybinding from a structured binding record produced by `mkMappingOption`.
|
Create a non-Lua keybinding from a structured binding record produced by `mkMappingOption`.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkSetBinding :: { value :: String | Null; description :: String } -> String -> AttrSet
|
mkSetBinding :: { value :: String | Null; description :: String } -> String -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `binding`: Binding record with `value` (key) and `description` fields.
|
- `binding`: Binding record with `value` (key) and `description` fields.
|
||||||
- `action`: Vimscript command or mapping string to execute.
|
- `action`: Vimscript command or mapping string to execute.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkSetBinding { value = "<leader>w"; description = "Save file"; } ":w<CR>"
|
mkSetBinding { value = "<leader>w"; description = "Save file"; } ":w<CR>"
|
||||||
=> mkBinding "<leader>w" ":w<CR>" "Save file"
|
=> mkBinding "<leader>w" ":w<CR>" "Save file"
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkSetBinding = binding: action:
|
mkSetBinding = binding: action:
|
||||||
mkBinding binding.value action binding.description;
|
mkBinding binding.value action binding.description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create an expression-mode Lua keybinding from a structured binding record.
|
Create an expression-mode Lua keybinding from a structured binding record.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkSetExprBinding :: { value :: String | Null; description :: String } -> String -> AttrSet
|
mkSetExprBinding :: { value :: String | Null; description :: String } -> String -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `binding`: Binding record with `value` (key) and `description` fields.
|
- `binding`: Binding record with `value` (key) and `description` fields.
|
||||||
- `action`: Lua expression evaluated as a Vim expression.
|
- `action`: Lua expression evaluated as a Vim expression.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkSetExprBinding { value = "<C-n>"; description = "Smart down"; } "v:count == 0 ? 'j' : 'gj'"
|
mkSetExprBinding { value = "<C-n>"; description = "Smart down"; } "v:count == 0 ? 'j' : 'gj'"
|
||||||
=> mkExprBinding "<C-n>" "v:count == 0 ? 'j' : 'gj'" "Smart down"
|
=> mkExprBinding "<C-n>" "v:count == 0 ? 'j' : 'gj'" "Smart down"
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkSetExprBinding = binding: action:
|
mkSetExprBinding = binding: action:
|
||||||
mkExprBinding binding.value action binding.description;
|
mkExprBinding binding.value action binding.description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a silent Lua keybinding from a structured binding record.
|
Create a silent Lua keybinding from a structured binding record.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkSetLuaBinding :: { value :: String | Null; description :: String } -> String -> AttrSet
|
mkSetLuaBinding :: { value :: String | Null; description :: String } -> String -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `binding`: Binding record with `value` (key) and `description` fields.
|
- `binding`: Binding record with `value` (key) and `description` fields.
|
||||||
- `action`: Lua expression to execute on keypress.
|
- `action`: Lua expression to execute on keypress.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkSetLuaBinding { value = "<leader>f"; description = "Find files"; } "require('telescope').find_files"
|
mkSetLuaBinding { value = "<leader>f"; description = "Find files"; } "require('telescope').find_files"
|
||||||
=> mkLuaBinding "<leader>f" "require('telescope').find_files" "Find files"
|
=> mkLuaBinding "<leader>f" "require('telescope').find_files" "Find files"
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkSetLuaBinding = binding: action:
|
mkSetLuaBinding = binding: action:
|
||||||
mkLuaBinding binding.value action binding.description;
|
mkLuaBinding binding.value action binding.description;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Apply `mkDefault` to every value in an attribute set.
|
Apply `mkDefault` to every value in an attribute set.
|
||||||
|
|
||||||
Useful for lowering the priority of a set of option defaults so they can
|
Useful for lowering the priority of a set of option defaults so they can
|
||||||
be overridden by user configuration.
|
be overridden by user configuration.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
pushDownDefault :: AttrSet -> AttrSet
|
pushDownDefault :: AttrSet -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `attr`: Attribute set whose values should be wrapped with `mkDefault`.
|
- `attr`: Attribute set whose values should be wrapped with `mkDefault`.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
pushDownDefault { a = true; b = "hello"; }
|
pushDownDefault { a = true; b = "hello"; }
|
||||||
=> { a = mkDefault true; b = mkDefault "hello"; }
|
=> { a = mkDefault true; b = mkDefault "hello"; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
pushDownDefault = attr: mapAttrs (_: mkDefault) attr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Build a keymap record by merging extra options with mode, key, and action fields.
|
Build a keymap record by merging extra options with mode, key, and action fields.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkKeymap :: String -> String -> String -> AttrSet -> AttrSet
|
mkKeymap :: String -> String -> String -> AttrSet -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `mode`: Vim mode string (e.g. `"n"`, `"v"`, `"i"`).
|
- `mode`: Vim mode string (e.g. `"n"`, `"v"`, `"i"`).
|
||||||
- `key`: Key sequence to bind.
|
- `key`: Key sequence to bind.
|
||||||
- `action`: Action to execute on keypress.
|
- `action`: Action to execute on keypress.
|
||||||
- `opt`: Extra options merged into the resulting record.
|
- `opt`: Extra options merged into the resulting record.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkKeymap "n" "<leader>w" ":w<CR>" { silent = true; }
|
mkKeymap "n" "<leader>w" ":w<CR>" { silent = true; }
|
||||||
=> { mode = "n"; key = "<leader>w"; action = ":w<CR>"; silent = true; }
|
=> { mode = "n"; key = "<leader>w"; action = ":w<CR>"; silent = true; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkKeymap = mode: key: action: opt: opt // {inherit mode key action;};
|
mkKeymap = mode: key: action: opt: opt // {inherit mode key action;};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -6,25 +6,25 @@
|
||||||
inherit (lib.lists) flatten;
|
inherit (lib.lists) flatten;
|
||||||
in {
|
in {
|
||||||
/**
|
/**
|
||||||
Build a boolean NixOS option with the given default value and description.
|
Build a boolean NixOS option with the given default value and description.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkBool :: Bool -> String -> Option
|
mkBool :: Bool -> String -> Option
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `value`: Default boolean value for the option.
|
- `value`: Default boolean value for the option.
|
||||||
- `description`: Documentation string for the option.
|
- `description`: Documentation string for the option.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkBool true "Enable feature X"
|
mkBool true "Enable feature X"
|
||||||
=> mkOption { type = bool; default = true; description = "Enable feature X"; }
|
=> mkOption { type = bool; default = true; description = "Enable feature X"; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkBool = value: description:
|
mkBool = value: description:
|
||||||
mkOption {
|
mkOption {
|
||||||
|
|
|
||||||
106
lib/dag.nix
106
lib/dag.nix
|
|
@ -101,96 +101,96 @@ in {
|
||||||
map = f: mapAttrs (n: v: v // {data = f n v.data;});
|
map = f: mapAttrs (n: v: v // {data = f n v.data;});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a DAG entry with explicit before and after dependency lists.
|
Create a DAG entry with explicit before and after dependency lists.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
entryBetween :: [String] -> [String] -> a -> DagEntry a
|
entryBetween :: [String] -> [String] -> a -> DagEntry a
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `before`: List of entry names this entry must come before.
|
- `before`: List of entry names this entry must come before.
|
||||||
- `after`: List of entry names this entry must come after.
|
- `after`: List of entry names this entry must come after.
|
||||||
- `data`: Payload for this DAG entry.
|
- `data`: Payload for this DAG entry.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
entryBetween [ "c" ] [ "a" ] "payload"
|
entryBetween [ "c" ] [ "a" ] "payload"
|
||||||
=> { data = "payload"; before = [ "c" ]; after = [ "a" ]; }
|
=> { data = "payload"; before = [ "c" ]; after = [ "a" ]; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
entryBetween = before: after: data: {inherit data before after;};
|
entryBetween = before: after: data: {inherit data before after;};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a DAG entry with no ordering constraints.
|
Create a DAG entry with no ordering constraints.
|
||||||
|
|
||||||
The entry may be placed anywhere in the topological sort result.
|
The entry may be placed anywhere in the topological sort result.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
entryAnywhere :: a -> DagEntry a
|
entryAnywhere :: a -> DagEntry a
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `data`: Payload for this DAG entry.
|
- `data`: Payload for this DAG entry.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
entryAnywhere "lua code here"
|
entryAnywhere "lua code here"
|
||||||
=> { data = "lua code here"; before = []; after = []; }
|
=> { data = "lua code here"; before = []; after = []; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
entryAnywhere = entryBetween [] [];
|
entryAnywhere = entryBetween [] [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a DAG entry that must come after the listed entries.
|
Create a DAG entry that must come after the listed entries.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
entryAfter :: [String] -> a -> DagEntry a
|
entryAfter :: [String] -> a -> DagEntry a
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `after`: List of entry names this entry must follow.
|
- `after`: List of entry names this entry must follow.
|
||||||
- `data`: Payload for this DAG entry.
|
- `data`: Payload for this DAG entry.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
entryAfter [ "init" ] "setup code"
|
entryAfter [ "init" ] "setup code"
|
||||||
=> { data = "setup code"; before = []; after = [ "init" ]; }
|
=> { data = "setup code"; before = []; after = [ "init" ]; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
entryAfter = entryBetween [];
|
entryAfter = entryBetween [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Create a DAG entry that must come before the listed entries.
|
Create a DAG entry that must come before the listed entries.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
entryBefore :: [String] -> a -> DagEntry a
|
entryBefore :: [String] -> a -> DagEntry a
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `before`: List of entry names this entry must precede.
|
- `before`: List of entry names this entry must precede.
|
||||||
- `data`: Payload for this DAG entry.
|
- `data`: Payload for this DAG entry.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
entryBefore [ "teardown" ] "cleanup code"
|
entryBefore [ "teardown" ] "cleanup code"
|
||||||
=> { data = "cleanup code"; before = [ "teardown" ]; after = []; }
|
=> { data = "cleanup code"; before = [ "teardown" ]; after = []; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
entryBefore = before: entryBetween before [];
|
entryBefore = before: entryBetween before [];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,30 +7,30 @@
|
||||||
in {
|
in {
|
||||||
# TODO: remove
|
# TODO: remove
|
||||||
/**
|
/**
|
||||||
Convert a list of diagnostic provider entries to a DAG-compatible attribute set.
|
Convert a list of diagnostic provider entries to a DAG-compatible attribute set.
|
||||||
|
|
||||||
Accepts either plain strings (provider type names) or attrsets with `type`
|
Accepts either plain strings (provider type names) or attrsets with `type`
|
||||||
and `package` fields, and produces named entries suitable for merging into
|
and `package` fields, and produces named entries suitable for merging into
|
||||||
a null-ls/none-ls DAG.
|
a null-ls/none-ls DAG.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
diagnosticsToLua :: { lang :: String; config :: [String | { type :: String; package :: Derivation }]; diagnosticsProviders :: AttrSet } -> AttrSet
|
diagnosticsToLua :: { lang :: String; config :: [String | { type :: String; package :: Derivation }]; diagnosticsProviders :: AttrSet } -> AttrSet
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `lang`: Language identifier used to prefix generated entry names.
|
- `lang`: Language identifier used to prefix generated entry names.
|
||||||
- `config`: List of provider names (strings) or `{ type; package }` records.
|
- `config`: List of provider names (strings) or `{ type; package }` records.
|
||||||
- `diagnosticsProviders`: Attribute set mapping provider type names to `{ package; nullConfig }` records.
|
- `diagnosticsProviders`: Attribute set mapping provider type names to `{ package; nullConfig }` records.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
diagnosticsToLua { lang = "python"; config = [ "flake8" ]; diagnosticsProviders = { flake8 = { package = pkgs.python3Packages.flake8; nullConfig = pkg: "..."; }; }; }
|
diagnosticsToLua { lang = "python"; config = [ "flake8" ]; diagnosticsProviders = { flake8 = { package = pkgs.python3Packages.flake8; nullConfig = pkg: "..."; }; }; }
|
||||||
=> { "python-diagnostics-flake8" = "..."; }
|
=> { "python-diagnostics-flake8" = "..."; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
diagnosticsToLua = {
|
diagnosticsToLua = {
|
||||||
lang,
|
lang,
|
||||||
|
|
@ -54,24 +54,24 @@ in {
|
||||||
config;
|
config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Build a boolean NixOS option that enables a language feature for all enabled languages.
|
Build a boolean NixOS option that enables a language feature for all enabled languages.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
mkEnable :: String -> Option
|
mkEnable :: String -> Option
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `desc`: Short description of the feature being enabled (interpolated into the option description).
|
- `desc`: Short description of the feature being enabled (interpolated into the option description).
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
mkEnable "LSP support"
|
mkEnable "LSP support"
|
||||||
=> mkOption { default = false; type = bool; description = "Turn on LSP support for enabled languages by default"; }
|
=> mkOption { default = false; type = bool; description = "Turn on LSP support for enabled languages by default"; }
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
mkEnable = desc:
|
mkEnable = desc:
|
||||||
mkOption {
|
mkOption {
|
||||||
|
|
@ -81,26 +81,26 @@ in {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A freeform submodule type for LSP server options.
|
A freeform submodule type for LSP server options.
|
||||||
|
|
||||||
Provides a structured set of well-known LSP configuration fields
|
Provides a structured set of well-known LSP configuration fields
|
||||||
(`enable`, `capabilities`, `on_attach`, `filetypes`, `cmd`, `root_markers`)
|
(`enable`, `capabilities`, `on_attach`, `filetypes`, `cmd`, `root_markers`)
|
||||||
while allowing arbitrary extra fields via `freeformType`.
|
while allowing arbitrary extra fields via `freeformType`.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
lspOptions :: SubmoduleType
|
lspOptions :: SubmoduleType
|
||||||
```
|
```
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
vim.languages.rust.lsp.options = {
|
vim.languages.rust.lsp.options = {
|
||||||
enable = true;
|
enable = true;
|
||||||
root_markers = [ "Cargo.toml" ];
|
root_markers = [ "Cargo.toml" ];
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
lspOptions = submodule {
|
lspOptions = submodule {
|
||||||
freeformType = attrsOf anything;
|
freeformType = attrsOf anything;
|
||||||
|
|
|
||||||
|
|
@ -2,28 +2,28 @@
|
||||||
inherit (lib.lists) elem all;
|
inherit (lib.lists) elem all;
|
||||||
in {
|
in {
|
||||||
/**
|
/**
|
||||||
Checks if all values are present in the list.
|
Checks if all values are present in the list.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
listContainsValues :: { list :: [a], values :: [a] } -> Bool
|
listContainsValues :: { list :: [a], values :: [a] } -> Bool
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `list`: A list of elements.
|
- `list`: A list of elements.
|
||||||
- `values`: A list of values to check for presence in the list.
|
- `values`: A list of values to check for presence in the list.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
listContainsValues { list = [1 2 3]; values = [2 3]; }
|
listContainsValues { list = [1 2 3]; values = [2 3]; }
|
||||||
=> true
|
=> true
|
||||||
|
|
||||||
listContainsValues { list = [1 2 3]; values = [2 4]; }
|
listContainsValues { list = [1 2 3]; values = [2 4]; }
|
||||||
=> false
|
=> false
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
listContainsValues = {
|
listContainsValues = {
|
||||||
list,
|
list,
|
||||||
|
|
|
||||||
90
lib/lua.nix
90
lib/lua.nix
|
|
@ -1,56 +1,56 @@
|
||||||
# Helpers for converting values to lua
|
# Helpers for converting values to lua
|
||||||
{lib}: let
|
{lib}: let
|
||||||
/**
|
/**
|
||||||
Test whether an object is a `luaInline` value (i.e. has `_type == "lua-inline"`).
|
Test whether an object is a `luaInline` value (i.e. has `_type == "lua-inline"`).
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
isLuaInline :: Any -> Bool
|
isLuaInline :: Any -> Bool
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `object`: Any Nix value.
|
- `object`: Any Nix value.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
isLuaInline (lib.mkLuaInline "vim.fn.getcwd()")
|
isLuaInline (lib.mkLuaInline "vim.fn.getcwd()")
|
||||||
=> true
|
=> true
|
||||||
|
|
||||||
isLuaInline "just a string"
|
isLuaInline "just a string"
|
||||||
=> false
|
=> false
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
isLuaInline = object: (object._type or null) == "lua-inline";
|
isLuaInline = object: (object._type or null) == "lua-inline";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Recursively convert a Nix value to its Lua representation as a string.
|
Recursively convert a Nix value to its Lua representation as a string.
|
||||||
|
|
||||||
Handles all primitive Nix types as well as lists, attribute sets,
|
Handles all primitive Nix types as well as lists, attribute sets,
|
||||||
derivations (rendered as their store path string), and `luaInline` values
|
derivations (rendered as their store path string), and `luaInline` values
|
||||||
(rendered verbatim). Null attributes are stripped from sets.
|
(rendered verbatim). Null attributes are stripped from sets.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
toLuaObject :: Any -> String
|
toLuaObject :: Any -> String
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `args`: Any Nix value to convert.
|
- `args`: Any Nix value to convert.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
toLuaObject { a = 1; b = true; c = null; }
|
toLuaObject { a = 1; b = true; c = null; }
|
||||||
=> ''{["a"] = 1,\n["b"] = true}''
|
=> ''{["a"] = 1,\n["b"] = true}''
|
||||||
|
|
||||||
toLuaObject [ "x" "y" ]
|
toLuaObject [ "x" "y" ]
|
||||||
=> ''{"x",\n"y"}''
|
=> ''{"x",\n"y"}''
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
toLuaObject = args:
|
toLuaObject = args:
|
||||||
{
|
{
|
||||||
|
|
@ -94,27 +94,27 @@ in
|
||||||
inherit isLuaInline toLuaObject;
|
inherit isLuaInline toLuaObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Convert a list of Lua expression strings into a Lua table string.
|
Convert a list of Lua expression strings into a Lua table string.
|
||||||
|
|
||||||
Each element is wrapped with `mkLuaInline` before conversion so that
|
Each element is wrapped with `mkLuaInline` before conversion so that
|
||||||
strings are treated as raw Lua rather than quoted string literals.
|
strings are treated as raw Lua rather than quoted string literals.
|
||||||
|
|
||||||
# Type
|
# Type
|
||||||
|
|
||||||
```
|
```
|
||||||
luaTable :: [String] -> String
|
luaTable :: [String] -> String
|
||||||
```
|
```
|
||||||
|
|
||||||
# Arguments
|
# Arguments
|
||||||
|
|
||||||
- `x`: List of Lua expression strings.
|
- `x`: List of Lua expression strings.
|
||||||
|
|
||||||
# Example
|
# Example
|
||||||
|
|
||||||
```nix
|
```nix
|
||||||
luaTable [ "vim.fn.getcwd()" "vim.fn.expand('%')" ]
|
luaTable [ "vim.fn.getcwd()" "vim.fn.expand('%')" ]
|
||||||
=> ''{vim.fn.getcwd(),\nvim.fn.expand('%')}''
|
=> ''{vim.fn.getcwd(),\nvim.fn.expand('%')}''
|
||||||
```
|
```
|
||||||
*/
|
*/
|
||||||
luaTable = x: (toLuaObject (map lib.mkLuaInline x));
|
luaTable = x: (toLuaObject (map lib.mkLuaInline x));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue