refactor(nvf): move core nvf config to a module

This commit is contained in:
Mohammad Rafiq 2025-05-06 15:54:26 +08:00
parent 3e92ace989
commit 57a73bbcae
No known key found for this signature in database
5 changed files with 118 additions and 84 deletions

View file

@ -1,93 +1,10 @@
{ inputs, pkgs, ... }:
{
nix.settings.substituters = [ "https://nvf.cachix.org" ];
nix.settings.trusted-public-keys = [
"nvf.cachix.org-1:GMQWiUhZ6ux9D5CvFFMwnc2nFrUHTeGaXRlVBXo+naI="
];
home-manager.users.rafiq = {
imports = [
inputs.nvf.homeManagerModules.default
./nvf/input.nix
./nvf/languages.nix
./nvf/ui.nix
./nvf/utilities.nix
];
home.sessionVariables.EDITOR = "nvim";
programs.nvf = {
enable = true;
enableManpages = true;
settings.vim = {
viAlias = true;
vimAlias = true;
options = {
# Indentation
autoindent = true;
smartindent = true;
expandtab = true;
smarttab = true;
wrap = true;
shiftwidth = 2;
tabstop = 2;
foldlevel = 1000; # Open all folds by default
# Search
hlsearch = true;
ignorecase = true;
incsearch = true;
smartcase = true; # case-sensitive if search contains uppercase
# Visual
number = true;
cursorline = true;
visualbell = true;
termguicolors = true;
# Input
backspace = "indent,eol,start";
};
keymaps = [
{
desc = "Open the file path under the cursor, making the file if it doesn't exist.";
key = "gf";
mode = "n";
action = ":cd %:p:h<CR>:e <cfile><CR>";
silent = true;
}
{
desc = "Delete the previous word.";
key = "<C-BS>";
mode = "i";
action = "<C-W>";
silent = true;
}
{
desc = "Open the filetree.";
key = "t";
mode = "n";
action = ":Yazi<CR>";
silent = true;
}
];
luaConfigRC.turn_off_inline_diagnostics =
# lua
''
vim.diagnostic.config({
virtual_text = false -- turn off inline diagnostics
})
'';
extraPlugins = with pkgs.vimPlugins; {
yuck-vim = {
package = yuck-vim;
};
nvim-treesitter-parsers = {
package = nvim-treesitter-parsers.yuck;
};
nvim-parinfer = {
package = nvim-parinfer;
};
};
};
};
};
}

View file

@ -18,9 +18,11 @@
nixosModules.enable = true;
nixosModules.hostname = hostname;
nixosModules.mainUser = "rafiq";
hmModules.enable = true;
nix-config.enable = true;
boot-config.enable = true;
hardware-config.usbAutoMount = true;
nw-config.backend = "networkmanager";
hmModules.enable = true;
hmModules.mainApps.editor = "nvf";
}

View file

@ -14,6 +14,7 @@ in
imports = [
inputs.home-manager.nixosModules.home-manager
./hardware.nix
./programs/editor.nix
];
options = {
@ -32,6 +33,12 @@ in
example = "firefox";
description = "What browser is the default.";
};
editor = lib.mkOption {
type = lib.types.str;
default = "nvf";
example = "nvf";
description = "What editor is the default.";
};
launcher = lib.mkOption {
type = lib.types.str;
default = "fuzzel";

View file

@ -0,0 +1,29 @@
{
config,
lib,
inputs,
pkgs,
...
}:
let
username = config.nixosModules.mainUser;
in
{
config = lib.mkIf (config.hmModules.mainApps.editor == "nvf") (
lib.mkMerge [
{
nix.settings.substituters = [ "https://nvf.cachix.org" ];
nix.settings.trusted-public-keys = [
"nvf.cachix.org-1:GMQWiUhZ6ux9D5CvFFMwnc2nFrUHTeGaXRlVBXo+naI="
];
home-manager.users.${username} = {
imports = [
inputs.nvf.homeManagerModules.default
./nvf/core.nix
];
};
}
]
);
}

View file

@ -0,0 +1,79 @@
{ pkgs, ... }:
{
home.sessionVariables.EDITOR = "nvim";
programs.nvf = {
enable = true;
enableManpages = true;
settings.vim = {
viAlias = true;
vimAlias = true;
options = {
# Indentation
autoindent = true;
smartindent = true;
expandtab = true;
smarttab = true;
wrap = true;
shiftwidth = 2;
tabstop = 2;
foldlevel = 1000; # Open all folds by default
# Search
hlsearch = true;
ignorecase = true;
incsearch = true;
smartcase = true; # case-sensitive if search contains uppercase
# Visual
number = true;
cursorline = true;
visualbell = true;
termguicolors = true;
# Input
backspace = "indent,eol,start";
};
keymaps = [
{
desc = "Open the file path under the cursor, making the file if it doesn't exist.";
key = "gf";
mode = "n";
action = ":cd %:p:h<CR>:e <cfile><CR>";
silent = true;
}
{
desc = "Delete the previous word.";
key = "<C-BS>";
mode = "i";
action = "<C-W>";
silent = true;
}
{
desc = "Open the filetree.";
key = "t";
mode = "n";
action = ":Yazi<CR>";
silent = true;
}
];
luaConfigRC.turn_off_inline_diagnostics =
# lua
''
vim.diagnostic.config({
virtual_text = false -- turn off inline diagnostics
})
'';
extraPlugins = with pkgs.vimPlugins; {
yuck-vim = {
package = yuck-vim;
};
nvim-treesitter-parsers = {
package = nvim-treesitter-parsers.yuck;
};
nvim-parinfer = {
package = nvim-parinfer;
};
};
};
};
}