diff --git a/flake.lock b/flake.lock index 547ffca..7f72b6f 100755 --- a/flake.lock +++ b/flake.lock @@ -91,6 +91,27 @@ "type": "github" } }, + "devshell": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722113426, + "narHash": "sha256-Yo/3loq572A8Su6aY5GP56knpuKYRvM2a1meP9oJZCw=", + "owner": "numtide", + "repo": "devshell", + "rev": "67cce7359e4cd3c45296fb4aaf6a19e2a9c757ae", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, "flake-compat": { "locked": { "lastModified": 1688025799, @@ -122,6 +143,20 @@ "type": "github" } }, + "flake-compat_3": { + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "revCount": 57, + "type": "tarball", + "url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.0.1/018afb31-abd1-7bff-a5e4-cff7e18efb7a/source.tar.gz" + }, + "original": { + "type": "tarball", + "url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz" + } + }, "flake-parts": { "inputs": { "nixpkgs-lib": [ @@ -143,6 +178,27 @@ "type": "github" } }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722555600, + "narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "8471fe90ad337a8074e957b69ca4d0089218391d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -197,6 +253,24 @@ "type": "github" } }, + "flake-utils_4": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "flakey-profile": { "locked": { "lastModified": 1712898590, @@ -212,6 +286,36 @@ "type": "github" } }, + "git-hooks": { + "inputs": { + "flake-compat": [ + "nixvim", + "flake-compat" + ], + "gitignore": "gitignore_2", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1723202784, + "narHash": "sha256-qbhjc/NEGaDbyy0ucycubq4N3//gDFFH3DOmp1D3u1Q=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "c7012d0c18567c889b948781bc74a501e92275d1", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -234,6 +338,28 @@ "type": "github" } }, + "gitignore_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "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" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -254,6 +380,27 @@ "type": "github" } }, + "home-manager_2": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1723399884, + "narHash": "sha256-97wn0ihhGqfMb8WcUgzzkM/TuAxce2Gd20A8oiruju4=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "086f619dd991a4d355c07837448244029fc2d9ab", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, "homebrew-cask": { "flake": false, "locked": { @@ -386,6 +533,27 @@ "type": "github" } }, + "nix-darwin_3": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722924007, + "narHash": "sha256-+CQDamNwqO33REJLft8c26NbUi2Td083hq6SvAm2xkU=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "91010a5613ffd7ee23ee9263213157a1c422b705", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, "nix-homebrew": { "inputs": { "brew-src": "brew-src", @@ -468,6 +636,56 @@ "type": "github" } }, + "nixvim": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat_3", + "flake-parts": "flake-parts_2", + "git-hooks": "git-hooks", + "home-manager": "home-manager_2", + "nix-darwin": "nix-darwin_3", + "nixpkgs": [ + "nixpkgs" + ], + "nuschtosSearch": "nuschtosSearch", + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1723816538, + "narHash": "sha256-h37ltjdifkd7iLtMtBXSBBeYSTuBEKMW6ClFoC7nReQ=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "00f32f0430f82c74919c72af84bc95bf5ae434e4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "nuschtosSearch": { + "inputs": { + "flake-utils": "flake-utils_4", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1723367906, + "narHash": "sha256-v1qA4WBGDI2uH/TVqRwuXSBP341W681psbzYJ8zrjog=", + "owner": "NuschtOS", + "repo": "search", + "rev": "6ca2c3ae05a915c160512bd41f6810f456c9b30d", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "repo": "search", + "type": "github" + } + }, "pre-commit-hooks-nix": { "inputs": { "flake-compat": [ @@ -508,6 +726,7 @@ "nix-darwin": "nix-darwin", "nix-homebrew": "nix-homebrew", "nixpkgs": "nixpkgs_3", + "nixvim": "nixvim", "stablepkgs": "stablepkgs" } }, @@ -612,6 +831,42 @@ "repo": "default", "type": "github" } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1723454642, + "narHash": "sha256-S0Gvsenh0II7EAaoc9158ZB4vYyuycvMGKGxIbERNAM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "349de7bc435bdff37785c2466f054ed1766173be", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 304e4e8..593cd6f 100755 --- a/flake.nix +++ b/flake.nix @@ -35,6 +35,10 @@ url = "github:tpwrules/nixos-apple-silicon"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = { @@ -79,8 +83,10 @@ ./users/youwen/linux/packages/x86_64 ./users/youwen/linux/programs ./users/youwen/common/neofetch + ./users/youwen/common/neovim ./users/youwen/common inputs.catppuccin.homeManagerModules.catppuccin + inputs.nixvim.homeManagerModules.nixvim ]; }; } @@ -111,8 +117,10 @@ ./users/youwen/common/neofetch/asahi-only.nix ./users/youwen/linux/laptop ./users/youwen/linux/packages/aarch-64 + ./users/youwen/common/neovim inputs.catppuccin.homeManagerModules.catppuccin + inputs.nixvim.homeManagerModules.nixvim ]; }; } @@ -151,10 +159,12 @@ ./users/youwen/linux/laptop ./users/youwen/linux/packages/x86_64 ./users/youwen/linux/programs + ./users/youwen/common/neovim ./users/youwen/common ./users/youwen/common/neofetch ./hosts/adrastea/home-manager-overrides.nix inputs.catppuccin.homeManagerModules.catppuccin + inputs.nixvim.homeManagerModules.nixvim ]; }; } @@ -177,6 +187,7 @@ ./users/youwen/darwin/darwin-home.nix ./users/youwen/common/core.nix ./users/youwen/common/neofetch + ./users/youwen/common/neovim ]; home-manager.backupFileExtension = "backup"; diff --git a/users/youwen/common/core.nix b/users/youwen/common/core.nix index 091ada1..22d43af 100755 --- a/users/youwen/common/core.nix +++ b/users/youwen/common/core.nix @@ -147,11 +147,4 @@ enableFishIntegration = true; enableBashIntegration = true; }; - - programs.neovim = { - enable = true; - defaultEditor = true; - viAlias = true; - vimAlias = true; - }; } diff --git a/users/youwen/common/neovim/default.nix b/users/youwen/common/neovim/default.nix new file mode 100644 index 0000000..8f4ba04 --- /dev/null +++ b/users/youwen/common/neovim/default.nix @@ -0,0 +1,291 @@ +{pkgs, ...}: { + programs.nixvim = { + enable = true; + viAlias = true; + vimAlias = true; + withNodeJs = true; + withRuby = true; + + extraPackages = with pkgs; [alejandra black stylua codespell]; + + luaLoader.enable = true; + + colorschemes.gruvbox.enable = true; + + opts = { + showmode = false; + }; + + globals = { + mapleader = " "; + }; + + keymaps = [ + { + # Unmap space (leader) + action = ""; + key = ""; + options = { + noremap = true; + silent = true; + }; + mode = "n"; + } + { + action = "sp"; + key = "-"; + options.silent = true; + options.desc = "Split window horizontally"; + } + { + action = "vsp"; + key = "|"; + options.silent = true; + options.desc = "Split window vertically"; + } + { + action = "ZenMode"; + key = "wz"; + options = { + silent = true; + noremap = true; + desc = "Zen mode"; + }; + } + { + action = "h"; + key = ""; + options = { + silent = true; + noremap = true; + desc = "Move to left window"; + }; + } + { + action = "j"; + key = ""; + options = { + silent = true; + noremap = true; + desc = "Move to lower window"; + }; + } + { + action = "k"; + key = ""; + options = { + silent = true; + noremap = true; + desc = "Move to upper window"; + }; + } + { + action = "l"; + key = ""; + options = { + silent = true; + noremap = true; + desc = "Move to right window"; + }; + } + { + action = "close"; + key = "wd"; + options = { + silent = true; + noremap = true; + desc = "Close current window"; + }; + } + { + action = "Telescope find_files"; + key = "ff"; + options = { + silent = true; + noremap = true; + desc = "Find files"; + }; + } + { + action = "Telescope live_grep"; + key = "/"; + options = { + silent = true; + noremap = true; + desc = "Live grep"; + }; + } + { + action = "Telescope buffers"; + key = "fb"; + options = { + silent = true; + noremap = true; + desc = "List buffers"; + }; + } + { + action = "Telescope help_tags"; + key = "fh"; + options = { + silent = true; + noremap = true; + desc = "Help tags"; + }; + } + { + action = "lua require'telescope.builtin'.lsp_definitions{}"; + key = "gd"; + options = { + silent = true; + noremap = true; + desc = "Go to definition"; + }; + } + { + action = "lua require'telescope.builtin'.git_files{}"; + key = " "; + options = { + silent = true; + noremap = true; + desc = "List Git files"; + }; + } + { + action = "lua require'telescope.builtin'.find_files{}"; + key = "ff"; + options = { + silent = true; + noremap = true; + desc = "List all files"; + }; + } + # { + # action = "lua require'conform'.format({ bufnr = args.bf })"; + # key = "cf"; + # options = { + # silent = true; + # noremap = true; + # desc = "Format buffer"; + # }; + # } + ]; + + plugins = { + lualine = { + enable = true; + globalstatus = true; + }; + lsp = { + enable = true; + inlayHints = true; + servers = { + bashls.enable = true; + clangd.enable = true; + hls.enable = true; + pyright.enable = true; + nixd.enable = true; + nushell.enable = true; + svelte.enable = true; + tailwindcss.enable = true; + typst-lsp.enable = true; + rust-analyzer = { + enable = true; + installCargo = true; + installRustc = true; + }; + marksman.enable = true; + }; + }; + presence-nvim = { + enable = true; + editingText = "Hacking %s"; + workspaceText = "The One True Text Editor"; + buttons = [ + { + label = "GitHub"; + url = "https://github.com/youwen5"; + } + { + label = "Code Forge"; + url = "https://code.youwen.dev/"; + } + ]; + }; + treesitter = { + enable = true; + settings = { + highlight.enable = true; + indent.enable = true; + }; + }; + wakatime.enable = true; + lazygit.enable = true; + intellitab.enable = true; + guess-indent.enable = true; + indent-blankline.enable = true; + which-key.enable = true; + zen-mode.enable = true; + markdown-preview.enable = true; + yanky = { + enable = true; + enableTelescope = true; + }; + telescope = { + enable = true; + }; + mini = { + enable = true; + modules = { + surround = {}; + pairs = {}; + ai = {}; + hipatterns = {}; + notify = {}; + tabline = {}; + trailspace = {}; + comment = {}; + }; + }; + trouble.enable = true; + direnv.enable = true; + cmp = { + enable = true; + settings = { + mapping = { + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.close()"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})"; + "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; + "" = "cmp.mapping.confirm({ select = true })"; + }; + completion.autocomplete = [ + "require('cmp.types').cmp.TriggerEvent.TextChanged" + ]; + }; + }; + cmp-async-path.enable = true; + cmp-buffer.enable = true; + cmp-conventionalcommits.enable = true; + cmp-git.enable = true; + cmp-nvim-lsp.enable = true; + crates-nvim.enable = true; + conform-nvim = { + enable = true; + formatOnSave = { + timeoutMs = 500; + lspFallback = true; + }; + formattersByFt = { + lua = ["stylua"]; + python = ["black"]; + nix = ["alejandra"]; + "*" = ["codespell"]; + "_" = ["trim_whitespace"]; + }; + }; + }; + }; +}