mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
lib: remove helpers
from internal usage
This commit is contained in:
parent
2c4e4681db
commit
cd76b4feb8
7 changed files with 38 additions and 39 deletions
|
@ -1,6 +1,7 @@
|
||||||
{ lib, helpers }:
|
{ lib }:
|
||||||
let
|
let
|
||||||
inherit (lib) types;
|
inherit (lib) types;
|
||||||
|
inherit (lib.nixvim) defaultNullOpts;
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
autoGroupOption = types.submodule {
|
autoGroupOption = types.submodule {
|
||||||
|
@ -14,34 +15,34 @@ rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
autoCmdOptions = {
|
autoCmdOptions = {
|
||||||
event = helpers.mkNullOrOption (with types; either str (listOf str)) ''
|
event = lib.nixvim.mkNullOrOption (with types; either str (listOf str)) ''
|
||||||
The event or events to register this autocommand.
|
The event or events to register this autocommand.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
group = helpers.mkNullOrOption (with types; either str int) ''
|
group = lib.nixvim.mkNullOrOption (with types; either str int) ''
|
||||||
The autocommand group name or id to match against.
|
The autocommand group name or id to match against.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
pattern = helpers.mkNullOrOption (with types; either str (listOf str)) ''
|
pattern = lib.nixvim.mkNullOrOption (with types; either str (listOf str)) ''
|
||||||
Pattern or patterns to match literally against.
|
Pattern or patterns to match literally against.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
buffer = helpers.mkNullOrOption types.int ''
|
buffer = lib.nixvim.mkNullOrOption types.int ''
|
||||||
Buffer number for buffer local autocommands |autocmd-buflocal|.
|
Buffer number for buffer local autocommands |autocmd-buflocal|.
|
||||||
Cannot be used with `pattern`.
|
Cannot be used with `pattern`.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Introduced early October 2023.
|
# Introduced early October 2023.
|
||||||
# TODO remove in early December 2023.
|
# TODO remove in early December 2023.
|
||||||
description = helpers.mkNullOrOption types.str ''
|
description = lib.nixvim.mkNullOrOption types.str ''
|
||||||
DEPRECATED, please use `desc`.
|
DEPRECATED, please use `desc`.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
desc = helpers.mkNullOrOption types.str ''
|
desc = lib.nixvim.mkNullOrOption types.str ''
|
||||||
A textual description of this autocommand.
|
A textual description of this autocommand.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
callback = helpers.mkNullOrOption (with types; either str rawLua) ''
|
callback = lib.nixvim.mkNullOrOption (with types; either str rawLua) ''
|
||||||
A function or a string.
|
A function or a string.
|
||||||
- if a string, the name of a Vimscript function to call when this autocommand is triggered.
|
- if a string, the name of a Vimscript function to call when this autocommand is triggered.
|
||||||
- Otherwise, a Lua function which is called when this autocommand is triggered.
|
- Otherwise, a Lua function which is called when this autocommand is triggered.
|
||||||
|
@ -65,13 +66,13 @@ rec {
|
||||||
}
|
}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
command = helpers.defaultNullOpts.mkStr "" ''
|
command = defaultNullOpts.mkStr "" ''
|
||||||
Vim command to execute on event. Cannot be used with `callback`.
|
Vim command to execute on event. Cannot be used with `callback`.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
once = helpers.defaultNullOpts.mkBool false "Run the autocommand only once.";
|
once = defaultNullOpts.mkBool false "Run the autocommand only once.";
|
||||||
|
|
||||||
nested = helpers.defaultNullOpts.mkBool false "Run nested autocommands.";
|
nested = defaultNullOpts.mkBool false "Run nested autocommands.";
|
||||||
};
|
};
|
||||||
|
|
||||||
autoCmdOption = types.submodule { options = autoCmdOptions; };
|
autoCmdOption = types.submodule { options = autoCmdOptions; };
|
||||||
|
|
|
@ -4,14 +4,12 @@
|
||||||
_nixvimTests ? false,
|
_nixvimTests ? false,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
# Build helpers recursively
|
|
||||||
lib.fix (
|
lib.fix (
|
||||||
self:
|
self:
|
||||||
let
|
let
|
||||||
# Used when importing parts of helpers
|
# Used when importing parts of our lib
|
||||||
call = lib.callPackageWith {
|
call = lib.callPackageWith {
|
||||||
inherit call pkgs self;
|
inherit call pkgs self;
|
||||||
helpers = self; # TODO: stop using `helpers` in the subsections
|
|
||||||
lib = self.extendedLib;
|
lib = self.extendedLib;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,28 @@
|
||||||
{ lib, helpers }:
|
{ lib }:
|
||||||
let
|
let
|
||||||
inherit (lib) optionalAttrs isAttrs types;
|
inherit (lib) optionalAttrs isAttrs types;
|
||||||
|
inherit (lib.nixvim) defaultNullOpts;
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
# These are the configuration options that change the behavior of each mapping.
|
# These are the configuration options that change the behavior of each mapping.
|
||||||
mapConfigOptions = {
|
mapConfigOptions = {
|
||||||
silent = helpers.defaultNullOpts.mkBool false "Whether this mapping should be silent. Equivalent to adding `<silent>` to a map.";
|
silent = defaultNullOpts.mkBool false "Whether this mapping should be silent. Equivalent to adding `<silent>` to a map.";
|
||||||
|
|
||||||
nowait = helpers.defaultNullOpts.mkBool false "Whether to wait for extra input on ambiguous mappings. Equivalent to adding `<nowait>` to a map.";
|
nowait = defaultNullOpts.mkBool false "Whether to wait for extra input on ambiguous mappings. Equivalent to adding `<nowait>` to a map.";
|
||||||
|
|
||||||
script = helpers.defaultNullOpts.mkBool false "Equivalent to adding `<script>` to a map.";
|
script = defaultNullOpts.mkBool false "Equivalent to adding `<script>` to a map.";
|
||||||
|
|
||||||
expr = helpers.defaultNullOpts.mkBool false "Means that the action is actually an expression. Equivalent to adding `<expr>` to a map.";
|
expr = defaultNullOpts.mkBool false "Means that the action is actually an expression. Equivalent to adding `<expr>` to a map.";
|
||||||
|
|
||||||
unique = helpers.defaultNullOpts.mkBool false "Whether to fail if the map is already defined. Equivalent to adding `<unique>` to a map.";
|
unique = defaultNullOpts.mkBool false "Whether to fail if the map is already defined. Equivalent to adding `<unique>` to a map.";
|
||||||
|
|
||||||
noremap = helpers.defaultNullOpts.mkBool true "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.";
|
noremap = defaultNullOpts.mkBool true "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.";
|
||||||
|
|
||||||
remap = helpers.defaultNullOpts.mkBool false "Make the mapping recursive. Inverses `noremap`.";
|
remap = defaultNullOpts.mkBool false "Make the mapping recursive. Inverses `noremap`.";
|
||||||
|
|
||||||
desc = helpers.mkNullOrOption lib.types.str "A textual description of this keybind, to be shown in which-key, if you have it.";
|
desc = lib.nixvim.mkNullOrOption lib.types.str "A textual description of this keybind, to be shown in which-key, if you have it.";
|
||||||
|
|
||||||
buffer = helpers.defaultNullOpts.mkBool false "Make the mapping buffer-local. Equivalent to adding `<buffer>` to a map.";
|
buffer = defaultNullOpts.mkBool false "Make the mapping buffer-local. Equivalent to adding `<buffer>` to a map.";
|
||||||
};
|
};
|
||||||
|
|
||||||
modes = {
|
modes = {
|
||||||
|
@ -120,7 +121,7 @@ rec {
|
||||||
{
|
{
|
||||||
type = types.maybeRaw types.str;
|
type = types.maybeRaw types.str;
|
||||||
description = "The action to execute.";
|
description = "The action to execute.";
|
||||||
apply = v: if options.lua.isDefined or false && config.lua then helpers.mkRaw v else v;
|
apply = v: if options.lua.isDefined or false && config.lua then lib.nixvim.mkRaw v else v;
|
||||||
}
|
}
|
||||||
// (optionalAttrs (isAttrs action) action)
|
// (optionalAttrs (isAttrs action) action)
|
||||||
// (optionalAttrs (defaults ? action) { default = defaults.action; })
|
// (optionalAttrs (defaults ? action) { default = defaults.action; })
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, helpers }:
|
{ lib }:
|
||||||
{
|
{
|
||||||
# TODO: DEPRECATED: use the `settings` option instead
|
# TODO: DEPRECATED: use the `settings` option instead
|
||||||
extraOptionsOptions = {
|
extraOptionsOptions = {
|
||||||
|
@ -68,7 +68,7 @@
|
||||||
|
|
||||||
setupCode = ''
|
setupCode = ''
|
||||||
require('${luaName}')${setup}(${
|
require('${luaName}')${setup}(${
|
||||||
lib.optionalString (cfg ? settings) (helpers.toLuaObject cfg.settings)
|
lib.optionalString (cfg ? settings) (lib.nixvim.toLuaObject cfg.settings)
|
||||||
})
|
})
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// lib.optionalAttrs hasSettings {
|
// lib.optionalAttrs hasSettings {
|
||||||
settings = helpers.mkSettingsOption {
|
settings = lib.nixvim.mkSettingsOption {
|
||||||
description = settingsDescription;
|
description = settingsDescription;
|
||||||
options = settingsOptions;
|
options = settingsOptions;
|
||||||
example = settingsExample;
|
example = settingsExample;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, helpers }:
|
{ lib }:
|
||||||
let
|
let
|
||||||
inherit (lib) types;
|
inherit (lib) types;
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ rec {
|
||||||
args
|
args
|
||||||
// {
|
// {
|
||||||
type = types.strLua;
|
type = types.strLua;
|
||||||
apply = helpers.mkRaw;
|
apply = lib.nixvim.mkRaw;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
mkNullOrLua = description: mkNullOrLua' { inherit description; };
|
mkNullOrLua = description: mkNullOrLua' { inherit description; };
|
||||||
|
@ -107,7 +107,7 @@ rec {
|
||||||
args
|
args
|
||||||
// {
|
// {
|
||||||
type = types.strLuaFn;
|
type = types.strLuaFn;
|
||||||
apply = helpers.mkRaw;
|
apply = lib.nixvim.mkRaw;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
mkNullOrLuaFn = description: mkNullOrLua' { inherit description; };
|
mkNullOrLuaFn = description: mkNullOrLua' { inherit description; };
|
||||||
|
@ -118,7 +118,7 @@ rec {
|
||||||
args
|
args
|
||||||
// {
|
// {
|
||||||
type = with types; either strLua type;
|
type = with types; either strLua type;
|
||||||
apply = v: if lib.isString v then helpers.mkRaw v else v;
|
apply = v: if lib.isString v then lib.nixvim.mkRaw v else v;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
mkNullOrStrLuaOr = type: description: mkNullOrStrLuaOr' { inherit type description; };
|
mkNullOrStrLuaOr = type: description: mkNullOrStrLuaOr' { inherit type description; };
|
||||||
|
@ -129,7 +129,7 @@ rec {
|
||||||
args
|
args
|
||||||
// {
|
// {
|
||||||
type = with types; either strLuaFn type;
|
type = with types; either strLuaFn type;
|
||||||
apply = v: if lib.isString v then helpers.mkRaw v else v;
|
apply = v: if lib.isString v then lib.nixvim.mkRaw v else v;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
mkNullOrStrLuaFnOr = type: description: mkNullOrStrLuaFnOr' { inherit type description; };
|
mkNullOrStrLuaFnOr = type: description: mkNullOrStrLuaFnOr' { inherit type description; };
|
||||||
|
@ -149,7 +149,7 @@ rec {
|
||||||
in
|
in
|
||||||
rec {
|
rec {
|
||||||
# TODO: removed 2024-06-14; remove stub 2024-09-01
|
# TODO: removed 2024-06-14; remove stub 2024-09-01
|
||||||
mkDesc = abort "mkDesc has been removed. Use the `pluginDefault` argument or `helpers.pluginDefaultText`.";
|
mkDesc = abort "mkDesc has been removed. Use the `pluginDefault` argument or `lib.nixvim.pluginDefaultText`.";
|
||||||
|
|
||||||
mkNullable' = args: mkNullOrOption' (processDefaultNullArgs args);
|
mkNullable' = args: mkNullOrOption' (processDefaultNullArgs args);
|
||||||
mkNullable =
|
mkNullable =
|
||||||
|
@ -277,7 +277,7 @@ rec {
|
||||||
if lib.isInt value then
|
if lib.isInt value then
|
||||||
value
|
value
|
||||||
else
|
else
|
||||||
helpers.mkRaw "vim.diagnostic.severity.${lib.strings.toUpper value}"
|
lib.nixvim.mkRaw "vim.diagnostic.severity.${lib.strings.toUpper value}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -291,7 +291,7 @@ rec {
|
||||||
type = with types; either ints.unsigned logLevel;
|
type = with types; either ints.unsigned logLevel;
|
||||||
apply = lib.mapNullable (
|
apply = lib.mapNullable (
|
||||||
value:
|
value:
|
||||||
if lib.isInt value then value else helpers.mkRaw "vim.log.levels.${lib.strings.toUpper value}"
|
if lib.isInt value then value else lib.nixvim.mkRaw "vim.log.levels.${lib.strings.toUpper value}"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
helpers,
|
|
||||||
_nixvimTests,
|
_nixvimTests,
|
||||||
}:
|
}:
|
||||||
rec {
|
rec {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ lib, helpers }:
|
{ lib }:
|
||||||
{
|
{
|
||||||
mkVimPlugin =
|
mkVimPlugin =
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
createSettingsOption = (lib.isString globalPrefix) && (globalPrefix != "");
|
createSettingsOption = (lib.isString globalPrefix) && (globalPrefix != "");
|
||||||
|
|
||||||
settingsOption = lib.optionalAttrs createSettingsOption {
|
settingsOption = lib.optionalAttrs createSettingsOption {
|
||||||
settings = helpers.mkSettingsOption {
|
settings = lib.nixvim.mkSettingsOption {
|
||||||
options = settingsOptions;
|
options = settingsOptions;
|
||||||
example = settingsExample;
|
example = settingsExample;
|
||||||
description = ''
|
description = ''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue