refactor(nvim): add _file and config attrs to all submodules
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-12-21 23:34:10 -05:00
parent e1d77a4f3b
commit 0f627107ce
23 changed files with 243 additions and 209 deletions

View file

@ -87,7 +87,6 @@
neovim = { neovim = {
enable = true; enable = true;
enableIde = true;
user = mainUser; user = mainUser;
}; };
}; };

View file

@ -84,7 +84,6 @@ in {
neovim = { neovim = {
enable = true; enable = true;
enableIde = true;
user = mainUser; user = mainUser;
}; };
}; };

View file

@ -70,7 +70,6 @@
neovim = { neovim = {
enable = true; enable = true;
enableIde = true;
user = mainUser; user = mainUser;
}; };
}; };

View file

@ -43,7 +43,6 @@
neovim = { neovim = {
enable = true; enable = true;
enableIde = true;
user = mainUser; user = mainUser;
}; };
}; };

View file

@ -70,7 +70,6 @@
neovim = { neovim = {
enable = true; enable = true;
enableIde = true;
user = mainUser; user = mainUser;
}; };
}; };

View file

@ -84,7 +84,6 @@
neovim = { neovim = {
enable = true; enable = true;
enableIde = true;
user = mainUser; user = mainUser;
}; };
}; };

View file

@ -106,7 +106,6 @@
neovim = { neovim = {
enable = true; enable = true;
enableIde = true;
user = mainUser; user = mainUser;
}; };
}; };

View file

@ -4,7 +4,9 @@ self: {
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) mkOption types; inherit (lib) mkIf mkOption types;
cfg = config.programs.neovim;
in { in {
imports = [ imports = [
./git ./git
@ -17,13 +19,10 @@ in {
user = mkOption { user = mkOption {
type = types.str; type = types.str;
}; };
enableIde = mkOption {
type = types.bool;
default = false;
};
}; };
config.programs.neovim = { config = mkIf cfg.enable {
programs.neovim = {
extraLuaConfig = extraLuaConfig =
# lua # lua
'' ''
@ -106,6 +105,7 @@ in {
} }
]; ];
}; };
};
# For accurate stack trace # For accurate stack trace
_file = ./default.nix; _file = ./default.nix;

View file

@ -8,7 +8,8 @@
cfg = config.programs.neovim; cfg = config.programs.neovim;
in { in {
programs = mkIf cfg.enable { config = mkIf cfg.enable {
programs = {
# I love doing typos # I love doing typos
bash.shellAliases = { bash.shellAliases = {
nivm = "nvim"; nivm = "nvim";
@ -20,7 +21,7 @@ in {
viAlias = true; viAlias = true;
vimAlias = true; vimAlias = true;
extraPackages = mkIf cfg.enableIde (attrValues { extraPackages = attrValues {
inherit inherit
(pkgs.nodePackages) (pkgs.nodePackages)
bash-language-server bash-language-server
@ -30,10 +31,9 @@ in {
(pkgs) (pkgs)
shellcheck shellcheck
; ;
}); };
extraLuaConfig = extraLuaConfig =
mkIf cfg.enableIde
# lua # lua
'' ''
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('FileType', {
@ -55,4 +55,8 @@ in {
''; '';
}; };
}; };
};
# For accurate stack trace
_file = ./default.nix;
} }

View file

@ -9,7 +9,7 @@
cfg = config.programs.neovim; cfg = config.programs.neovim;
in { in {
config = mkIf cfg.enableIde { config = mkIf cfg.enable {
xdg.configFile."clangd/config.yaml".source = writeYAML "config.yaml" { xdg.configFile."clangd/config.yaml".source = writeYAML "config.yaml" {
CompileFlags.Add = ["-D__cpp_concepts=202002L"]; CompileFlags.Add = ["-D__cpp_concepts=202002L"];
}; };
@ -21,6 +21,7 @@ in {
'' ''
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('FileType', {
pattern = { 'cpp', 'c' }, pattern = { 'cpp', 'c' },
-- FIXME: load direnv here https://github.com/actionshrimp/direnv.nvim?tab=readme-ov-file#using-nvim-lspconfig
command = 'setlocal ts=4 sw=4 sts=0 expandtab', command = 'setlocal ts=4 sw=4 sts=0 expandtab',
}); });
''; '';
@ -57,4 +58,7 @@ in {
}; };
}; };
}; };
# For accurate stack trace
_file = ./default.nix;
} }

View file

@ -10,7 +10,7 @@ self: {
cfg = config.programs.neovim; cfg = config.programs.neovim;
in { in {
config = mkIf cfg.enableIde { config = mkIf cfg.enable {
programs = { programs = {
neovim = { neovim = {
extraPackages = attrValues { extraPackages = attrValues {
@ -73,5 +73,5 @@ in {
}; };
# For accurate stack trace # For accurate stack trace
_file = ./csharp.nix; _file = ./default.nix;
} }

View file

@ -1,9 +1,12 @@
self: { self: {
config,
lib, lib,
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) fileContents mkBefore; inherit (lib) fileContents mkBefore mkIf;
cfg = config.programs.neovim;
in { in {
imports = [ imports = [
./bash ./bash
@ -21,8 +24,8 @@ in {
(import ./web self) (import ./web self)
]; ];
config.programs = { config = mkIf cfg.enable {
neovim = { programs.neovim = {
extraLuaConfig = extraLuaConfig =
mkBefore mkBefore
# lua # lua

View file

@ -6,8 +6,8 @@
inherit (lib) mkIf; inherit (lib) mkIf;
cfg = config.programs.neovim; cfg = config.programs.neovim;
in in {
mkIf cfg.enableIde { config = mkIf cfg.enable {
programs = { programs = {
neovim = { neovim = {
extraLuaConfig = extraLuaConfig =
@ -24,4 +24,8 @@ in
''; '';
}; };
}; };
} };
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -10,8 +10,8 @@
javaSdk = pkgs.temurin-bin-17; javaSdk = pkgs.temurin-bin-17;
javaPkgs = attrValues {inherit (pkgs) gradle maven;}; javaPkgs = attrValues {inherit (pkgs) gradle maven;};
in in {
mkIf cfg.enableIde { config = mkIf cfg.enable {
home.packages = javaPkgs; home.packages = javaPkgs;
xdg.dataFile.".gradle/gradle.properties".text = '' xdg.dataFile.".gradle/gradle.properties".text = ''
@ -81,4 +81,8 @@ in
]; ];
}; };
}; };
} };
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -7,8 +7,8 @@
inherit (lib) attrValues mkIf; inherit (lib) attrValues mkIf;
cfg = config.programs.neovim; cfg = config.programs.neovim;
in in {
mkIf cfg.enableIde { config = mkIf cfg.enable {
programs = { programs = {
neovim = { neovim = {
extraPackages = attrValues { extraPackages = attrValues {
@ -26,6 +26,7 @@ in
pattern = 'yaml', pattern = 'yaml',
command = 'setlocal ts=4 sw=4 sts=0 expandtab', command = 'setlocal ts=4 sw=4 sts=0 expandtab',
}); });
vim.api.nvim_create_autocmd('FileType', { vim.api.nvim_create_autocmd('FileType', {
pattern = 'json', pattern = 'json',
command = 'setlocal ts=4 sw=4 sts=0 expandtab', command = 'setlocal ts=4 sw=4 sts=0 expandtab',
@ -54,4 +55,8 @@ in
''; '';
}; };
}; };
} };
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -9,8 +9,8 @@
cfg = config.programs.neovim; cfg = config.programs.neovim;
flakeEnv = config.programs.bash.sessionVariables.FLAKE; flakeEnv = config.programs.bash.sessionVariables.FLAKE;
in in {
mkIf cfg.enableIde { config = mkIf cfg.enable {
programs = { programs = {
neovim = { neovim = {
extraPackages = attrValues { extraPackages = attrValues {
@ -38,8 +38,8 @@ in
require("neodev").setup({ require("neodev").setup({
override = function(root_dir, library) override = function(root_dir, library)
if root_dir:find('${flakeEnv}', 1, true) == 1 then if root_dir:find('${flakeEnv}', 1, true) == 1 then
library.enabled = true library.enabled = true;
library.plugins = true library.plugins = true;
end end
end, end,
}); });
@ -52,4 +52,8 @@ in
]; ];
}; };
}; };
} };
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -19,9 +19,7 @@ self: {
hash = "sha256-deQvQOOyK6iP7kjVrgEdFTyOP80RWXMrETs6gi7DTmo="; hash = "sha256-deQvQOOyK6iP7kjVrgEdFTyOP80RWXMrETs6gi7DTmo=";
}; };
in { in {
# live-server --quiet --browser=firefox --open=%outputfile% --watch=%outputfile% --wait=800 config = mkIf cfg.enable {
config = mkIf cfg.enableIde {
programs = { programs = {
neovim = { neovim = {
extraPackages = attrValues { extraPackages = attrValues {
@ -165,5 +163,5 @@ in {
}; };
# For accurate stack trace # For accurate stack trace
_file = ./markdown.nix; _file = ./default.nix;
} }

View file

@ -18,13 +18,10 @@ self: {
flakeEnv = config.programs.bash.sessionVariables.FLAKE; flakeEnv = config.programs.bash.sessionVariables.FLAKE;
flakeDir = "${removePrefix "/home/${cfg.user}/" flakeEnv}"; flakeDir = "${removePrefix "/home/${cfg.user}/" flakeEnv}";
in { in {
config = mkIf cfg.enableIde { config = mkIf cfg.enable {
assertions = [ assertions = [
{ {
assertion = assertion = hasPrefix "/home/${cfg.user}/" flakeEnv;
cfg.enableIde
&& hasPrefix "/home/${cfg.user}/" flakeEnv
|| !cfg.enableIde;
message = '' message = ''
Your $FLAKE environment variable needs to point to a directory in Your $FLAKE environment variable needs to point to a directory in
the main users' home to use the neovim module. the main users' home to use the neovim module.
@ -79,5 +76,5 @@ in {
}; };
# For accurate stack trace # For accurate stack trace
_file = ./nix.nix; _file = ./default.nix;
} }

View file

@ -7,23 +7,20 @@
inherit (lib) attrValues mkIf; inherit (lib) attrValues mkIf;
cfg = config.programs.neovim; cfg = config.programs.neovim;
in {
config = mkIf cfg.enableIde {
programs = {
neovim = {
withPython3 = true;
extraPython3Packages = py: pythonPkgs = py:
(attrValues { (attrValues {
inherit (py) python-lsp-server; inherit (py) python-lsp-server;
}) })
++ py.python-lsp-server.optional-dependencies.all; ++ py.python-lsp-server.optional-dependencies.all;
in {
config = mkIf cfg.enable {
programs = {
neovim = {
withPython3 = true;
extraPackages = extraPython3Packages = pythonPkgs;
(attrValues { extraPackages = pythonPkgs pkgs.python3Packages;
inherit (pkgs.python3Packages) python-lsp-server;
})
++ pkgs.python3Packages.python-lsp-server.optional-dependencies.all;
extraLuaConfig = extraLuaConfig =
# lua # lua
@ -45,4 +42,7 @@ in {
}; };
}; };
}; };
# For accurate stack trace
_file = ./default.nix;
} }

View file

@ -7,8 +7,8 @@
inherit (lib) attrValues mkIf; inherit (lib) attrValues mkIf;
cfg = config.programs.neovim; cfg = config.programs.neovim;
in in {
mkIf cfg.enableIde { config = mkIf cfg.enable {
programs = { programs = {
neovim = { neovim = {
extraPackages = attrValues { extraPackages = attrValues {
@ -35,4 +35,8 @@ in
''; '';
}; };
}; };
} };
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -11,7 +11,7 @@ self: {
cfg = config.programs.neovim; cfg = config.programs.neovim;
in { in {
config = mkIf cfg.enableIde { config = mkIf cfg.enable {
programs = { programs = {
neovim = { neovim = {
withNodeJs = true; withNodeJs = true;
@ -200,5 +200,5 @@ in {
}; };
# For accurate stack trace # For accurate stack trace
_file = ./web.nix; _file = ./default.nix;
} }

View file

@ -5,19 +5,19 @@ self: {
... ...
}: let }: let
inherit (self.inputs) nvim-theme-src; inherit (self.inputs) nvim-theme-src;
inherit (lib) attrValues fileContents optionals; inherit (lib) attrValues fileContents mkIf;
cfg = config.programs.neovim; cfg = config.programs.neovim;
in { in {
imports = [./treesitter.nix]; imports = [./treesitter.nix];
config.programs.neovim = { config = mkIf cfg.enable {
programs.neovim = {
extraPackages = attrValues { extraPackages = attrValues {
inherit (pkgs) bat; inherit (pkgs) bat;
}; };
plugins = plugins = [
[
{ {
plugin = pkgs.vimPlugins.dracula-nvim.overrideAttrs { plugin = pkgs.vimPlugins.dracula-nvim.overrideAttrs {
src = nvim-theme-src; src = nvim-theme-src;
@ -100,8 +100,7 @@ in {
type = "lua"; type = "lua";
config = fileContents ./config/heirline.lua; config = fileContents ./config/heirline.lua;
} }
]
++ optionals cfg.enableIde [
{ {
plugin = pkgs.vimPlugins.neo-tree-nvim; plugin = pkgs.vimPlugins.neo-tree-nvim;
type = "lua"; type = "lua";
@ -177,7 +176,8 @@ in {
} }
]; ];
}; };
};
# For accurate stack trace # For accurate stack trace
_file = ./theme.nix; _file = ./default.nix;
} }

View file

@ -1,4 +1,14 @@
{pkgs, ...}: { {
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf;
cfg = config.programs.neovim;
in {
config = mkIf cfg.enable {
programs.neovim.plugins = [ programs.neovim.plugins = [
{ {
plugin = pkgs.vimPlugins.nvim-treesitter-context; plugin = pkgs.vimPlugins.nvim-treesitter-context;
@ -31,4 +41,8 @@
''; '';
} }
]; ];
};
# For accurate stack trace
_file = ./treesitter.nix;
} }