mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-31 16:14:46 +02:00
treewide: Reformat with nixfmt
This commit is contained in:
parent
c6281260dc
commit
62f32bfc71
459 changed files with 28139 additions and 26377 deletions
|
@ -1,45 +1,43 @@
|
|||
modules: {
|
||||
modules:
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
helpers,
|
||||
...
|
||||
}: let
|
||||
}:
|
||||
let
|
||||
inherit (lib) types;
|
||||
fileModuleType = types.submoduleWith {
|
||||
shorthandOnlyDefinesConfig = true;
|
||||
specialArgs.helpers = helpers;
|
||||
modules = [
|
||||
({
|
||||
name,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
imports = modules;
|
||||
options.plugin = lib.mkOption {
|
||||
type = types.package;
|
||||
description = "A derivation with the content of the file in it";
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
};
|
||||
config = {
|
||||
path = name;
|
||||
type = lib.mkDefault (
|
||||
if lib.hasSuffix ".vim" name
|
||||
then "vim"
|
||||
else "lua"
|
||||
);
|
||||
plugin = pkgs.writeTextDir config.path config.content;
|
||||
};
|
||||
})
|
||||
(
|
||||
{ name, config, ... }:
|
||||
{
|
||||
imports = modules;
|
||||
options.plugin = lib.mkOption {
|
||||
type = types.package;
|
||||
description = "A derivation with the content of the file in it";
|
||||
readOnly = true;
|
||||
internal = true;
|
||||
};
|
||||
config = {
|
||||
path = name;
|
||||
type = lib.mkDefault (if lib.hasSuffix ".vim" name then "vim" else "lua");
|
||||
plugin = pkgs.writeTextDir config.path config.content;
|
||||
};
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
options = {
|
||||
files = lib.mkOption {
|
||||
type = types.attrsOf fileModuleType;
|
||||
description = "Files to include in the Vim config.";
|
||||
default = {};
|
||||
default = { };
|
||||
};
|
||||
|
||||
filesPlugin = lib.mkOption {
|
||||
|
@ -50,23 +48,24 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
inherit (config) files;
|
||||
concatFilesOption = attr:
|
||||
lib.flatten (lib.mapAttrsToList (_: builtins.getAttr attr) files);
|
||||
in {
|
||||
# Each file can declare plugins/packages/warnings/assertions
|
||||
extraPlugins = concatFilesOption "extraPlugins";
|
||||
extraPackages = concatFilesOption "extraPackages";
|
||||
warnings = concatFilesOption "warnings";
|
||||
assertions = concatFilesOption "assertions";
|
||||
config =
|
||||
let
|
||||
inherit (config) files;
|
||||
concatFilesOption = attr: lib.flatten (lib.mapAttrsToList (_: builtins.getAttr attr) files);
|
||||
in
|
||||
{
|
||||
# Each file can declare plugins/packages/warnings/assertions
|
||||
extraPlugins = concatFilesOption "extraPlugins";
|
||||
extraPackages = concatFilesOption "extraPackages";
|
||||
warnings = concatFilesOption "warnings";
|
||||
assertions = concatFilesOption "assertions";
|
||||
|
||||
# A directory with all the files in it
|
||||
filesPlugin = pkgs.buildEnv {
|
||||
name = "nixvim-config";
|
||||
paths =
|
||||
(lib.mapAttrsToList (_: file: file.plugin) files)
|
||||
++ (lib.mapAttrsToList pkgs.writeTextDir config.extraFiles);
|
||||
# A directory with all the files in it
|
||||
filesPlugin = pkgs.buildEnv {
|
||||
name = "nixvim-config";
|
||||
paths =
|
||||
(lib.mapAttrsToList (_: file: file.plugin) files)
|
||||
++ (lib.mapAttrsToList pkgs.writeTextDir config.extraFiles);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{lib}:
|
||||
with lib; {
|
||||
{ lib }:
|
||||
with lib;
|
||||
{
|
||||
options = {
|
||||
enable = mkEnableOption "nixvim";
|
||||
defaultEditor = mkEnableOption "nixvim as the default editor";
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
helpers,
|
||||
...
|
||||
}:
|
||||
with lib; {
|
||||
with lib;
|
||||
{
|
||||
options = {
|
||||
viAlias = mkOption {
|
||||
type = types.bool;
|
||||
|
@ -69,92 +70,90 @@ with lib; {
|
|||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
defaultPlugin = {
|
||||
plugin = null;
|
||||
config = "";
|
||||
optional = false;
|
||||
};
|
||||
config =
|
||||
let
|
||||
defaultPlugin = {
|
||||
plugin = null;
|
||||
config = "";
|
||||
optional = false;
|
||||
};
|
||||
|
||||
normalizedPlugins = map (x:
|
||||
defaultPlugin
|
||||
// (
|
||||
if x ? plugin
|
||||
then x
|
||||
else {plugin = x;}
|
||||
))
|
||||
config.extraPlugins;
|
||||
normalizedPlugins = map (
|
||||
x: defaultPlugin // (if x ? plugin then x else { plugin = x; })
|
||||
) config.extraPlugins;
|
||||
|
||||
neovimConfig = pkgs.neovimUtils.makeNeovimConfig ({
|
||||
inherit
|
||||
(config)
|
||||
extraPython3Packages
|
||||
viAlias
|
||||
vimAlias
|
||||
withNodeJs
|
||||
;
|
||||
# inherit customRC;
|
||||
plugins = normalizedPlugins;
|
||||
}
|
||||
# Necessary to make sure the runtime path is set properly in NixOS 22.05,
|
||||
# or more generally before the commit:
|
||||
# cda1f8ae468 - neovim: pass packpath via the wrapper
|
||||
// optionalAttrs (functionArgs pkgs.neovimUtils.makeNeovimConfig ? configure) {
|
||||
configure.packages = {
|
||||
nixvim = {
|
||||
start = map (x: x.plugin) normalizedPlugins;
|
||||
opt = [];
|
||||
neovimConfig = pkgs.neovimUtils.makeNeovimConfig (
|
||||
{
|
||||
inherit (config)
|
||||
extraPython3Packages
|
||||
viAlias
|
||||
vimAlias
|
||||
withNodeJs
|
||||
;
|
||||
# inherit customRC;
|
||||
plugins = normalizedPlugins;
|
||||
}
|
||||
# Necessary to make sure the runtime path is set properly in NixOS 22.05,
|
||||
# or more generally before the commit:
|
||||
# cda1f8ae468 - neovim: pass packpath via the wrapper
|
||||
// optionalAttrs (functionArgs pkgs.neovimUtils.makeNeovimConfig ? configure) {
|
||||
configure.packages = {
|
||||
nixvim = {
|
||||
start = map (x: x.plugin) normalizedPlugins;
|
||||
opt = [ ];
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
customRC =
|
||||
''
|
||||
vim.cmd([[
|
||||
${neovimConfig.neovimRcContent}
|
||||
]])
|
||||
''
|
||||
+ config.content;
|
||||
customRC =
|
||||
''
|
||||
vim.cmd([[
|
||||
${neovimConfig.neovimRcContent}
|
||||
]])
|
||||
''
|
||||
+ config.content;
|
||||
|
||||
init = helpers.writeLua "init.lua" customRC;
|
||||
initPath = toString init;
|
||||
init = helpers.writeLua "init.lua" customRC;
|
||||
initPath = toString init;
|
||||
|
||||
extraWrapperArgs = builtins.concatStringsSep " " (
|
||||
(optional (config.extraPackages != [])
|
||||
''--prefix PATH : "${makeBinPath config.extraPackages}"'')
|
||||
++ (optional config.wrapRc
|
||||
''--add-flags -u --add-flags "${init}"'')
|
||||
);
|
||||
extraWrapperArgs = builtins.concatStringsSep " " (
|
||||
(optional (config.extraPackages != [ ]) ''--prefix PATH : "${makeBinPath config.extraPackages}"'')
|
||||
++ (optional config.wrapRc ''--add-flags -u --add-flags "${init}"'')
|
||||
);
|
||||
|
||||
wrappedNeovim = pkgs.wrapNeovimUnstable config.package (neovimConfig
|
||||
// {
|
||||
wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs;
|
||||
wrapRc = false;
|
||||
});
|
||||
in {
|
||||
type = lib.mkForce "lua";
|
||||
finalPackage = wrappedNeovim;
|
||||
initContent = customRC;
|
||||
inherit initPath;
|
||||
wrappedNeovim = pkgs.wrapNeovimUnstable config.package (
|
||||
neovimConfig
|
||||
// {
|
||||
wrapperArgs = lib.escapeShellArgs neovimConfig.wrapperArgs + " " + extraWrapperArgs;
|
||||
wrapRc = false;
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
type = lib.mkForce "lua";
|
||||
finalPackage = wrappedNeovim;
|
||||
initContent = customRC;
|
||||
inherit initPath;
|
||||
|
||||
printInitPackage = pkgs.writeShellApplication {
|
||||
name = "nixvim-print-init";
|
||||
runtimeInputs = with pkgs; [stylua bat];
|
||||
text = ''
|
||||
stylua - <"${initPath}" | bat --language=lua
|
||||
printInitPackage = pkgs.writeShellApplication {
|
||||
name = "nixvim-print-init";
|
||||
runtimeInputs = with pkgs; [
|
||||
stylua
|
||||
bat
|
||||
];
|
||||
text = ''
|
||||
stylua - <"${initPath}" | bat --language=lua
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfigLuaPre = lib.optionalString config.wrapRc ''
|
||||
-- Ignore the user lua configuration
|
||||
vim.opt.runtimepath:remove(vim.fn.stdpath('config')) -- ~/.config/nvim
|
||||
vim.opt.runtimepath:remove(vim.fn.stdpath('config') .. "/after") -- ~/.config/nvim/after
|
||||
vim.opt.runtimepath:remove(vim.fn.stdpath('data') .. "/site") -- ~/.local/share/nvim/site
|
||||
'';
|
||||
|
||||
extraPlugins = if config.wrapRc then [ config.filesPlugin ] else [ ];
|
||||
};
|
||||
|
||||
extraConfigLuaPre = lib.optionalString config.wrapRc ''
|
||||
-- Ignore the user lua configuration
|
||||
vim.opt.runtimepath:remove(vim.fn.stdpath('config')) -- ~/.config/nvim
|
||||
vim.opt.runtimepath:remove(vim.fn.stdpath('config') .. "/after") -- ~/.config/nvim/after
|
||||
vim.opt.runtimepath:remove(vim.fn.stdpath('data') .. "/site") -- ~/.local/share/nvim/site
|
||||
'';
|
||||
|
||||
extraPlugins =
|
||||
if config.wrapRc
|
||||
then [config.filesPlugin]
|
||||
else [];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue