From 0e26a915c856f65e296d4c986ac63a6050886c73 Mon Sep 17 00:00:00 2001 From: dichgrem Date: Wed, 24 Dec 2025 19:11:10 +0800 Subject: [PATCH] feat:lazyvim-nix add:opencode --- flake.lock | 57 ++++++- flake.nix | 14 +- home/nvim/default.nix | 232 +++++---------------------- home/nvim/lua/config/autocmds.lua | 8 - home/nvim/lua/config/lazy.lua | 53 ------ home/nvim/lua/plugins/copilot.lua | 28 ---- home/nvim/lua/plugins/treesitter.lua | 30 ---- modules/system/environment.nix | 3 +- 8 files changed, 105 insertions(+), 320 deletions(-) delete mode 100644 home/nvim/lua/config/autocmds.lua delete mode 100644 home/nvim/lua/config/lazy.lua delete mode 100644 home/nvim/lua/plugins/copilot.lua delete mode 100644 home/nvim/lua/plugins/treesitter.lua diff --git a/flake.lock b/flake.lock index b663e62..2c81d93 100644 --- a/flake.lock +++ b/flake.lock @@ -105,6 +105,24 @@ "type": "github" } }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "fromYaml": { "flake": false, "locked": { @@ -160,6 +178,27 @@ "type": "github" } }, + "lazyvim": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1765315270, + "narHash": "sha256-E06fubkv6gWLiQd/K0njl8wtFShu30rDLNRhf/LRma0=", + "owner": "pfassina", + "repo": "lazyvim-nix", + "rev": "a3615f3ac58cefacb83123643394f88d09006912", + "type": "github" + }, + "original": { + "owner": "pfassina", + "repo": "lazyvim-nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1766309749, @@ -204,6 +243,7 @@ "root": { "inputs": { "home-manager": "home-manager", + "lazyvim": "lazyvim", "nixpkgs": "nixpkgs", "stylix": "stylix" } @@ -221,7 +261,7 @@ "nixpkgs" ], "nur": "nur", - "systems": "systems", + "systems": "systems_2", "tinted-foot": "tinted-foot", "tinted-kitty": "tinted-kitty", "tinted-schemes": "tinted-schemes", @@ -257,6 +297,21 @@ "type": "github" } }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "tinted-foot": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 1cf6ded..6c31adc 100644 --- a/flake.nix +++ b/flake.nix @@ -2,17 +2,17 @@ description = "🥶"; inputs = { + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + home-manager.url = "github:nix-community/home-manager"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + lazyvim.inputs.nixpkgs.follows = "nixpkgs"; + lazyvim.url = "github:pfassina/lazyvim-nix"; + stylix.inputs.nixpkgs.follows = "nixpkgs"; + stylix.url = "github:danth/stylix"; # chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable"; # daeuniverse.url = "github:daeuniverse/flake.nix"; # disko.inputs.nixpkgs.follows = "nixpkgs"; # disko.url = "github:nix-community/disko"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; - home-manager.url = "github:nix-community/home-manager"; - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - # nixvim.inputs.nixpkgs.follows = "nixpkgs"; - # nixvim.url = "github:nix-community/nixvim"; - stylix.inputs.nixpkgs.follows = "nixpkgs"; - stylix.url = "github:danth/stylix"; }; outputs = inputs: let diff --git a/home/nvim/default.nix b/home/nvim/default.nix index 51cd097..62dffbc 100644 --- a/home/nvim/default.nix +++ b/home/nvim/default.nix @@ -1,233 +1,81 @@ -{ config -, lib -, pkgs -, ... -}: { - programs.neovim = { +{ inputs, config, lib, pkgs, ... }: +{ + imports = [ inputs.lazyvim.homeManagerModules.default ]; + programs.lazyvim = { enable = true; + + configFiles = ./lua; + + extras = { + lang = { + go.enable = true; + clangd.enable = true; + rust.enable = true; + typescript.enable = true; + python.enable = true; + tailwind.enable = true; + java.enable = true; + json.enable = true; + yaml.enable = true; + toml.enable = true; + docker.enable = true; + kotlin.enable = true; + dart.enable = true; + nix.enable = true; + }; + }; + extraPackages = with pkgs; [ - #Go + # All + tree-sitter + + # Go gopls gofumpt golines - #Lua + # Lua stylua lua-language-server - #Nix + # Nix nixd nixpkgs-fmt - #Java + # Java google-java-format jdt-language-server - #Rust + # Rust clippy rustfmt rust-analyzer - #Shell + # Shell shfmt bash-language-server - #C/C++ + # C/C++ clang-tools - #Kotlin + # Kotlin ktlint kotlin-language-server - #Python + # Python ruff black python312Packages.python-lsp-server - #JS/TS/Web + # JS/TS/Web biome prettierd nodePackages.prettier + # Data formats jq #JSON taplo #TOML yamlfmt #YAML ]; - - 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 - neo-tree-nvim - neoconf-nvim - neodev-nvim - noice-nvim - nui-nvim - nvim-lint - nvim-lspconfig - nvim-notify - nvim-spectre - nvim-treesitter - nvim-treesitter-context - 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 = "lazyvim.plugins.extras.lang.kotlin" }, - { import = "lazyvim.plugins.extras.lang.dart" }, - { 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 - go - lua - rust - java - dart - kotlin - python - 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; } diff --git a/home/nvim/lua/config/autocmds.lua b/home/nvim/lua/config/autocmds.lua deleted file mode 100644 index 4221e75..0000000 --- a/home/nvim/lua/config/autocmds.lua +++ /dev/null @@ -1,8 +0,0 @@ --- 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/lazy.lua b/home/nvim/lua/config/lazy.lua deleted file mode 100644 index 343d042..0000000 --- a/home/nvim/lua/config/lazy.lua +++ /dev/null @@ -1,53 +0,0 @@ -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/plugins/copilot.lua b/home/nvim/lua/plugins/copilot.lua deleted file mode 100644 index c222e7a..0000000 --- a/home/nvim/lua/plugins/copilot.lua +++ /dev/null @@ -1,28 +0,0 @@ -return { - { - "zbirenbaum/copilot.lua", - cmd = "Copilot", - event = "InsertEnter", - config = function() - require("copilot").setup({ - suggestion = { enabled = true, auto_trigger = true }, - }) - end, - }, - - { - "CopilotC-Nvim/CopilotChat.nvim", - branch = "main", - dependencies = { - { "zbirenbaum/copilot.lua" }, - { "nvim-lua/plenary.nvim" }, - }, - opts = { - debug = false, - }, - keys = { - { "cc", "CopilotChatToggle", desc = "CopilotChat - Toggle" }, - { "ce", "CopilotChatExplain", mode = "v", desc = "CopilotChat - Explain code" }, - }, - }, -} diff --git a/home/nvim/lua/plugins/treesitter.lua b/home/nvim/lua/plugins/treesitter.lua deleted file mode 100644 index 805c2eb..0000000 --- a/home/nvim/lua/plugins/treesitter.lua +++ /dev/null @@ -1,30 +0,0 @@ -return { - { - "LazyVim/LazyVim", - opts = { - treesitter = false, - }, - }, - { - "nvim-treesitter/nvim-treesitter", - event = { "BufReadPost", "BufNewFile" }, - opts = { - ensure_installed = {}, - auto_install = false, - highlight = { enable = true }, - indent = { enable = true }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "gnn", - node_incremental = "grn", - scope_incremental = "grc", - node_decremental = "grm", - }, - }, - }, - config = function(_, opts) - require("nvim-treesitter.configs").setup(opts) - end, - }, -} \ No newline at end of file diff --git a/modules/system/environment.nix b/modules/system/environment.nix index a12a050..b06e8c3 100644 --- a/modules/system/environment.nix +++ b/modules/system/environment.nix @@ -70,6 +70,7 @@ in { lm_sensors usbutils libsecret + lsof # Niri wlr-randr @@ -95,7 +96,7 @@ in { nodejs_24 # Agent - codex + opencode gemini-cli ]; };