Skip to content

Commit

Permalink
lib: remove nixvimTypes alias
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Sep 27, 2024
1 parent bafc630 commit 2f49c76
Show file tree
Hide file tree
Showing 59 changed files with 262 additions and 279 deletions.
17 changes: 11 additions & 6 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,18 @@ lib.fix (
wrapVimscriptForLua
;

# TODO: Removed 2024-09-27
maintainers = throw "The `maintainers` alias has been removed. Use `lib.maintainers` on a lib with nixvim's extensions.";

# TODO: Deprecate the old `nixvimTypes` alias?
nixvimTypes = self.extendedLib.types;

toLuaObject = self.lua.toLua;
mkLuaInline = self.lua.mkInline;
}
//
# TODO: Removed 2024-09-27; remove after 24.11
lib.mapAttrs
(
old: new:
throw "The `${old}` alias has been removed. Use `${new}` on a lib with nixvim's extensions."
)
{
maintainers = "lib.maintainers";
nixvimTypes = "lib.types";
}
)
2 changes: 1 addition & 1 deletion lib/neovim-plugin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
}
// lib.optionalAttrs hasConfigAttrs {
luaConfig = lib.mkOption {
type = lib.nixvim.nixvimTypes.pluginLuaConfig;
type = lib.types.pluginLuaConfig;
default = { };
description = "The plugin's lua configuration";
};
Expand Down
4 changes: 2 additions & 2 deletions modules/commands.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let
commandAttributes = lib.types.submodule {
options = {
command = lib.mkOption {
type = with helpers.nixvimTypes; either str rawLua;
type = with lib.types; either str rawLua;
description = "The command to run.";
};

Expand All @@ -24,7 +24,7 @@ let
''
The number of arguments to expect, see :h command-nargs.
'';
complete = helpers.mkNullOrOption (with lib.types; either str helpers.nixvimTypes.rawLua) ''
complete = helpers.mkNullOrOption (with lib.types; either str rawLua) ''
Tab-completion behaviour, see :h command-complete.
'';
range =
Expand Down
2 changes: 1 addition & 1 deletion modules/filetype.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let
# Raw filetype
str
# Function to set the filetype
helpers.nixvimTypes.rawLua
rawLua
# ["filetype" {priority = xx;}]
(listOf (
either str (submodule {
Expand Down
4 changes: 2 additions & 2 deletions modules/highlights.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
options = {
highlight = lib.mkOption {
type = lib.types.attrsOf helpers.nixvimTypes.highlight;
type = lib.types.attrsOf lib.types.highlight;
default = { };
description = "Define new highlight groups";
example = {
Expand All @@ -16,7 +16,7 @@
};

highlightOverride = lib.mkOption {
type = lib.types.attrsOf helpers.nixvimTypes.highlight;
type = lib.types.attrsOf lib.types.highlight;
default = { };
description = "Define highlight groups to override existing highlight";
example = {
Expand Down
52 changes: 25 additions & 27 deletions plugins/by-name/airline/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mkVimPlugin {
name:
nameValuePair "section_${name}" (
helpers.mkNullOrOption (
with helpers.nixvimTypes;
with lib.types;
oneOf [
rawLua
str
Expand Down Expand Up @@ -111,7 +111,7 @@ mkVimPlugin {
detect_spelllang =
helpers.defaultNullOpts.mkNullable
(
with helpers.nixvimTypes;
with lib.types;
oneOf [
rawLua
intFlag
Expand Down Expand Up @@ -179,47 +179,45 @@ mkVimPlugin {
If you want to use plain ascii symbols, set this variable: >
'';

mode_map = helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (attrsOf str)) ''
mode_map = helpers.mkNullOrOption (with lib.types; maybeRaw (attrsOf str)) ''
Define the set of text to display for each mode.
Default: see source
'';

exclude_filenames = helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (listOf str)) ''
exclude_filenames = helpers.mkNullOrOption (with lib.types; maybeRaw (listOf str)) ''
Define the set of filename match queries which excludes a window from having its
statusline modified.
Default: see source for current list
'';

exclude_filetypes = helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (listOf str)) ''
exclude_filetypes = helpers.mkNullOrOption (with lib.types; maybeRaw (listOf str)) ''
Define the set of filetypes which are excluded from having its window statusline modified.
Default: see source for current list
'';

filetype_overrides =
helpers.mkNullOrOption (with helpers.nixvimTypes; maybeRaw (attrsOf (listOf str)))
''
Define the set of names to be displayed instead of a specific filetypes.
Example:
```nix
{
coc-explorer = ["CoC Explorer" ""];
defx = ["defx" "%{b:defx.paths[0]}"];
fugitive = ["fugitive" "%{airline#util#wrap(airline#extensions#branch#get_head(),80)}"];
gundo = ["Gundo" "" ];
help = ["Help" "%f"];
minibufexpl = ["MiniBufExplorer" ""];
startify = ["startify" ""];
vim-plug = ["Plugins" ""];
vimfiler = ["vimfiler" "%{vimfiler#get_status_string()}"];
vimshell = ["vimshell" "%{vimshell#get_status_string()}"];
vaffle = ["Vaffle" "%{b:vaffle.dir}"];
}
```
'';
filetype_overrides = helpers.mkNullOrOption (with lib.types; maybeRaw (attrsOf (listOf str))) ''
Define the set of names to be displayed instead of a specific filetypes.
Example:
```nix
{
coc-explorer = ["CoC Explorer" ""];
defx = ["defx" "%{b:defx.paths[0]}"];
fugitive = ["fugitive" "%{airline#util#wrap(airline#extensions#branch#get_head(),80)}"];
gundo = ["Gundo" "" ];
help = ["Help" "%f"];
minibufexpl = ["MiniBufExplorer" ""];
startify = ["startify" ""];
vim-plug = ["Plugins" ""];
vimfiler = ["vimfiler" "%{vimfiler#get_status_string()}"];
vimshell = ["vimshell" "%{vimshell#get_status_string()}"];
vaffle = ["Vaffle" "%{b:vaffle.dir}"];
}
```
'';

exclude_preview = helpers.defaultNullOpts.mkFlagInt 0 ''
Defines whether the preview window should be excluded from having its window statusline
Expand Down
4 changes: 2 additions & 2 deletions plugins/by-name/bufferline/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
...
}:
let
inherit (lib.nixvim) defaultNullOpts nixvimTypes mkSettingsRenamedOptionModules;
types = nixvimTypes;
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts mkSettingsRenamedOptionModules;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "bufferline";
Expand Down
4 changes: 2 additions & 2 deletions plugins/by-name/clipboard-image/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let
imgDir =
helpers.defaultNullOpts.mkNullable
(
with helpers.nixvimTypes;
with lib.types;
oneOf [
str
(listOf str)
Expand All @@ -29,7 +29,7 @@ let
'';

imgDirTxt = helpers.defaultNullOpts.mkNullable (
with helpers.nixvimTypes;
with lib.types;
oneOf [
str
(listOf str)
Expand Down
4 changes: 2 additions & 2 deletions plugins/by-name/dap/dap-python.nix
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ in
By default the `VIRTUAL_ENV` and `CONDA_PREFIX` environment variables are used if present.
'';

testRunner = helpers.mkNullOrOption (types.either types.str helpers.nixvimTypes.rawLua) ''
testRunner = helpers.mkNullOrOption (types.either types.str types.rawLua) ''
The name of test runner to use by default.
The default value is dynamic and depends on `pytest.ini` or `manage.py` markers.
If neither is found "unittest" is used.
'';

testRunners = helpers.mkNullOrOption (with helpers.nixvimTypes; attrsOf strLuaFn) ''
testRunners = helpers.mkNullOrOption (with lib.types; attrsOf strLuaFn) ''
Set to register test runners.
Built-in are test runners for unittest, pytest and django.
The key is the test runner name, the value a function to generate the
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/debugprint/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ helpers.neovim-plugin.mkNeovimPlugin {

settingsOptions = {
keymaps =
helpers.defaultNullOpts.mkAttrsOf (with helpers.nixvimTypes; attrsOf (either str rawLua))
helpers.defaultNullOpts.mkAttrsOf (with lib.types; attrsOf (either str rawLua))
{
normal = {
plain_below = "g?p";
Expand Down
4 changes: 2 additions & 2 deletions plugins/by-name/edgy/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ helpers.neovim-plugin.mkNeovimPlugin {
in
helpers.mkNullOrOption' {
type =
with helpers.nixvimTypes;
with lib.types;
either strLua (submodule {
freeformType = attrsOf anything;
options = {
Expand Down Expand Up @@ -181,7 +181,7 @@ helpers.neovim-plugin.mkNeovimPlugin {
# This option accepts an attrs or a lua string.
# Hence, we convert the string to raw lua in `apply`.
keys = helpers.defaultNullOpts.mkAttrsOf' {
type = with helpers.nixvimTypes; either strLuaFn (enum [ false ]);
type = with lib.types; either strLuaFn (enum [ false ]);
apply = x: if x == null then null else mapAttrs (_: v: if isString v then helpers.mkRaw v else v) x;
description = ''
Buffer-local keymaps to be added to edgebar buffers.
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/fidget/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ let
with types;
oneOf [
str
helpers.nixvimTypes.rawLua
rawLua
(listOf str)
(attrsOf (either str ints.unsigned))
]
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/firenvim/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
...
}:
let
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts;
types = lib.nixvim.nixvimTypes;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "firenvim";
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/gitblame/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
...
}:
let
inherit (lib) types;
inherit (lib.nixvim) defaultNullOpts;
types = lib.nixvim.nixvimTypes;
in
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "gitblame";
Expand Down
3 changes: 1 addition & 2 deletions plugins/by-name/gitlinker/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ with lib;
'';

actionCallback =
helpers.defaultNullOpts.mkNullable (with types; either str helpers.nixvimTypes.rawLua)
"copy_to_clipboard"
helpers.defaultNullOpts.mkNullable (with types; either str rawLua) "copy_to_clipboard"
''
Callback for what to do with the url.
Expand Down
4 changes: 2 additions & 2 deletions plugins/by-name/gitsigns/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ with lib;
freeformType = with types; attrsOf anything;
options = {
toplevel = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
type = with lib.types; maybeRaw str;
description = ''
Path to the top-level of the parent git repository.
'';
};

gitdir = mkOption {
type = with helpers.nixvimTypes; maybeRaw str;
type = with lib.types; maybeRaw str;
description = ''
Path to the git directory of the parent git repository (typically the `.git/` directory).
'';
Expand Down
6 changes: 3 additions & 3 deletions plugins/by-name/hydra/hydras-option.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ let
'';

mode = helpers.defaultNullOpts.mkNullable (
with helpers.nixvimTypes; either helpers.keymaps.modeEnum (listOf helpers.keymaps.modeEnum)
with lib.types; either helpers.keymaps.modeEnum (listOf helpers.keymaps.modeEnum)
) "n" "Modes where the hydra exists, same as `vim.keymap.set()` accepts.";

body = helpers.mkNullOrStr ''
Expand Down Expand Up @@ -75,12 +75,12 @@ let
'';

mode = helpers.mkNullOrOption (
with helpers.nixvimTypes; either helpers.keymaps.modeEnum (listOf helpers.keymaps.modeEnum)
with lib.types; either helpers.keymaps.modeEnum (listOf helpers.keymaps.modeEnum)
) "Override `mode` for this head.";
};
};
headType =
with helpers.nixvimTypes;
with lib.types;
# More precisely, a tuple: [head action opts]
listOf (
nullOr (
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/hydra/settings-options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ with lib;
'';

funcs = mkOption {
type = with helpers.nixvimTypes; attrsOf strLuaFn;
type = with lib.types; attrsOf strLuaFn;
description = ''
Table from function names to function.
Functions should return a string.
Expand Down
4 changes: 2 additions & 2 deletions plugins/by-name/improved-search/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ helpers.vim-plugin.mkVimPlugin {
See [here](https://github.com/backdround/improved-search.nvim?tab=readme-ov-file#functions-and-operators) for the list of available callbacks.
'';
type =
with helpers.nixvimTypes;
with lib.types;
listOf (submodule {
options = {
key = mkOption {
Expand All @@ -34,7 +34,7 @@ helpers.vim-plugin.mkVimPlugin {

action = mkOption {
type =
with helpers.nixvimTypes;
with lib.types;
maybeRaw (
# https://github.com/backdround/improved-search.nvim?tab=readme-ov-file#functions-and-operators
enum [
Expand Down
2 changes: 1 addition & 1 deletion plugins/by-name/leap/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ in
};

safeLabels =
helpers.defaultNullOpts.mkNullable (with helpers.nixvimTypes; maybeRaw (listOf str))
helpers.defaultNullOpts.mkNullable (with lib.types; maybeRaw (listOf str))
(stringToCharacters "sfnut/SFNLHMUGT?Z")
''
When the number of matches does not exceed the number of these "safe" labels plus one, the
Expand Down
6 changes: 3 additions & 3 deletions plugins/by-name/lint/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ let
};

args = {
type = listOf (either str helpers.nixvimTypes.rawLua);
type = listOf (either str rawLua);
description = ''
List of arguments.
Can contain functions with zero arguments that will be evaluated once the linter is used.
Expand Down Expand Up @@ -86,7 +86,7 @@ let
};

parser = {
type = helpers.nixvimTypes.strLuaFn;
type = lib.types.strLuaFn;
description = "The code for your parser function.";
example = ''
require('lint.parser').from_pattern(pattern, groups, severity_map, defaults, opts)
Expand Down Expand Up @@ -211,7 +211,7 @@ in
};

callback = mkOption {
type = with types; nullOr (either str helpers.nixvimTypes.rawLua);
type = with types; nullOr (either str rawLua);
default = defaultCallback;
description = "What action to perform for linting";
};
Expand Down
Loading

0 comments on commit 2f49c76

Please sign in to comment.