mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
feat: vim.byteCompileLua
This commit is contained in:
parent
afa5e3594b
commit
97d49d331c
3 changed files with 23 additions and 4 deletions
|
@ -99,6 +99,8 @@ configuration formats.
|
||||||
yourself by adding `vim.opt.listchars:append({ eol = '<char>' })` to your
|
yourself by adding `vim.opt.listchars:append({ eol = '<char>' })` to your
|
||||||
lua configuration
|
lua configuration
|
||||||
|
|
||||||
|
- Pre-compile lua files using LuaJIT for performance. Can be disabled with `vim.byteCompileLua = false`.
|
||||||
|
|
||||||
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd()
|
[Neovim documentation on `vim.cmd`]: https://neovim.io/doc/user/lua.html#vim.cmd()
|
||||||
|
|
||||||
- Make Neovim's configuration file entirely Lua based. This comes with a few
|
- Make Neovim's configuration file entirely Lua based. This comes with a few
|
||||||
|
|
|
@ -7,11 +7,10 @@ inputs: {
|
||||||
extraModules ? [],
|
extraModules ? [],
|
||||||
}: let
|
}: let
|
||||||
inherit (pkgs) vimPlugins;
|
inherit (pkgs) vimPlugins;
|
||||||
inherit (pkgs.vimUtils) buildVimPlugin;
|
|
||||||
inherit (lib.strings) isString toString;
|
inherit (lib.strings) isString toString;
|
||||||
inherit (lib.lists) filter map concatLists;
|
inherit (lib.lists) filter map concatLists;
|
||||||
inherit (lib.attrsets) recursiveUpdate getAttr;
|
inherit (lib.attrsets) recursiveUpdate getAttr;
|
||||||
inherit (lib.asserts) assertMsg;
|
inherit (builtins) baseNameOf;
|
||||||
|
|
||||||
# import modules.nix with `check`, `pkgs` and `lib` as arguments
|
# import modules.nix with `check`, `pkgs` and `lib` as arguments
|
||||||
# check can be disabled while calling this file is called
|
# check can be disabled while calling this file is called
|
||||||
|
@ -100,6 +99,16 @@ inputs: {
|
||||||
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
|
||||||
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
|
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
|
||||||
|
|
||||||
|
luaConfig =
|
||||||
|
if vimOptions.byteCompileLua
|
||||||
|
then pkgs.runCommandLocal "init.lua" {text = vimOptions.builtLuaConfigRC;} "echo -n \"$text\" | ${pkgs.luajit}/bin/luajit -bd -- - $out"
|
||||||
|
else pkgs.writeText "init.lua" vimOptions.builtLuaConfigRC;
|
||||||
|
|
||||||
|
extraLuaFiles =
|
||||||
|
if vimOptions.byteCompileLua
|
||||||
|
then map (file: pkgs.runCommandLocal (baseNameOf file) {} "${pkgs.luajit}/bin/luajit -bd -- ${file} $out") vimOptions.extraLuaFiles
|
||||||
|
else vimOptions.extraLuaFiles;
|
||||||
|
|
||||||
# Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to
|
# Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to
|
||||||
# generate a wrapped Neovim package.
|
# generate a wrapped Neovim package.
|
||||||
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
|
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
|
||||||
|
@ -107,8 +116,9 @@ inputs: {
|
||||||
plugins = concatLists [builtStartPlugins builtOptPlugins];
|
plugins = concatLists [builtStartPlugins builtOptPlugins];
|
||||||
appName = "nvf";
|
appName = "nvf";
|
||||||
extraBinPath = vimOptions.extraPackages;
|
extraBinPath = vimOptions.extraPackages;
|
||||||
initLua = vimOptions.builtLuaConfigRC;
|
# initLua = vimOptions.builtLuaConfigRC;
|
||||||
luaFiles = vimOptions.extraLuaFiles;
|
# luaFiles = vimOptions.extraLuaFiles;
|
||||||
|
luaFiles = [luaConfig] ++ extraLuaFiles;
|
||||||
|
|
||||||
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
|
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
|
||||||
inherit extraLuaPackages extraPython3Packages;
|
inherit extraLuaPackages extraPython3Packages;
|
||||||
|
|
|
@ -23,6 +23,13 @@ in {
|
||||||
];
|
];
|
||||||
|
|
||||||
options.vim = {
|
options.vim = {
|
||||||
|
byteCompileLua = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = true;
|
||||||
|
example = false;
|
||||||
|
description = "Enable the pre-compilation of lua files using LuaJIT.";
|
||||||
|
};
|
||||||
|
|
||||||
enableLuaLoader = mkEnableOption ''
|
enableLuaLoader = mkEnableOption ''
|
||||||
the experimental Lua module loader to speed up the start up process
|
the experimental Lua module loader to speed up the start up process
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue