2024-02-22 13:48:54 -08:00
|
|
|
{
|
|
|
|
description = "Generate a .luarc.json for Lua/Neovim devShells";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
|
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs = inputs @ {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
flake-parts,
|
|
|
|
}:
|
|
|
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
|
|
|
flake = {
|
|
|
|
overlays.default = final: prev: {
|
2024-02-22 14:07:20 -08:00
|
|
|
mk-luarc = {
|
2024-02-22 13:48:54 -08:00
|
|
|
# list of plugins that have a /lua directory
|
|
|
|
nvim ? final.neovim-unwrapped,
|
|
|
|
neodev-types ? "stable",
|
|
|
|
plugins ? [],
|
|
|
|
}: let
|
|
|
|
lib = final.lib;
|
|
|
|
plugin-lib-dirs = lib.lists.map (plugin:
|
|
|
|
if
|
|
|
|
builtins.hasAttr "vimPlugin" plugin
|
|
|
|
&& plugin.vimPlugin
|
|
|
|
|| plugin.pname == "nvim-treesitter"
|
|
|
|
then "${plugin}/lua"
|
|
|
|
else "${plugin}/lib/lua/5.1")
|
|
|
|
plugins;
|
2024-02-22 14:07:20 -08:00
|
|
|
in {
|
|
|
|
runtime.version = "LuaJIT";
|
|
|
|
Lua = {
|
|
|
|
globals = [
|
|
|
|
"vim"
|
|
|
|
];
|
|
|
|
workspace = {
|
|
|
|
library =
|
|
|
|
[
|
|
|
|
"${nvim}/share/nvim/runtime/lua"
|
|
|
|
"${final.vimPlugins.neodev-nvim}/types/${neodev-types}"
|
|
|
|
"\${3rd}/busted/library"
|
|
|
|
"\${3rd}/luassert/library"
|
|
|
|
]
|
|
|
|
++ plugin-lib-dirs;
|
|
|
|
ignoreDir = [
|
|
|
|
".git"
|
|
|
|
".github"
|
|
|
|
".direnv"
|
|
|
|
"result"
|
|
|
|
"nix"
|
|
|
|
"doc"
|
2024-02-22 13:48:54 -08:00
|
|
|
];
|
2024-02-22 14:07:20 -08:00
|
|
|
};
|
|
|
|
diagnostics = {
|
|
|
|
libraryFiles = "Disable";
|
|
|
|
disable = [];
|
2024-02-22 13:48:54 -08:00
|
|
|
};
|
|
|
|
};
|
2024-02-22 14:07:20 -08:00
|
|
|
};
|
|
|
|
luarc-to-json = luarc: final.runCommand ".luarc.json" {
|
2024-02-22 13:48:54 -08:00
|
|
|
buildInputs = [
|
|
|
|
final.jq
|
|
|
|
];
|
|
|
|
passAsFile = ["rawJSON"];
|
|
|
|
rawJSON = builtins.toJSON luarc;
|
|
|
|
} ''
|
|
|
|
{
|
|
|
|
jq . <"$rawJSONPath"
|
|
|
|
} >$out
|
|
|
|
'';
|
2024-02-22 14:07:20 -08:00
|
|
|
mk-luarc-json = attrs: final.luarc-to-json (final.mk-luarc attrs);
|
2024-02-22 13:48:54 -08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|