From c75945ddba6d7883ba68ccecb7dd527843e202e1 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 01/31] Refactor nixvim to move it as standalone package instead of nixos module --- flake/perSystem.nix | 3 ++ nixos/configurations/Akun/default.nix | 1 + nixos/configurations/Tytonidae/default.nix | 2 +- nixos/modules/programs/nixvim/default.nix | 25 ------------- nixos/modules/programs/nixvim/option.nix | 42 ---------------------- overlays/additions/default.nix | 1 + overlays/additions/nixvim.nix | 5 +++ pkgs/nixvim/package.nix | 13 +++++++ 8 files changed, 24 insertions(+), 68 deletions(-) delete mode 100644 nixos/modules/programs/nixvim/default.nix delete mode 100644 nixos/modules/programs/nixvim/option.nix create mode 100644 overlays/additions/nixvim.nix create mode 100644 pkgs/nixvim/package.nix diff --git a/flake/perSystem.nix b/flake/perSystem.nix index 57dd4d6..51b052e 100644 --- a/flake/perSystem.nix +++ b/flake/perSystem.nix @@ -11,6 +11,7 @@ system, lib, self', + inputs', ... }: let inherit (inputs) nixpkgs; @@ -20,6 +21,7 @@ config = { allowUnfree = true; }; + overlays = [(_final: _prev: {inherit lib;})]; }; devShells.default = pkgs.mkShell { name = "nixos-shell"; @@ -36,6 +38,7 @@ inputsScope = lib.makeScope pkgs.newScope (self: { inherit inputs rootPath; srcs = self.callPackage (rootPath + "/_sources/generated.nix") {}; + inherit (inputs'.nixvim.legacyPackages) makeNixvim makeNixvimWithModule; }); in lib.packagesFromDirectoryRecursive { diff --git a/nixos/configurations/Akun/default.nix b/nixos/configurations/Akun/default.nix index d85239d..4c6df44 100644 --- a/nixos/configurations/Akun/default.nix +++ b/nixos/configurations/Akun/default.nix @@ -59,6 +59,7 @@ localsend zulip wechat + nixvim ]; environment.variables.EDITOR = "hx"; diff --git a/nixos/configurations/Tytonidae/default.nix b/nixos/configurations/Tytonidae/default.nix index e6ec0d6..22112ea 100644 --- a/nixos/configurations/Tytonidae/default.nix +++ b/nixos/configurations/Tytonidae/default.nix @@ -37,7 +37,6 @@ }; programs = { bash.enable = true; - nixvim.enable = true; guix.enable = true; dae.enable = true; openssh.enable = true; @@ -91,6 +90,7 @@ waypipe wineWow64Packages.waylandFull iperf3 + nixvim sbctl ]; diff --git a/nixos/modules/programs/nixvim/default.nix b/nixos/modules/programs/nixvim/default.nix deleted file mode 100644 index a86ca40..0000000 --- a/nixos/modules/programs/nixvim/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ - lib, - config, - ... -}: let - cfg = config.youthlic.programs.nixvim; -in { - imports = lib.youthlic.loadImports ./.; - options = { - youthlic.programs.nixvim = { - enable = lib.mkEnableOption "nixvim"; - }; - }; - config = lib.mkIf cfg.enable { - programs.nixvim = { - enable = true; - enableMan = true; - colorschemes.gruvbox-material = { - enable = true; - autoLoad = true; - }; - plugins.lualine.enable = true; - }; - }; -} diff --git a/nixos/modules/programs/nixvim/option.nix b/nixos/modules/programs/nixvim/option.nix deleted file mode 100644 index cee4335..0000000 --- a/nixos/modules/programs/nixvim/option.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ - lib, - config, - ... -}: let - cfg = config.youthlic.programs.nixvim; -in { - config = lib.mkIf cfg.enable { - programs.nixvim = { - opts = { - backspace = ["indent" "eol" "start"]; - tabstop = 4; - shiftwidth = 4; - expandtab = true; - shiftround = true; - autoindent = true; - nu = true; - rnu = true; - wildmenu = true; - hlsearch = false; - ignorecase = true; - smartcase = true; - completeopt = ["menu" "noselect"]; - cursorline = true; - termguicolors = true; - signcolumn = "yes"; - autoread = true; - title = true; - swapfile = false; - backup = false; - updatetime = 50; - mouse = "a"; - undofile = true; - exrc = true; - scrolloff = 5; - wrap = true; - splitright = true; - splitbelow = true; - }; - }; - }; -} diff --git a/overlays/additions/default.nix b/overlays/additions/default.nix index 4825574..32fbc04 100644 --- a/overlays/additions/default.nix +++ b/overlays/additions/default.nix @@ -9,6 +9,7 @@ in ./wallpapers.nix ./waydroid-script.nix ./rime-yuhaostar.nix + ./nixvim.nix ./pkgsNoCuda.nix ] diff --git a/overlays/additions/nixvim.nix b/overlays/additions/nixvim.nix new file mode 100644 index 0000000..43cd9ae --- /dev/null +++ b/overlays/additions/nixvim.nix @@ -0,0 +1,5 @@ +{outputs, ...}: _final: prev: let + inherit (prev.stdenv.hostPlatform) system; +in { + inherit (outputs.packages.${system}) nixvim; +} diff --git a/pkgs/nixvim/package.nix b/pkgs/nixvim/package.nix new file mode 100644 index 0000000..c01cf6b --- /dev/null +++ b/pkgs/nixvim/package.nix @@ -0,0 +1,13 @@ +{ + makeNixvimWithModule, + pkgs, + lib, +}: +makeNixvimWithModule { + inherit pkgs; + module = { + imports = with lib; youthlic.loadImports' ./. (filter (name: !hasSuffix "/package.nix" (toString name))); + enableMan = true; + plugins.lualine.enable = true; + }; +} From 0bae976b088ce22ee1f2141325d5afff243b0b0c Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 02/31] pkgs(nixvim): Add some basic structure --- pkgs/nixvim/autocmds.nix | 1 + pkgs/nixvim/coding.nix | 16 ++++++++++++++++ pkgs/nixvim/editor.nix | 22 ++++++++++++++++++++++ pkgs/nixvim/formatting.nix | 2 ++ pkgs/nixvim/keymaps.nix | 1 + pkgs/nixvim/linting.nix | 1 + pkgs/nixvim/lsp.nix | 2 ++ pkgs/nixvim/options.nix | 2 ++ pkgs/nixvim/treesitter.nix | 2 ++ pkgs/nixvim/ui.nix | 2 ++ pkgs/nixvim/util.nix | 4 ++++ 11 files changed, 55 insertions(+) create mode 100644 pkgs/nixvim/autocmds.nix create mode 100644 pkgs/nixvim/coding.nix create mode 100644 pkgs/nixvim/editor.nix create mode 100644 pkgs/nixvim/formatting.nix create mode 100644 pkgs/nixvim/keymaps.nix create mode 100644 pkgs/nixvim/linting.nix create mode 100644 pkgs/nixvim/lsp.nix create mode 100644 pkgs/nixvim/options.nix create mode 100644 pkgs/nixvim/treesitter.nix create mode 100644 pkgs/nixvim/ui.nix create mode 100644 pkgs/nixvim/util.nix diff --git a/pkgs/nixvim/autocmds.nix b/pkgs/nixvim/autocmds.nix new file mode 100644 index 0000000..6462967 --- /dev/null +++ b/pkgs/nixvim/autocmds.nix @@ -0,0 +1 @@ +{...}: {} diff --git a/pkgs/nixvim/coding.nix b/pkgs/nixvim/coding.nix new file mode 100644 index 0000000..b600e44 --- /dev/null +++ b/pkgs/nixvim/coding.nix @@ -0,0 +1,16 @@ +{...}: { + plugins = { + # mini-pairs = { + # enable = true; + # }; + # ts-comments = { + # enable = true; + # }; + # mini-ai = { + # enable = true; + # }; + # lazydev = { + # enable = true; + # }; + }; +} diff --git a/pkgs/nixvim/editor.nix b/pkgs/nixvim/editor.nix new file mode 100644 index 0000000..79432dc --- /dev/null +++ b/pkgs/nixvim/editor.nix @@ -0,0 +1,22 @@ +{...}: { + plugins = { + # grug-far = { + # enable = true; + # }; + # flash = { + # enable = true; + # }; + # which-key = { + # enable = true; + # }; + # gitsigns = { + # enable = true; + # }; + # trouble = { + # enable = true; + # }; + # todo-comments = { + # enable = true; + # }; + }; +} diff --git a/pkgs/nixvim/formatting.nix b/pkgs/nixvim/formatting.nix new file mode 100644 index 0000000..ea8f50d --- /dev/null +++ b/pkgs/nixvim/formatting.nix @@ -0,0 +1,2 @@ +{...}: { +} diff --git a/pkgs/nixvim/keymaps.nix b/pkgs/nixvim/keymaps.nix new file mode 100644 index 0000000..6462967 --- /dev/null +++ b/pkgs/nixvim/keymaps.nix @@ -0,0 +1 @@ +{...}: {} diff --git a/pkgs/nixvim/linting.nix b/pkgs/nixvim/linting.nix new file mode 100644 index 0000000..6462967 --- /dev/null +++ b/pkgs/nixvim/linting.nix @@ -0,0 +1 @@ +{...}: {} diff --git a/pkgs/nixvim/lsp.nix b/pkgs/nixvim/lsp.nix new file mode 100644 index 0000000..ea8f50d --- /dev/null +++ b/pkgs/nixvim/lsp.nix @@ -0,0 +1,2 @@ +{...}: { +} diff --git a/pkgs/nixvim/options.nix b/pkgs/nixvim/options.nix new file mode 100644 index 0000000..ea8f50d --- /dev/null +++ b/pkgs/nixvim/options.nix @@ -0,0 +1,2 @@ +{...}: { +} diff --git a/pkgs/nixvim/treesitter.nix b/pkgs/nixvim/treesitter.nix new file mode 100644 index 0000000..ea8f50d --- /dev/null +++ b/pkgs/nixvim/treesitter.nix @@ -0,0 +1,2 @@ +{...}: { +} diff --git a/pkgs/nixvim/ui.nix b/pkgs/nixvim/ui.nix new file mode 100644 index 0000000..ea8f50d --- /dev/null +++ b/pkgs/nixvim/ui.nix @@ -0,0 +1,2 @@ +{...}: { +} diff --git a/pkgs/nixvim/util.nix b/pkgs/nixvim/util.nix new file mode 100644 index 0000000..fdae385 --- /dev/null +++ b/pkgs/nixvim/util.nix @@ -0,0 +1,4 @@ +{ + ... +}: { +} From 419edec01f3be200ac9870c1dabbf1d652d08d1a Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 03/31] pkgs(nixvim): Use nixvim to precompile lua to byte code --- pkgs/nixvim/package.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/pkgs/nixvim/package.nix b/pkgs/nixvim/package.nix index c01cf6b..1d29025 100644 --- a/pkgs/nixvim/package.nix +++ b/pkgs/nixvim/package.nix @@ -9,5 +9,21 @@ makeNixvimWithModule { imports = with lib; youthlic.loadImports' ./. (filter (name: !hasSuffix "/package.nix" (toString name))); enableMan = true; plugins.lualine.enable = true; + performance = { + # combinePlugins = { + # enable = true; + # standalonePlugins = []; + # }; + byteCompileLua = { + enable = true; + configs = true; + initLua = true; + luaLib = true; + nvimRuntime = true; + plugins = true; + }; + }; + wrapRc = true; + luaLoader.enable = true; }; } From cdf7e9908a8a347526e33367dfa61d7acee85371 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 04/31] pkgs(nixvim): Add basic lsp support for nix language --- pkgs/nixvim/lsp.nix | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkgs/nixvim/lsp.nix b/pkgs/nixvim/lsp.nix index ea8f50d..e8b43ff 100644 --- a/pkgs/nixvim/lsp.nix +++ b/pkgs/nixvim/lsp.nix @@ -1,2 +1,11 @@ {...}: { + plugins.lspconfig.enable = true; + lsp = { + inlayHints.enable = true; + servers = { + nixd = { + enable = true; + }; + }; + }; } From 946630847805ef0282e4deff89a86681d3884305 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 05/31] pkgs(nixvim): Set colorscheme and enable lualine plugin --- pkgs/nixvim/ui.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/nixvim/ui.nix b/pkgs/nixvim/ui.nix index ea8f50d..d933f88 100644 --- a/pkgs/nixvim/ui.nix +++ b/pkgs/nixvim/ui.nix @@ -1,2 +1,9 @@ {...}: { + colorschemes.gruvbox-material = { + enable = true; + autoLoad = true; + }; + plugins = { + bufferline.enable = true; + }; } From 7078dd84eb49b3d0f4a5750e705d485a8e36caac Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 06/31] pkgs(nixvim): Enable treesitter support and enable which-key plugin --- pkgs/nixvim/treesitter.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkgs/nixvim/treesitter.nix b/pkgs/nixvim/treesitter.nix index ea8f50d..2f322e4 100644 --- a/pkgs/nixvim/treesitter.nix +++ b/pkgs/nixvim/treesitter.nix @@ -1,2 +1,19 @@ {...}: { + plugins = { + treesitter = { + enable = true; + # folding = true; + nixvimInjections = true; + settings = { + highlight = { + enable = true; + additional_vim_regex_highlighting = true; + }; + indent.enable = true; + }; + }; + which-key = { + enable = true; + }; + }; } From 8806190f7504f6e3b505e2d19a7ac898106327ff Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 07/31] pkgs(nixvim): Config neovim startup options --- pkgs/nixvim/options.nix | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/pkgs/nixvim/options.nix b/pkgs/nixvim/options.nix index ea8f50d..c14489a 100644 --- a/pkgs/nixvim/options.nix +++ b/pkgs/nixvim/options.nix @@ -1,2 +1,67 @@ {...}: { + opts = { + autoindent = true; + autoread = true; + backspace = ["indent" "eol" "start"]; + backup = false; + + breakindent = true; + breakindentopt = "sbr"; + showbreak = "↪"; + + cdhome = true; + cedit = ""; + cmdheight = 1; + completeopt = ["fuzzy" "menuone" "noselect" "popup"]; + concealcursor = "v"; + confirm = true; + cursorline = true; + 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:·"; # eol:⏎ + magic = true; + more = true; + mouse = "a"; + + number = true; + numberwidth = 2; + relativenumber = true; + + scrollback = 100000; + scrolloff = 5; + shiftround = true; + shiftwidth = 2; + signcolumn = "auto"; + 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,s,<,>"; + wildmenu = true; + wildmode = ["full"]; + wildoptions = ["fuzzy" "pum"]; + winborder = "rounded"; + wrap = true; + }; } From 37914d6957c4e62bf453bf060baa9967d6b2822e Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 08/31] pkgs(nixvim): Use conform.nvim as formatting plugin, and add two usercmds for it --- pkgs/nixvim/formatting.nix | 100 +++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/pkgs/nixvim/formatting.nix b/pkgs/nixvim/formatting.nix index ea8f50d..b16b1a4 100644 --- a/pkgs/nixvim/formatting.nix +++ b/pkgs/nixvim/formatting.nix @@ -1,2 +1,102 @@ {...}: { + userCommands = let + formatCmd = { + desc = "Format all the buffer"; + # conform.format function can deal with range by itself + range = "%"; + bang = true; + bar = true; + nargs = "?"; + complete = { + __raw = + #lua + '' + function(ArgLead, CmdLine, CursorPos) + return vim.iter(require("conform").list_all_formatters()):filter(function(val) + return val.available + end):map(function(val) + return val.name + end):filter(function(name) + return string.match(name, ArgLead) ~= nil + end):totable() + end + ''; + }; + command = { + __raw = + #lua + '' + function(opts) + local format = require("conform").format + if #(opts.fargs) == 0 then + return format() + else + return format({ formatters = { opts.fargs[1] } }) + end + end + ''; + }; + }; + in { + Format = formatCmd; + Fmt = formatCmd; + Formatter = { + desc = "Show config of formatter"; + nargs = "?"; + bar = true; + complete = { + __raw = + #lua + '' + function(ArgLead, CmdLine, CursorPos) + return vim.iter(require("conform").list_all_formatters()):map(function(val) + return val.name + end):filter(function(name) + return string.match(name, ArgLead) ~= nil + end):totable() + end + ''; + }; + command = { + __raw = + #lua + '' + function(opts) + local conform = require("conform") + if #(opts.fargs) == 0 then + local formatters = conform.list_all_formatters() + print(vim.inspect(formatters)) + return formatters + else + local config = conform.get_formatter_config(opts.fargs[1]) + print(vim.inspect(config)) + return config + end + end + ''; + }; + }; + }; + keymaps = [ + { + action = { + __raw = + #lua + '' + function(opts) + return require("conform").format() + end + ''; + }; + key = "="; + mode = ["n" "v"]; + options = { + desc = "Format with conform"; + }; + } + ]; + plugins.conform-nvim = { + enable = true; + settings.formatters.injected.options.ignore_errors = true; + }; } From d242144445028fd0867f8d8fcf9125fdcbd2a2bc Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 09/31] pkgs(nixvim): Add some language supports for formatting --- pkgs/nixvim/lang/c/formatting.nix | 31 ++++++++++++++ pkgs/nixvim/lang/cxx/formatting.nix | 31 ++++++++++++++ pkgs/nixvim/lang/json/formatting.nix | 30 ++++++++++++++ pkgs/nixvim/lang/lua/formatting.nix | 31 ++++++++++++++ pkgs/nixvim/lang/markdown/formatting.nix | 30 ++++++++++++++ pkgs/nixvim/lang/nix/formatting.nix | 53 ++++++++++++++++++++++++ pkgs/nixvim/lang/python/formatting.nix | 53 ++++++++++++++++++++++++ pkgs/nixvim/lang/rust/formatting.nix | 31 ++++++++++++++ pkgs/nixvim/lang/toml/formatting.nix | 32 ++++++++++++++ pkgs/nixvim/lang/yaml/formatting.nix | 30 ++++++++++++++ 10 files changed, 352 insertions(+) create mode 100644 pkgs/nixvim/lang/c/formatting.nix create mode 100644 pkgs/nixvim/lang/cxx/formatting.nix create mode 100644 pkgs/nixvim/lang/json/formatting.nix create mode 100644 pkgs/nixvim/lang/lua/formatting.nix create mode 100644 pkgs/nixvim/lang/markdown/formatting.nix create mode 100644 pkgs/nixvim/lang/nix/formatting.nix create mode 100644 pkgs/nixvim/lang/python/formatting.nix create mode 100644 pkgs/nixvim/lang/rust/formatting.nix create mode 100644 pkgs/nixvim/lang/toml/formatting.nix create mode 100644 pkgs/nixvim/lang/yaml/formatting.nix diff --git a/pkgs/nixvim/lang/c/formatting.nix b/pkgs/nixvim/lang/c/formatting.nix new file mode 100644 index 0000000..0e7f2dd --- /dev/null +++ b/pkgs/nixvim/lang/c/formatting.nix @@ -0,0 +1,31 @@ +{ + lib, + pkgs, + ... +}: { + plugins.conform-nvim.settings = { + formatters_by_ft.c = { + __unkeyed-1 = "clang-format"; + lsp_format = "fallback"; + }; + formatters.clang-format = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.clang-format") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("clang-format") + if exe ~= "" then + return exe + else + return "${lib.getExe' pkgs.clang-tools "clang-format"}" + end + end + }) + end + ''; + }; + }; +} diff --git a/pkgs/nixvim/lang/cxx/formatting.nix b/pkgs/nixvim/lang/cxx/formatting.nix new file mode 100644 index 0000000..8f136d9 --- /dev/null +++ b/pkgs/nixvim/lang/cxx/formatting.nix @@ -0,0 +1,31 @@ +{ + lib, + pkgs, + ... +}: { + plugins.conform-nvim.settings = { + formatters_by_ft.cpp = { + __unkeyed-1 = "clang-format"; + lsp_format = "fallback"; + }; + formatters.clang-format = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.clang-format") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("clang-format") + if exe ~= "" then + return exe + else + return "${lib.getExe' pkgs.clang-tools "clang-format"}" + end + end + }) + end + ''; + }; + }; +} diff --git a/pkgs/nixvim/lang/json/formatting.nix b/pkgs/nixvim/lang/json/formatting.nix new file mode 100644 index 0000000..8c9afd1 --- /dev/null +++ b/pkgs/nixvim/lang/json/formatting.nix @@ -0,0 +1,30 @@ +{ + lib, + pkgs, + ... +}: { + plugins.conform-nvim.settings = { + formatters_by_ft.json = { + __unkeyed-1 = "deno_fmt"; + }; + formatters.deno_fmt = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.deno_fmt") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("deno") + if exe ~= "" then + return exe + else + return "${lib.getExe pkgs.deno}" + end + end + }) + end + ''; + }; + }; +} diff --git a/pkgs/nixvim/lang/lua/formatting.nix b/pkgs/nixvim/lang/lua/formatting.nix new file mode 100644 index 0000000..d1dd041 --- /dev/null +++ b/pkgs/nixvim/lang/lua/formatting.nix @@ -0,0 +1,31 @@ +{ + lib, + pkgs, + ... +}: { + plugins.conform-nvim.settings = { + formatters_by_ft.lua = { + __unkeyed-1 = "stylua"; + lsp_format = "fallback"; + }; + formatters.stylua = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.stylua") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("stylua") + if exe ~= "" then + return exe + else + return "${lib.getExe pkgs.stylua}" + end + end + }) + end + ''; + }; + }; +} diff --git a/pkgs/nixvim/lang/markdown/formatting.nix b/pkgs/nixvim/lang/markdown/formatting.nix new file mode 100644 index 0000000..31e7e97 --- /dev/null +++ b/pkgs/nixvim/lang/markdown/formatting.nix @@ -0,0 +1,30 @@ +{ + lib, + pkgs, + ... +}: { + plugins.conform-nvim.settings = { + formatters_by_ft.markdown = { + __unkeyed-1 = "deno_fmt"; + }; + formatters.deno_fmt = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.deno_fmt") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("deno") + if exe ~= "" then + return exe + else + return "${lib.getExe pkgs.deno}" + end + end + }) + end + ''; + }; + }; +} diff --git a/pkgs/nixvim/lang/nix/formatting.nix b/pkgs/nixvim/lang/nix/formatting.nix new file mode 100644 index 0000000..f93b545 --- /dev/null +++ b/pkgs/nixvim/lang/nix/formatting.nix @@ -0,0 +1,53 @@ +{ + lib, + pkgs, + ... +}: { + plugins.conform-nvim.settings = { + formatters_by_ft.nix = { + __unkeyed-1 = "alejandra"; + __unkeyed-2 = "injected"; + lsp_format = "fallback"; + }; + formatters = { + alejandra = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.alejandra") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("alejandra") + if exe ~= "" then + return exe + else + return "${lib.getExe pkgs.alejandra}" + end + end + }) + end + ''; + }; + nixfmt = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.nixfmt") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("nixfmt") + if exe ~= "" then + return exe + else + return "${lib.getExe pkgs.nixfmt-rfc-style}" + end + end + }) + end + ''; + }; + }; + }; +} diff --git a/pkgs/nixvim/lang/python/formatting.nix b/pkgs/nixvim/lang/python/formatting.nix new file mode 100644 index 0000000..cd62386 --- /dev/null +++ b/pkgs/nixvim/lang/python/formatting.nix @@ -0,0 +1,53 @@ +{ + lib, + pkgs, + ... +}: { + plugins.conform-nvim.settings = { + formatters_by_ft.python = { + __unkeyed-1 = "ruff_format"; + __unkeyed-2 = "ruff_organize_imports"; + lsp_format = "fallback"; + }; + formatters = { + ruff_organize_imports = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.ruff_organize_imports") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("ruff") + if exe ~= "" then + return exe + else + return "${lib.getExe pkgs.ruff}" + end + end + }) + end + ''; + }; + ruff_format = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.ruff_format") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("ruff") + if exe ~= "" then + return exe + else + return "${lib.getExe pkgs.ruff}" + end + end + }) + end + ''; + }; + }; + }; +} diff --git a/pkgs/nixvim/lang/rust/formatting.nix b/pkgs/nixvim/lang/rust/formatting.nix new file mode 100644 index 0000000..c569c36 --- /dev/null +++ b/pkgs/nixvim/lang/rust/formatting.nix @@ -0,0 +1,31 @@ +{ + lib, + pkgs, + ... +}: { + plugins.conform-nvim.settings = { + formatters_by_ft.rust = { + __unkeyed-1 = "rustfmt"; + lsp_format = "fallback"; + }; + formatters.rustfmt = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.rustfmt") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("rustfmt") + if exe ~= "" then + return exe + else + return "${lib.getExe pkgs.rustfmt}" + end + end + }) + end + ''; + }; + }; +} diff --git a/pkgs/nixvim/lang/toml/formatting.nix b/pkgs/nixvim/lang/toml/formatting.nix new file mode 100644 index 0000000..56b880b --- /dev/null +++ b/pkgs/nixvim/lang/toml/formatting.nix @@ -0,0 +1,32 @@ +{ + lib, + pkgs, + ... +}: { + plugins.conform-nvim.settings = { + formatters_by_ft.toml = { + __unkeyed-1 = "taplo"; + lsp_format = "fallback"; + }; + formatters.taplo = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.taplo") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("taplo") + if exe ~= "" then + return exe + else + return "${lib.getExe pkgs.taplo}" + end + end, + args = { "format", "-o", "reorder_keys=true", "-o", "reorder_inline_tables=true", "-o", "reorder_arrays=true", "-" }, + }) + end + ''; + }; + }; +} diff --git a/pkgs/nixvim/lang/yaml/formatting.nix b/pkgs/nixvim/lang/yaml/formatting.nix new file mode 100644 index 0000000..8bc2d6b --- /dev/null +++ b/pkgs/nixvim/lang/yaml/formatting.nix @@ -0,0 +1,30 @@ +{ + lib, + pkgs, + ... +}: { + plugins.conform-nvim.settings = { + formatters_by_ft.yaml = { + __unkeyed-1 = "deno_fmt"; + }; + formatters.deno_fmt = { + __raw = + #lua + '' + function() + local defaultFormatter = require("conform.formatters.deno_fmt") + return vim.tbl_extend("force", defaultFormatter, { + command = function() + local exe = vim.fn["exepath"]("deno") + if exe ~= "" then + return exe + else + return "${lib.getExe pkgs.deno}" + end + end + }) + end + ''; + }; + }; +} From cf90eede7ee30b2427c7f11f969721e4e4e7688d Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 10/31] Add neovide support for neovim --- home/david/modules/programs/niri/config.nix | 1 + nixos/configurations/Akun/default.nix | 1 + nixos/configurations/Tytonidae/default.nix | 1 + pkgs/nixvim/package.nix | 29 +++++++++++++++++++++ 4 files changed, 32 insertions(+) diff --git a/home/david/modules/programs/niri/config.nix b/home/david/modules/programs/niri/config.nix index 996f987..85bfb96 100644 --- a/home/david/modules/programs/niri/config.nix +++ b/home/david/modules/programs/niri/config.nix @@ -482,6 +482,7 @@ in (window-rule [ (match [{app-id = "^Alacritty$";}]) (match [{app-id = "^com\\.mitchellh\\.ghostty$";}]) + (match [{app-id = "^neovide$";}]) (leaf "draw-border-with-background" [false]) ]) (window-rule [ diff --git a/nixos/configurations/Akun/default.nix b/nixos/configurations/Akun/default.nix index 4c6df44..caff7ac 100644 --- a/nixos/configurations/Akun/default.nix +++ b/nixos/configurations/Akun/default.nix @@ -60,6 +60,7 @@ zulip wechat nixvim + neovide ]; environment.variables.EDITOR = "hx"; diff --git a/nixos/configurations/Tytonidae/default.nix b/nixos/configurations/Tytonidae/default.nix index 22112ea..40243d6 100644 --- a/nixos/configurations/Tytonidae/default.nix +++ b/nixos/configurations/Tytonidae/default.nix @@ -91,6 +91,7 @@ wineWow64Packages.waylandFull iperf3 nixvim + neovide sbctl ]; diff --git a/pkgs/nixvim/package.nix b/pkgs/nixvim/package.nix index 1d29025..17a15b2 100644 --- a/pkgs/nixvim/package.nix +++ b/pkgs/nixvim/package.nix @@ -25,5 +25,34 @@ makeNixvimWithModule { }; wrapRc = true; luaLoader.enable = true; + extraConfigLua = + #lua + '' + if vim.g.neovide then + vim.o.guifont = [[Maple\ Mono\ NF\ CN,Noto Color Emoji:h16]] + vim.g.neovide_opacity = 0.9 + vim.g.linespace = 0.2 + + vim.g.neovide_floating_shadow = true + vim.g.neovide_floating_z_height = 10 + vim.g.neovide_light_angle_degrees = 45 + vim.g.neovide_light_radius = 5 + + vim.g.neovide_position_animation_length = 0.1 + vim.g.neovide_scroll_animation_length = 0.2 + vim.g.neovide_scroll_animation_far_lines = 5 + vim.g.neovide_hide_mouse_when_typing = true + vim.g.neovide_refresh_rate = 120 + vim.g.neovide_confirm_quit = true + vim.g.neovide_input_ime = true + + vim.g.neovide_cursor_animation_length = 0.1 + vim.g.neovide_cursor_short_animation_length = 0.04 + vim.g.neovide_cursor_antialiasing = true + vim.g.neovide_cursor_animate_in_insert_mode = true + vim.g.neovide_cursor_animate_command_line = true + vim.g.neovide_cursor_unfocused_outline_width = 0.125 + end + ''; }; } From 745a964d79b2a5b7d1b17015819bd278f5e551c1 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 11/31] pkgs(nixvim): Add vim-startuptime plugin for profile the startup time --- _sources/generated.json | 21 +++++++++++++++++++++ _sources/generated.nix | 12 ++++++++++++ flake/perSystem.nix | 1 + nvfetcher.toml | 4 ++++ pkgs/nixvim/package.nix | 4 ++++ pkgs/nixvim/util.nix | 11 +++++++++++ pkgs/nixvimPlugins/vim-startuptime.nix | 11 +++++++++++ 7 files changed, 64 insertions(+) create mode 100644 pkgs/nixvimPlugins/vim-startuptime.nix diff --git a/_sources/generated.json b/_sources/generated.json index 54dbc68..7923ab6 100644 --- a/_sources/generated.json +++ b/_sources/generated.json @@ -130,6 +130,27 @@ }, "version": "Serif2.003" }, + "nvim_vim-startuptime": { + "cargoLocks": null, + "date": "2025-02-17", + "extract": null, + "name": "nvim_vim-startuptime", + "passthru": null, + "pinned": false, + "src": { + "deepClone": false, + "fetchSubmodules": false, + "leaveDotGit": false, + "name": null, + "owner": "dstein64", + "repo": "vim-startuptime", + "rev": "b6f0d93f6b8cf6eee0b4c94450198ba2d6a05ff6", + "sha256": "sha256-0YLDkU1y89O5z7tgxaH5USQpJDfTuN0fsPJOAp6pa5Y=", + "sparseCheckout": [], + "type": "github" + }, + "version": "b6f0d93f6b8cf6eee0b4c94450198ba2d6a05ff6" + }, "radicle-ci-broker": { "cargoLocks": null, "date": "2025-06-27", diff --git a/_sources/generated.nix b/_sources/generated.nix index b1b87ba..923a673 100644 --- a/_sources/generated.nix +++ b/_sources/generated.nix @@ -82,6 +82,18 @@ sha256 = "sha256-mfbBSdJrUCZiUUmsmndtEW6H3z6KfBn+dEftBySf2j4="; }; }; + nvim_vim-startuptime = { + pname = "nvim_vim-startuptime"; + version = "b6f0d93f6b8cf6eee0b4c94450198ba2d6a05ff6"; + src = fetchFromGitHub { + owner = "dstein64"; + repo = "vim-startuptime"; + rev = "b6f0d93f6b8cf6eee0b4c94450198ba2d6a05ff6"; + fetchSubmodules = false; + sha256 = "sha256-0YLDkU1y89O5z7tgxaH5USQpJDfTuN0fsPJOAp6pa5Y="; + }; + date = "2025-02-17"; + }; radicle-ci-broker = { pname = "radicle-ci-broker"; version = "d5f684b2ec12dc875ec0278c8e2fe71faaa88d38"; diff --git a/flake/perSystem.nix b/flake/perSystem.nix index 51b052e..153026c 100644 --- a/flake/perSystem.nix +++ b/flake/perSystem.nix @@ -39,6 +39,7 @@ inherit inputs rootPath; srcs = self.callPackage (rootPath + "/_sources/generated.nix") {}; inherit (inputs'.nixvim.legacyPackages) makeNixvim makeNixvimWithModule; + inherit (self'.legacyPackages) nixvimPlugins; }); in lib.packagesFromDirectoryRecursive { diff --git a/nvfetcher.toml b/nvfetcher.toml index 5354cb9..0b5a51a 100644 --- a/nvfetcher.toml +++ b/nvfetcher.toml @@ -58,3 +58,7 @@ fetch.url = "http://wallpaper.youthlic.social/hollow-knight-quest.3840x2160.mp4" src.github = "forfudan/yuhao-ime-release" fetch.url = "https://github.com/forfudan/yuhao-ime-release/releases/download/$ver/yuhao_star_xingchen_$ver.zip" url.name = "yustar_$ver.zip" + +[nvim_vim-startuptime] +src.git = "https://github.com/dstein64/vim-startuptime.git" +fetch.github = "dstein64/vim-startuptime" diff --git a/pkgs/nixvim/package.nix b/pkgs/nixvim/package.nix index 17a15b2..848a75e 100644 --- a/pkgs/nixvim/package.nix +++ b/pkgs/nixvim/package.nix @@ -2,9 +2,13 @@ makeNixvimWithModule, pkgs, lib, + nixvimPlugins, }: makeNixvimWithModule { inherit pkgs; + extraSpecialArgs = { + inherit nixvimPlugins; + }; module = { imports = with lib; youthlic.loadImports' ./. (filter (name: !hasSuffix "/package.nix" (toString name))); enableMan = true; diff --git a/pkgs/nixvim/util.nix b/pkgs/nixvim/util.nix index fdae385..51b5641 100644 --- a/pkgs/nixvim/util.nix +++ b/pkgs/nixvim/util.nix @@ -1,4 +1,15 @@ { + pkgs, + nixvimPlugins, ... }: { + extraPlugins = [ + { + config = + #vim + '' + ''; + plugin = nixvimPlugins.vim-startuptime; + } + ]; } diff --git a/pkgs/nixvimPlugins/vim-startuptime.nix b/pkgs/nixvimPlugins/vim-startuptime.nix new file mode 100644 index 0000000..bda263c --- /dev/null +++ b/pkgs/nixvimPlugins/vim-startuptime.nix @@ -0,0 +1,11 @@ +{ + srcs, + vimUtils, +}: let + inherit (srcs.nvim_vim-startuptime) src version date; +in + vimUtils.buildVimPlugin { + pname = "vim-startuptime"; + version = "0-unstable-${date}-git${version}"; + inherit src; + } From 3649602a07aff20c1a695e9537f5956f1940679b Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 12/31] pkg(nixvim): Fix format command completion function --- pkgs/nixvim/formatting.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/nixvim/formatting.nix b/pkgs/nixvim/formatting.nix index b16b1a4..7472324 100644 --- a/pkgs/nixvim/formatting.nix +++ b/pkgs/nixvim/formatting.nix @@ -17,7 +17,7 @@ end):map(function(val) return val.name end):filter(function(name) - return string.match(name, ArgLead) ~= nil + return string.match(name, "^" .. ArgLead) ~= nil end):totable() end ''; @@ -52,7 +52,7 @@ return vim.iter(require("conform").list_all_formatters()):map(function(val) return val.name end):filter(function(name) - return string.match(name, ArgLead) ~= nil + return string.match(name, "^" .. ArgLead) ~= nil end):totable() end ''; From e70d021a247433f896d5edb5a197658856ca432c Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 13/31] Add neovim_git flake input, and use neovim_git in nixvim --- flake.lock | 307 ++++++++++++++++++++++++++++++++++------ flake.nix | 5 + flake/perSystem.nix | 1 + pkgs/nixvim/package.nix | 2 + 4 files changed, 271 insertions(+), 44 deletions(-) diff --git a/flake.lock b/flake.lock index 09ee453..30b552d 100644 --- a/flake.lock +++ b/flake.lock @@ -101,7 +101,7 @@ "nur-ataraxiasjel", "devenv" ], - "nixpkgs": "nixpkgs_7" + "nixpkgs": "nixpkgs_8" }, "locked": { "lastModified": 1744206633, @@ -205,10 +205,10 @@ "devenv": { "inputs": { "cachix": "cachix", - "flake-compat": "flake-compat_4", - "git-hooks": "git-hooks", + "flake-compat": "flake-compat_6", + "git-hooks": "git-hooks_2", "nix": "nix", - "nixpkgs": "nixpkgs_9" + "nixpkgs": "nixpkgs_10" }, "locked": { "lastModified": 1748273445, @@ -305,6 +305,38 @@ } }, "flake-compat_3": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_4": { + "flake": false, + "locked": { + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-compat_5": { "flake": false, "locked": { "lastModified": 1746162366, @@ -320,7 +352,7 @@ "type": "github" } }, - "flake-compat_4": { + "flake-compat_6": { "flake": false, "locked": { "lastModified": 1733328505, @@ -376,6 +408,48 @@ } }, "flake-parts_3": { + "inputs": { + "nixpkgs-lib": [ + "neovim-nightly", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1754487366, + "narHash": "sha256-pHYj8gUBapuUzKV/kN/tR3Zvqc7o6gdFB9XKXIp1SQ8=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "af66ad14b28a127c5c0f3bbb298218fc63528a18", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_4": { + "inputs": { + "nixpkgs-lib": [ + "neovim-nightly", + "hercules-ci-effects", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1751413152, + "narHash": "sha256-Tyw1RjYEsp5scoigs1384gIg6e0GoBVjms4aXFfRssQ=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "77826244401ea9de6e3bac47c2db46005e1f30b5", + "type": "github" + }, + "original": { + "id": "flake-parts", + "type": "indirect" + } + }, + "flake-parts_5": { "inputs": { "nixpkgs-lib": [ "nixvim", @@ -396,7 +470,7 @@ "type": "github" } }, - "flake-parts_4": { + "flake-parts_6": { "inputs": { "nixpkgs-lib": [ "nur", @@ -417,7 +491,7 @@ "type": "github" } }, - "flake-parts_5": { + "flake-parts_7": { "inputs": { "nixpkgs-lib": [ "nur-ataraxiasjel", @@ -440,7 +514,7 @@ "type": "github" } }, - "flake-parts_6": { + "flake-parts_8": { "inputs": { "nixpkgs-lib": "nixpkgs-lib_2" }, @@ -540,12 +614,35 @@ } }, "git-hooks": { + "inputs": { + "flake-compat": "flake-compat_4", + "gitignore": "gitignore_2", + "nixpkgs": [ + "neovim-nightly", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1754416808, + "narHash": "sha256-c6yg0EQ9xVESx6HGDOCMcyRSjaTpNJP10ef+6fRcofA=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "9c52372878df6911f9afc1e2a1391f55e4dfc864", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "git-hooks_2": { "inputs": { "flake-compat": [ "nur-ataraxiasjel", "devenv" ], - "gitignore": "gitignore_2", + "gitignore": "gitignore_3", "nixpkgs": [ "nur-ataraxiasjel", "devenv", @@ -589,6 +686,28 @@ } }, "gitignore_2": { + "inputs": { + "nixpkgs": [ + "neovim-nightly", + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "gitignore_3": { "inputs": { "nixpkgs": [ "nur-ataraxiasjel", @@ -650,6 +769,28 @@ "type": "github" } }, + "hercules-ci-effects": { + "inputs": { + "flake-parts": "flake-parts_4", + "nixpkgs": [ + "neovim-nightly", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1752595130, + "narHash": "sha256-CNBgr4OZSuklGtNOa9CnTNo9+Xceqn/EDAC1Tc43fH8=", + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "rev": "5f2e09654b2e70ba643e41609d9f9b6640f22113", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "hercules-ci-effects", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -821,6 +962,46 @@ "url": "https://git.lix.systems/lix-project/nixos-module" } }, + "neovim-nightly": { + "inputs": { + "flake-compat": "flake-compat_3", + "flake-parts": "flake-parts_3", + "git-hooks": "git-hooks", + "hercules-ci-effects": "hercules-ci-effects", + "neovim-src": "neovim-src", + "nixpkgs": "nixpkgs_3", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1754641381, + "narHash": "sha256-eMoujl/X1lbdjRbC/HHCpZmUb5tqTAYSL1hocy+o7nc=", + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "rev": "83aaf3085f808dec9ea1b5d16b216875a8081b37", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "neovim-nightly-overlay", + "type": "github" + } + }, + "neovim-src": { + "flake": false, + "locked": { + "lastModified": 1754610154, + "narHash": "sha256-ORfF40X4BGiFxnLNQbdsQbUTW4TkUHfPqyZWHaYL5NE=", + "owner": "neovim", + "repo": "neovim", + "rev": "038eb01b41b66379f75164507571497929f8847c", + "type": "github" + }, + "original": { + "owner": "neovim", + "repo": "neovim", + "type": "github" + } + }, "niri-flake": { "inputs": { "niri-stable": "niri-stable", @@ -885,9 +1066,9 @@ "nur-ataraxiasjel", "devenv" ], - "flake-parts": "flake-parts_5", + "flake-parts": "flake-parts_7", "libgit2": "libgit2", - "nixpkgs": "nixpkgs_8", + "nixpkgs": "nixpkgs_9", "nixpkgs-23-11": [ "nur-ataraxiasjel", "devenv" @@ -941,8 +1122,8 @@ }, "nixos-cosmic": { "inputs": { - "flake-compat": "flake-compat_3", - "nixpkgs": "nixpkgs_3", + "flake-compat": "flake-compat_5", + "nixpkgs": "nixpkgs_4", "nixpkgs-stable": "nixpkgs-stable_3", "rust-overlay": "rust-overlay_4" }, @@ -1071,6 +1252,22 @@ } }, "nixpkgs_10": { + "locked": { + "lastModified": 1746807397, + "narHash": "sha256-zU2z0jlkJGWLhdNr/8AJSxqK8XD0IlQgHp3VZcP56Aw=", + "owner": "cachix", + "repo": "devenv-nixpkgs", + "rev": "c5208b594838ea8e6cca5997fbf784b7cca1ca90", + "type": "github" + }, + "original": { + "owner": "cachix", + "ref": "rolling", + "repo": "devenv-nixpkgs", + "type": "github" + } + }, + "nixpkgs_11": { "locked": { "lastModified": 1748190013, "narHash": "sha256-R5HJFflOfsP5FBtk+zE8FpL8uqE7n62jqOsADvVshhE=", @@ -1086,7 +1283,7 @@ "type": "github" } }, - "nixpkgs_11": { + "nixpkgs_12": { "locked": { "lastModified": 1747958103, "narHash": "sha256-qmmFCrfBwSHoWw7cVK4Aj+fns+c54EBP8cGqp/yK410=", @@ -1119,6 +1316,22 @@ } }, "nixpkgs_3": { + "locked": { + "lastModified": 1754393734, + "narHash": "sha256-fbnmAwTQkuXHKBlcL5Nq1sMAzd3GFqCOQgEQw6Hy0Ak=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a683adc19ff5228af548c6539dbc3440509bfed3", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { "locked": { "lastModified": 1751011381, "narHash": "sha256-krGXKxvkBhnrSC/kGBmg5MyupUUT5R6IBCLEzx9jhMM=", @@ -1134,7 +1347,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_5": { "locked": { "lastModified": 1752950548, "narHash": "sha256-NS6BLD0lxOrnCiEOcvQCDVPXafX1/ek1dfJHX1nUIzc=", @@ -1150,7 +1363,7 @@ "type": "github" } }, - "nixpkgs_5": { + "nixpkgs_6": { "locked": { "lastModified": 1752077645, "narHash": "sha256-HM791ZQtXV93xtCY+ZxG1REzhQenSQO020cu6rHtAPk=", @@ -1166,7 +1379,7 @@ "type": "github" } }, - "nixpkgs_6": { + "nixpkgs_7": { "locked": { "lastModified": 1752950548, "narHash": "sha256-NS6BLD0lxOrnCiEOcvQCDVPXafX1/ek1dfJHX1nUIzc=", @@ -1182,7 +1395,7 @@ "type": "github" } }, - "nixpkgs_7": { + "nixpkgs_8": { "locked": { "lastModified": 1733212471, "narHash": "sha256-M1+uCoV5igihRfcUKrr1riygbe73/dzNnzPsmaLCmpo=", @@ -1198,7 +1411,7 @@ "type": "github" } }, - "nixpkgs_8": { + "nixpkgs_9": { "locked": { "lastModified": 1717432640, "narHash": "sha256-+f9c4/ZX5MWDOuB1rKoWj+lBNm0z0rs4CK47HBLxy1o=", @@ -1214,26 +1427,10 @@ "type": "github" } }, - "nixpkgs_9": { - "locked": { - "lastModified": 1746807397, - "narHash": "sha256-zU2z0jlkJGWLhdNr/8AJSxqK8XD0IlQgHp3VZcP56Aw=", - "owner": "cachix", - "repo": "devenv-nixpkgs", - "rev": "c5208b594838ea8e6cca5997fbf784b7cca1ca90", - "type": "github" - }, - "original": { - "owner": "cachix", - "ref": "rolling", - "repo": "devenv-nixpkgs", - "type": "github" - } - }, "nixvim": { "inputs": { - "flake-parts": "flake-parts_3", - "nixpkgs": "nixpkgs_5", + "flake-parts": "flake-parts_5", + "nixpkgs": "nixpkgs_6", "nuschtosSearch": "nuschtosSearch", "systems": "systems_3" }, @@ -1253,8 +1450,8 @@ }, "nur": { "inputs": { - "flake-parts": "flake-parts_4", - "nixpkgs": "nixpkgs_6" + "flake-parts": "flake-parts_6", + "nixpkgs": "nixpkgs_7" }, "locked": { "lastModified": 1753043887, @@ -1274,8 +1471,8 @@ "inputs": { "devenv": "devenv", "devenv-root": "devenv-root", - "flake-parts": "flake-parts_6", - "nixpkgs": "nixpkgs_10" + "flake-parts": "flake-parts_8", + "nixpkgs": "nixpkgs_11" }, "locked": { "lastModified": 1752784378, @@ -1379,16 +1576,17 @@ "home-manager": "home-manager_2", "lanzaboote": "lanzaboote", "lix-module": "lix-module", + "neovim-nightly": "neovim-nightly", "niri-flake": "niri-flake", "nixos-cosmic": "nixos-cosmic", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_4", + "nixpkgs": "nixpkgs_5", "nixvim": "nixvim", "nur": "nur", "nur-ataraxiasjel": "nur-ataraxiasjel", "sops-nix": "sops-nix", "stylix": "stylix", - "treefmt-nix": "treefmt-nix" + "treefmt-nix": "treefmt-nix_2" } }, "rust-overlay": { @@ -1674,7 +1872,28 @@ }, "treefmt-nix": { "inputs": { - "nixpkgs": "nixpkgs_11" + "nixpkgs": [ + "neovim-nightly", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1754492133, + "narHash": "sha256-B+3g9+76KlGe34Yk9za8AF3RL+lnbHXkLiVHLjYVOAc=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "1298185c05a56bff66383a20be0b41a307f52228", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + }, + "treefmt-nix_2": { + "inputs": { + "nixpkgs": "nixpkgs_12" }, "locked": { "lastModified": 1753006367, diff --git a/flake.nix b/flake.nix index baf23ae..342bcf5 100644 --- a/flake.nix +++ b/flake.nix @@ -194,6 +194,11 @@ owner = "nix-community"; repo = "nixvim"; }; + neovim-nightly = { + type = "github"; + owner = "nix-community"; + repo = "neovim-nightly-overlay"; + }; lanzaboote = { type = "github"; diff --git a/flake/perSystem.nix b/flake/perSystem.nix index 153026c..875c94a 100644 --- a/flake/perSystem.nix +++ b/flake/perSystem.nix @@ -40,6 +40,7 @@ srcs = self.callPackage (rootPath + "/_sources/generated.nix") {}; inherit (inputs'.nixvim.legacyPackages) makeNixvim makeNixvimWithModule; inherit (self'.legacyPackages) nixvimPlugins; + neovim_git = inputs'.neovim-nightly.packages.default; }); in lib.packagesFromDirectoryRecursive { diff --git a/pkgs/nixvim/package.nix b/pkgs/nixvim/package.nix index 848a75e..57a7c9a 100644 --- a/pkgs/nixvim/package.nix +++ b/pkgs/nixvim/package.nix @@ -3,6 +3,7 @@ pkgs, lib, nixvimPlugins, + neovim_git, }: makeNixvimWithModule { inherit pkgs; @@ -13,6 +14,7 @@ makeNixvimWithModule { imports = with lib; youthlic.loadImports' ./. (filter (name: !hasSuffix "/package.nix" (toString name))); enableMan = true; plugins.lualine.enable = true; + package = neovim_git; performance = { # combinePlugins = { # enable = true; From 54d4bc057e912ee3f36a037964ac88b8bbbb2f7e Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 14/31] pkg(nixvim): Delete reorder_array option for taplo and reformat all toml files --- .../modules/programs/alacritty/alacritty.toml | 2 +- home/modules/programs/helix/config.toml | 30 ++++++------ home/modules/programs/starship/config.toml | 46 +++++++++---------- nvfetcher.toml | 30 ++++++------ pkgs/nixvim/lang/toml/formatting.nix | 2 +- templates/python/pyproject.toml | 8 ++-- templates/rust/rust-toolchain.toml | 2 +- 7 files changed, 60 insertions(+), 60 deletions(-) diff --git a/home/david/modules/programs/alacritty/alacritty.toml b/home/david/modules/programs/alacritty/alacritty.toml index 4db938e..94c88cc 100644 --- a/home/david/modules/programs/alacritty/alacritty.toml +++ b/home/david/modules/programs/alacritty/alacritty.toml @@ -3,9 +3,9 @@ ipc_socket = true live_config_reload = true [window] +blur = true dynamic_padding = true opacity = 0.8 -blur = true [scrolling] history = 100000 diff --git a/home/modules/programs/helix/config.toml b/home/modules/programs/helix/config.toml index 63d0616..917096c 100644 --- a/home/modules/programs/helix/config.toml +++ b/home/modules/programs/helix/config.toml @@ -1,18 +1,19 @@ [editor] -line-number = "relative" -cursorline = true -cursorcolumn = false -true-color = true -undercurl = true bufferline = "multiple" color-modes = true +cursorcolumn = false +cursorline = true default-line-ending = "lf" +line-number = "relative" popup-border = "all" +true-color = true +undercurl = true # letters in the beginning are used first # move home raw letters to the beginning jump-label-alphabet = "jkdls;aurieowpqnvmcxz" [editor.statusline] +center = ["diagnostics"] left = [ "mode", "spacer", @@ -25,7 +26,9 @@ left = [ "spacer", "spinner", ] -center = ["diagnostics"] +mode.insert = "INSERT" +mode.normal = "NORMAL" +mode.select = "SELECT" right = [ "register", "file-line-ending", @@ -36,14 +39,11 @@ right = [ "position-percentage", ] separator = "|" -mode.normal = "NORMAL" -mode.insert = "INSERT" -mode.select = "SELECT" [editor.lsp] -display-progress-messages = true -display-messages = true display-inlay-hints = true +display-messages = true +display-progress-messages = true [editor.cursor-shape] insert = "bar" @@ -54,16 +54,16 @@ select = "underline" hidden = false [editor.whitespace.render] -space = "none" -tab = "all" nbsp = "all" newline = "none" +space = "none" +tab = "all" [editor.whitespace.characters] -space = "·" nbsp = "⍽" -tab = "→" newline = "⏎" +space = "·" +tab = "→" tabpad = "·" [editor.indent-guides] diff --git a/home/modules/programs/starship/config.toml b/home/modules/programs/starship/config.toml index c56813b..453179f 100644 --- a/home/modules/programs/starship/config.toml +++ b/home/modules/programs/starship/config.toml @@ -1,43 +1,43 @@ "$schema" = 'https://starship.rs/config-schema.json' [character] -success_symbol = '[λ](bold blue)' error_symbol = '[λ](bold red)' -vimcmd_symbol = '[Λ](bold blue)' +success_symbol = '[λ](bold blue)' vimcmd_replace_one_symbol = '[Λ](bold purple)' vimcmd_replace_symbol = '[Λ](bold purple)' +vimcmd_symbol = '[Λ](bold blue)' vimcmd_visual_symbol = '[Λ](bold yellow)' [[battery.display]] -threshold = 10 style = 'bold red' +threshold = 10 [[battery.display]] -threshold = 30 -style = 'bold yellow' discharging_symbol = '💦' +style = 'bold yellow' +threshold = 30 [[battery.display]] -threshold = 100 style = 'green' +threshold = 100 [git_branch] format = 'on [$symbol$branch(:$remote_branch)]($style) ' symbol = " " [git_status] -diverged = '⇕⇡${ahead_count}⇣${behind_count}' -conflicted = "[⚔️${count}](red)" ahead = '[⇡${count}](bold green)' behind = '[⇣${count}](bold yellow)' -untracked = '[!${count}](red)' -stashed = "[📦${count}](purple)" -modified = '[M${count}](bold yellow)' -staged = "[+${count}](green)" -renamed = "[»${count}](bold yellow)" +conflicted = "[⚔️${count}](red)" deleted = '[-${count}](blue)' -up_to_date = '[✓](green)' +diverged = '⇕⇡${ahead_count}⇣${behind_count}' format = '([(\[$all_status\])(\[$ahead_behind\])]($style) ) ' +modified = '[M${count}](bold yellow)' +renamed = "[»${count}](bold yellow)" +staged = "[+${count}](green)" +stashed = "[📦${count}](purple)" +untracked = '[!${count}](red)' +up_to_date = '[✓](green)' [git_commit] format = '([\($hash$tag\)]($style) )' @@ -45,11 +45,11 @@ only_detached = false [directory] fish_style_pwd_dir_length = 2 -truncation_length = 2 -truncate_to_repo = false -repo_root_style = "bold green" -use_os_path_sep = false read_only = " 󰌾" +repo_root_style = "bold green" +truncate_to_repo = false +truncation_length = 2 +use_os_path_sep = false [aws] symbol = " " @@ -133,9 +133,9 @@ symbol = " " symbol = " " [os.symbols] +AlmaLinux = " " Alpaquita = " " Alpine = " " -AlmaLinux = " " Amazon = " " Android = " " Arch = " " @@ -162,20 +162,20 @@ Mint = " " NetBSD = " " NixOS = " " OpenBSD = "󰈺 " -openSUSE = " " OracleLinux = "󰌷 " Pop = " " Raspbian = " " -Redhat = " " RedHatEnterprise = " " -RockyLinux = " " +Redhat = " " Redox = "󰀘 " -Solus = "󰠳 " +RockyLinux = " " SUSE = " " +Solus = "󰠳 " Ubuntu = " " Unknown = " " Void = " " Windows = "󰍲 " +openSUSE = " " [package] symbol = "󰏗 " diff --git a/nvfetcher.toml b/nvfetcher.toml index 0b5a51a..4676d28 100644 --- a/nvfetcher.toml +++ b/nvfetcher.toml @@ -1,64 +1,64 @@ [juicity] -src.git = "https://github.com/juicity/juicity" fetch.git = "https://githuh.com/juicity/juicity" +src.git = "https://github.com/juicity/juicity" [tree-sitter-idris] -src.git = "https://github.com/kayhide/tree-sitter-idris" fetch.git = "https://github.com/kayhide/tree-sitter-idris" passthru.name = "idris" +src.git = "https://github.com/kayhide/tree-sitter-idris" [noto-serif-cjk] -src.github = "notofonts/noto-cjk" fetch.github = "notofonts/noto-cjk" git.sparseCheckout = ["Serif/OTC"] +src.github = "notofonts/noto-cjk" [noto-sans-cjk] -src.github = "notofonts/noto-cjk" fetch.github = "notofonts/noto-cjk" git.sparseCheckout = ["Sans/OTC"] +src.github = "notofonts/noto-cjk" [spotx] -src.git = "https://github.com/SpotX-Official/SpotX-Bash.git" fetch.github = "SpotX-Official/SpotX-Bash" +src.git = "https://github.com/SpotX-Official/SpotX-Bash.git" [TrackersListCollection] -src.git = "https://github.com/XIU2/TrackersListCollection.git" fetch.github = "XIU2/TrackersListCollection" git.sparseCheckout = ["all.txt"] +src.git = "https://github.com/XIU2/TrackersListCollection.git" [wshowkeys-mao] -src.git = "https://github.com/DreamMaoMao/wshowkeys.git" fetch.github = "DreamMaoMao/wshowkeys" +src.git = "https://github.com/DreamMaoMao/wshowkeys.git" [OuterWildsTextAdventure] -src.git = "https://github.com/top-mind/OuterWildsTextAdventureWeb.git" fetch.github = "top-mind/OuterWildsTextAdventureWeb" +src.git = "https://github.com/top-mind/OuterWildsTextAdventureWeb.git" [cliphist] -src.git = "https://github.com/sentriz/cliphist.git" fetch.github = "sentriz/cliphist" +src.git = "https://github.com/sentriz/cliphist.git" [radicle-ci-broker] -src.git = "https://seed.radicle.garden/zwTxygwuz5LDGBq255RA2CbNGrz8.git" fetch.git = "https://seed.radicle.garden/zwTxygwuz5LDGBq255RA2CbNGrz8.git" +src.git = "https://seed.radicle.garden/zwTxygwuz5LDGBq255RA2CbNGrz8.git" ["wallpaper_hieda-no-akyuu-touhou.1920x1080.mp4"] -src.cmd = "curl -sL http://wallpaper.youthlic.social/hieda-no-akyuu-touhou.1920x1080.mp4 | sha256sum | cut -d ' ' -f 1" fetch.url = "http://wallpaper.youthlic.social/hieda-no-akyuu-touhou.1920x1080.mp4" +src.cmd = "curl -sL http://wallpaper.youthlic.social/hieda-no-akyuu-touhou.1920x1080.mp4 | sha256sum | cut -d ' ' -f 1" ["wallpaper_outer-wilds.3840x2160.mp4"] -src.cmd = "curl -sL http://wallpaper.youthlic.social/outer-wilds.3840x2160.mp4 | sha256sum | cut -d ' ' -f 1" fetch.url = "http://wallpaper.youthlic.social/outer-wilds.3840x2160.mp4" +src.cmd = "curl -sL http://wallpaper.youthlic.social/outer-wilds.3840x2160.mp4 | sha256sum | cut -d ' ' -f 1" ["wallpaper_hollow-knight-quest.3840x2160.mp4"] -src.cmd = "curl -sL http://wallpaper.youthlic.social/hollow-knight-quest.3840x2160.mp4 | sha256sum | cut -d ' ' -f 1" fetch.url = "http://wallpaper.youthlic.social/hollow-knight-quest.3840x2160.mp4" +src.cmd = "curl -sL http://wallpaper.youthlic.social/hollow-knight-quest.3840x2160.mp4 | sha256sum | cut -d ' ' -f 1" [rime-yuhaostar] -src.github = "forfudan/yuhao-ime-release" fetch.url = "https://github.com/forfudan/yuhao-ime-release/releases/download/$ver/yuhao_star_xingchen_$ver.zip" +src.github = "forfudan/yuhao-ime-release" url.name = "yustar_$ver.zip" [nvim_vim-startuptime] -src.git = "https://github.com/dstein64/vim-startuptime.git" fetch.github = "dstein64/vim-startuptime" +src.git = "https://github.com/dstein64/vim-startuptime.git" diff --git a/pkgs/nixvim/lang/toml/formatting.nix b/pkgs/nixvim/lang/toml/formatting.nix index 56b880b..3fbb0da 100644 --- a/pkgs/nixvim/lang/toml/formatting.nix +++ b/pkgs/nixvim/lang/toml/formatting.nix @@ -23,7 +23,7 @@ return "${lib.getExe pkgs.taplo}" end end, - args = { "format", "-o", "reorder_keys=true", "-o", "reorder_inline_tables=true", "-o", "reorder_arrays=true", "-" }, + args = { "format", "-o", "reorder_keys=true", "-o", "reorder_inline_tables=true", "-" }, }) end ''; diff --git a/templates/python/pyproject.toml b/templates/python/pyproject.toml index faab326..c7885d2 100644 --- a/templates/python/pyproject.toml +++ b/templates/python/pyproject.toml @@ -1,16 +1,16 @@ [project] -name = "python" -version = "0.1.0" +dependencies = ["numpy>=2.2.6"] description = "Add your description here" +name = "python" readme = "README.md" requires-python = ">=3.12" -dependencies = ["numpy>=2.2.6"] +version = "0.1.0" [dependency-groups] dev = ["ipython>=9.2.0", "ptpython>=3.0.30"] [build-system] -requires = ["hatchling"] build-backend = "hatchling.build" +requires = ["hatchling"] [tool.hatch.build.targets.wheel] packages = ["app"] diff --git a/templates/rust/rust-toolchain.toml b/templates/rust/rust-toolchain.toml index 698a98c..90e92de 100644 --- a/templates/rust/rust-toolchain.toml +++ b/templates/rust/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] channel = "stable" -profile = "default" components = ["rust-src"] +profile = "default" From 7477166d9ed5548777de9cddf16d0483e0914637 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 15/31] pkg(nixvim): Remove all lang configuration to single file --- pkgs/nixvim/lang/{c/formatting.nix => c.nix} | 2 +- pkgs/nixvim/lang/{cxx/formatting.nix => cxx.nix} | 2 +- pkgs/nixvim/lang/{json/formatting.nix => json.nix} | 2 +- pkgs/nixvim/lang/{lua/formatting.nix => lua.nix} | 5 ++++- .../lang/{markdown/formatting.nix => markdown.nix} | 2 +- pkgs/nixvim/lang/{nix/formatting.nix => nix.nix} | 10 +++++++++- pkgs/nixvim/lang/{python/formatting.nix => python.nix} | 2 +- pkgs/nixvim/lang/{rust/formatting.nix => rust.nix} | 2 +- pkgs/nixvim/lang/{toml/formatting.nix => toml.nix} | 2 +- pkgs/nixvim/lang/{yaml/formatting.nix => yaml.nix} | 2 +- 10 files changed, 21 insertions(+), 10 deletions(-) rename pkgs/nixvim/lang/{c/formatting.nix => c.nix} (94%) rename pkgs/nixvim/lang/{cxx/formatting.nix => cxx.nix} (94%) rename pkgs/nixvim/lang/{json/formatting.nix => json.nix} (93%) rename pkgs/nixvim/lang/{lua/formatting.nix => lua.nix} (88%) rename pkgs/nixvim/lang/{markdown/formatting.nix => markdown.nix} (93%) rename pkgs/nixvim/lang/{nix/formatting.nix => nix.nix} (90%) rename pkgs/nixvim/lang/{python/formatting.nix => python.nix} (96%) rename pkgs/nixvim/lang/{rust/formatting.nix => rust.nix} (93%) rename pkgs/nixvim/lang/{toml/formatting.nix => toml.nix} (94%) rename pkgs/nixvim/lang/{yaml/formatting.nix => yaml.nix} (93%) diff --git a/pkgs/nixvim/lang/c/formatting.nix b/pkgs/nixvim/lang/c.nix similarity index 94% rename from pkgs/nixvim/lang/c/formatting.nix rename to pkgs/nixvim/lang/c.nix index 0e7f2dd..4681dbc 100644 --- a/pkgs/nixvim/lang/c/formatting.nix +++ b/pkgs/nixvim/lang/c.nix @@ -3,7 +3,7 @@ pkgs, ... }: { - plugins.conform-nvim.settings = { + youthlic.plugins.conform-nvim.settings = { formatters_by_ft.c = { __unkeyed-1 = "clang-format"; lsp_format = "fallback"; diff --git a/pkgs/nixvim/lang/cxx/formatting.nix b/pkgs/nixvim/lang/cxx.nix similarity index 94% rename from pkgs/nixvim/lang/cxx/formatting.nix rename to pkgs/nixvim/lang/cxx.nix index 8f136d9..5fd866b 100644 --- a/pkgs/nixvim/lang/cxx/formatting.nix +++ b/pkgs/nixvim/lang/cxx.nix @@ -3,7 +3,7 @@ pkgs, ... }: { - plugins.conform-nvim.settings = { + youthlic.plugins.conform-nvim.settings = { formatters_by_ft.cpp = { __unkeyed-1 = "clang-format"; lsp_format = "fallback"; diff --git a/pkgs/nixvim/lang/json/formatting.nix b/pkgs/nixvim/lang/json.nix similarity index 93% rename from pkgs/nixvim/lang/json/formatting.nix rename to pkgs/nixvim/lang/json.nix index 8c9afd1..f740749 100644 --- a/pkgs/nixvim/lang/json/formatting.nix +++ b/pkgs/nixvim/lang/json.nix @@ -3,7 +3,7 @@ pkgs, ... }: { - plugins.conform-nvim.settings = { + youthlic.plugins.conform-nvim.settings = { formatters_by_ft.json = { __unkeyed-1 = "deno_fmt"; }; diff --git a/pkgs/nixvim/lang/lua/formatting.nix b/pkgs/nixvim/lang/lua.nix similarity index 88% rename from pkgs/nixvim/lang/lua/formatting.nix rename to pkgs/nixvim/lang/lua.nix index d1dd041..b66574f 100644 --- a/pkgs/nixvim/lang/lua/formatting.nix +++ b/pkgs/nixvim/lang/lua.nix @@ -3,7 +3,10 @@ pkgs, ... }: { - plugins.conform-nvim.settings = { + lsp.servers.lua_ls = { + enable = true; + }; + youthlic.plugins.conform-nvim.settings = { formatters_by_ft.lua = { __unkeyed-1 = "stylua"; lsp_format = "fallback"; diff --git a/pkgs/nixvim/lang/markdown/formatting.nix b/pkgs/nixvim/lang/markdown.nix similarity index 93% rename from pkgs/nixvim/lang/markdown/formatting.nix rename to pkgs/nixvim/lang/markdown.nix index 31e7e97..cae1834 100644 --- a/pkgs/nixvim/lang/markdown/formatting.nix +++ b/pkgs/nixvim/lang/markdown.nix @@ -3,7 +3,7 @@ pkgs, ... }: { - plugins.conform-nvim.settings = { + youthlic.plugins.conform-nvim.settings = { formatters_by_ft.markdown = { __unkeyed-1 = "deno_fmt"; }; diff --git a/pkgs/nixvim/lang/nix/formatting.nix b/pkgs/nixvim/lang/nix.nix similarity index 90% rename from pkgs/nixvim/lang/nix/formatting.nix rename to pkgs/nixvim/lang/nix.nix index f93b545..98af73c 100644 --- a/pkgs/nixvim/lang/nix/formatting.nix +++ b/pkgs/nixvim/lang/nix.nix @@ -3,7 +3,15 @@ pkgs, ... }: { - plugins.conform-nvim.settings = { + lsp.servers = { + nixd = { + enable = true; + }; + nil_ls = { + enable = true; + }; + }; + youthlic.plugins.conform-nvim.settings = { formatters_by_ft.nix = { __unkeyed-1 = "alejandra"; __unkeyed-2 = "injected"; diff --git a/pkgs/nixvim/lang/python/formatting.nix b/pkgs/nixvim/lang/python.nix similarity index 96% rename from pkgs/nixvim/lang/python/formatting.nix rename to pkgs/nixvim/lang/python.nix index cd62386..67f08c7 100644 --- a/pkgs/nixvim/lang/python/formatting.nix +++ b/pkgs/nixvim/lang/python.nix @@ -3,7 +3,7 @@ pkgs, ... }: { - plugins.conform-nvim.settings = { + youthlic.plugins.conform-nvim.settings = { formatters_by_ft.python = { __unkeyed-1 = "ruff_format"; __unkeyed-2 = "ruff_organize_imports"; diff --git a/pkgs/nixvim/lang/rust/formatting.nix b/pkgs/nixvim/lang/rust.nix similarity index 93% rename from pkgs/nixvim/lang/rust/formatting.nix rename to pkgs/nixvim/lang/rust.nix index c569c36..bcbf89b 100644 --- a/pkgs/nixvim/lang/rust/formatting.nix +++ b/pkgs/nixvim/lang/rust.nix @@ -3,7 +3,7 @@ pkgs, ... }: { - plugins.conform-nvim.settings = { + youthlic.plugins.conform-nvim.settings = { formatters_by_ft.rust = { __unkeyed-1 = "rustfmt"; lsp_format = "fallback"; diff --git a/pkgs/nixvim/lang/toml/formatting.nix b/pkgs/nixvim/lang/toml.nix similarity index 94% rename from pkgs/nixvim/lang/toml/formatting.nix rename to pkgs/nixvim/lang/toml.nix index 3fbb0da..b674308 100644 --- a/pkgs/nixvim/lang/toml/formatting.nix +++ b/pkgs/nixvim/lang/toml.nix @@ -3,7 +3,7 @@ pkgs, ... }: { - plugins.conform-nvim.settings = { + youthlic.plugins.conform-nvim.settings = { formatters_by_ft.toml = { __unkeyed-1 = "taplo"; lsp_format = "fallback"; diff --git a/pkgs/nixvim/lang/yaml/formatting.nix b/pkgs/nixvim/lang/yaml.nix similarity index 93% rename from pkgs/nixvim/lang/yaml/formatting.nix rename to pkgs/nixvim/lang/yaml.nix index 8bc2d6b..d04f189 100644 --- a/pkgs/nixvim/lang/yaml/formatting.nix +++ b/pkgs/nixvim/lang/yaml.nix @@ -3,7 +3,7 @@ pkgs, ... }: { - plugins.conform-nvim.settings = { + youthlic.plugins.conform-nvim.settings = { formatters_by_ft.yaml = { __unkeyed-1 = "deno_fmt"; }; From cfdd89c0807443b6f576500eb5b79026d2cdb557 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 16/31] pkg(nixvim): Add blink-cmp, lazydev, mini-ai, mini-pairs and ts-comments plugins to improve coding UX --- pkgs/nixvim/coding.nix | 16 ---- pkgs/nixvim/coding/blink-cmp.nix | 55 +++++++++++++ pkgs/nixvim/coding/lazydev.nix | 15 ++++ pkgs/nixvim/coding/mini-ai.nix | 121 +++++++++++++++++++++++++++++ pkgs/nixvim/coding/mini-pairs.nix | 71 +++++++++++++++++ pkgs/nixvim/coding/ts-comments.nix | 3 + 6 files changed, 265 insertions(+), 16 deletions(-) delete mode 100644 pkgs/nixvim/coding.nix create mode 100644 pkgs/nixvim/coding/blink-cmp.nix create mode 100644 pkgs/nixvim/coding/lazydev.nix create mode 100644 pkgs/nixvim/coding/mini-ai.nix create mode 100644 pkgs/nixvim/coding/mini-pairs.nix create mode 100644 pkgs/nixvim/coding/ts-comments.nix diff --git a/pkgs/nixvim/coding.nix b/pkgs/nixvim/coding.nix deleted file mode 100644 index b600e44..0000000 --- a/pkgs/nixvim/coding.nix +++ /dev/null @@ -1,16 +0,0 @@ -{...}: { - plugins = { - # mini-pairs = { - # enable = true; - # }; - # ts-comments = { - # enable = true; - # }; - # mini-ai = { - # enable = true; - # }; - # lazydev = { - # enable = true; - # }; - }; -} diff --git a/pkgs/nixvim/coding/blink-cmp.nix b/pkgs/nixvim/coding/blink-cmp.nix new file mode 100644 index 0000000..b7574c9 --- /dev/null +++ b/pkgs/nixvim/coding/blink-cmp.nix @@ -0,0 +1,55 @@ +{...}: { + youthlic.plugins.blink-cmp = { + enable = true; + setupLspCapabilities = true; + settings = { + snippets = { + expand = { + __raw = + #lua + '' + function(snippet, _) + return {} + end + ''; + }; + }; + appearance = { + # use_nvim_cmp_as_default = false; + }; + completion = { + accept = { + auto_brackets = { + enabled = true; + }; + }; + menu = { + draw = { + treesitter = ["lsp"]; + }; + }; + documentation = { + auto_show = true; + auto_show_delay_ms = 200; + }; + ghost_text = { + enabled = { + __raw = + #lua + ''vim.g.ai_cmp''; + }; + }; + }; + sources = { + compat = []; + default = ["lsp" "path" "snippets" "buffer"]; + }; + cmdline = { + enabled = false; + }; + keymap = { + preset = "enter"; + }; + }; + }; +} diff --git a/pkgs/nixvim/coding/lazydev.nix b/pkgs/nixvim/coding/lazydev.nix new file mode 100644 index 0000000..2432afc --- /dev/null +++ b/pkgs/nixvim/coding/lazydev.nix @@ -0,0 +1,15 @@ +{...}: { + youthlic.plugins = { + lazydev = { + enable = true; + settings = { + library = [ + { + path = "$''{3rd}/luv/library"; + words = ["vim%.uv"]; + } + ]; + }; + }; + }; +} diff --git a/pkgs/nixvim/coding/mini-ai.nix b/pkgs/nixvim/coding/mini-ai.nix new file mode 100644 index 0000000..6644fc2 --- /dev/null +++ b/pkgs/nixvim/coding/mini-ai.nix @@ -0,0 +1,121 @@ +{...}: { + youthlic.plugins.mini-ai = { + enable = true; + luaConfig.pre = + #lua + '' + do + local ai = require("mini.ai") + _M.__coding_plugin_mini_ai_opts = { + n_lines = 500, + custom_textobjects = { + o = ai.gen_spec.treesitter({ -- code block + a = { "@block.outer", "@conditional.outer", "@loop.outer" }, + i = { "@block.inner", "@conditional.inner", "@loop.inner" }, + }), + f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }), -- function + c = ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }), -- class + t = { "<([%p%w]-)%f[^<%w][^<>]->.-", "^<.->().*()$" }, -- tags + d = { "%f[%d]%d+" }, -- digits + e = { -- Word with case + { "%u[%l%d]+%f[^%l%d]", "%f[%S][%l%d]+%f[^%l%d]", "%f[%P][%l%d]+%f[^%l%d]", "^[%l%d]+%f[^%l%d]" }, + "^().*()$", + }, + g = function(ai_type) + local start_line, end_line = 1, vim.fn.line("$") + if ai_type == "i" then + local first_nonblank, last_nonblank = vim.fn.nextnonblank(start_line), vim.fn.prevnonblank(end_line) + if first_nonblank == 0 or last_nonblank == 0 then + return { from = { line = start_line, col = 1 } } + end + start_line, end_line = first_nonblank, last_nonblank + end + + local to_col = math.max(vim.fn.getline(end_line):len(), 1) + return { + from = { + line = start_line, + col = 1, + }, + to = { + line = end_line, + col = to_col, + }, + } + end, -- buffer + u = ai.gen_spec.function_call(), -- u for "Usage" + U = ai.gen_spec.function_call({ name_pattern = "[%w_]" }), -- without dot in function name + }, + } + end + ''; + settings = { + __raw = + #lua + "_M.__coding_plugin_mini_ai_opts"; + }; + luaConfig.post = + #lua + '' + _M.on_load("which-key", function() + local opts = _M.__coding_plugin_mini_ai_opts + local objects = { + { " ", desc = "whitespace" }, + { '"', desc = '" string' }, + { "'", desc = "' string" }, + { "(", desc = "() block" }, + { ")", desc = "() block with ws" }, + { "<", desc = "<> block" }, + { ">", desc = "<> block with ws" }, + { "?", desc = "user prompt" }, + { "U", desc = "use/call without dot" }, + { "[", desc = "[] block" }, + { "]", desc = "[] block with ws" }, + { "_", desc = "underscore" }, + { "`", desc = "` string" }, + { "a", desc = "argument" }, + { "b", desc = ")]} block" }, + { "c", desc = "class" }, + { "d", desc = "digit(s)" }, + { "e", desc = "CamelCase / snake_case" }, + { "f", desc = "function" }, + { "g", desc = "entire file" }, + { "i", desc = "indent" }, + { "o", desc = "block, conditional, loop" }, + { "q", desc = "quote `\"'" }, + { "t", desc = "tag" }, + { "u", desc = "use/call" }, + { "{", desc = "{} block" }, + { "}", desc = "{} with ws" }, + } + + ---@type wk.Spec[] + local ret = { mode = { "o", "x" } } + ---@type table + local mappings = vim.tbl_extend("force", {}, { + around = "a", + inside = "i", + around_next = "an", + inside_next = "in", + around_last = "al", + inside_last = "il", + }, opts.mappings or {}) + mappings.goto_left = nil + mappings.goto_right = nil + + for name, prefix in pairs(mappings) do + name = name:gsub("^around_", ""):gsub("^inside_", "") + ret[#ret + 1] = { prefix, group = name } + for _, obj in ipairs(objects) do + local desc = obj.desc + if prefix:sub(1, 1) == "i" then + desc = desc:gsub(" with ws", "") + end + ret[#ret + 1] = { prefix .. obj[1], desc = obj.desc } + end + end + require("which-key").add(ret, { notify = false }) + end) + ''; + }; +} diff --git a/pkgs/nixvim/coding/mini-pairs.nix b/pkgs/nixvim/coding/mini-pairs.nix new file mode 100644 index 0000000..d991b1b --- /dev/null +++ b/pkgs/nixvim/coding/mini-pairs.nix @@ -0,0 +1,71 @@ +{...}: { + youthlic.plugins.mini-pairs = { + enable = true; + settings = { + modes = { + insert = true; + command = true; + terminal = false; + }; + }; + luaConfig.post = + #lua + '' + do + local opts = { + skip_next = [=[[%w%%'%[%"%.%`%$]]=], + skip_ts = { "string" }, + skip_unbalanced = true, + markdown = true, + } + _M.on_load("snacks", function() + vim.schedule(function() + Snacks.toggle({ + name = "Mini Pairs", + get = function() + return not vim.g.minipairs_disable + end, + set = function(state) + vim.g.minipairs_disable = not state + end, + }):map("up") + end) + end) + local pairs = require("mini.pairs") + local open = pairs.open + pairs.open = function(pair, neigh_pattern) + if vim.fn.getcmdline() ~= "" then + return open(pair, neigh_pattern) + end + local o, c = pair:sub(1, 1), pair:sub(2, 2) + local line = vim.api.nvim_get_current_line() + local cursor = vim.api.nvim_win_get_cursor(0) + local next = line:sub(cursor[2] + 1, cursor[2] + 1) + local before = line:sub(1, cursor[2]) + if opts.markdown and o == "`" and vim.bo.filetype == "markdown" and before:match("^%s*``") then + return "`\n``" .. vim.api.nvim_replace_termcodes("", true, true, true) + end + if opts.skip_next and next ~= "" and next:match(opts.skip_next) then + return o + end + if opts.skip_ts and #opts.skip_ts > 0 then + local ok, captures = pcall(vim.treesitter.get_captures_at_pos, 0, cursor[1] - 1, math.max(cursor[2] - 1, 0)) + for _, capture in ipairs(ok and captures or {}) do + if vim.tbl_contains(opts.skip_ts, capture.capture) then + return o + end + end + end + if opts.skip_unbalanced and next == c and c ~= o then + local _, count_open = line:gsub(vim.pesc(pair:sub(1, 1)), "") + local _, count_close = line:gsub(vim.pesc(pair:sub(2, 2)), "") + if count_close > count_open then + return o + end + end + return open(pair, neigh_pattern) + end + end + ''; + }; +} diff --git a/pkgs/nixvim/coding/ts-comments.nix b/pkgs/nixvim/coding/ts-comments.nix new file mode 100644 index 0000000..1507e17 --- /dev/null +++ b/pkgs/nixvim/coding/ts-comments.nix @@ -0,0 +1,3 @@ +{...}: { + youthlic.plugins.ts-comments.enable = true; +} From 933446925aa30f0aacb8343f80d86b97b3425c6c Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 17/31] pkg(nixvim): Add .stylua.toml file to specify lua format --- pkgs/nixvim/.stylua.toml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 pkgs/nixvim/.stylua.toml diff --git a/pkgs/nixvim/.stylua.toml b/pkgs/nixvim/.stylua.toml new file mode 100644 index 0000000..febcadb --- /dev/null +++ b/pkgs/nixvim/.stylua.toml @@ -0,0 +1,5 @@ +column_width = 120 +indent_type = "Spaces" +indent_width = 2 +[sort_requires] +enabled = true From 58b503453b4bc53e7e934c87bca330d80e9ba88f Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 18/31] pkg(nixvim): Move vim-startuptime to util/vim-startuptime.nix --- pkgs/nixvim/{util.nix => util/vim-startuptime.nix} | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) rename pkgs/nixvim/{util.nix => util/vim-startuptime.nix} (69%) diff --git a/pkgs/nixvim/util.nix b/pkgs/nixvim/util/vim-startuptime.nix similarity index 69% rename from pkgs/nixvim/util.nix rename to pkgs/nixvim/util/vim-startuptime.nix index 51b5641..5430c38 100644 --- a/pkgs/nixvim/util.nix +++ b/pkgs/nixvim/util/vim-startuptime.nix @@ -1,13 +1,11 @@ -{ - pkgs, - nixvimPlugins, - ... -}: { +{nixvimPlugins, ...}: { extraPlugins = [ { config = #vim '' + lua << EOF + EOF ''; plugin = nixvimPlugins.vim-startuptime; } From 2b6bc9763d3d1c7be05242ab5bd9527d9a51f9de Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 19/31] pkg(nixvim): Add lazy-load file to use AutoCmd to load plugin --- pkgs/nixvim/util/lazy-load.nix | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 pkgs/nixvim/util/lazy-load.nix diff --git a/pkgs/nixvim/util/lazy-load.nix b/pkgs/nixvim/util/lazy-load.nix new file mode 100644 index 0000000..4b515c3 --- /dev/null +++ b/pkgs/nixvim/util/lazy-load.nix @@ -0,0 +1,38 @@ +{...}: { + extraConfigLuaPre = + #lua + '' + do + _M.plugins = {} + _M.load = function(name) + _M.plugins = vim.tbl_deep_extend("force", _M.plugins, { + name = { + loaded = true, + }, + }) + vim.schedule(function() + vim.api.nvim_exec_autocmds("User", { pattern = "LazyLoad", modeline = false, data = name }) + end) + end + _M._is_loaded = function(name) + local plugins = _M.plugins + return plugins[name] and plugins[name].loaded + end + _M.on_load = function(name, fn) + if _M._is_loaded(name) then + fn(name) + else + vim.api.nvim_create_autocmd("User", { + pattern = "LazyLoad", + callback = function(event) + if event.data == name then + fn(name) + return true + end + end, + }) + end + end + end + ''; +} From 3948d2b53d1e9d6570c00f29dec6a3322fb8634a Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 20/31] pkg(nixvim): Add snack plugin for many little features --- pkgs/nixvim/util/snacks.nix | 85 +++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 pkgs/nixvim/util/snacks.nix diff --git a/pkgs/nixvim/util/snacks.nix b/pkgs/nixvim/util/snacks.nix new file mode 100644 index 0000000..0d653b1 --- /dev/null +++ b/pkgs/nixvim/util/snacks.nix @@ -0,0 +1,85 @@ +{...}: { + youthlic.plugins.snacks = { + enable = true; + luaConfig.content = + #lua + '' + -- Terminal Mappings + _M.__util_plugin_snacks_term_nav = function(direction) + ---@param self snacks.terminal + return function(self) + return self:is_floating() and "" + or vim.schedule(function() + vim.cmd.wincmd(direction) + end) + end + end + ''; + settings = { + bigfile = { + enabled = true; + }; + quickfile = { + enabled = true; + }; + terminal = { + win = { + keys = { + nav_h = { + __unkeyed-1 = "h"; + __unkeyed-2 = { + __raw = + #lua + '' + _M.__util_plugin_snacks_term_nav("h") + ''; + }; + desc = "Go to Left Window"; + expr = true; + mode = "t"; + }; + nav_j = { + __unkeyed-1 = "j"; + __unkeyed-2 = { + __raw = + #lua + '' + _M.__util_plugin_snacks_term_nav("j") + ''; + }; + desc = "Go to Lower Window"; + expr = true; + mode = "t"; + }; + nav_k = { + __unkeyed-1 = "k"; + __unkeyed-2 = { + __raw = + #lua + '' + _M.__util_plugin_snacks_term_nav("k") + ''; + }; + desc = "Go to Upper Window"; + expr = true; + mode = "t"; + }; + nav_l = { + __unkeyed-1 = "l"; + __unkeyed-2 = { + __raw = + #lua + '' + _M.__util_plugin_snacks_term_nav("l") + ''; + }; + desc = "Go to Right Window"; + expr = true; + mode = "t"; + }; + }; + }; + }; + }; + }; +} From dbb0d619375eb4e27eab709a39de193ca956604e Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 21/31] pkg(nixvim): Refactor ui module for nixvim --- pkgs/nixvim/ui.nix | 9 ----- pkgs/nixvim/ui/bufferline.nix | 69 +++++++++++++++++++++++++++++++++ pkgs/nixvim/ui/colorschemes.nix | 7 ++++ pkgs/nixvim/ui/lualine.nix | 21 ++++++++++ 4 files changed, 97 insertions(+), 9 deletions(-) delete mode 100644 pkgs/nixvim/ui.nix create mode 100644 pkgs/nixvim/ui/bufferline.nix create mode 100644 pkgs/nixvim/ui/colorschemes.nix create mode 100644 pkgs/nixvim/ui/lualine.nix diff --git a/pkgs/nixvim/ui.nix b/pkgs/nixvim/ui.nix deleted file mode 100644 index d933f88..0000000 --- a/pkgs/nixvim/ui.nix +++ /dev/null @@ -1,9 +0,0 @@ -{...}: { - colorschemes.gruvbox-material = { - enable = true; - autoLoad = true; - }; - plugins = { - bufferline.enable = true; - }; -} diff --git a/pkgs/nixvim/ui/bufferline.nix b/pkgs/nixvim/ui/bufferline.nix new file mode 100644 index 0000000..109272a --- /dev/null +++ b/pkgs/nixvim/ui/bufferline.nix @@ -0,0 +1,69 @@ +{...}: { + youthlic.plugins.bufferline = { + enable = true; + settings = { + options = { + close_command = { + __raw = + #lua + '' + function(n) + Snacks.bufdelete(n) + end + ''; + }; + right_mouse_command = { + __raw = + #lua + '' + function(n) + Snacks.bufdelete(n) + end + ''; + }; + diagnostics = "nvim_lsp"; + always_show_bufferline = false; + diagnostics_indicator = { + __raw = + #lua + '' + function(_, _, diag) + local icons = { + Error = " ", + Warn = " ", + Hint = " ", + Info = " ", + } + local ret = (diag.error and icons.Error .. diag.error .. " " or "") + .. (diag.warning and icons.Warn .. diag.warning or "") + return vim.trim(ret) + end + ''; + }; + offsets = [ + { + filetype = "neo-tree"; + text = "Neo-tree"; + highlight = "Directory"; + text_align = "left"; + } + { + filetype = "snacks_layout_box"; + } + ]; + get_element_icon = { + __raw = + #lua + '' + function(opts) + local icons = { + octo = "", + } + return icons[opts.filetype] + end + ''; + }; + }; + }; + }; +} diff --git a/pkgs/nixvim/ui/colorschemes.nix b/pkgs/nixvim/ui/colorschemes.nix new file mode 100644 index 0000000..81523cf --- /dev/null +++ b/pkgs/nixvim/ui/colorschemes.nix @@ -0,0 +1,7 @@ +{...}: { + colorschemes.gruvbox = { + enable = true; + settings = { + }; + }; +} diff --git a/pkgs/nixvim/ui/lualine.nix b/pkgs/nixvim/ui/lualine.nix new file mode 100644 index 0000000..4925ee2 --- /dev/null +++ b/pkgs/nixvim/ui/lualine.nix @@ -0,0 +1,21 @@ +{...}: { + youthlic.plugins.lualine = { + enable = true; + luaConfig.pre = + #lua + '' + do + vim.g.lualine_laststatus = vim.o.laststatus + if vim.fn.argc(-1) > 0 then + vim.o.statusline = " " + else + vim.o.laststatus = 0 + end + end + do + vim.o.laststatus = vim.g.lualine_laststatus + end + ''; + settings = {}; + }; +} From 44cbe023d0531ebb84c477daf77372a8f64233fe Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 22/31] pkg(nixvim): Refactor tree-sitter module --- pkgs/nixvim/treesitter.nix | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkgs/nixvim/treesitter.nix b/pkgs/nixvim/treesitter.nix index 2f322e4..95b46aa 100644 --- a/pkgs/nixvim/treesitter.nix +++ b/pkgs/nixvim/treesitter.nix @@ -1,5 +1,5 @@ {...}: { - plugins = { + youthlic.plugins = { treesitter = { enable = true; # folding = true; @@ -12,8 +12,5 @@ indent.enable = true; }; }; - which-key = { - enable = true; - }; }; } From 96c4fb932d39ac0fd427c163ec571546e35d68be Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 23/31] pkg(nixvim): Move neovide configuration to single file --- pkgs/nixvim/neovide.nix | 33 +++++++++++++++++++++++++++++++++ pkgs/nixvim/package.nix | 29 ----------------------------- 2 files changed, 33 insertions(+), 29 deletions(-) create mode 100644 pkgs/nixvim/neovide.nix diff --git a/pkgs/nixvim/neovide.nix b/pkgs/nixvim/neovide.nix new file mode 100644 index 0000000..cb88ab3 --- /dev/null +++ b/pkgs/nixvim/neovide.nix @@ -0,0 +1,33 @@ +{...}: { + extraConfigLua = + #lua + '' + if vim.g.neovide then + vim.o.guifont = [[Maple Mono NF CN,Noto Color Emoji:h16]] + vim.g.neovide_opacity = 0.9 + vim.g.linespace = 0.2 + vim.g.neovide_text_gamma = 0.8 + vim.g.neovide_text_contrast = 0.1 + + vim.g.neovide_floating_shadow = true + vim.g.neovide_floating_z_height = 10 + vim.g.neovide_light_angle_degrees = 45 + vim.g.neovide_light_radius = 5 + + vim.g.neovide_position_animation_length = 0.1 + vim.g.neovide_scroll_animation_length = 0.2 + vim.g.neovide_scroll_animation_far_lines = 5 + vim.g.neovide_hide_mouse_when_typing = true + vim.g.neovide_refresh_rate = 120 + vim.g.neovide_confirm_quit = true + vim.g.neovide_input_ime = true + + vim.g.neovide_cursor_animation_length = 0.1 + vim.g.neovide_cursor_short_animation_length = 0.04 + vim.g.neovide_cursor_antialiasing = true + vim.g.neovide_cursor_animate_in_insert_mode = true + vim.g.neovide_cursor_animate_command_line = true + vim.g.neovide_cursor_unfocused_outline_width = 0.125 + end + ''; +} diff --git a/pkgs/nixvim/package.nix b/pkgs/nixvim/package.nix index 57a7c9a..24cd8f3 100644 --- a/pkgs/nixvim/package.nix +++ b/pkgs/nixvim/package.nix @@ -31,34 +31,5 @@ makeNixvimWithModule { }; wrapRc = true; luaLoader.enable = true; - extraConfigLua = - #lua - '' - if vim.g.neovide then - vim.o.guifont = [[Maple\ Mono\ NF\ CN,Noto Color Emoji:h16]] - vim.g.neovide_opacity = 0.9 - vim.g.linespace = 0.2 - - vim.g.neovide_floating_shadow = true - vim.g.neovide_floating_z_height = 10 - vim.g.neovide_light_angle_degrees = 45 - vim.g.neovide_light_radius = 5 - - vim.g.neovide_position_animation_length = 0.1 - vim.g.neovide_scroll_animation_length = 0.2 - vim.g.neovide_scroll_animation_far_lines = 5 - vim.g.neovide_hide_mouse_when_typing = true - vim.g.neovide_refresh_rate = 120 - vim.g.neovide_confirm_quit = true - vim.g.neovide_input_ime = true - - vim.g.neovide_cursor_animation_length = 0.1 - vim.g.neovide_cursor_short_animation_length = 0.04 - vim.g.neovide_cursor_antialiasing = true - vim.g.neovide_cursor_animate_in_insert_mode = true - vim.g.neovide_cursor_animate_command_line = true - vim.g.neovide_cursor_unfocused_outline_width = 0.125 - end - ''; }; } From f764a607c036bd0740a396ac259fa0c1435d3fba Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 24/31] pkg(nixvim): Set leader key and modify some options --- pkgs/nixvim/options.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkgs/nixvim/options.nix b/pkgs/nixvim/options.nix index c14489a..7ce19e8 100644 --- a/pkgs/nixvim/options.nix +++ b/pkgs/nixvim/options.nix @@ -1,4 +1,13 @@ {...}: { + globals = { + mapleader = { + __raw = + #lua + '' + vim.keycode("") + ''; + }; + }; opts = { autoindent = true; autoread = true; @@ -38,13 +47,14 @@ mouse = "a"; number = true; - numberwidth = 2; + numberwidth = 4; relativenumber = true; scrollback = 100000; scrolloff = 5; shiftround = true; shiftwidth = 2; + showmode = false; signcolumn = "auto"; smoothscroll = true; splitbelow = true; From 9238672dad5043f4c551fd58996c7b5ec23f30df Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 25/31] pkg(nixvim): Add which-key plugin --- pkgs/nixvim/editor.nix | 5 +---- pkgs/nixvim/editor/which-key.nix | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 pkgs/nixvim/editor/which-key.nix diff --git a/pkgs/nixvim/editor.nix b/pkgs/nixvim/editor.nix index 79432dc..2f99757 100644 --- a/pkgs/nixvim/editor.nix +++ b/pkgs/nixvim/editor.nix @@ -1,14 +1,11 @@ {...}: { - plugins = { + youthlic.plugins = { # grug-far = { # enable = true; # }; # flash = { # enable = true; # }; - # which-key = { - # enable = true; - # }; # gitsigns = { # enable = true; # }; diff --git a/pkgs/nixvim/editor/which-key.nix b/pkgs/nixvim/editor/which-key.nix new file mode 100644 index 0000000..57d19dc --- /dev/null +++ b/pkgs/nixvim/editor/which-key.nix @@ -0,0 +1,17 @@ +{...}: { + youthlic.plugins = { + which-key = { + enable = true; + settings = { + preset = "helix"; + win = { + no_overlap = false; + }; + show_help = false; + }; + }; + web-devicons = { + enable = true; + }; + }; +} From d794974e0cbf9910a64f8203ae2a10f5388fb782 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 26/31] pkg(nixvim): Add gitsigns plugin --- pkgs/nixvim/editor.nix | 3 - pkgs/nixvim/editor/gitsigns.nix | 97 +++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 pkgs/nixvim/editor/gitsigns.nix diff --git a/pkgs/nixvim/editor.nix b/pkgs/nixvim/editor.nix index 2f99757..cbbe016 100644 --- a/pkgs/nixvim/editor.nix +++ b/pkgs/nixvim/editor.nix @@ -6,9 +6,6 @@ # flash = { # enable = true; # }; - # gitsigns = { - # enable = true; - # }; # trouble = { # enable = true; # }; diff --git a/pkgs/nixvim/editor/gitsigns.nix b/pkgs/nixvim/editor/gitsigns.nix new file mode 100644 index 0000000..d4eb3c6 --- /dev/null +++ b/pkgs/nixvim/editor/gitsigns.nix @@ -0,0 +1,97 @@ +{...}: { + youthlic.plugins.gitsigns = { + enable = true; + luaConfig.post = + #lua + '' + _M.on_load("snacks", function() + vim.schedule(function() + Snacks.toggle({ + name = "Git Signs", + get = function() + return require("gitsigns.config").config.signcolumn + end, + set = function(state) + require("gitsigns").toggle_signs(state) + end, + }):map("uG") + end) + end) + ''; + settings = { + current_line_blame = true; + signcolumn = true; + numhl = true; + linehl = false; + signs = { + add = {text = "┃";}; + change = {text = "┃";}; + delete = {text = "";}; + topdelete = {text = "";}; + changedelete = {text = "┃";}; + untracked = {text = "┃";}; + }; + signs_staged = { + add = {text = "┃";}; + change = {text = "┃";}; + delete = {text = "";}; + topdelete = {text = "";}; + changedelete = {text = "┃";}; + }; + on_attach = { + __raw = + #lua + '' + function(buffer) + local gs = package.loaded.gitsigns + + local map = function(mode, l, r, desc) + vim.keymap.set(mode, l, r, { + buffer = buffer, + desc = desc, + }) + end + + map("n", "]h", function() + if vim.wo.diff then + vim.cmd.normal({ "]c", bang = true }) + else + gs.nav_hunk("next") + end + end, "Next Hunk") + map("n", "[h", function() + if vim.wo.diff then + vim.cmd.normal({ "[c", bang = true }) + else + gs.nav_hunk("prev") + end + end, "Prev Hunk") + map("n", "]H", function() + gs.nav_hunk("last") + end, "Last Hunk") + map("n", "[H", function() + gs.nav_hunk("first") + end, "First Hunk") + map({ "n", "v" }, "ghs", ":Gitsigns stage_hunk", "Stage Hunk") + map({ "n", "v" }, "ghr", ":Gitsigns reset_hunk", "Reset Hunk") + map("n", "ghS", gs.stage_buffer, "Stage Buffer") + map("n", "ghu", gs.undo_stage_hunk, "Undo Stage Hunk") + map("n", "ghR", gs.reset_buffer, "Reset Buffer") + map("n", "ghp", gs.preview_hunk_inline, "Preview Hunk Inline") + map("n", "ghb", function() + gs.blame_line({ full = true }) + end, "Blame Line") + map("n", "ghB", function() + gs.blame() + end, "Blame Buffer") + map("n", "ghd", gs.diffthis, "Diff This") + map("n", "ghD", function() + gs.diffthis("~") + end, "Diff This ~") + map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "GitSigns Select Hunk") + end + ''; + }; + }; + }; +} From bf50c2b05c3f321b7647c7e93c22500ead034d9b Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 27/31] pkg(nixvim): Add trouble plugin --- pkgs/nixvim/editor.nix | 3 --- pkgs/nixvim/editor/trouble.nix | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 pkgs/nixvim/editor/trouble.nix diff --git a/pkgs/nixvim/editor.nix b/pkgs/nixvim/editor.nix index cbbe016..e78f273 100644 --- a/pkgs/nixvim/editor.nix +++ b/pkgs/nixvim/editor.nix @@ -6,9 +6,6 @@ # flash = { # enable = true; # }; - # trouble = { - # enable = true; - # }; # todo-comments = { # enable = true; # }; diff --git a/pkgs/nixvim/editor/trouble.nix b/pkgs/nixvim/editor/trouble.nix new file mode 100644 index 0000000..ec79cd4 --- /dev/null +++ b/pkgs/nixvim/editor/trouble.nix @@ -0,0 +1,30 @@ +{...}: { + youthlic.plugins.trouble = { + enable = true; + settings = { + modes = { + lsp = { + win = { + position = "right"; + }; + }; + preview_float = { + mode = "diagnostics"; + preview = { + type = "float"; + relative = "editor"; + border = "rounded"; + title = "Preview"; + title_pos = "center"; + position = [0 (-2)]; + size = { + width = 0.3; + height = 0.3; + }; + zindex = 200; + }; + }; + }; + }; + }; +} From 86f39ed4ce151b5c34c606d9f617ef3518315051 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 28/31] pkg(nixvim): Modify some nixvim options --- pkgs/nixvim/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/nixvim/package.nix b/pkgs/nixvim/package.nix index 24cd8f3..454b0bd 100644 --- a/pkgs/nixvim/package.nix +++ b/pkgs/nixvim/package.nix @@ -13,7 +13,7 @@ makeNixvimWithModule { module = { imports = with lib; youthlic.loadImports' ./. (filter (name: !hasSuffix "/package.nix" (toString name))); enableMan = true; - plugins.lualine.enable = true; + enablePrintInit = true; package = neovim_git; performance = { # combinePlugins = { From 39ca09b05fa7005b804dd26cbed63c5f5ddd8b14 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 29/31] pkg(nixvim): Add extra module to modify option --- pkgs/nixvim/formatting.nix | 2 +- pkgs/nixvim/lsp.nix | 2 +- pkgs/nixvim/module.nix | 47 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 pkgs/nixvim/module.nix diff --git a/pkgs/nixvim/formatting.nix b/pkgs/nixvim/formatting.nix index 7472324..d0c373b 100644 --- a/pkgs/nixvim/formatting.nix +++ b/pkgs/nixvim/formatting.nix @@ -95,7 +95,7 @@ }; } ]; - plugins.conform-nvim = { + youthlic.plugins.conform-nvim = { enable = true; settings.formatters.injected.options.ignore_errors = true; }; diff --git a/pkgs/nixvim/lsp.nix b/pkgs/nixvim/lsp.nix index e8b43ff..018b782 100644 --- a/pkgs/nixvim/lsp.nix +++ b/pkgs/nixvim/lsp.nix @@ -1,5 +1,5 @@ {...}: { - plugins.lspconfig.enable = true; + youthlic.plugins.lspconfig.enable = true; lsp = { inlayHints.enable = true; servers = { diff --git a/pkgs/nixvim/module.nix b/pkgs/nixvim/module.nix new file mode 100644 index 0000000..8426876 --- /dev/null +++ b/pkgs/nixvim/module.nix @@ -0,0 +1,47 @@ +{ + lib, + config, + options, + ... +}: let + cfg = config.youthlic; +in { + options = { + youthlic.plugins = lib.mkOption { + type = lib.types.attrsOf (lib.types.submodule ({ + name, + lib, + ... + }: { + freeformType = lib.types.anything; + options = { + enable = lib.mkEnableOption "nvimPlugins.${name}"; + }; + })); + default = {}; + }; + }; + config = let + enabledPlugins = lib.filterAttrs (_name: value: value.enable) cfg.plugins; + in + lib.mkMerge [ + { + plugins = enabledPlugins; + } + { + plugins = lib.pipe enabledPlugins [ + builtins.attrNames + (lib.filter (name: options.plugins.${name} ? luaConfig)) + (map (name: + lib.nameValuePair name { + luaConfig.post = + #lua + '' + _M.load("${name}") + ''; + })) + lib.listToAttrs + ]; + } + ]; +} From 56dc7f3bba08e2d8cea3a7580ce291108aea3c15 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 30/31] pkg(nixvim): Add some lsp configuration --- pkgs/nixvim/lsp.nix | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/pkgs/nixvim/lsp.nix b/pkgs/nixvim/lsp.nix index 018b782..bc2e419 100644 --- a/pkgs/nixvim/lsp.nix +++ b/pkgs/nixvim/lsp.nix @@ -2,10 +2,34 @@ youthlic.plugins.lspconfig.enable = true; lsp = { inlayHints.enable = true; - servers = { - nixd = { - enable = true; - }; - }; + luaConfig.post = + #lua + '' + do + vim.diagnostic.config({ + underline = true, + virtual_lines = { + current_line = true, + }, + signs = true, + severity_sort = true, + float = { + scope = "cursor", + source = "if_many", + }, + jump = { + on_jump = function(diagnostic, bufnr) + vim.diagnostic.open_float({ + scope = "cursor", + severity_sort = true, + source = "if_many", + bufnr = bufnr, + }) + end, + wrap = true, + }, + }) + end + ''; }; } From 400742f8a94e3d4c197411f04203a180ad01b586 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 13 Jul 2025 06:04:55 +0800 Subject: [PATCH 31/31] pkg(nixvim): Add idris2 language configuration --- pkgs/nixvim/lang/idris2.nix | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 pkgs/nixvim/lang/idris2.nix diff --git a/pkgs/nixvim/lang/idris2.nix b/pkgs/nixvim/lang/idris2.nix new file mode 100644 index 0000000..53e6fa8 --- /dev/null +++ b/pkgs/nixvim/lang/idris2.nix @@ -0,0 +1,9 @@ +{pkgs, ...}: { + extraPackagesAfter = with pkgs; [idris2Packages.idris2Lsp]; + lsp.servers.idris2 = { + enable = true; + }; + youthlic.plugins.idris2 = { + enable = true; + }; +}