diff --git a/flake.lock b/flake.lock index 56d629b..a3d6b80 100644 --- a/flake.lock +++ b/flake.lock @@ -77,11 +77,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1760395520, - "narHash": "sha256-4hVEyj3H4i0kwtO8dDIKee1WoZ0iMZxr3ageSdJ6Cck=", + "lastModified": 1760747305, + "narHash": "sha256-SsuuyaFp4TbJ+ofti9EXot9gIOk4vZqccat/zERVQN4=", "owner": "chaotic-cx", "repo": "nyx", - "rev": "c438d72cee048fe6203df15c81a230efb16fa409", + "rev": "9838e14b30857ac0a50dbe98a5ba2233d6ccb2de", "type": "github" }, "original": { @@ -117,11 +117,11 @@ ] }, "locked": { - "lastModified": 1758287904, - "narHash": "sha256-IGmaEf3Do8o5Cwp1kXBN1wQmZwQN3NLfq5t4nHtVtcU=", + "lastModified": 1760701190, + "narHash": "sha256-y7UhnWlER8r776JsySqsbTUh2Txf7K30smfHlqdaIQw=", "owner": "nix-community", "repo": "disko", - "rev": "67ff9807dd148e704baadbd4fd783b54282ca627", + "rev": "3a9450b26e69dcb6f8de6e2b07b3fc1c288d85f5", "type": "github" }, "original": { @@ -279,11 +279,11 @@ ] }, "locked": { - "lastModified": 1760312644, - "narHash": "sha256-U9SkK45314urw9P7MmjhEgiQwwD/BTj+T3HTuz1JU1Q=", + "lastModified": 1760662441, + "narHash": "sha256-mlDqR1Ntgs9uYYEAUR1IhamKBO0lxoNS4zGLzEZaY0A=", "owner": "nix-community", "repo": "home-manager", - "rev": "e121f3773fa596ecaba5b22e518936a632d72a90", + "rev": "722792af097dff5790f1a66d271a47759f477755", "type": "github" }, "original": { @@ -299,11 +299,11 @@ ] }, "locked": { - "lastModified": 1760500983, - "narHash": "sha256-zfY4F4CpeUjTGgecIJZ+M7vFpwLc0Gm9epM/iMQd4w8=", + "lastModified": 1760929667, + "narHash": "sha256-nZh6uvc71nVNaf/y+wesnjwsmJ6IZZUnP2EzpZe48To=", "owner": "nix-community", "repo": "home-manager", - "rev": "c53e65ec92f38d30e3c14f8d628ab55d462947aa", + "rev": "189c21cf879669008ccf06e78a553f17e88d8ef0", "type": "github" }, "original": { @@ -349,11 +349,11 @@ ] }, "locked": { - "lastModified": 1760266702, - "narHash": "sha256-TP19RpzIyo1JeYAhKii13seYwmhkv7IOD+dCnQOrcgQ=", + "lastModified": 1760534924, + "narHash": "sha256-OIOCC86DxTxp1VG7xAiM+YABtVqp6vTkYIoAiGQMqso=", "owner": "Jovian-Experiments", "repo": "Jovian-NixOS", - "rev": "3d7e970d4cac5d3ee3fe7cafa17cc9868fa21fed", + "rev": "100b4e000032b865563a9754e5bca189bc544764", "type": "github" }, "original": { @@ -387,11 +387,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1760284886, - "narHash": "sha256-TK9Kr0BYBQ/1P5kAsnNQhmWWKgmZXwUQr4ZMjCzWf2c=", - "owner": "NixOS", + "lastModified": 1760703608, + "narHash": "sha256-MMIIShabm9KnYTmm0WbJ2h+jxI86gfE7NcByVOaBNNU=", + "owner": "PedroHLC", "repo": "nixpkgs", - "rev": "cf3f5c4def3c7b5f1fc012b3d839575dbe552d43", + "rev": "95d8e5f411dc2fcc7f73a72766aaabfab1a1c456", "type": "github" }, "original": { @@ -431,11 +431,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1760284886, - "narHash": "sha256-TK9Kr0BYBQ/1P5kAsnNQhmWWKgmZXwUQr4ZMjCzWf2c=", + "lastModified": 1760878510, + "narHash": "sha256-K5Osef2qexezUfs0alLvZ7nQFTGS9DL2oTVsIXsqLgs=", "owner": "nixos", "repo": "nixpkgs", - "rev": "cf3f5c4def3c7b5f1fc012b3d839575dbe552d43", + "rev": "5e2a59a5b1a82f89f2c7e598302a9cacebb72a67", "type": "github" }, "original": { @@ -471,11 +471,11 @@ "systems": "systems_2" }, "locked": { - "lastModified": 1760472915, - "narHash": "sha256-8o8VoHB5IRiK+HmO387ICkkI5npIbDAoIqaIwIAy10E=", + "lastModified": 1760906375, + "narHash": "sha256-inbXtSqhaDOxvosjvt8hP/Az/wWwRCxjipH4x5DSD6A=", "owner": "nix-community", "repo": "nixvim", - "rev": "32a3fa118d187dc9c88f35a78e763a5b895b6227", + "rev": "5c1be58f6d938ff93516d00cc3d2c0def4d80198", "type": "github" }, "original": { @@ -551,11 +551,11 @@ ] }, "locked": { - "lastModified": 1760236527, - "narHash": "sha256-h9+WEQtUIZaZMvA1pnbZbMM+5X39OFnW92Q8hNoToD0=", + "lastModified": 1760668505, + "narHash": "sha256-Ed0cGwPZtLRiSvMx4KgPx8bhLYzn5jiJ7s5o5vj4oG0=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "a38dd7f462825c75ce8567816ae38c2e7d826bfa", + "rev": "18234d2c11b10eaec9ccc3a1089a5ea872ec8858", "type": "github" }, "original": { diff --git a/home/default.nix b/home/default.nix index c1b8ca0..49b37b9 100644 --- a/home/default.nix +++ b/home/default.nix @@ -8,11 +8,13 @@ ls = lib.filesystem.listFilesRecursive; in { imports = - ls ./cli + [ + ./nvim/default.nix + ] + ++ ls ./cli ++ ls ./gui ++ ls ./tui ++ ls ./wayland; - home = { file = { ".config" = { diff --git a/home/nvim/default.nix b/home/nvim/default.nix new file mode 100644 index 0000000..2cfd401 --- /dev/null +++ b/home/nvim/default.nix @@ -0,0 +1,205 @@ +{ + config, + lib, + pkgs, + ... +}: let + neo-tree-nvim-main = pkgs.vimUtils.buildVimPlugin { + pname = "neo-tree-nvim-main"; + version = "3.35.2+6"; + src = pkgs.fetchFromGitHub { + owner = "nvim-neo-tree"; + repo = "neo-tree.nvim"; + rev = "8dd9f08ff086d09d112f1873f88dc0f74b598cdb"; + sha256 = "sha256-edthaqznGTJ+VFVORK7gfHI9J14PLAghG9prsWlzXtc="; + }; + doCheck = false; + meta.homepage = "https://github.com/nvim-neo-tree/neo-tree.nvim/"; + meta.hydraPlatforms = []; + }; +in { + programs.neovim = { + enable = true; + extraPackages = with pkgs; [ + # LazyVim + lua-language-server + stylua + ]; + + plugins = with pkgs.vimPlugins; [ + lazy-nvim + ]; + + extraLuaConfig = let + plugins = with pkgs.vimPlugins; [ + LazyVim + bufferline-nvim + cmp_luasnip + conform-nvim + dashboard-nvim + flash-nvim + friendly-snippets + gitsigns-nvim + lualine-nvim + { + name = "neo-tree.nvim"; + path = neo-tree-nvim-main; + } + neoconf-nvim + neodev-nvim + noice-nvim + nui-nvim + nvim-lint + nvim-lspconfig + nvim-notify + nvim-spectre + nvim-treesitter + nvim-treesitter-context + nvim-treesitter-textobjects + nvim-ts-autotag + nvim-ts-context-commentstring + nvim-web-devicons + persistence-nvim + plenary-nvim + todo-comments-nvim + tokyonight-nvim + trouble-nvim + vim-illuminate + vim-startuptime + which-key-nvim + fzf-lua + snacks-nvim + { + name = "lazydev.nvim"; + path = lazydev-nvim; + } + { + name = "blink.cmp"; + path = blink-cmp; + } + { + name = "LuaSnip"; + path = luasnip; + } + { + name = "mini.ai"; + path = mini-nvim; + } + { + name = "mini.bufremove"; + path = mini-nvim; + } + { + name = "mini.comment"; + path = mini-nvim; + } + { + name = "mini.indentscope"; + path = mini-nvim; + } + { + name = "mini.pairs"; + path = mini-nvim; + } + { + name = "mini.surround"; + path = mini-nvim; + } + { + name = "mini.icons"; + path = mini-icons; + } + { + name = "grug-far.nvim"; + path = grug-far-nvim; + } + ]; + mkEntryFromDrv = drv: + if lib.isDerivation drv + then { + name = "${lib.getName drv}"; + path = drv; + } + else drv; + lazyPath = pkgs.linkFarm "lazy-plugins" (builtins.map mkEntryFromDrv plugins); + in '' + require("lazy").setup({ + defaults = { + lazy = true, + }, + dev = { + -- reuse files from pkgs.vimPlugins.* + path = "${lazyPath}", + patterns = { "." }, + -- fallback to download + fallback = true, + }, + rocks = { + enabled = false, + hererocks = false, + }, + spec = { + { "LazyVim/LazyVim", import = "lazyvim.plugins" }, + -- The following configs are needed for fixing lazyvim on nix + -- disable mason.nvim, use programs.neovim.extraPackages + { "mason-org/mason-lspconfig.nvim", enabled = false }, + { "mason-org/mason.nvim", enabled = false }, + -- import/override with your plugins + { import = "lazyvim.plugins.extras.lang.go" }, + { import = "lazyvim.plugins.extras.lang.clangd" }, + { import = "lazyvim.plugins.extras.lang.rust" }, + { import = "lazyvim.plugins.extras.lang.typescript" }, + { import = "lazyvim.plugins.extras.lang.python" }, + { import = "lazyvim.plugins.extras.lang.tailwind" }, + { import = "lazyvim.plugins.extras.lang.java" }, + { import = "lazyvim.plugins.extras.lang.json" }, + { import = "lazyvim.plugins.extras.lang.yaml" }, + { import = "lazyvim.plugins.extras.lang.toml" }, + { import = "lazyvim.plugins.extras.lang.docker" }, + { import = "plugins" }, + -- treesitter handled by xdg.configFile."nvim/parser", put this line at the end of spec to clear ensure_installed + { "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = {} + end, + }, + }, + }) + ''; + }; + + # https://github.com/nvim-treesitter/nvim-treesitter#i-get-query-error-invalid-node-type-at-position + xdg.configFile."nvim/parser".source = let + parsers = pkgs.symlinkJoin { + name = "treesitter-parsers"; + paths = + (pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: + with plugins; [ + bash + c + lua + python + go + rust + java + javascript + typescript + tsx + vue + html + css + json + yaml + toml + dockerfile + ])) + .dependencies; + }; + in "${parsers}/parser"; + + # Normal LazyVim config here, see https://github.com/LazyVim/starter/tree/main/lua + xdg.configFile."nvim/lua".source = ./lua; + + # Set default editor + home.sessionVariables.EDITOR = "nvim"; +} \ No newline at end of file diff --git a/home/nvim/lua/config/autocmds.lua b/home/nvim/lua/config/autocmds.lua new file mode 100644 index 0000000..4221e75 --- /dev/null +++ b/home/nvim/lua/config/autocmds.lua @@ -0,0 +1,8 @@ +-- Autocmds are automatically loaded on the VeryLazy event +-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua +-- +-- Add any additional autocmds here +-- with `vim.api.nvim_create_autocmd` +-- +-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults) +-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell") diff --git a/home/nvim/lua/config/keymaps.lua b/home/nvim/lua/config/keymaps.lua new file mode 100644 index 0000000..aa48b03 --- /dev/null +++ b/home/nvim/lua/config/keymaps.lua @@ -0,0 +1,31 @@ +-- Keymaps are automatically loaded on the VeryLazy event +-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua +-- Add any additional keymaps here + +local map = vim.keymap.set +local opts = { noremap = true, silent = true } + +-- === VSCode-like buffer/tab navigation === +map("n", "", "bnext", { desc = "Next buffer (like VSCode)" }) +map("n", "", "bprevious", { desc = "Previous buffer (like VSCode)" }) + +-- === Close buffer like Ctrl + W in VSCode === +vim.keymap.set("n", "", "BufferLinePickClose", { desc = "Close buffer (BufferLine)" }) + +vim.keymap.set("n", "", function() + if vim.bo.buftype == "terminal" then + vim.cmd("vsplit | terminal") + else + vim.cmd("botright split | terminal") + end +end, { desc = "Split terminal" }) + +-- 在终端模式下的快捷键 +vim.keymap.set("t", "", "h", { desc = "Go to left window" }) +vim.keymap.set("t", "", "j", { desc = "Go to lower window" }) +vim.keymap.set("t", "", "k", { desc = "Go to upper window" }) +vim.keymap.set("t", "", "l", { desc = "Go to right window" }) + +vim.keymap.set("n", "xo", function() + vim.fn.jobstart({ "xdg-open", vim.fn.expand("%:p") }, { detach = true }) +end, { desc = "使用系统默认应用程序打开当前文件" }) diff --git a/home/nvim/lua/config/lazy.lua b/home/nvim/lua/config/lazy.lua new file mode 100644 index 0000000..d73bfa1 --- /dev/null +++ b/home/nvim/lua/config/lazy.lua @@ -0,0 +1,53 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + spec = { + -- add LazyVim and import its plugins + { "LazyVim/LazyVim", import = "lazyvim.plugins" }, + -- import/override with your plugins + { import = "plugins" }, + }, + defaults = { + -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. + -- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default. + lazy = false, + -- It's recommended to leave version=false for now, since a lot the plugin that support versioning, + -- have outdated releases, which may break your Neovim install. + version = false, -- always use the latest git commit + -- version = "*", -- try installing the latest stable version for plugins that support semver + }, + install = { colorscheme = { "tokyonight", "habamax" } }, + checker = { + enabled = true, -- check for plugin updates periodically + notify = false, -- notify on update + }, -- automatically check for plugin updates + performance = { + rtp = { + -- disable some rtp plugins + disabled_plugins = { + "gzip", + -- "matchit", + -- "matchparen", + -- "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", + }, + }, + }, +}) diff --git a/home/nvim/lua/config/options.lua b/home/nvim/lua/config/options.lua new file mode 100644 index 0000000..3ea1454 --- /dev/null +++ b/home/nvim/lua/config/options.lua @@ -0,0 +1,3 @@ +-- Options are automatically loaded before lazy.nvim startup +-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua +-- Add any additional options here diff --git a/home/nvim/lua/plugins/colorscheme.lua b/home/nvim/lua/plugins/colorscheme.lua new file mode 100644 index 0000000..5fa6dfb --- /dev/null +++ b/home/nvim/lua/plugins/colorscheme.lua @@ -0,0 +1,16 @@ +return { + { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + opts = { + style = "storm", + }, + config = function(_, opts) + require("tokyonight").setup(opts) + vim.defer_fn(function() + vim.cmd([[colorscheme tokyonight]]) + end, 0) + end, + }, +} diff --git a/home/nvim/lua/plugins/dashboard.lua b/home/nvim/lua/plugins/dashboard.lua new file mode 100644 index 0000000..02a47d1 --- /dev/null +++ b/home/nvim/lua/plugins/dashboard.lua @@ -0,0 +1,18 @@ +-- ~/.config/nvim/lua/plugins/dashboard.lua +return { + "folke/snacks.nvim", + opts = { + dashboard = { + preset = { + header = [[ +███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ +████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║ +██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║ +██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║ +██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║ +╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + ]], + }, + }, + }, +} diff --git a/home/nvim/lua/plugins/osc52.lua b/home/nvim/lua/plugins/osc52.lua new file mode 100644 index 0000000..7a20603 --- /dev/null +++ b/home/nvim/lua/plugins/osc52.lua @@ -0,0 +1,18 @@ +return { + "ojroques/nvim-osc52", + config = function() + require("osc52").setup { + max_length = 0, -- 不限制长度 + silent = false, + trim = false, + } + + local function copy() + if vim.v.event.operator == "y" and vim.v.event.regname == "" then + require("osc52").copy_register("") + end + end + + vim.api.nvim_create_autocmd("TextYankPost", { callback = copy }) + end, +} diff --git a/home/tui/neovim.nix b/home/tui/neovim.nix deleted file mode 100644 index a6cd6c7..0000000 --- a/home/tui/neovim.nix +++ /dev/null @@ -1,5 +0,0 @@ -{pkgs, ...}: { - home.packages = with pkgs; [ - neovim - ]; -}