Compare commits
6 Commits
faaa36a2ad
...
01f2f2c7ff
| Author | SHA1 | Date |
|---|---|---|
|
|
01f2f2c7ff | |
|
|
a4cc5d9b9c | |
|
|
b5a3526f8a | |
|
|
23c9863c97 | |
|
|
b6630684fb | |
|
|
815a099805 |
12
CHANGELOG.md
12
CHANGELOG.md
|
|
@ -2,6 +2,18 @@
|
|||
|
||||
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
|
||||
|
||||
### Features
|
||||
|
|
|
|||
96
README.md
96
README.md
|
|
@ -10,6 +10,7 @@ A [neovim] plugin and configuration management plugin, highly inspired by [lazy]
|
|||
- [Installation](#installation)
|
||||
- [Flake installation](#flake-installation)
|
||||
- [Usage](#usage)
|
||||
- [Minimal example](#minimal-example)
|
||||
- [Documentation](#documentation)
|
||||
- [nix](#nix)
|
||||
- [`mkPluginsFromInputs`](#mkpluginsfrominputs)
|
||||
|
|
@ -86,6 +87,81 @@ inputs.sloth-flake.url = "github:lemarsu/sloth-flake.nvim?tag=0.0.5";
|
|||
|
||||
## Usage
|
||||
|
||||
### Minimal example
|
||||
|
||||
sloth-flake has been made for this typical use case. I was a long vim/neovim
|
||||
user, had a repository with a lot of neovim config in it, and I discovered
|
||||
[nix]. At first, I kept my [lazy] setup, but it wasn't integrated with the rest
|
||||
of my nix config. I've seen a bunch of solution to handle your vim files, but
|
||||
not was for my taste. I wanted a configuration that allow me keep the maximum
|
||||
of my old lazy config, and let nix handle the rest. So after some trial and
|
||||
errors, I made this flake, and turn my old neovim configuration repository in a
|
||||
flake that produce a neovim binary bundled with my configuration.
|
||||
|
||||
Here's a minimal flake to make a bundled neovim plugin with sloth-flake.nvim:
|
||||
|
||||
`flake.nix`
|
||||
```nix
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
sloth-flake.url = "github:lemarsu/sloth-flake.nvim";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
outputs = {utils, sloth-flake, ...}@inputs:
|
||||
utils.lib.eachDefaultSystem (system: {
|
||||
packages = rec {
|
||||
default = neovim;
|
||||
neovim = pkgs.callPackage ./package.nix {inherit sloth-flake;};
|
||||
};
|
||||
});
|
||||
}
|
||||
```
|
||||
|
||||
`./package.nix`
|
||||
```nix
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
sloth-flake,
|
||||
...
|
||||
}:
|
||||
sloth-flake.lib.mkNeovimPkg {
|
||||
inherit pkgs;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
vimdiffAlias = true;
|
||||
runtime = {
|
||||
init = ./init.lua;
|
||||
src = with lib.fileset;
|
||||
toSource {
|
||||
root = ./.;
|
||||
fileset = unions [
|
||||
./after
|
||||
./colors
|
||||
./ftplugin
|
||||
./lua
|
||||
./plugin
|
||||
./queries
|
||||
./spell
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
dependencies = [./dependencies.nix];
|
||||
}
|
||||
```
|
||||
|
||||
`dependencies.nix`
|
||||
```nix
|
||||
{pkgs, ...}: with pkgs.vimPlugins;
|
||||
[
|
||||
# Your plugin list
|
||||
telescope-nvim
|
||||
# TODO More examples
|
||||
]
|
||||
```
|
||||
|
||||
Once installed, you can call the `sloth-flake.lib.mkNeovimPkg` to build your neovim package.
|
||||
|
||||
`mkNeovimPkg` requires a *set* as argument with at least `pkgs` that represents your nixpkgs.
|
||||
|
|
@ -182,27 +258,36 @@ The function accepts the following attributes:
|
|||
Here's a list of all accepted arguments
|
||||
|
||||
| name | default | description |
|
||||
|-------------------------|-------------------------|----------------------------------------------------------------|
|
||||
|-------------------------|-------------------------|---------------------------------------------------------------------|
|
||||
| `pkgs` | N/A | The nixpkgs set. **REQUIRED** |
|
||||
| `package` | `pkgs.neovim-unwrapped` | The unwrapped neovim package to use |
|
||||
| `init` | `null` | The `init.lua` of your config (string, path or init config object)¹ |
|
||||
| `runtime` | `{}` | Your Runtime configuration (see below) |
|
||||
| `dependencies` | `[]` | A list of your dependencies (see below) |
|
||||
| `dependenciesExtraArgs` | `{}` | Extra arguments to load your dependencies in other files |
|
||||
| `extraLuaPackages` | `null` | Extra lua packages needed for the plugin |
|
||||
| `viAlias` | `false` | Wether to create a `vi` alias to run neovim |
|
||||
| `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:
|
||||
|
||||
| name | default | description |
|
||||
|-----------|---------|--------------------------------|
|
||||
| `version` | `null` | The version of your runtime |
|
||||
| `init` | `null` | The `init.lua` of your config¹ |
|
||||
| `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:
|
||||
- path: the path of the file to load other dependencies
|
||||
- package: a nix package of a neovim/vim plugin
|
||||
|
|
@ -211,11 +296,12 @@ The dependencies is a list of element of either:
|
|||
The Plugin configuration object accepts the following properties:
|
||||
|
||||
| name | default | description |
|
||||
|----------------|---------|----------------------------------------------------------------|
|
||||
|--------------------|---------|----------------------------------------------------------------|
|
||||
| `plugin` | N/A | The plugin to load² **REQUIRED** |
|
||||
| `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 |
|
||||
| `dependencies` | `[]` | The plugin dependencies³ |
|
||||
| `extraLuaPackages` | `null` | Extra lua packages needed for the plugin |
|
||||
| `lazy` | `false` | Should the plugin be loaded lazily |
|
||||
| `cmd` | `[]` | Command to put as place_holder to load the lazy plugin⁴ |
|
||||
| `ft` | `[]` | Filetype to watch to load the lazy plugin⁴ |
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
|
@ -0,0 +1,78 @@
|
|||
*my-awesome-plugin.txt* An awesome plugin that greets you :)
|
||||
|
||||
==============================================================================
|
||||
CONTENTS *my-awesome-plugin-contents*
|
||||
|
||||
1. Introduction ......................... |my-awesome-plugin-introduction|
|
||||
2. Setup ................................ |my-awesome-plugin-setup|
|
||||
3. Commands ............................. |my-awesome-plugin-commands|
|
||||
4. API .................................. |my-awesome-plugin-api|
|
||||
|
||||
==============================================================================
|
||||
1. INTRODUCTION *my-awesome-plugin-introduction*
|
||||
|
||||
my-awesome-plugin makes Neovim, your favorite text editor, capable of greeting
|
||||
you. See bellow how it works:
|
||||
|
||||
+--------------+ +--------------+
|
||||
| | | |
|
||||
| | | |
|
||||
| | | |
|
||||
| Hello | -----------> | [your-name] |
|
||||
| | | |
|
||||
| | | |
|
||||
+--------------+ +--------------+
|
||||
|
||||
==============================================================================
|
||||
2. SETUP *my-awesome-plugin-setup*
|
||||
|
||||
Make sure to add to call the setup function with the proper configuration on
|
||||
your `init` file.
|
||||
|
||||
If you use `init.vim`: >
|
||||
|
||||
lua require('my_awesome_plugin').setup { name = 'Alexander, The Great'}
|
||||
|
||||
|
||||
Or, if you use `init.lua`: >
|
||||
|
||||
require('my_awesome_plugin').setup { name = 'Alexander, The Great'}
|
||||
|
||||
==============================================================================
|
||||
3. COMMANDS *my-awesome-plugin-commands*
|
||||
|
||||
:MyAwesomePluginGenericGreet *MyAwesomePluginGenericGreet*
|
||||
|
||||
Shows a generic greet message.
|
||||
|
||||
:MyAwesomePluginGreet *MyAwesomePluginGreet*
|
||||
|
||||
Shows a personalized, accordingly to the setup configuration, greet message.
|
||||
|
||||
==============================================================================
|
||||
4. API *my-awesome-plugin-api*
|
||||
|
||||
|
||||
my_awesome_plugin.setup({config}) *my_awesome_plugin.setup()*
|
||||
Configures this plugin. Currently supported configuration variables
|
||||
are:
|
||||
• `name`: a string to be used in the greet message
|
||||
|
||||
Parameters: ~
|
||||
{config}(required, table) Table of values; keys are as listed
|
||||
above. Accept defaults by omitting the relevant key.
|
||||
|
||||
my_awesome_plugin.is_configured() *my_awesome_plugin.is_configured()*
|
||||
Tell if the plugin is configured.
|
||||
Return: ~
|
||||
true/false
|
||||
|
||||
my_awesome_plugin.greet() *my_awesome_plugin.greet()*
|
||||
Show a greeting message. If the plugin was previously configured with
|
||||
|my_awesome_plugin.setup()|, show a personalized message.
|
||||
|
||||
my_awesome_plugin.generic_greet() *my_awesome_plugin.generic_greet()*
|
||||
Show a generic greeting message.
|
||||
|
||||
==============================================================================
|
||||
vim:tw=78:ts=8:ft=help:norl:noet:fen:noet:
|
||||
|
|
@ -0,0 +1,339 @@
|
|||
{
|
||||
"nodes": {
|
||||
"alejandra": {
|
||||
"inputs": {
|
||||
"fenix": "fenix",
|
||||
"flakeCompat": "flakeCompat",
|
||||
"nixpkgs": [
|
||||
"sloth-flake",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1660592437,
|
||||
"narHash": "sha256-xFumnivtVwu5fFBOrTxrv6fv3geHKF04RGP23EsDVaI=",
|
||||
"owner": "kamadorueda",
|
||||
"repo": "alejandra",
|
||||
"rev": "e7eac49074b70814b542fee987af2987dd0520b5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "kamadorueda",
|
||||
"ref": "3.0.0",
|
||||
"repo": "alejandra",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"fenix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"sloth-flake",
|
||||
"alejandra",
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1657607339,
|
||||
"narHash": "sha256-HaqoAwlbVVZH2n4P3jN2FFPMpVuhxDy1poNOR7kzODc=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "b814c83d9e6aa5a28d0cf356ecfdafb2505ad37d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flakeCompat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1650374568,
|
||||
"narHash": "sha256-Z+s0J8/r907g149rllvwhb4pKi8Wam5ij0st8PwAh+E=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "b4a34015c698c7793d592d66adbab377907a2be8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nil": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1717086091,
|
||||
"narHash": "sha256-GmsEQa4HZeMfec37LZnwG/Lt/XmqFLXsjv5QWojeNiM=",
|
||||
"owner": "oxalica",
|
||||
"repo": "nil",
|
||||
"rev": "ab3ddb8f063774cf7e22eb610f5ecfdb77309f3c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "nil",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1717774105,
|
||||
"narHash": "sha256-HV97wqUQv9wvptiHCb3Y0/YH0lJ60uZ8FYfEOIzYEqI=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d226935fd75012939397c83f6c385e4d6d832288",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1716977081,
|
||||
"narHash": "sha256-pFe5jLeIPlKEln5n2h998d7cpzXFdbrBMRe3suz4K1o=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "ac82a513e55582291805d6f09d35b6d8b60637a1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1717196966,
|
||||
"narHash": "sha256-yZKhxVIKd2lsbOqYd5iDoUIwsRZFqE87smE2Vzf6Ck0=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "57610d2f8f0937f39dbd72251e9614b1561942d8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_4": {
|
||||
"locked": {
|
||||
"lastModified": 1660438583,
|
||||
"narHash": "sha256-rJUTYxFKlWUJI3njAwEc1pKAVooAViZGJvsgqfh/q/E=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "bbd8f7cd87d0b29294ef3072ffdbd61d60f05da4",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"sloth-flake": "sloth-flake",
|
||||
"utils": "utils_2"
|
||||
}
|
||||
},
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1657557289,
|
||||
"narHash": "sha256-PRW+nUwuqNTRAEa83SfX+7g+g8nQ+2MMbasQ9nt6+UM=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "caf23f29144b371035b864a1017dbc32573ad56d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rust-lang",
|
||||
"ref": "nightly",
|
||||
"repo": "rust-analyzer",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"sloth-flake",
|
||||
"nil",
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"sloth-flake",
|
||||
"nil",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1717035469,
|
||||
"narHash": "sha256-MzH+yjKULH3HCRj9QCTwBvqq4LZkR0ZqRE/QfGOGC2E=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "095702e63a40e86f339d11864da9dc965b70a01e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"sloth-flake": {
|
||||
"inputs": {
|
||||
"alejandra": "alejandra",
|
||||
"nil": "nil",
|
||||
"nixpkgs": "nixpkgs_3",
|
||||
"utils": "utils",
|
||||
"yants": "yants"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 0,
|
||||
"narHash": "sha256-VvZ+kCRRZcMM5j+wCNCfCUZby12gFS103ItEJhwcO3A=",
|
||||
"path": "/nix/store/5xmp1bx8p395yl60c033ywjd50wahsqy-source",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"path": "/nix/store/5xmp1bx8p395yl60c033ywjd50wahsqy-source",
|
||||
"type": "path"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_3": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"yants": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_4"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1686863218,
|
||||
"narHash": "sha256-kooxYm3/3ornWtVBNHM3Zh020gACUyFX2G0VQXnB+mk=",
|
||||
"owner": "divnix",
|
||||
"repo": "yants",
|
||||
"rev": "8f0da0dba57149676aa4817ec0c880fbde7a648d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "divnix",
|
||||
"repo": "yants",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
# If you start your configuration from this example, you should uncomment
|
||||
# the next line, and delete the one after.
|
||||
# sloth-flake.url = "github:lemarsu/sloth-flake.nvim";
|
||||
sloth-flake.url = "../..";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
outputs = {
|
||||
nixpkgs,
|
||||
sloth-flake,
|
||||
utils,
|
||||
...
|
||||
}:
|
||||
utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
packages = rec {
|
||||
default = neovim;
|
||||
neovim = sloth-flake.lib.mkNeovimPkg {
|
||||
inherit pkgs;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
vimdiffAlias = true;
|
||||
dependencies = with pkgs.vimPlugins; [
|
||||
telescope-nvim
|
||||
];
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
@ -6,21 +6,21 @@
|
|||
package ? pkgs.neovim-unwrapped,
|
||||
dependencies ? [],
|
||||
dependenciesExtraArgs ? {},
|
||||
runtime ? {},
|
||||
extraLuaPackages ? (_: []),
|
||||
runtime ? null,
|
||||
init ? null,
|
||||
viAlias ? false,
|
||||
vimAlias ? false,
|
||||
vimdiffAlias ? false,
|
||||
nvimdiffAlias ? false,
|
||||
...
|
||||
} @ config: let
|
||||
inherit (builtins) map;
|
||||
inherit (builtins) isString isPath map;
|
||||
inherit (pkgs) callPackage bash lib;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.lists) concatMap optional;
|
||||
inherit (lib.trivial) flip;
|
||||
# inherit (lib.lists) concatMap filter foldl' map optional reverseList;
|
||||
# inherit (lib.attrsets) attrNames optionalAttrs;
|
||||
# inherit (lib.strings) concatStringsSep fileContents hasSuffix removePrefix removeSuffix replaceStrings;
|
||||
# inherit (lib.debug) traceIf traceSeq traceVal traceValSeq traceValFn;
|
||||
inherit (lib.attrsets) optionalAttrs;
|
||||
|
||||
deps = callPackage ./deps.nix {inherit dependenciesExtraArgs types;};
|
||||
|
||||
|
|
@ -29,20 +29,69 @@
|
|||
runtimePlugin = deps.mkRuntimePlugin runtime;
|
||||
plugins =
|
||||
normalizedPlugins
|
||||
++ (deps.normalizePlugins [runtimePlugin sloth-flake]);
|
||||
++ (
|
||||
deps.normalizePlugins
|
||||
([sloth-flake] ++ (optional (runtime != null) runtimePlugin))
|
||||
);
|
||||
|
||||
extractPlugin = p: {inherit (p) optional plugin;};
|
||||
extractPlugins = map extractPlugin;
|
||||
|
||||
customRC = let
|
||||
rc = ({init ? ../lua/default_init.lua, ...}: init) runtime;
|
||||
extractLuaPackageFn = plugin:
|
||||
optional (plugin ? extraLuaPackages) plugin.extraLuaPackages;
|
||||
extractLuaPackagesFn = plugins: let
|
||||
fnList = concatMap extractLuaPackageFn plugins;
|
||||
concatPackages = ps: fn: fn ps;
|
||||
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 =
|
||||
pkgs.neovimUtils.makeNeovimConfig {
|
||||
inherit customRC;
|
||||
plugins = extractPlugins plugins;
|
||||
extraLuaPackages = ps:
|
||||
(extractLuaPackagesFn plugins ps) ++ (extraLuaPackages ps);
|
||||
}
|
||||
// {luaRcContent = customRC;};
|
||||
params =
|
||||
|
|
|
|||
|
|
@ -11,13 +11,20 @@ in rec {
|
|||
# The version of the runtime
|
||||
version = option string;
|
||||
|
||||
# The init configuration file
|
||||
init = option (either path string);
|
||||
|
||||
# The content of the runtime directory
|
||||
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
|
||||
basicPluginType = with yants;
|
||||
struct "basicPlugin" {
|
||||
|
|
@ -65,6 +72,9 @@ in rec {
|
|||
# Ensure thoses plugins are loaded before the current one
|
||||
dependencies = option (list drv);
|
||||
|
||||
# Ensure those packages are available
|
||||
extraLuaPackages = option function;
|
||||
|
||||
# Should this plugin be load lazily ?
|
||||
lazy = option bool;
|
||||
|
||||
|
|
@ -98,14 +108,20 @@ in rec {
|
|||
# Default is pkgs.neovim-unwrapped
|
||||
package = option drv;
|
||||
|
||||
# init.lua configuration
|
||||
init = option (eitherN [string path neovimInitType]);
|
||||
|
||||
# An array of dependencies.
|
||||
dependencies = list dependency;
|
||||
dependencies = option (list dependency);
|
||||
|
||||
# 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 = runtimeType;
|
||||
runtime = option runtimeType;
|
||||
|
||||
# Create a vi alias
|
||||
viAlias = option bool;
|
||||
|
|
|
|||
Loading…
Reference in New Issue