mirror of
https://github.com/zoriya/flake.git
synced 2026-05-24 07:30:21 +00:00
Auto create .luarc.json
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
result
|
||||
log
|
||||
.luarc.json
|
||||
|
||||
@@ -109,9 +109,31 @@
|
||||
|
||||
packages = eachSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
vim = import ./nvim (inputs
|
||||
// {
|
||||
inherit pkgs;
|
||||
lib = nixpkgs.lib;
|
||||
});
|
||||
in rec {
|
||||
default = nvim;
|
||||
nvim = import ./nvim (inputs // { inherit pkgs; lib = nixpkgs.lib; });
|
||||
nvim = vim.nvim;
|
||||
});
|
||||
|
||||
devShells = eachSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
vim = import ./nvim (inputs
|
||||
// {
|
||||
inherit pkgs;
|
||||
lib = nixpkgs.lib;
|
||||
});
|
||||
in rec {
|
||||
default = nvim-lua;
|
||||
nvim-lua = pkgs.mkShell {
|
||||
name = "nvim-lua";
|
||||
shellHook = ''
|
||||
ln -fs ${vim.luarc} .luarc.json
|
||||
'';
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: {
|
||||
nvim,
|
||||
plugins ? {
|
||||
start = [];
|
||||
opt = [];
|
||||
},
|
||||
meta ? {luvit = true;},
|
||||
lua-version ? "5.1",
|
||||
disabled-diagnostics ? [],
|
||||
}: let
|
||||
# stolen from https://github.com/mrcjkb/nix-gen-luarc-json
|
||||
pluginPackages =
|
||||
map (
|
||||
x:
|
||||
if x ? plugin
|
||||
then x.plugin
|
||||
else x
|
||||
)
|
||||
(plugins.start ++ plugins.opt);
|
||||
partitions = builtins.partition (plugin:
|
||||
plugin.vimPlugin
|
||||
or false
|
||||
|| plugin.pname or "" == "nvim-treesitter")
|
||||
pluginPackages;
|
||||
nvim-plugins = partitions.right;
|
||||
rocks = partitions.wrong;
|
||||
plugin-luadirs = builtins.map (plugin: "${plugin}/lua") nvim-plugins;
|
||||
pkg-libdirs = builtins.map (pkg: "${pkg}/lib/lua/${lua-version}") rocks;
|
||||
pkg-sharedirs = builtins.map (pkg: "${pkg}/share/lua/${lua-version}") rocks;
|
||||
|
||||
luarc = {
|
||||
"$schema" = "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json";
|
||||
runtime = {
|
||||
version = "LuaJIT";
|
||||
};
|
||||
workspace = {
|
||||
checkThirdParty = false;
|
||||
library =
|
||||
[
|
||||
"${nvim}/share/nvim/runtime/lua"
|
||||
"$VIMRUNTIME/lua"
|
||||
"\${3rd}/busted/library"
|
||||
"\${3rd}/luassert/library"
|
||||
]
|
||||
++ plugin-luadirs
|
||||
++ pkg-libdirs
|
||||
++ pkg-sharedirs
|
||||
++ (lib.optional (meta.luvit or false) "${pkgs.vimPlugins.luvit-meta}/library");
|
||||
ignoreDir = [
|
||||
".git"
|
||||
".github"
|
||||
".direnv"
|
||||
"result"
|
||||
"nix"
|
||||
"doc"
|
||||
];
|
||||
};
|
||||
diagnostics = {
|
||||
libraryFiles = "Disable";
|
||||
globals = ["vim"];
|
||||
disable = disabled-diagnostics;
|
||||
};
|
||||
};
|
||||
in
|
||||
(pkgs.formats.json {}).generate ".luarc.json" luarc
|
||||
@@ -4,11 +4,12 @@
|
||||
stdenv,
|
||||
...
|
||||
}: {
|
||||
name ? "nvim",
|
||||
package ? pkgs.neovim,
|
||||
config,
|
||||
plugins ? {
|
||||
start = [];
|
||||
opts = [];
|
||||
opt = [];
|
||||
},
|
||||
extraPackages ? [],
|
||||
extraLuaPackages ? p: [],
|
||||
@@ -17,21 +18,19 @@
|
||||
withPerl ? false,
|
||||
withRuby ? false,
|
||||
withNodeJs ? false,
|
||||
withSqlite ? false,
|
||||
}: let
|
||||
builder = (import ./bytecompile.nix) {inherit pkgs lib;};
|
||||
pack = (import ./pack.nix) {inherit pkgs lib;};
|
||||
mkLuarc = (import ./luarc.nix) {inherit pkgs lib;};
|
||||
|
||||
nvim = builder.byteCompileVim package;
|
||||
|
||||
# TODO: only the (unused) init.lua seems to be byte compiled, idk why
|
||||
conf = builder.byteCompileLuaDrv (
|
||||
(pkgs.runCommandLocal "nvim-config" {} ''
|
||||
mkdir $out
|
||||
cp -r ${config}/* $out
|
||||
ls $out
|
||||
'')
|
||||
);
|
||||
conf = builder.byteCompileLuaDrv (pkgs.runCommandLocal "nvim-config" {} ''
|
||||
mkdir $out
|
||||
cp -r ${config}/* $out
|
||||
ls $out
|
||||
'');
|
||||
|
||||
pluginPack = let
|
||||
normalize = optional: p: let
|
||||
@@ -62,7 +61,7 @@
|
||||
|
||||
withDeps = p: [p] ++ builtins.concatMap withDeps (map (normalize false) (p.plugin.dependencies or []));
|
||||
|
||||
plugs = (map (normalize false) plugins.start) ++ (map (normalize true) plugins.opts);
|
||||
plugs = (map (normalize false) plugins.start) ++ (map (normalize true) plugins.opt);
|
||||
allPlugs = lib.unique (builtins.concatMap withDeps plugs);
|
||||
partitioned = builtins.partition (p: p.optional) (preparePlugins allPlugs);
|
||||
opt = map (p: p.plugin) partitioned.right;
|
||||
@@ -90,8 +89,8 @@
|
||||
|
||||
${builtins.readFile (config + "/init.lua")}
|
||||
'';
|
||||
in
|
||||
pkgs.wrapNeovimUnstable nvim {
|
||||
in {
|
||||
${name} = pkgs.wrapNeovimUnstable nvim {
|
||||
wrapRc = false;
|
||||
wrapperArgs = builtins.concatStringsSep " " [
|
||||
(lib.optionals (extraPackages != []) ''--prefix PATH : "${lib.makeBinPath extraPackages}"'')
|
||||
@@ -99,4 +98,7 @@ in
|
||||
];
|
||||
|
||||
inherit withPython3 withNodeJs withPerl withRuby extraPython3Packages extraLuaPackages;
|
||||
}
|
||||
};
|
||||
|
||||
luarc = mkLuarc { nvim = package; inherit plugins; };
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
"/keymap"
|
||||
"/lang"
|
||||
"/lua"
|
||||
"/lsp"
|
||||
"/pack"
|
||||
"/parser"
|
||||
"/plugin"
|
||||
Reference in New Issue
Block a user