From 55c578d3db77626d27b86d3fadb8d25a54c97629 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sat, 8 Nov 2025 03:53:33 +0800 Subject: [PATCH] Revert "feat: Move nvchad config to `ulic-youthlic/nvchad-starter`" This reverts commit 9c59296b243e6964d80773b0bc3382e112857880. --- flake.lock | 13 ++--- flake.nix | 4 +- nvchad/init.lua | 37 ++++++++++++ nvchad/lua/autocmds.lua | 1 + nvchad/lua/chadrc.lua | 31 ++++++++++ nvchad/lua/configs/conform.lua | 18 ++++++ nvchad/lua/configs/idris2.lua | 8 +++ nvchad/lua/configs/lazy.lua | 45 +++++++++++++++ nvchad/lua/configs/lspconfig.lua | 23 ++++++++ nvchad/lua/mappings.lua | 32 +++++++++++ nvchad/lua/options.lua | 99 ++++++++++++++++++++++++++++++++ nvchad/lua/plugins/init.lua | 56 ++++++++++++++++++ 12 files changed, 356 insertions(+), 11 deletions(-) create mode 100644 nvchad/init.lua create mode 100644 nvchad/lua/autocmds.lua create mode 100644 nvchad/lua/chadrc.lua create mode 100644 nvchad/lua/configs/conform.lua create mode 100644 nvchad/lua/configs/idris2.lua create mode 100644 nvchad/lua/configs/lazy.lua create mode 100644 nvchad/lua/configs/lspconfig.lua create mode 100644 nvchad/lua/mappings.lua create mode 100644 nvchad/lua/options.lua create mode 100644 nvchad/lua/plugins/init.lua diff --git a/flake.lock b/flake.lock index d80729b..daea469 100644 --- a/flake.lock +++ b/flake.lock @@ -1260,17 +1260,14 @@ "nvchad-starter": { "flake": false, "locked": { - "lastModified": 1762537390, + "lastModified": 1, "narHash": "sha256-Y6UCxZkTMCxnteIRtuvl49ceQNSu+EIH2PbjOGvvp/I=", - "owner": "ulic-youthlic", - "repo": "nvchad-starter", - "rev": "b713ab7064a8aac684e724f82a253e753754d396", - "type": "github" + "path": "./nvchad", + "type": "path" }, "original": { - "owner": "ulic-youthlic", - "repo": "nvchad-starter", - "type": "github" + "path": "./nvchad", + "type": "path" } }, "pre-commit-hooks-nix": { diff --git a/flake.nix b/flake.nix index 7ca5cae..50ab6f7 100644 --- a/flake.nix +++ b/flake.nix @@ -186,9 +186,7 @@ repo = "neovim-nightly-overlay"; }; nvchad-starter = { - type = "github"; - owner = "ulic-youthlic"; - repo = "nvchad-starter"; + url = "path:./nvchad"; flake = false; }; nix4nvchad = { diff --git a/nvchad/init.lua b/nvchad/init.lua new file mode 100644 index 0000000..e861b68 --- /dev/null +++ b/nvchad/init.lua @@ -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) diff --git a/nvchad/lua/autocmds.lua b/nvchad/lua/autocmds.lua new file mode 100644 index 0000000..d2db0bb --- /dev/null +++ b/nvchad/lua/autocmds.lua @@ -0,0 +1 @@ +require "nvchad.autocmds" diff --git a/nvchad/lua/chadrc.lua b/nvchad/lua/chadrc.lua new file mode 100644 index 0000000..bd014be --- /dev/null +++ b/nvchad/lua/chadrc.lua @@ -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 diff --git a/nvchad/lua/configs/conform.lua b/nvchad/lua/configs/conform.lua new file mode 100644 index 0000000..dd5af91 --- /dev/null +++ b/nvchad/lua/configs/conform.lua @@ -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 diff --git a/nvchad/lua/configs/idris2.lua b/nvchad/lua/configs/idris2.lua new file mode 100644 index 0000000..8504e40 --- /dev/null +++ b/nvchad/lua/configs/idris2.lua @@ -0,0 +1,8 @@ +local options = {} + +options = { + default_regexp_syntax = true, + use_default_semantic_hl_groups = true +} + +return options diff --git a/nvchad/lua/configs/lazy.lua b/nvchad/lua/configs/lazy.lua new file mode 100644 index 0000000..e3b15c2 --- /dev/null +++ b/nvchad/lua/configs/lazy.lua @@ -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", + }, + }, + }, +} diff --git a/nvchad/lua/configs/lspconfig.lua b/nvchad/lua/configs/lspconfig.lua new file mode 100644 index 0000000..d8d5552 --- /dev/null +++ b/nvchad/lua/configs/lspconfig.lua @@ -0,0 +1,23 @@ +require("nvchad.configs.lspconfig").defaults() + +vim.diagnostic.config({ + virtual_lines = { + current_line = true, + source = "if_many" + }, + virtual_text = false +}) + +local servers = { + "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 diff --git a/nvchad/lua/mappings.lua b/nvchad/lua/mappings.lua new file mode 100644 index 0000000..b561611 --- /dev/null +++ b/nvchad/lua/mappings.lua @@ -0,0 +1,32 @@ +require "nvchad.mappings" + +local map = vim.keymap.set + +map("n", "", ":", { desc = "CMD enter command mode" }) +map("n", "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" }, "", "Telescope help_tags", { desc = "telescope help page" }) +map("i", "", "", { desc = "backspace" }) +map({ "n", "v" }, "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" }) +map("n", "gh", "0") +map("n", "gl", "$") +map("n", "gs", "^") diff --git a/nvchad/lua/options.lua b/nvchad/lua/options.lua new file mode 100644 index 0000000..200ea2f --- /dev/null +++ b/nvchad/lua/options.lua @@ -0,0 +1,99 @@ +local opt = vim.opt + +local options = { + autoindent = true, + autoread = true, + backspace = { + "indent", + "eol", + "start", + }, + backup = false, + breakindent = true, + breakindentopt = { "sbr" }, + showbreak = "↪", + cdhome = true, + cmdheight = 1, + completeopt = { + "fuzzy", + "menuone", + "noselect", + "popup", + }, + concealcursor = { ["v"] = true }, + confirm = true, + cursorline = true, + cursorlineopt = { "number", "screenline" }, + diffopt = { + "algorithm:minimal", + "closeoff", + "context:20", + "followwrap", + "internal", + "linematch:40", + }, + errorbells = true, + expandtab = true, + exrc = true, + foldcolumn = "auto", + fsync = true, + gdefault = false, + helplang = { + "zh", + "en", + }, + history = 10000, + hlsearch = true, + ignorecase = true, + smartcase = true, + inccommand = "split", + list = true, + listchars = { + tab = "--→", + trail = "·", + multispace = " ", + nbsp = "⍽", + space = "·", + }, + magic = true, + more = true, + mouse = "a", + number = true, + numberwidth = 4, + relativenumber = true, + scrollback = 100000, + scrolloff = 5, + shiftround = true, + shiftwidth = 2, + showmode = false, + signcolumn = "yes", + smoothscroll = true, + splitbelow = true, + splitright = true, + startofline = true, + swapfile = false, + tabclose = { + "uselast", + }, + tabstop = 2, + termguicolors = true, + undofile = true, + undolevels = 100000, + virtualedit = { + "block", + "onemore", + }, + whichwrap = { b = true, s = true, ["<"] = true, [">"] = true }, + wildmenu = true, + wildmode = { "full" }, + wildoptions = { + "fuzzy", + "pum", + }, + winborder = "solid", + wrap = true +} + +for key, value in pairs(options) do + opt[key] = value +end diff --git a/nvchad/lua/plugins/init.lua b/nvchad/lua/plugins/init.lua new file mode 100644 index 0000000..60c51b2 --- /dev/null +++ b/nvchad/lua/plugins/init.lua @@ -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, + }, +}