From 56e20dd9c8815087100adeb8b1892e3633ff9bbc Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 20 Jun 2026 02:08:55 +0300 Subject: [PATCH] lib: format nixdoc values Signed-off-by: NotAShelf Change-Id: Ia6dcbf5c44ff6d29e5760111179341226a6a6964 --- lib/attrsets.nix | 26 ++--- lib/binds.nix | 278 +++++++++++++++++++++++----------------------- lib/config.nix | 26 ++--- lib/dag.nix | 106 +++++++++--------- lib/languages.nix | 88 +++++++-------- lib/lists.nix | 30 ++--- lib/lua.nix | 90 +++++++-------- 7 files changed, 322 insertions(+), 322 deletions(-) diff --git a/lib/attrsets.nix b/lib/attrsets.nix index a282e992..9d098802 100644 --- a/lib/attrsets.nix +++ b/lib/attrsets.nix @@ -2,25 +2,25 @@ inherit (builtins) listToAttrs; 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. - - `list`: The list to map over. + - `f`: Function mapping each list element to a `{ name; value }` pair. + - `list`: The list to map over. - # Example + # Example - ```nix - mapListToAttrs (x: { name = x; value = x; }) ["a" "b"] - => { a = "a"; b = "b"; } - ``` + ```nix + mapListToAttrs (x: { name = x; value = x; }) ["a" "b"] + => { a = "a"; b = "b"; } + ``` */ mapListToAttrs = f: list: listToAttrs (map f list); } diff --git a/lib/binds.nix b/lib/binds.nix index 9e32be9b..217f8b54 100644 --- a/lib/binds.nix +++ b/lib/binds.nix @@ -6,26 +6,26 @@ 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. - - `action`: Lua expression to execute on keypress. - - `desc`: Human-readable description of the binding. + - `key`: The key sequence to bind, or `null` to disable. + - `action`: Lua expression to execute on keypress. + - `desc`: Human-readable description of the binding. - # Example + # Example - ```nix - mkLuaBinding "f" "require('telescope').find_files" "Find files" - => { "f" = { action = "require('telescope').find_files"; desc = "Find files"; lua = true; silent = true; }; } - ``` + ```nix + mkLuaBinding "f" "require('telescope').find_files" "Find files" + => { "f" = { action = "require('telescope').find_files"; desc = "Find files"; lua = true; silent = true; }; } + ``` */ mkLuaBinding = key: action: desc: 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. - - `action`: Lua expression evaluated as a Vim expression. - - `desc`: Human-readable description of the binding. + - `key`: The key sequence to bind, or `null` to disable. + - `action`: Lua expression evaluated as a Vim expression. + - `desc`: Human-readable description of the binding. - # Example + # Example - ```nix - mkExprBinding "" "v:count == 0 ? 'j' : 'gj'" "Smart down" - => { "" = { action = "v:count == 0 ? 'j' : 'gj'"; desc = "Smart down"; lua = true; silent = true; expr = true; }; } - ``` + ```nix + mkExprBinding "" "v:count == 0 ? 'j' : 'gj'" "Smart down" + => { "" = { action = "v:count == 0 ? 'j' : 'gj'"; desc = "Smart down"; lua = true; silent = true; expr = true; }; } + ``` */ mkExprBinding = key: action: desc: 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. - - `action`: Vimscript command or mapping string to execute. - - `desc`: Human-readable description of the binding. + - `key`: The key sequence to bind, or `null` to disable. + - `action`: Vimscript command or mapping string to execute. + - `desc`: Human-readable description of the binding. - # Example + # Example - ```nix - mkBinding "w" ":w" "Save file" - => { "w" = { action = ":w"; desc = "Save file"; silent = true; }; } - ``` + ```nix + mkBinding "w" ":w" "Save file" + => { "w" = { action = ":w"; desc = "Save file"; silent = true; }; } + ``` */ mkBinding = key: action: desc: 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. - - `default`: Default key value, or `null` for no binding. + - `description`: Documentation string for the option. + - `default`: Default key value, or `null` for no binding. - # Example + # Example - ```nix - mkMappingOption "Toggle file tree" "e" - => mkOption { type = nullOr str; default = "e"; description = "Toggle file tree"; } - ``` + ```nix + mkMappingOption "Toggle file tree" "e" + => mkOption { type = nullOr str; default = "e"; description = "Toggle file tree"; } + ``` */ mkMappingOption = description: default: 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 - keys to `{ description }` records. Produces an attribute set mapping - keys to `{ value; description }` records. Nesting is handled recursively. + Takes two attribute sets: one mapping keys to values and another mapping + keys to `{ description }` records. Produces an attribute set mapping + 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. - - `mappingDefinitions`: Attribute set of key → `{ description }` pairs. + - `actualMappings`: Attribute set of key → value pairs. + - `mappingDefinitions`: Attribute set of key → `{ description }` pairs. - # Example + # Example - ```nix - addDescriptionsToMappings { someKey = "some_value"; } { someKey = { description = "Some Description"; }; } - => { someKey = { value = "some_value"; description = "Some Description"; }; } - ``` + ```nix + addDescriptionsToMappings { someKey = "some_value"; } { someKey = { description = "Some Description"; }; } + => { someKey = { value = "some_value"; description = "Some Description"; }; } + ``` */ addDescriptionsToMappings = actualMappings: mappingDefinitions: mapAttrs (name: value: let @@ -165,124 +165,124 @@ 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. - - `action`: Vimscript command or mapping string to execute. + - `binding`: Binding record with `value` (key) and `description` fields. + - `action`: Vimscript command or mapping string to execute. - # Example + # Example - ```nix - mkSetBinding { value = "w"; description = "Save file"; } ":w" - => mkBinding "w" ":w" "Save file" - ``` + ```nix + mkSetBinding { value = "w"; description = "Save file"; } ":w" + => mkBinding "w" ":w" "Save file" + ``` */ mkSetBinding = binding: action: 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. - - `action`: Lua expression evaluated as a Vim expression. + - `binding`: Binding record with `value` (key) and `description` fields. + - `action`: Lua expression evaluated as a Vim expression. - # Example + # Example - ```nix - mkSetExprBinding { value = ""; description = "Smart down"; } "v:count == 0 ? 'j' : 'gj'" - => mkExprBinding "" "v:count == 0 ? 'j' : 'gj'" "Smart down" - ``` + ```nix + mkSetExprBinding { value = ""; description = "Smart down"; } "v:count == 0 ? 'j' : 'gj'" + => mkExprBinding "" "v:count == 0 ? 'j' : 'gj'" "Smart down" + ``` */ mkSetExprBinding = binding: action: 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. - - `action`: Lua expression to execute on keypress. + - `binding`: Binding record with `value` (key) and `description` fields. + - `action`: Lua expression to execute on keypress. - # Example + # Example - ```nix - mkSetLuaBinding { value = "f"; description = "Find files"; } "require('telescope').find_files" - => mkLuaBinding "f" "require('telescope').find_files" "Find files" - ``` + ```nix + mkSetLuaBinding { value = "f"; description = "Find files"; } "require('telescope').find_files" + => mkLuaBinding "f" "require('telescope').find_files" "Find files" + ``` */ mkSetLuaBinding = binding: action: 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 - be overridden by user configuration. + Useful for lowering the priority of a set of option defaults so they can + 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 - pushDownDefault { a = true; b = "hello"; } - => { a = mkDefault true; b = mkDefault "hello"; } - ``` + ```nix + pushDownDefault { a = true; b = "hello"; } + => { a = mkDefault true; b = mkDefault "hello"; } + ``` */ 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"`). - - `key`: Key sequence to bind. - - `action`: Action to execute on keypress. - - `opt`: Extra options merged into the resulting record. + - `mode`: Vim mode string (e.g. `"n"`, `"v"`, `"i"`). + - `key`: Key sequence to bind. + - `action`: Action to execute on keypress. + - `opt`: Extra options merged into the resulting record. - # Example + # Example - ```nix - mkKeymap "n" "w" ":w" { silent = true; } - => { mode = "n"; key = "w"; action = ":w"; silent = true; } - ``` + ```nix + mkKeymap "n" "w" ":w" { silent = true; } + => { mode = "n"; key = "w"; action = ":w"; silent = true; } + ``` */ mkKeymap = mode: key: action: opt: opt // {inherit mode key action;}; }; diff --git a/lib/config.nix b/lib/config.nix index 7ace434b..c0708aee 100644 --- a/lib/config.nix +++ b/lib/config.nix @@ -6,25 +6,25 @@ inherit (lib.lists) flatten; 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. - - `description`: Documentation string for the option. + - `value`: Default boolean value for the option. + - `description`: Documentation string for the option. - # Example + # Example - ```nix - mkBool true "Enable feature X" - => mkOption { type = bool; default = true; description = "Enable feature X"; } - ``` + ```nix + mkBool true "Enable feature X" + => mkOption { type = bool; default = true; description = "Enable feature X"; } + ``` */ mkBool = value: description: mkOption { diff --git a/lib/dag.nix b/lib/dag.nix index bf86d7bb..dbd58734 100644 --- a/lib/dag.nix +++ b/lib/dag.nix @@ -101,96 +101,96 @@ in { 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. - - `after`: List of entry names this entry must come after. - - `data`: Payload for this DAG entry. + - `before`: List of entry names this entry must come before. + - `after`: List of entry names this entry must come after. + - `data`: Payload for this DAG entry. - # Example + # Example - ```nix - entryBetween [ "c" ] [ "a" ] "payload" - => { data = "payload"; before = [ "c" ]; after = [ "a" ]; } - ``` + ```nix + entryBetween [ "c" ] [ "a" ] "payload" + => { data = "payload"; before = [ "c" ]; after = [ "a" ]; } + ``` */ 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 - entryAnywhere "lua code here" - => { data = "lua code here"; before = []; after = []; } - ``` + ```nix + entryAnywhere "lua code here" + => { data = "lua code here"; before = []; after = []; } + ``` */ 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. - - `data`: Payload for this DAG entry. + - `after`: List of entry names this entry must follow. + - `data`: Payload for this DAG entry. - # Example + # Example - ```nix - entryAfter [ "init" ] "setup code" - => { data = "setup code"; before = []; after = [ "init" ]; } - ``` + ```nix + entryAfter [ "init" ] "setup code" + => { data = "setup code"; before = []; after = [ "init" ]; } + ``` */ 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. - - `data`: Payload for this DAG entry. + - `before`: List of entry names this entry must precede. + - `data`: Payload for this DAG entry. - # Example + # Example - ```nix - entryBefore [ "teardown" ] "cleanup code" - => { data = "cleanup code"; before = [ "teardown" ]; after = []; } - ``` + ```nix + entryBefore [ "teardown" ] "cleanup code" + => { data = "cleanup code"; before = [ "teardown" ]; after = []; } + ``` */ entryBefore = before: entryBetween before []; diff --git a/lib/languages.nix b/lib/languages.nix index b2371bdb..a5f8b8f4 100644 --- a/lib/languages.nix +++ b/lib/languages.nix @@ -7,30 +7,30 @@ in { # 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` - and `package` fields, and produces named entries suitable for merging into - a null-ls/none-ls DAG. + Accepts either plain strings (provider type names) or attrsets with `type` + and `package` fields, and produces named entries suitable for merging into + 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. - - `config`: List of provider names (strings) or `{ type; package }` records. - - `diagnosticsProviders`: Attribute set mapping provider type names to `{ package; nullConfig }` records. + - `lang`: Language identifier used to prefix generated entry names. + - `config`: List of provider names (strings) or `{ type; package }` records. + - `diagnosticsProviders`: Attribute set mapping provider type names to `{ package; nullConfig }` records. - # Example + # Example - ```nix - diagnosticsToLua { lang = "python"; config = [ "flake8" ]; diagnosticsProviders = { flake8 = { package = pkgs.python3Packages.flake8; nullConfig = pkg: "..."; }; }; } - => { "python-diagnostics-flake8" = "..."; } - ``` + ```nix + diagnosticsToLua { lang = "python"; config = [ "flake8" ]; diagnosticsProviders = { flake8 = { package = pkgs.python3Packages.flake8; nullConfig = pkg: "..."; }; }; } + => { "python-diagnostics-flake8" = "..."; } + ``` */ diagnosticsToLua = { lang, @@ -54,24 +54,24 @@ in { 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 - mkEnable "LSP support" - => mkOption { default = false; type = bool; description = "Turn on LSP support for enabled languages by default"; } - ``` + ```nix + mkEnable "LSP support" + => mkOption { default = false; type = bool; description = "Turn on LSP support for enabled languages by default"; } + ``` */ mkEnable = desc: 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 - (`enable`, `capabilities`, `on_attach`, `filetypes`, `cmd`, `root_markers`) - while allowing arbitrary extra fields via `freeformType`. + Provides a structured set of well-known LSP configuration fields + (`enable`, `capabilities`, `on_attach`, `filetypes`, `cmd`, `root_markers`) + while allowing arbitrary extra fields via `freeformType`. - # Type + # Type - ``` - lspOptions :: SubmoduleType - ``` + ``` + lspOptions :: SubmoduleType + ``` - # Example + # Example - ```nix - vim.languages.rust.lsp.options = { - enable = true; - root_markers = [ "Cargo.toml" ]; - }; - ``` + ```nix + vim.languages.rust.lsp.options = { + enable = true; + root_markers = [ "Cargo.toml" ]; + }; + ``` */ lspOptions = submodule { freeformType = attrsOf anything; diff --git a/lib/lists.nix b/lib/lists.nix index 448014fb..f45997d8 100644 --- a/lib/lists.nix +++ b/lib/lists.nix @@ -2,28 +2,28 @@ inherit (lib.lists) elem all; 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. - - `values`: A list of values to check for presence in the list. + - `list`: A list of elements. + - `values`: A list of values to check for presence in the list. - # Example + # Example - ```nix - listContainsValues { list = [1 2 3]; values = [2 3]; } - => true + ```nix + listContainsValues { list = [1 2 3]; values = [2 3]; } + => true - listContainsValues { list = [1 2 3]; values = [2 4]; } - => false - ``` + listContainsValues { list = [1 2 3]; values = [2 4]; } + => false + ``` */ listContainsValues = { list, diff --git a/lib/lua.nix b/lib/lua.nix index 547feddc..90d557b7 100644 --- a/lib/lua.nix +++ b/lib/lua.nix @@ -1,56 +1,56 @@ # Helpers for converting values to lua {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 - isLuaInline (lib.mkLuaInline "vim.fn.getcwd()") - => true + ```nix + isLuaInline (lib.mkLuaInline "vim.fn.getcwd()") + => true - isLuaInline "just a string" - => false - ``` + isLuaInline "just a string" + => false + ``` */ 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, - derivations (rendered as their store path string), and `luaInline` values - (rendered verbatim). Null attributes are stripped from sets. + Handles all primitive Nix types as well as lists, attribute sets, + derivations (rendered as their store path string), and `luaInline` values + (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 - toLuaObject { a = 1; b = true; c = null; } - => ''{["a"] = 1,\n["b"] = true}'' + ```nix + toLuaObject { a = 1; b = true; c = null; } + => ''{["a"] = 1,\n["b"] = true}'' - toLuaObject [ "x" "y" ] - => ''{"x",\n"y"}'' - ``` + toLuaObject [ "x" "y" ] + => ''{"x",\n"y"}'' + ``` */ toLuaObject = args: { @@ -94,27 +94,27 @@ in 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 - strings are treated as raw Lua rather than quoted string literals. + Each element is wrapped with `mkLuaInline` before conversion so that + 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 - luaTable [ "vim.fn.getcwd()" "vim.fn.expand('%')" ] - => ''{vim.fn.getcwd(),\nvim.fn.expand('%')}'' - ``` + ```nix + luaTable [ "vim.fn.getcwd()" "vim.fn.expand('%')" ] + => ''{vim.fn.getcwd(),\nvim.fn.expand('%')}'' + ``` */ luaTable = x: (toLuaObject (map lib.mkLuaInline x)); }