Compare commits

..

9 commits

Author SHA1 Message Date
diniamo
1c0b31cc10 improve helper functions 2024-08-10 16:52:14 +02:00
diniamo
78c01d50ed fix: use luajit from the neovim package's lua attribute 2024-08-10 09:05:06 +02:00
diniamo
d48f52f065 fix: add Gerg's suggestion 2024-08-09 09:29:41 +02:00
diniamo
1340eb34a0 style: improve code clarity 2024-08-09 09:29:29 +02:00
diniamo
fa660627fc style: remove leftover commented code 2024-08-08 12:34:16 +02:00
diniamo
5c79c458fc feat: byte-compile plugins 2024-08-05 14:57:02 +02:00
diniamo
13cc59ab99 feat: use <<< instead of echo -n | 2024-08-05 14:10:31 +02:00
diniamo
97d49d331c feat: vim.byteCompileLua 2024-08-05 13:55:16 +02:00
diniamo
afa5e3594b feat: print-nvf-config(-path) -> nvf-print-config(-path) 2024-08-05 13:55:16 +02:00
10 changed files with 35 additions and 99 deletions

View file

@ -83,7 +83,7 @@ Release notes for release 0.5
- Updated indent-blankine.nvim to v3 - this comes with a few option changes, which will be migrated with `renamedOptionModule`
[jacekpoz](https://jacekpoz.pl):
[jacekpoz](https://github.com/jacekpoz):
- Fixed scrollOffset not being used

View file

@ -62,7 +62,7 @@ vim.api.nvim_set_keymap('n', '<leader>a', ':lua camelToSnake()<CR>', { noremap =
- Added rose-pine theme.
[jacekpoz](https://jacekpoz.pl):
[jacekpoz](https://github.com/jacekpoz):
- Added `vim.autocomplete.alwaysComplete`. Allows users to have the autocomplete window popup only when manually activated.

View file

@ -62,17 +62,14 @@ configuration formats.
recommended to go through rustacean.nvim's README to take a closer look at its
features and usage
[jacekpoz](https://jacekpoz.pl):
[jacekpoz](https://github.com/jacekpoz):
[ocaml-lsp]: https://github.com/ocaml/ocaml-lsp
[new-file-template.nvim]: https://github.com/otavioschwanck/new-file-template.nvim
- Add [ocaml-lsp] support
- Fix "Emac" typo
- Add [new-file-template.nvim] to automatically fill new file contents using templates.
[diniamo](https://github.com/diniamo):
- Move the `theme` dag entry to before `luaScript`.
@ -102,6 +99,8 @@ configuration formats.
yourself by adding `vim.opt.listchars:append({ eol = '<char>' })` to your
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()
- Make Neovim's configuration file entirely Lua based. This comes with a few

View file

@ -628,15 +628,9 @@
};
plugin-nvim-nio = {
# (required by nvim-dap-ui)
# (required nvim-dap-ui)
url = "github:nvim-neotest/nvim-nio";
flake = false;
};
plugin-new-file-template-nvim = {
# (required by new-file-template.nvim)
url = "github:otavioschwanck/new-file-template.nvim";
flake = false;
};
};
}

View file

@ -10,6 +10,7 @@ inputs: {
inherit (lib.strings) isString toString;
inherit (lib.lists) filter map concatLists;
inherit (lib.attrsets) recursiveUpdate;
inherit (builtins) baseNameOf;
# import modules.nix with `check`, `pkgs` and `lib` as arguments
# check can be disabled while calling this file is called
@ -28,6 +29,8 @@ inputs: {
# alias to the internal configuration
vimOptions = module.config.vim;
luajit = vimOptions.package.lua;
# build a vim plugin with the given name and arguments
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
# instead
@ -40,12 +43,20 @@ inputs: {
inherit src;
nativeBuildInputs = with pkgs.vimUtils; [
luajit
vimCommandCheckHook
vimGenDocHook
neovimRequireCheckHook
];
passthru.vimPlugin = true;
buildPhase = lib.optionalString vimOptions.byteCompileLua ''
runHook preBuild
find . -type f -name '*.lua' -exec luajit -bd -- {} {} \;
runHook postBuild
'';
installPhase = ''
runHook preInstall
@ -93,6 +104,16 @@ inputs: {
extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages;
extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages;
luaConfig =
if vimOptions.byteCompileLua
then pkgs.runCommandLocal "init.lua" {text = vimOptions.builtLuaConfigRC;} "${luajit}/bin/luajit -bd -- - $out <<< \"$text\""
else pkgs.writeText "init.lua" vimOptions.builtLuaConfigRC;
extraLuaFiles =
if vimOptions.byteCompileLua
then map (file: pkgs.runCommandLocal (baseNameOf file) {} "${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
# generate a wrapped Neovim package.
neovim-wrapped = inputs.mnw.lib.wrap pkgs {
@ -100,8 +121,7 @@ inputs: {
plugins = concatLists [builtStartPlugins builtOptPlugins];
appName = "nvf";
extraBinPath = vimOptions.extraPackages;
initLua = vimOptions.builtLuaConfigRC;
luaFiles = vimOptions.extraLuaFiles;
luaFiles = [luaConfig] ++ extraLuaFiles;
inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3;
inherit extraLuaPackages extraPython3Packages;

View file

@ -4,7 +4,6 @@
./ccc
./gestures
./motion
./new-file-template
./telescope
./icon-picker
./images

View file

@ -1,23 +0,0 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkIf;
inherit (lib.nvim.dag) entryAnywhere;
inherit (lib.nvim.lua) toLuaObject;
cfg = config.vim.utility.new-file-template;
in {
config = mkIf cfg.enable {
vim = {
startPlugins = [
"new-file-template-nvim"
];
pluginRC.new-file-template = entryAnywhere ''
require('new-file-template').setup(${toLuaObject cfg.setupOpts})
'';
};
};
}

View file

@ -1,6 +0,0 @@
{
imports = [
./config.nix
./new-file-template.nix
];
}

View file

@ -1,54 +0,0 @@
{lib, ...}: let
inherit (lib.options) mkOption;
inherit (lib.types) attrsOf bool listOf str;
inherit (lib.nvim.types) mkPluginSetupOption;
in {
options.vim.utility.new-file-template = {
enable = mkOption {
type = bool;
default = false;
description = ''
new-file-template.nvim: Automatically insert a template on new files in neovim.
::: {.note}
For custom templates add a directory containing `lua/templates/*.lua`
to `vim.additionalRuntimePaths`.
:::
[custom-template-docs]: https://github.com/otavioschwanck/new-file-template.nvim?tab=readme-ov-file#creating-new-templates
More documentation on the templates available at [custom-template-docs]
'';
};
setupOpts = mkPluginSetupOption "nvim-file-template.nvim" {
disableInsert = mkOption {
type = bool;
default = false;
description = "Enter insert mode after inserting the template";
};
disableAutocmd = mkOption {
type = bool;
default = false;
description = "Disable the autocmd that creates the template";
};
disableFiletype = mkOption {
type = listOf str;
default = [];
description = "Disable default templates for specific filetypes";
};
disableSpecific = mkOption {
type = attrsOf (listOf str);
default = {};
description = "Disable specific regexp for the default templates.";
example = "{ ruby = [\".*\"]; }";
};
suffixAsFiletype = mkOption {
type = bool;
default = false;
description = "Use suffix of filename rather than `vim.bo.filetype` as filetype";
};
};
};
}

View file

@ -23,6 +23,13 @@ in {
];
options.vim = {
byteCompileLua = mkOption {
type = bool;
default = true;
example = false;
description = "Enable the pre-compilation of lua files using LuaJIT.";
};
enableLuaLoader = mkEnableOption ''
the experimental Lua module loader to speed up the start up process