Compare commits
6 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
a4cc5d9b9c | |
|
|
b5a3526f8a | |
|
|
23c9863c97 | |
|
|
b6630684fb | |
|
|
815a099805 | |
|
|
3d20bc0ade |
12
CHANGELOG.md
12
CHANGELOG.md
|
|
@ -2,6 +2,18 @@
|
||||||
|
|
||||||
All notable changes to this project will be documented in this file.
|
All notable changes to this project will be documented in this file.
|
||||||
|
|
||||||
|
## [0.0.10] - 2024-06-09
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- Runtime is now optional
|
||||||
|
- [**breaking**] `init.lua` configuration is now a `mkNeovimPkg`'s option
|
||||||
|
- Add option init config object to generate `init.lua`
|
||||||
|
|
||||||
|
### Miscellaneous Tasks
|
||||||
|
|
||||||
|
- Add alejandra to nix shell
|
||||||
|
|
||||||
## [0.0.9] - 2024-06-09
|
## [0.0.9] - 2024-06-09
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
|
|
||||||
60
README.md
60
README.md
|
|
@ -181,28 +181,37 @@ The function accepts the following attributes:
|
||||||
|
|
||||||
Here's a list of all accepted arguments
|
Here's a list of all accepted arguments
|
||||||
|
|
||||||
| name | default | description |
|
| name | default | description |
|
||||||
|-------------------------|-------------------------|----------------------------------------------------------------|
|
|-------------------------|-------------------------|---------------------------------------------------------------------|
|
||||||
| `pkgs` | N/A | The nixpkgs set. **REQUIRED** |
|
| `pkgs` | N/A | The nixpkgs set. **REQUIRED** |
|
||||||
| `package` | `pkgs.neovim-unwrapped` | The unwrapped neovim package to use |
|
| `package` | `pkgs.neovim-unwrapped` | The unwrapped neovim package to use |
|
||||||
| `runtime` | `{}` | Your Runtime configuration (see below) |
|
| `init` | `null` | The `init.lua` of your config (string, path or init config object)¹ |
|
||||||
| `dependencies` | `[]` | A list of your dependencies (see below) |
|
| `runtime` | `{}` | Your Runtime configuration (see below) |
|
||||||
| `dependenciesExtraArgs` | `{}` | Extra arguments to load your dependencies in other files |
|
| `dependencies` | `[]` | A list of your dependencies (see below) |
|
||||||
| `viAlias` | `false` | Wether to create a `vi` alias to run neovim |
|
| `dependenciesExtraArgs` | `{}` | Extra arguments to load your dependencies in other files |
|
||||||
| `vimAlias` | `false` | Wether to create a `vim` alias to run neovim |
|
| `extraLuaPackages` | `null` | Extra lua packages needed for the plugin |
|
||||||
| `vimdiffAlias` | `false` | Wether to create a `vimdiff` alias to run neovim in diff mode |
|
| `viAlias` | `false` | Wether to create a `vi` alias to run neovim |
|
||||||
| `nvimdiffAlias` | `false` | Wether to create a `nvimdiff` alias to run neovim in diff mode |
|
| `vimAlias` | `false` | Wether to create a `vim` alias to run neovim |
|
||||||
|
| `vimdiffAlias` | `false` | Wether to create a `vimdiff` alias to run neovim in diff mode |
|
||||||
|
| `nvimdiffAlias` | `false` | Wether to create a `nvimdiff` alias to run neovim in diff mode |
|
||||||
|
|
||||||
|
> ¹ If you give your own `init.lua` as string or path, you'll have to call `sloth-flake` lua plugin yourself. See more below.
|
||||||
|
|
||||||
|
The init configuration object accepts the following properties:
|
||||||
|
|
||||||
|
| name | default | description |
|
||||||
|
|------------|---------|----------------------------------------------------------------------------|
|
||||||
|
| `init` | `null` | Lua code call before plugins init. String or path. |
|
||||||
|
| `postInit` | `null` | Lua code call after plugins init and before plugin config. String or path. |
|
||||||
|
| `config` | `null` | Luas cod call after plugins config. String or path. |
|
||||||
|
|
||||||
The Runtime configuration object accepts the following properties:
|
The Runtime configuration object accepts the following properties:
|
||||||
|
|
||||||
| name | default | description |
|
| name | default | description |
|
||||||
|-----------|---------|--------------------------------|
|
|-----------|---------|--------------------------------|
|
||||||
| `version` | `null` | The version of your runtime |
|
| `version` | `null` | The version of your runtime |
|
||||||
| `init` | `null` | The `init.lua` of your config¹ |
|
|
||||||
| `src` | `null` | The content of your runtime |
|
| `src` | `null` | The content of your runtime |
|
||||||
|
|
||||||
> ¹ If you give your own `init.lua`, you'll have to call `sloth-flake` lua plugin yourself. See more below.
|
|
||||||
|
|
||||||
The dependencies is a list of element of either:
|
The dependencies is a list of element of either:
|
||||||
- path: the path of the file to load other dependencies
|
- path: the path of the file to load other dependencies
|
||||||
- package: a nix package of a neovim/vim plugin
|
- package: a nix package of a neovim/vim plugin
|
||||||
|
|
@ -210,17 +219,18 @@ The dependencies is a list of element of either:
|
||||||
|
|
||||||
The Plugin configuration object accepts the following properties:
|
The Plugin configuration object accepts the following properties:
|
||||||
|
|
||||||
| name | default | description |
|
| name | default | description |
|
||||||
|----------------|---------|----------------------------------------------------------------|
|
|--------------------|---------|----------------------------------------------------------------|
|
||||||
| `plugin` | N/A | The plugin to load² **REQUIRED** |
|
| `plugin` | N/A | The plugin to load² **REQUIRED** |
|
||||||
| `init` | `null` | Lua code (as string of path) to call before loading the plugin |
|
| `init` | `null` | Lua code (as string of path) to call before loading the plugin |
|
||||||
| `config` | `null` | Lua code (as string of path) to call after loading the plugin |
|
| `config` | `null` | Lua code (as string of path) to call after loading the plugin |
|
||||||
| `dependencies` | `[]` | The plugin dependencies³ |
|
| `dependencies` | `[]` | The plugin dependencies³ |
|
||||||
| `lazy` | `false` | Should the plugin be loaded lazily |
|
| `extraLuaPackages` | `null` | Extra lua packages needed for the plugin |
|
||||||
| `cmd` | `[]` | Command to put as place_holder to load the lazy plugin⁴ |
|
| `lazy` | `false` | Should the plugin be loaded lazily |
|
||||||
| `ft` | `[]` | Filetype to watch to load the lazy plugin⁴ |
|
| `cmd` | `[]` | Command to put as place_holder to load the lazy plugin⁴ |
|
||||||
| `events` | `[]` | Events to watch to load the lazy plugin⁴⁵ |
|
| `ft` | `[]` | Filetype to watch to load the lazy plugin⁴ |
|
||||||
| `keymaps` | `[]` | Keymaps that when press will load the lazy plugin⁴⁶ |
|
| `events` | `[]` | Events to watch to load the lazy plugin⁴⁵ |
|
||||||
|
| `keymaps` | `[]` | Keymaps that when press will load the lazy plugin⁴⁶ |
|
||||||
|
|
||||||
> ² The plugin can be either a nix package or an object with only `name` and
|
> ² The plugin can be either a nix package or an object with only `name` and
|
||||||
> `src` as properties. The latter will be used to create a nix package of your
|
> `src` as properties. The latter will be used to create a nix package of your
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
in {
|
in {
|
||||||
inherit formatter;
|
inherit formatter;
|
||||||
devShells.default = import ./shell.nix {
|
devShells.default = import ./shell.nix {
|
||||||
inherit pkgs nil;
|
inherit pkgs nil formatter;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,21 @@
|
||||||
package ? pkgs.neovim-unwrapped,
|
package ? pkgs.neovim-unwrapped,
|
||||||
dependencies ? [],
|
dependencies ? [],
|
||||||
dependenciesExtraArgs ? {},
|
dependenciesExtraArgs ? {},
|
||||||
runtime ? {},
|
extraLuaPackages ? (_: []),
|
||||||
|
runtime ? null,
|
||||||
|
init ? null,
|
||||||
viAlias ? false,
|
viAlias ? false,
|
||||||
vimAlias ? false,
|
vimAlias ? false,
|
||||||
vimdiffAlias ? false,
|
vimdiffAlias ? false,
|
||||||
nvimdiffAlias ? false,
|
nvimdiffAlias ? false,
|
||||||
...
|
...
|
||||||
} @ config: let
|
} @ config: let
|
||||||
inherit (builtins) map;
|
inherit (builtins) isString isPath map;
|
||||||
inherit (pkgs) callPackage bash lib;
|
inherit (pkgs) callPackage bash lib;
|
||||||
inherit (lib.strings) optionalString;
|
inherit (lib.strings) optionalString;
|
||||||
|
inherit (lib.lists) concatMap optional;
|
||||||
inherit (lib.trivial) flip;
|
inherit (lib.trivial) flip;
|
||||||
# inherit (lib.lists) concatMap filter foldl' map optional reverseList;
|
inherit (lib.attrsets) optionalAttrs;
|
||||||
# inherit (lib.attrsets) attrNames optionalAttrs;
|
|
||||||
# inherit (lib.strings) concatStringsSep fileContents hasSuffix removePrefix removeSuffix replaceStrings;
|
|
||||||
# inherit (lib.debug) traceIf traceSeq traceVal traceValSeq traceValFn;
|
|
||||||
|
|
||||||
deps = callPackage ./deps.nix {inherit dependenciesExtraArgs types;};
|
deps = callPackage ./deps.nix {inherit dependenciesExtraArgs types;};
|
||||||
|
|
||||||
|
|
@ -29,20 +29,69 @@
|
||||||
runtimePlugin = deps.mkRuntimePlugin runtime;
|
runtimePlugin = deps.mkRuntimePlugin runtime;
|
||||||
plugins =
|
plugins =
|
||||||
normalizedPlugins
|
normalizedPlugins
|
||||||
++ (deps.normalizePlugins [runtimePlugin sloth-flake]);
|
++ (
|
||||||
|
deps.normalizePlugins
|
||||||
|
([sloth-flake] ++ (optional (runtime != null) runtimePlugin))
|
||||||
|
);
|
||||||
|
|
||||||
extractPlugin = p: {inherit (p) optional plugin;};
|
extractPlugin = p: {inherit (p) optional plugin;};
|
||||||
extractPlugins = map extractPlugin;
|
extractPlugins = map extractPlugin;
|
||||||
|
|
||||||
customRC = let
|
extractLuaPackageFn = plugin:
|
||||||
rc = ({init ? ../lua/default_init.lua, ...}: init) runtime;
|
optional (plugin ? extraLuaPackages) plugin.extraLuaPackages;
|
||||||
|
extractLuaPackagesFn = plugins: let
|
||||||
|
fnList = concatMap extractLuaPackageFn plugins;
|
||||||
|
concatPackages = ps: fn: fn ps;
|
||||||
in
|
in
|
||||||
deps.textOrContent rc;
|
ps: concatMap (concatPackages ps) fnList;
|
||||||
|
|
||||||
|
buildInit = {
|
||||||
|
init ? null,
|
||||||
|
postInit ? null,
|
||||||
|
config ? null,
|
||||||
|
}: let
|
||||||
|
initStr = optionalString (! isNull init) ''
|
||||||
|
(function()
|
||||||
|
${deps.textOrContent init}
|
||||||
|
end)();
|
||||||
|
|
||||||
|
'';
|
||||||
|
|
||||||
|
slothCall =
|
||||||
|
if isNull postInit
|
||||||
|
then "require('sloth-flake').setup {}"
|
||||||
|
else ''
|
||||||
|
require('sloth-flake').setup {
|
||||||
|
post_init = function()
|
||||||
|
${deps.textOrContent postInit}
|
||||||
|
end,
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
|
||||||
|
configStr = optionalString (! isNull config) ''
|
||||||
|
|
||||||
|
(function()
|
||||||
|
${deps.textOrContent config}
|
||||||
|
end)()
|
||||||
|
'';
|
||||||
|
in ''
|
||||||
|
-- Generated by sloth-flake
|
||||||
|
${initStr}
|
||||||
|
${slothCall}
|
||||||
|
${configStr}
|
||||||
|
'';
|
||||||
|
|
||||||
|
customRC =
|
||||||
|
if isString init || isPath init
|
||||||
|
then deps.textOrContent init
|
||||||
|
else buildInit (optionalAttrs (! isNull init) init);
|
||||||
|
|
||||||
neovimConfig =
|
neovimConfig =
|
||||||
pkgs.neovimUtils.makeNeovimConfig {
|
pkgs.neovimUtils.makeNeovimConfig {
|
||||||
inherit customRC;
|
inherit customRC;
|
||||||
plugins = extractPlugins plugins;
|
plugins = extractPlugins plugins;
|
||||||
|
extraLuaPackages = ps:
|
||||||
|
(extractLuaPackagesFn plugins ps) ++ (extraLuaPackages ps);
|
||||||
}
|
}
|
||||||
// {luaRcContent = customRC;};
|
// {luaRcContent = customRC;};
|
||||||
params =
|
params =
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,20 @@ in rec {
|
||||||
# The version of the runtime
|
# The version of the runtime
|
||||||
version = option string;
|
version = option string;
|
||||||
|
|
||||||
# The init configuration file
|
|
||||||
init = option (either path string);
|
|
||||||
|
|
||||||
# The content of the runtime directory
|
# The content of the runtime directory
|
||||||
src = any;
|
src = any;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
neovimInitType = with yants;
|
||||||
|
struct "neovimInit" {
|
||||||
|
# Lua code to call before plugins loaded
|
||||||
|
init = option (either string path);
|
||||||
|
# Lua code called after init but before import
|
||||||
|
postInit = option (either string path);
|
||||||
|
# Lua code called after all plugins are loaded
|
||||||
|
config = option (either string path);
|
||||||
|
};
|
||||||
|
|
||||||
# As simple remote plugin definition
|
# As simple remote plugin definition
|
||||||
basicPluginType = with yants;
|
basicPluginType = with yants;
|
||||||
struct "basicPlugin" {
|
struct "basicPlugin" {
|
||||||
|
|
@ -65,6 +72,9 @@ in rec {
|
||||||
# Ensure thoses plugins are loaded before the current one
|
# Ensure thoses plugins are loaded before the current one
|
||||||
dependencies = option (list drv);
|
dependencies = option (list drv);
|
||||||
|
|
||||||
|
# Ensure those packages are available
|
||||||
|
extraLuaPackages = option function;
|
||||||
|
|
||||||
# Should this plugin be load lazily ?
|
# Should this plugin be load lazily ?
|
||||||
lazy = option bool;
|
lazy = option bool;
|
||||||
|
|
||||||
|
|
@ -98,14 +108,20 @@ in rec {
|
||||||
# Default is pkgs.neovim-unwrapped
|
# Default is pkgs.neovim-unwrapped
|
||||||
package = option drv;
|
package = option drv;
|
||||||
|
|
||||||
|
# init.lua configuration
|
||||||
|
init = option (eitherN [string path neovimInitType]);
|
||||||
|
|
||||||
# An array of dependencies.
|
# An array of dependencies.
|
||||||
dependencies = list dependency;
|
dependencies = option (list dependency);
|
||||||
|
|
||||||
# Extra argument to pass to dependencies files
|
# Extra argument to pass to dependencies files
|
||||||
dependenciesExtraArgs = attrs any;
|
dependenciesExtraArgs = option (attrs any);
|
||||||
|
|
||||||
|
# Ensure those packages are available
|
||||||
|
extraLuaPackages = option function;
|
||||||
|
|
||||||
# Runtime configuration
|
# Runtime configuration
|
||||||
runtime = runtimeType;
|
runtime = option runtimeType;
|
||||||
|
|
||||||
# Create a vi alias
|
# Create a vi alias
|
||||||
viAlias = option bool;
|
viAlias = option bool;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue