feat: Add nvchad module and enable nvchad instead of nixvim

This commit is contained in:
ulic-youthlic 2025-10-18 23:10:53 +08:00
parent 66196be557
commit 65a72ab802
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
16 changed files with 460 additions and 4 deletions

78
flake.lock generated
View file

@ -524,6 +524,24 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_3": {
"inputs": {
"systems": "systems_5"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flakey-profile": { "flakey-profile": {
"locked": { "locked": {
"lastModified": 1712898590, "lastModified": 1712898590,
@ -1018,6 +1036,30 @@
"type": "github" "type": "github"
} }
}, },
"nix4nvchad": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
],
"nvchad-starter": [
"nvchad-starter"
]
},
"locked": {
"lastModified": 1759653262,
"narHash": "sha256-uTiQXY/ZlplEq1j2jH0k6oDzldid0xHgnLsLQyRRbvk=",
"owner": "nix-community",
"repo": "nix4nvchad",
"rev": "9d91858966b5d4e87ee52e16993988dfea9b0f94",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nix4nvchad",
"type": "github"
}
},
"nixos-hardware": { "nixos-hardware": {
"locked": { "locked": {
"lastModified": 1760106635, "lastModified": 1760106635,
@ -1261,7 +1303,7 @@
"flake-parts": "flake-parts_6", "flake-parts": "flake-parts_6",
"nixpkgs": "nixpkgs_7", "nixpkgs": "nixpkgs_7",
"nuschtosSearch": "nuschtosSearch", "nuschtosSearch": "nuschtosSearch",
"systems": "systems_5" "systems": "systems_6"
}, },
"locked": { "locked": {
"lastModified": 1760906375, "lastModified": 1760906375,
@ -1323,7 +1365,7 @@
}, },
"nuschtosSearch": { "nuschtosSearch": {
"inputs": { "inputs": {
"flake-utils": "flake-utils_2", "flake-utils": "flake-utils_3",
"ixx": "ixx", "ixx": "ixx",
"nixpkgs": [ "nixpkgs": [
"nixvim", "nixvim",
@ -1344,6 +1386,19 @@
"type": "github" "type": "github"
} }
}, },
"nvchad-starter": {
"flake": false,
"locked": {
"lastModified": 1,
"narHash": "sha256-F3ysDLjeyNGHcZYOQHbw8kjBqf3L+ESrZs9XMRefOJQ=",
"path": "./nvchad",
"type": "path"
},
"original": {
"path": "./nvchad",
"type": "path"
}
},
"pre-commit-hooks-nix": { "pre-commit-hooks-nix": {
"inputs": { "inputs": {
"flake-compat": [ "flake-compat": [
@ -1389,10 +1444,12 @@
"niri-flake": "niri-flake", "niri-flake": "niri-flake",
"nix-doom": "nix-doom", "nix-doom": "nix-doom",
"nix-gaming": "nix-gaming", "nix-gaming": "nix-gaming",
"nix4nvchad": "nix4nvchad",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs_6", "nixpkgs": "nixpkgs_6",
"nixvim": "nixvim", "nixvim": "nixvim",
"nur": "nur", "nur": "nur",
"nvchad-starter": "nvchad-starter",
"sops-nix": "sops-nix", "sops-nix": "sops-nix",
"spacemacs": "spacemacs", "spacemacs": "spacemacs",
"stylix": "stylix", "stylix": "stylix",
@ -1513,7 +1570,7 @@
"nixpkgs" "nixpkgs"
], ],
"nur": "nur_2", "nur": "nur_2",
"systems": "systems_6", "systems": "systems_7",
"tinted-foot": "tinted-foot", "tinted-foot": "tinted-foot",
"tinted-kitty": "tinted-kitty", "tinted-kitty": "tinted-kitty",
"tinted-schemes": "tinted-schemes", "tinted-schemes": "tinted-schemes",
@ -1624,6 +1681,21 @@
"type": "github" "type": "github"
} }
}, },
"systems_7": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"tinted-foot": { "tinted-foot": {
"flake": false, "flake": false,
"locked": { "locked": {

View file

@ -194,6 +194,19 @@
owner = "nix-community"; owner = "nix-community";
repo = "neovim-nightly-overlay"; repo = "neovim-nightly-overlay";
}; };
nvchad-starter = {
url = "path:./nvchad";
flake = false;
};
nix4nvchad = {
type = "github";
owner = "nix-community";
repo = "nix4nvchad";
inputs = {
nixpkgs.follows = "nixpkgs";
nvchad-starter.follows = "nvchad-starter";
};
};
lanzaboote = { lanzaboote = {
type = "github"; type = "github";

View file

@ -57,6 +57,7 @@
firefox.enable = true; firefox.enable = true;
openssh.enable = true; openssh.enable = true;
helix.enable = true; helix.enable = true;
nvchad.enable = true;
# spacemacs.enable = true; # spacemacs.enable = true;
}; };
}; };

View file

@ -0,0 +1,26 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.david.programs.nvchad;
in
{
options = {
david.programs.nvchad = {
enable = lib.mkEnableOption "nvchad";
};
};
config = lib.mkIf cfg.enable {
programs.nvchad = {
enable = true;
extraPackages = with pkgs; [
editor-runtime
];
neovim = pkgs.neovim-nightly;
backup = true;
};
};
}

View file

@ -8,6 +8,7 @@
(with inputs; [ (with inputs; [
sops-nix.homeManagerModules.sops sops-nix.homeManagerModules.sops
betterfox-nix.homeModules.betterfox betterfox-nix.homeModules.betterfox
nix4nvchad.homeManagerModule
]) ])
++ lib.youthlic.loadImports ./.; ++ lib.youthlic.loadImports ./.;

View file

@ -91,7 +91,7 @@
waypipe waypipe
wineWow64Packages.waylandFull wineWow64Packages.waylandFull
iperf3 iperf3
nixvim neovim-nightly
doom-emacs doom-emacs
neovide neovide
osu-lazer-bin # typochecker: disable-line osu-lazer-bin # typochecker: disable-line

37
nvchad/init.lua Normal file
View file

@ -0,0 +1,37 @@
vim.g.base46_cache = vim.fn.stdpath "data" .. "/base46/"
vim.g.mapleader = " "
-- bootstrap lazy and all plugins
local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim"
if not vim.uv.fs_stat(lazypath) then
local repo = "https://github.com/folke/lazy.nvim.git"
vim.fn.system { "git", "clone", "--filter=blob:none", repo, "--branch=stable", lazypath }
end
vim.opt.rtp:prepend(lazypath)
local lazy_config = require "configs.lazy"
-- load plugins
require("lazy").setup({
{
"NvChad/NvChad",
lazy = false,
branch = "v2.5",
import = "nvchad.plugins",
},
{ import = "plugins" },
}, lazy_config)
-- load theme
dofile(vim.g.base46_cache .. "defaults")
dofile(vim.g.base46_cache .. "statusline")
require "options"
require "autocmds"
vim.schedule(function()
require "mappings"
end)

1
nvchad/lua/autocmds.lua Normal file
View file

@ -0,0 +1 @@
require "nvchad.autocmds"

31
nvchad/lua/chadrc.lua Normal file
View file

@ -0,0 +1,31 @@
-- This file needs to have same structure as nvconfig.lua
-- https://github.com/NvChad/ui/blob/v3.0/lua/nvconfig.lua
-- Please read that file to know all available options :( @type ChadrcConfig
local M = {}
M.base46 = {
theme = "solarized_light",
-- hl_override = {
-- Comment = { italic = true },
-- ["@comment"] = { italic = true },
-- },
}
M.nvdash = { load_on_startup = true }
M.ui = {
cmp = {
style = "atom_colored",
},
tabufline = {
-- lazyload = true,
enabled = false,
},
statusline = {
enabled = true,
separator_style = "arrow",
theme = "default",
},
}
return M

View file

@ -0,0 +1,18 @@
local options = {
formatters_by_ft = {
lua = { "stylua" },
-- css = { "prettier" },
-- html = { "prettier" },
nix = {
"nixfmt",
lsp_format = "fallback",
},
},
format_on_save = {
-- These options will be passed to conform.format()
timeout_ms = 500,
lsp_fallback = true,
},
}
return options

View file

@ -0,0 +1,8 @@
local options = {}
options = {
default_regexp_syntax = true,
use_default_semantic_hl_groups = true
}
return options

View file

@ -0,0 +1,45 @@
return {
defaults = { lazy = true },
install = { colorscheme = { "nvchad" } },
ui = {
icons = {
ft = "",
lazy = "󰂠 ",
loaded = "",
not_loaded = "",
},
},
performance = {
rtp = {
disabled_plugins = {
"2html_plugin",
"tohtml",
"getscript",
"getscriptPlugin",
"gzip",
"logipat",
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"matchit",
"tar",
"tarPlugin",
"rrhelper",
"spellfile_plugin",
"vimball",
"vimballPlugin",
"zip",
"zipPlugin",
"tutor",
"rplugin",
"syntax",
"synmenu",
"optwin",
"compiler",
"bugreport",
"ftplugin",
},
},
},
}

View file

@ -0,0 +1,16 @@
require("nvchad.configs.lspconfig").defaults()
local servers = {
"rust_analyzer",
"nixd",
"nil_ls",
"lua_ls",
"jsonls",
"taplo"
}
vim.lsp.enable(servers, true)
local lua_ls_libraries = vim.deepcopy(vim.lsp.config.lua_ls.settings.Lua.workspace.library)
table.insert(lua_ls_libraries,
#lua_ls_libraries, vim.fn.stdpath "data" .. "/lazy/NvChad/lua/nvchad")
vim.lsp.config.lua_ls.settings.Lua.workspace.library = lua_ls_libraries

29
nvchad/lua/mappings.lua Normal file
View file

@ -0,0 +1,29 @@
require "nvchad.mappings"
local map = vim.keymap.set
map("n", "<M-x>", ":", { desc = "CMD enter command mode" })
map("n", "<leader>ti", function()
local is_enabled = vim.lsp.inlay_hint.is_enabled()
if is_enabled then
vim.lsp.inlay_hint.enable(false)
else
vim.lsp.inlay_hint.enable(true)
end
end, { desc = "Toggle lsp inlay hint" })
map({ "n", "v" }, "j", "gj")
map({ "n", "v" }, "k", "gk")
map({ "n", "v" }, "gj", "j")
map({ "n", "v" }, "gk", "k")
map({ "n", "v" }, "<C-h>", "<cmd>Telescope help_tags<CR>", { desc = "telescope help page" })
map("i", "<C-d>", "<BS>", { desc = "backspace" })
map({ "n", "v" }, "<leader>tm", function()
local image_api = require("image")
local is_enabled = image_api.is_enabled()
if is_enabled then
image_api.disable()
else
image_api.enable()
end
end, { desc = "Toggle image.nvim" })

102
nvchad/lua/options.lua Normal file
View file

@ -0,0 +1,102 @@
require "nvchad.options"
local o = vim.o
local opt = vim.opt
o.autoindent = true
o.autoread = true
opt.backspace = {
"indent",
"eol",
"start",
}
o.backup = false
opt.breakindent = true
opt.breakindentopt = { "sbr" }
o.showbreak = ""
o.cdhome = true
o.cmdheight = 1
opt.completeopt = {
"fuzzy",
"menuone",
"noselect",
"popup",
}
opt.concealcursor = { ["v"] = true }
o.confirm = true
o.cursorline = true
opt.cursorlineopt = { "number", "screenline" }
opt.diffopt = {
"algorithm:minimal",
"closeoff",
"context:20",
"followwrap",
"internal",
"linematch:40",
}
o.errorbells = true
o.expandtab = true
o.exrc = true
o.foldcolumn = "auto"
o.fsync = true
o.gdefault = false
opt.helplang = {
"zh",
"en",
}
o.history = 10000
o.hlsearch = true
o.ignorecase = true
o.smartcase = true
o.inccommand = "split"
o.list = true
opt.listchars = {
tab = "--→",
trail = "·",
multispace = " ",
nbsp = "",
space = "·",
}
o.magic = true
o.more = true
o.mouse = "a"
o.number = true
o.numberwidth = 4
o.relativenumber = true
o.scrollback = 100000
o.scrolloff = 5
o.shiftround = true
o.shiftwidth = 2
o.showmode = false
o.signcolumn = "yes"
o.smoothscroll = true
o.splitbelow = true
o.splitright = true
o.startofline = true
o.swapfile = false
opt.tabclose = {
"uselast",
}
o.tabstop = 2
o.termguicolors = true
o.undofile = true
o.undolevels = 100000
opt.virtualedit = {
"block",
"onemore",
}
opt.whichwrap = { b = true, s = true, ["<"] = true, [">"] = true }
o.wildmenu = true
opt.wildmode = { "full" }
opt.wildoptions = {
"fuzzy",
"pum",
}
o.winborder = "solid"
o.wrap = true

View file

@ -0,0 +1,56 @@
return {
{
"stevearc/conform.nvim",
event = "BufWritePre", -- uncomment for format on save
opts = require "configs.conform",
},
{
"neovim/nvim-lspconfig",
config = function()
require "configs.lspconfig"
end,
},
{ import = "nvchad.blink.lazyspec" },
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = {
"markdown",
"typst",
"lua",
"toml",
"yaml",
"json",
"rust"
},
},
},
{
"idris-community/idris2-nvim",
dependencies = {
"neovim/nvim-lspconfig",
"MunifTanjim/nui.nvim"
},
main = "idris2",
opts = require("configs.idris2"),
ft = { "idris2", "ipkg", "lidris2" }
},
{
"3rd/image.nvim",
opts = {
processor = "magick_cli",
integrations = {
markdown = {
only_render_image_at_cursor = true,
only_render_image_at_cursor_mode = "popup",
},
}
},
ft = { "markdown", "typst" }
},
{
"mrcjkb/rustaceanvim",
version = "^6",
lazy = false,
},
}