From 85f0f1e98b560bcbe19c38f64e3c87e1bb00325a Mon Sep 17 00:00:00 2001 From: sloane <1699281+sloanelybutsurely@users.noreply.github.com> Date: Wed, 3 Apr 2024 08:02:10 -0400 Subject: [PATCH] add separate nixvim config --- .config/nixvim/config/colorscheme.nix | 6 + .config/nixvim/config/default.nix | 9 + .config/nixvim/config/keys.nix | 91 +++++++ .config/nixvim/config/plugins.nix | 63 +++++ .config/nixvim/config/settings.nix | 10 + .config/nixvim/flake.lock | 336 ++++++++++++++++++++++++++ .config/nixvim/flake.nix | 51 ++++ 7 files changed, 566 insertions(+) create mode 100644 .config/nixvim/config/colorscheme.nix create mode 100644 .config/nixvim/config/default.nix create mode 100644 .config/nixvim/config/keys.nix create mode 100644 .config/nixvim/config/plugins.nix create mode 100644 .config/nixvim/config/settings.nix create mode 100644 .config/nixvim/flake.lock create mode 100644 .config/nixvim/flake.nix diff --git a/.config/nixvim/config/colorscheme.nix b/.config/nixvim/config/colorscheme.nix new file mode 100644 index 0000000..e665049 --- /dev/null +++ b/.config/nixvim/config/colorscheme.nix @@ -0,0 +1,6 @@ +{ + colorschemes.catppuccin = { + enable = true; + flavour = "frappe"; + }; +} diff --git a/.config/nixvim/config/default.nix b/.config/nixvim/config/default.nix new file mode 100644 index 0000000..5fc8bfd --- /dev/null +++ b/.config/nixvim/config/default.nix @@ -0,0 +1,9 @@ +{ + # Import all your configuration modules here + imports = [ + ./settings.nix + ./plugins.nix + ./keys.nix + ./colorscheme.nix + ]; +} diff --git a/.config/nixvim/config/keys.nix b/.config/nixvim/config/keys.nix new file mode 100644 index 0000000..63c2cee --- /dev/null +++ b/.config/nixvim/config/keys.nix @@ -0,0 +1,91 @@ +{ + plugins.which-key = { + enable = true; + keyLabels = { + "" = "SPC"; + "" = "RET"; + "" = "TAB"; + }; + registrations = { + "g" = "Git"; + }; + }; + + globals.mapleader = " "; + + keymaps = [ + { key = ";"; action = ":"; } + { key = "q;"; action = "q:"; } + + { key = "y"; action = "\"+y"; } + { key = "Y"; action = "\"+Y"; } + { key = "p"; action = "\"+p"; } + { key = "P"; action = "\"+P"; } + + { key = "w"; action = "w"; } + { key = "q"; action = "q"; } + { key = ""; action = "nohlsearch"; mode = "n"; } + + # root level leader commands + { + key = ""; + action = "Telescope find_files"; + options = { desc = "Find files in project"; }; + } + { + key = "/"; + action = "Telescope live_grep"; + options = { desc = "Search project"; }; + } + { + key = ""; + action = "NERDTreeToggle"; + options = { desc = "Toggle NERDTree"; }; + } + + # git + { + key = "gs"; + action = "Git"; + options = { desc = "Status"; }; + } + { + key = "gp"; + action = "Git push"; + options = { desc = "Push"; }; + } + { + key = "gP"; + action = "Git push --force-with-lease"; + options = { desc = "Push (force with lease)"; }; + } + { + key = "gf"; + action = "Git fetch"; + options = { desc = "Fetch"; }; + } + # git rebase + { + key = "gro"; + action = "Git rebase origin/main"; + options = { desc = "origin/main"; }; + } + { + + key = "grO"; + action = "Git rebase --interactive origin/main"; + options = { desc = "-i origin/main"; }; + } + { + + key = "grm"; + action = "Git rebase origin/master"; + options = { desc = "origin/master"; }; + } + { + key = "grM"; + action = "Git rebase --interactive origin/master"; + options = { desc = "-i origin/master"; }; + } + ]; +} diff --git a/.config/nixvim/config/plugins.nix b/.config/nixvim/config/plugins.nix new file mode 100644 index 0000000..75f1532 --- /dev/null +++ b/.config/nixvim/config/plugins.nix @@ -0,0 +1,63 @@ +{ pkgs, ... }: +{ + extraPlugins = with pkgs.vimPlugins; [ + vim-abolish + vim-dispatch + vim-repeat + vim-sensible + + vim-rhubarb + vim-sort-motion + vim-textobj-user + + nerdtree + ]; + + plugins = { + surround.enable = true; + commentary.enable = true; + + fugitive.enable = true; + + tmux-navigator.enable = true; + + lsp = { + enable = true; + servers = { + elixirls.enable = true; + tsserver.enable = true; + nil_ls.enable = true; + }; + }; + + telescope = { + enable = true; + defaults = { preview = false; }; + extensions.fzf-native.enable = true; + }; + + cmp = { + enable = true; + autoEnableSources = true; + settings.sources = [ + { name = "nvim_lsp"; } + { name = "path"; } + { name = "buffer"; } + ]; + cmdline = { + ":" = { + mapping = { __raw = "cmp.mapping.preset.cmdline()"; }; + sources = [ + { name = "path"; } + { name = "cmdline"; } + ]; + }; + }; + }; + + treesitter = { + enable = true; + indent = true; + }; + }; +} diff --git a/.config/nixvim/config/settings.nix b/.config/nixvim/config/settings.nix new file mode 100644 index 0000000..c051f57 --- /dev/null +++ b/.config/nixvim/config/settings.nix @@ -0,0 +1,10 @@ +{ + config.options = { + number = true; + relativenumber = true; + + tabstop = 2; + shiftwidth = 2; + expandtab = true; + }; +} diff --git a/.config/nixvim/flake.lock b/.config/nixvim/flake.lock new file mode 100644 index 0000000..11b3e41 --- /dev/null +++ b/.config/nixvim/flake.lock @@ -0,0 +1,336 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1711099426, + "narHash": "sha256-HzpgM/wc3aqpnHJJ2oDqPBkNsqWbW0WfWUO8lKu8nGk=", + "owner": "numtide", + "repo": "devshell", + "rev": "2d45b54ca4a183f2fdcf4b19c895b64fbf620ee8", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-compat": { + "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-compat_2": { + "flake": false, + "locked": { + "lastModified": 1696426674, + "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1709336216, + "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709336216, + "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "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" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixvim", + "pre-commit-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": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1711133180, + "narHash": "sha256-WJOahf+6115+GMl3wUfURu8fszuNeJLv9qAWFQl3Vmo=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "1c2c5e4cabba4c43504ef0f8cc3f3dfa284e2dbb", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nix-darwin": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1710717205, + "narHash": "sha256-Wf3gHh5uV6W1TV/A8X8QJf99a5ypDSugY4sNtdJDe0A=", + "owner": "lnl7", + "repo": "nix-darwin", + "rev": "bcc8afd06e237df060c85bad6af7128e05fd61a3", + "type": "github" + }, + "original": { + "owner": "lnl7", + "repo": "nix-darwin", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1711163522, + "narHash": "sha256-YN/Ciidm+A0fmJPWlHBGvVkcarYWSC+s3NTPk/P+q3c=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "44d0940ea560dee511026a53f0e2e2cde489b4d4", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1709237383, + "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1711001935, + "narHash": "sha256-URtGpHue7HHZK0mrHnSf8wJ6OmMKYSsoLmJybrOLFSQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "20f77aa09916374aa3141cbc605c955626762c9a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "devshell": "devshell", + "flake-compat": "flake-compat", + "flake-parts": "flake-parts_2", + "home-manager": "home-manager", + "nix-darwin": "nix-darwin", + "nixpkgs": "nixpkgs_2", + "pre-commit-hooks": "pre-commit-hooks" + }, + "locked": { + "lastModified": 1711199922, + "narHash": "sha256-Oz5WNOPp95K4JLyoNQKyEdaUM5JzliC62jwTpGPqYNE=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "7170aad28139cd3629b2b6ce4c9272bf41c2ad45", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat_2", + "flake-utils": "flake-utils_2", + "gitignore": "gitignore", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "nixpkgs-stable": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1710923068, + "narHash": "sha256-6hOpUiuxuwpXXc/xfJsBUJeqqgGI+JMJuLo45aG3cKc=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "e611897ddfdde3ed3eaac4758635d7177ff78673", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "nixvim": "nixvim" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "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" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/.config/nixvim/flake.nix b/.config/nixvim/flake.nix new file mode 100644 index 0000000..8ce0cb9 --- /dev/null +++ b/.config/nixvim/flake.nix @@ -0,0 +1,51 @@ +{ + description = "sloane's neovim config via nix"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nixvim.url = "github:nix-community/nixvim"; + flake-parts.url = "github:hercules-ci/flake-parts"; + }; + + outputs = { + nixvim, + flake-parts, + ... + } @ inputs: + flake-parts.lib.mkFlake {inherit inputs;} { + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + + perSystem = { + pkgs, + system, + ... + }: let + nixvimLib = nixvim.lib.${system}; + nixvim' = nixvim.legacyPackages.${system}; + nixvimModule = { + inherit pkgs; + module = import ./config; # import the module directly + # You can use `extraSpecialArgs` to pass additional arguments to your module files + extraSpecialArgs = { + # inherit (inputs) foo; + }; + }; + nvim = nixvim'.makeNixvimWithModule nixvimModule; + in { + checks = { + # Run `nix flake check .` to verify that your config is not broken + default = nixvimLib.check.mkTestDerivationFromNixvimModule nixvimModule; + }; + + packages = { + # Lets you run `nix run .` to start nixvim + default = nvim; + }; + }; + }; +}