Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into nixpkgs_module
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSturgeon committed Sep 20, 2024
2 parents 1855238 + c2080ed commit 827594e
Show file tree
Hide file tree
Showing 104 changed files with 2,516 additions and 206 deletions.
2 changes: 1 addition & 1 deletion .github/mergify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ queue_rules:
update_method: rebase
merge_method: fast-forward
merge_conditions:
- check-success = buildbot/nix-eval
- check-success = buildbot/nix-build
queue_conditions:
- or:
# Allow queuing PRs that have been approved
Expand Down
12 changes: 11 additions & 1 deletion flake-modules/legacy-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,24 @@
perSystem =
{
pkgs,
config,
helpers,
makeNixvimWithModule,
...
}:
{
legacyPackages = rec {
inherit makeNixvimWithModule;
makeNixvim = module: makeNixvimWithModule { inherit module; };

nixvimConfiguration = helpers.modules.evalNixvim {
modules = [
{ nixpkgs.pkgs = pkgs; }
];
extraSpecialArgs = {
defaultPkgs = pkgs;
};
check = false;
};
};
};
}
15 changes: 4 additions & 11 deletions flake-modules/tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,11 @@
system,
helpers,
makeNixvimWithModule,
self',
...
}:
let
evaluatedNixvim = helpers.modules.evalNixvim {
modules = [
{ nixpkgs.pkgs = pkgs; }
];
extraSpecialArgs = {
defaultPkgs = pkgs;
};
check = false;
};
inherit (self'.legacyPackages) nixvimConfiguration;
in
{
checks = {
Expand Down Expand Up @@ -53,11 +46,11 @@

maintainers = import ../tests/maintainers.nix { inherit pkgs; };

plugins-by-name = pkgs.callPackage ../tests/plugins-by-name.nix { inherit evaluatedNixvim; };
plugins-by-name = pkgs.callPackage ../tests/plugins-by-name.nix { inherit nixvimConfiguration; };

generated = pkgs.callPackage ../tests/generated.nix { };

package-options = pkgs.callPackage ../tests/package-options.nix { inherit evaluatedNixvim; };
package-options = pkgs.callPackage ../tests/package-options.nix { inherit nixvimConfiguration; };
} // import ../tests { inherit pkgs pkgsUnfree helpers; };
};
}
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions generated/efmls-configs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
linter = {
lang = "c";
possible = [
"clang_format"
"clang_tidy"
"cppcheck"
"cpplint"
Expand Down Expand Up @@ -135,6 +136,7 @@
linter = {
lang = "c++";
possible = [
"clang_format"
"clang_tidy"
"clazy"
"cppcheck"
Expand Down
99 changes: 85 additions & 14 deletions lib/utils.nix
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,98 @@ rec {
end
'';

/**
Convert the given String to a Lua [long literal].
For example, you could use this to safely pass a Vimscript string to the
`vim.cmd` function.
[long literal]: https://www.lua.org/manual/5.4/manual.html#3.1
# Examples
```nix
nix-repl> toLuaLongLiteral "simple"
"[[simple]]"
```
```nix
nix-repl> toLuaLongLiteral "]]"
"[=[]]]=]"
```
# Type
```
toLuaLongLiteral :: String -> String
```
*/
toLuaLongLiteral =
string:
let
findTokens =
depth:
let
infix = lib.strings.replicate depth "=";
tokens.open = "[${infix}[";
tokens.close = "]${infix}]";
in
if lib.hasInfix tokens.close string then findTokens (depth + 1) else tokens;

tokens = findTokens 0;
in
tokens.open + string + tokens.close;

/**
Convert the given String into a Vimscript [:let-heredoc].
For example, you could use this to invoke [:lua].
[:let-heredoc]: https://neovim.io/doc/user/eval.html#%3Alet-heredoc
[:lua]: https://neovim.io/doc/user/lua.html#%3Alua-heredoc
# Examples
```nix
toVimscriptHeredoc "simple"
=> "<< EOF\nsimple\nEOF"
```
```nix
toVimscriptHeredoc "EOF"
=> "<< EOFF\nEOF\nEOFF"
```
# Type
```
toVimscriptHeredoc :: String -> String
```
*/
toVimscriptHeredoc =
string:
let
findToken =
depth:
let
token = "EOF" + lib.strings.replicate depth "F";
in
if lib.hasInfix token string then findToken (depth + 1) else token;

token = findToken 0;
in
''
<< ${token}
${string}
${token}'';

# Wrap Vimscript for using in lua,
# but only if the string contains something other than whitespaces
# TODO: account for a possible ']]' in the string
wrapVimscriptForLua =
string:
lib.optionalString (hasContent string) ''
vim.cmd([[
${string}
]])
'';
string: lib.optionalString (hasContent string) "vim.cmd(${toLuaLongLiteral string})";

# Wrap lua script for using in Vimscript,
# but only if the string contains something other than whitespaces
# TODO: account for a possible 'EOF' if the string
wrapLuaForVimscript =
string:
lib.optionalString (hasContent string) ''
lua << EOF
${string}
EOF
'';
string: lib.optionalString (hasContent string) "lua ${toVimscriptHeredoc string}";

# Split a list into a several sub-list, each with a max-size of `size`
groupListBySize =
Expand Down
28 changes: 15 additions & 13 deletions plugins/by-name/alpha/default.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
lib,
helpers,
config,
options,
pkgs,
...
}:
with lib;
let
inherit (lib) types mkOption;

cfg = config.plugins.alpha;

sectionType = types.submodule {
Expand All @@ -24,11 +24,12 @@ let
description = "Type of section";
};

val = helpers.mkNullOrOption (
with helpers.nixvimTypes;
val = lib.nixvim.mkNullOrOption (
with types;
nullOr (oneOf [

# "button", "text"
str
(maybeRaw str)
# "padding"
int
(listOf (
Expand All @@ -52,7 +53,7 @@ in
{
options = {
plugins.alpha = {
enable = mkEnableOption "alpha-nvim";
enable = lib.mkEnableOption "alpha-nvim";

package = lib.mkPackageOption pkgs "alpha-nvim" {
default = [
Expand All @@ -74,15 +75,15 @@ in
] { nullable = true; };

theme = mkOption {
type = with helpers.nixvimTypes; nullOr (maybeRaw str);
apply = v: if isString v then helpers.mkRaw "require'alpha.themes.${v}'.config" else v;
type = with types; nullOr (maybeRaw str);
apply = v: if lib.isString v then lib.nixvim.mkRaw "require'alpha.themes.${v}'.config" else v;
default = null;
example = "dashboard";
description = "You can directly use a pre-defined theme.";
};

layout = mkOption {
type = types.listOf sectionType;
type = with types; either (maybeRaw str) (listOf sectionType);
default = [ ];
description = "List of sections to layout for the dashboard";
example = [
Expand Down Expand Up @@ -141,7 +142,7 @@ in
];
};

opts = helpers.mkNullOrOption (with types; attrsOf anything) ''
opts = lib.nixvim.mkNullOrOption (with types; attrsOf anything) ''
Optional global options.
'';
};
Expand All @@ -154,12 +155,12 @@ in

opt = options.plugins.alpha;
in
mkIf cfg.enable {
lib.mkIf cfg.enable {
# TODO: deprecated 2024-08-29 remove after 24.11
warnings = lib.mkIf opt.iconsEnabled.isDefined [
''
nixvim (plugins.alpha):
The option definition `plugins.alpha.iconsEnabled' in ${showFiles opt.iconsEnabled.files} has been deprecated; please remove it.
The option definition `plugins.alpha.iconsEnabled' in ${lib.showFiles opt.iconsEnabled.files} has been deprecated; please remove it.
You should use `plugins.alpha.iconsPackage' instead.
''
];
Expand Down Expand Up @@ -197,7 +198,8 @@ in
});
in
''
require('alpha').setup(${helpers.toLuaObject setupOptions})
require('alpha').setup(${lib.nixvim.toLuaObject setupOptions})
require('alpha.term')
'';
};
}
19 changes: 19 additions & 0 deletions plugins/by-name/compiler/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
lib,
...
}:
lib.nixvim.neovim-plugin.mkNeovimPlugin {
name = "compiler";
originalName = "compiler.nvim";
package = "compiler-nvim";

maintainers = [ lib.maintainers.khaneliman ];

description = ''
> [!Note]
> Some languages require you manually install their compilers in your machine, so `compiler.nvim` is able to call them.
> Please check [here], as the packages will be different depending your operative system.
[here]: https://github.com/Zeioth/Compiler.nvim/wiki/how-to-install-the-required-dependencies
'';
}
5 changes: 0 additions & 5 deletions plugins/by-name/coq-thirdparty/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ in
src = "vimtex";
short_name = "vTEX";
}
{
src = "copilot";
short_name = "COP";
accept_key = "<c-f>";
}
{ src = "demo"; }
];
};
Expand Down
11 changes: 10 additions & 1 deletion plugins/by-name/direnv/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ helpers.vim-plugin.mkVimPlugin {
originalName = "direnv.vim";
package = "direnv-vim";
globalPrefix = "direnv_";
extraPackages = [ pkgs.direnv ];

maintainers = [ helpers.maintainers.alisonjenkins ];

Expand All @@ -36,4 +35,14 @@ helpers.vim-plugin.mkVimPlugin {
Stop echoing output from Direnv command.
'';
};

extraOptions = {
direnvPackage = lib.mkPackageOption pkgs "direnv" {
nullable = true;
};
};

extraConfig = cfg: {
extraPackages = [ cfg.direnvPackage ];
};
}
Loading

0 comments on commit 827594e

Please sign in to comment.