nichts/modules/editors/nvf/settings.nix

97 lines
3 KiB
Nix
Raw Normal View History

2024-07-06 17:14:45 +02:00
# Credits to raf aka Notashelf, link to his repo is in the README.md
2024-07-06 15:15:37 +02:00
{
config,
lib,
2024-07-06 17:14:45 +02:00
pkgs,
inputs,
2024-07-06 15:15:37 +02:00
...
}: let
2024-07-16 11:13:12 +02:00
inherit (builtins) filter map toString path;
2024-07-06 15:15:37 +02:00
inherit (lib.filesystem) listFilesRecursive;
inherit (lib.strings) hasSuffix fileContents;
inherit (lib.attrsets) genAttrs;
2024-07-22 01:20:41 +02:00
inherit (lib) mkIf;
2024-07-06 15:15:37 +02:00
2024-07-21 17:36:55 +02:00
cfg = config.modules.system.programs.editors.neovim;
2024-07-06 15:15:37 +02:00
nvf = inputs.neovim-flake;
2024-07-28 11:00:54 +02:00
inherit (nvf.lib.nvim.dag) entryBefore;
2024-07-06 15:15:37 +02:00
in {
2024-07-06 17:14:45 +02:00
config = mkIf cfg.enable {
2024-07-06 15:15:37 +02:00
programs.neovim-flake = {
enable = true;
defaultEditor = true;
enableManpages = true;
settings = {
vim = {
# use neovim-unwrapped from nixpkgs
# alternatively, neovim-nightly from the neovim-nightly overlay
# via inputs.neovim-nightly.packages.${pkgs.stdenv.system}.neovim
2024-07-06 17:14:45 +02:00
package = pkgs.neovim-unwrapped;
2024-07-06 15:15:37 +02:00
viAlias = true;
vimAlias = true;
withNodeJs = false;
withPython3 = false;
withRuby = false;
preventJunkFiles = true;
useSystemClipboard = true;
2024-07-10 23:10:52 +02:00
tabWidth = 4;
autoIndent = true;
2024-07-06 15:15:37 +02:00
spellcheck = {
enable = true;
2024-07-06 17:14:45 +02:00
# TODO add de
2024-07-07 23:45:18 +02:00
languages = ["en" "de"];
2024-07-06 15:15:37 +02:00
};
enableLuaLoader = true;
enableEditorconfig = true;
2024-07-08 00:13:37 +02:00
debugMode = {
enable = false;
logFile = "/tmp/nvim.log";
};
2024-07-06 15:15:37 +02:00
2024-07-08 00:13:37 +02:00
additionalRuntimePaths = [
2024-07-16 11:13:12 +02:00
#(mkRuntimeDir "after")
#(mkRuntimeDir "spell")
2024-07-16 21:31:03 +02:00
./runtime
./runtime
2024-07-08 00:13:37 +02:00
];
2024-07-06 15:15:37 +02:00
# while I should be doing this in luaConfigRC below
# I have come to realise that spellfile contents are
# actually **not** loaded when luaConfigRC is used.
# as spellfile is a vim thing, this should be fine
2024-07-16 11:13:12 +02:00
# configRC.spellfile = entryAnywhere ''
# set spellfile=${toString ./runtime/spell/en.utf-8.add} " toString sanitizes the path
# '';
2024-07-06 15:15:37 +02:00
# additional lua configuration that I can append
# or, to be more precise, randomly inject into
# the lua configuration of my Neovim configuration
# wrapper. this is recursively read from the lua
# directory, so we do not need to use require
2024-07-10 22:10:54 +02:00
2024-07-08 00:13:37 +02:00
luaConfigRC = let
# get the name of each lua file in the lua directory, where setting files reside
# and import them recursively
configPaths = filter (hasSuffix ".lua") (map toString (listFilesRecursive ./lua));
2024-07-06 15:15:37 +02:00
2024-07-08 00:13:37 +02:00
# generates a key-value pair that looks roughly as follows:
# `<filePath> = entryAnywhere ''<contents of filePath>''`
# which is expected by neovim-flake's modified DAG library
luaConfig = genAttrs configPaths (file:
entryBefore ["luaScript"] ''
${fileContents "${file}"}
'');
in
luaConfig;
2024-07-06 15:15:37 +02:00
};
};
};
};
}