From d1adefae9d4cffb0f27103d4bd1507d4df842371 Mon Sep 17 00:00:00 2001 From: Natalie Date: Mon, 21 Apr 2025 14:46:41 -0700 Subject: [PATCH] initial nixvim --- flake.lock | 152 ++++++++++++++++++++++++++--- flake.nix | 5 + hosts/laptop/home.nix | 8 +- lib/mkSystem.nix | 1 + modules/nixvim/default.nix | 98 +++++++++++++++++++ modules/nixvim/keymaps.nix | 42 ++++++++ modules/nixvim/opts.nix | 65 ++++++++++++ modules/nixvim/plugins/default.nix | 0 8 files changed, 358 insertions(+), 13 deletions(-) create mode 100644 modules/nixvim/default.nix create mode 100644 modules/nixvim/keymaps.nix create mode 100644 modules/nixvim/opts.nix create mode 100644 modules/nixvim/plugins/default.nix diff --git a/flake.lock b/flake.lock index 80d90dd..93b44f8 100644 --- a/flake.lock +++ b/flake.lock @@ -168,6 +168,27 @@ } }, "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1743550720, + "narHash": "sha256-hIshGgKZCgWh6AYJpJmRgFdR3WUbkY04o82X05xqQiY=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "c621e8422220273271f52058f618c94e405bb0f5", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-parts_2": { "inputs": { "nixpkgs-lib": [ "stylix", @@ -226,6 +247,24 @@ } }, "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "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" + } + }, + "flake-utils_4": { "inputs": { "systems": [ "stylix", @@ -246,9 +285,9 @@ "type": "github" } }, - "flake-utils_4": { + "flake-utils_5": { "inputs": { - "systems": "systems_4" + "systems": "systems_5" }, "locked": { "lastModified": 1705309234, @@ -264,9 +303,9 @@ "type": "github" } }, - "flake-utils_5": { + "flake-utils_6": { "inputs": { - "systems": "systems_5" + "systems": "systems_6" }, "locked": { "lastModified": 1710146030, @@ -282,9 +321,9 @@ "type": "github" } }, - "flake-utils_6": { + "flake-utils_7": { "inputs": { - "systems": "systems_6" + "systems": "systems_7" }, "locked": { "lastModified": 1705309234, @@ -460,6 +499,34 @@ "type": "github" } }, + "ixx": { + "inputs": { + "flake-utils": [ + "nixvim", + "nuschtosSearch", + "flake-utils" + ], + "nixpkgs": [ + "nixvim", + "nuschtosSearch", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737371634, + "narHash": "sha256-fTVAWzT1UMm1lT+YxHuVPtH+DATrhYfea3B0MxG/cGw=", + "owner": "NuschtOS", + "repo": "ixx", + "rev": "a1176e2a10ce745ff8f63e4af124ece8fe0b1648", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "ref": "v0.0.7", + "repo": "ixx", + "type": "github" + } + }, "langref": { "flake": false, "locked": { @@ -670,9 +737,31 @@ "type": "github" } }, - "nur": { + "nixvim": { "inputs": { "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs" + ], + "nuschtosSearch": "nuschtosSearch" + }, + "locked": { + "lastModified": 1745244491, + "narHash": "sha256-UlwXkytxGW/aokB9fZ6cSznYKM9ynDLHqhjcPve0KL4=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "7a58109958d14bcece8ec3e2085e41ea3351e387", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "nur": { + "inputs": { + "flake-parts": "flake-parts_2", "nixpkgs": [ "stylix", "nixpkgs" @@ -693,6 +782,29 @@ "type": "github" } }, + "nuschtosSearch": { + "inputs": { + "flake-utils": "flake-utils_3", + "ixx": "ixx", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1745046075, + "narHash": "sha256-8v4y6k16Ra/fiecb4DxhsoOGtzLKgKlS+9/XJ9z0T2I=", + "owner": "NuschtOS", + "repo": "search", + "rev": "066afe8643274470f4a294442aadd988356a478f", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "repo": "search", + "type": "github" + } + }, "root": { "inputs": { "darwin": "darwin", @@ -704,6 +816,7 @@ "nixos-cosmic": "nixos-cosmic", "nixpkgs": "nixpkgs_2", "nixpkgs-stable": "nixpkgs-stable_2", + "nixvim": "nixvim", "rust-overlay": "rust-overlay_2", "stylix": "stylix", "zig": "zig", @@ -759,7 +872,7 @@ "base16-vim": "base16-vim", "firefox-gnome-theme": "firefox-gnome-theme", "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_4", "git-hooks": "git-hooks", "gnome-shell": "gnome-shell", "home-manager": "home-manager_2", @@ -767,7 +880,7 @@ "nixpkgs" ], "nur": "nur", - "systems": "systems_3", + "systems": "systems_4", "tinted-foot": "tinted-foot", "tinted-kitty": "tinted-kitty", "tinted-schemes": "tinted-schemes", @@ -878,6 +991,21 @@ "type": "github" } }, + "systems_7": { + "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": { @@ -985,7 +1113,7 @@ "zig": { "inputs": { "flake-compat": "flake-compat_3", - "flake-utils": "flake-utils_4", + "flake-utils": "flake-utils_5", "nixpkgs": "nixpkgs_3" }, "locked": { @@ -1005,7 +1133,7 @@ "zig-overlay": { "inputs": { "flake-compat": "flake-compat_4", - "flake-utils": "flake-utils_6", + "flake-utils": "flake-utils_7", "nixpkgs": [ "zls", "nixpkgs" @@ -1027,7 +1155,7 @@ }, "zls": { "inputs": { - "flake-utils": "flake-utils_5", + "flake-utils": "flake-utils_6", "gitignore": "gitignore_3", "langref": "langref", "nixpkgs": "nixpkgs_4", diff --git a/flake.nix b/flake.nix index 1b24c96..a630079 100644 --- a/flake.nix +++ b/flake.nix @@ -13,6 +13,11 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + darwin = { url = "github:lnl7/nix-darwin/master"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/hosts/laptop/home.nix b/hosts/laptop/home.nix index 8b91846..5707977 100644 --- a/hosts/laptop/home.nix +++ b/hosts/laptop/home.nix @@ -4,9 +4,15 @@ pkgs, lib, userSettings, + systemSettings, ... }: { - programs = import ../../modules/shared/homeManagerPrograms.nix {inherit inputs config pkgs lib userSettings;}; + imports = [ + inputs.nixvim.homeManagerModules.nixvim + #set up nixvim + ../../modules/nixvim + ]; + programs = import ../../modules/shared/homeManagerPrograms.nix {inherit inputs config pkgs lib userSettings systemSettings;}; home = { inherit (userSettings) username; diff --git a/lib/mkSystem.nix b/lib/mkSystem.nix index 7b97346..435f9fd 100644 --- a/lib/mkSystem.nix +++ b/lib/mkSystem.nix @@ -21,6 +21,7 @@ else inputs.stylix.nixosModules.stylix; systemSettings = rec { + inherit darwin; host = if darwin then userSettings.darwinHost diff --git a/modules/nixvim/default.nix b/modules/nixvim/default.nix new file mode 100644 index 0000000..19b3946 --- /dev/null +++ b/modules/nixvim/default.nix @@ -0,0 +1,98 @@ +{ + pkgs, + inputs, + nixvim, + ... +}: { + imports = [ + ./opts.nix + ./keymaps.nix + ./plugins + ]; + programs.nixvim = { + enable = true; + + defaultEditor = true; + + globals = { + #Set leader to space, and localleader to \ + mapleader = " "; + maplocalleader = "\\"; + + have_nerd_font = true; + }; + + clipboard = { + providers = { + wl-copy.enable = true; # For Wayland + xsel.enable = true; # For X11 + }; + + # Sync clipboard between OS and Neovim + # Remove this option if you want your OS clipboard to remain independent. + register = "unnamedplus"; + }; + + opts = { + # Show line numbers + number = true; + # You can also add relative line numbers, to help with jumping. + # Experiment for yourself to see if you like it! + #relativenumber = true + + # Enable mouse mode, can be useful for resizing splits for example! + mouse = "a"; + + # Don't show the mode, since it's already in the statusline + showmode = false; + + # Enable break indent + breakindent = true; + + # Save undo history + undofile = true; + + # Case-insensitive searching UNLESS \C or one or more capital letters in the search term + ignorecase = true; + smartcase = true; + + # Keep signcolumn on by default + signcolumn = "yes"; + + # Decrease update time + updatetime = 250; + + # Decrease mapped sequence wait time + # Displays which-key popup sooner + timeoutlen = 300; + + # Configure how new splits should be opened + splitright = true; + splitbelow = true; + + # Sets how neovim will display certain whitespace characters in the editor + # See `:help 'list'` + # and `:help 'listchars'` + list = true; + # NOTE: .__raw here means that this field is raw lua code + listchars.__raw = "{ tab = '» ', trail = '·', nbsp = '␣' }"; + + # Preview substitutions live, as you type! + inccommand = "split"; + + # Show which line your cursor is on + cursorline = true; + + # Minimal number of screen lines to keep above and below the cursor. + scrolloff = 10; + + # if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), + # instead raise a dialog asking if you wish to save the current file(s) + # See `:help 'confirm'` + confirm = true; + + # See `:help hlsearch` + hlsearch = true; + }; + }; +} diff --git a/modules/nixvim/keymaps.nix b/modules/nixvim/keymaps.nix new file mode 100644 index 0000000..8710d6b --- /dev/null +++ b/modules/nixvim/keymaps.nix @@ -0,0 +1,42 @@ +{pkgs, ...}: { + programs.nixvim = { + keymaps = [ + # Keybinds to make split navigation easier. + # Use CTRL+ to switch between windows + # + # See `:help wincmd` for a list of all window commands + { + mode = "n"; + key = ""; + action = ""; + options = { + desc = "Move focus to the left window"; + }; + } + { + mode = "n"; + key = ""; + action = ""; + options = { + desc = "Move focus to the right window"; + }; + } + { + mode = "n"; + key = ""; + action = ""; + options = { + desc = "Move focus to the lower window"; + }; + } + { + mode = "n"; + key = ""; + action = ""; + options = { + desc = "Move focus to the upper window"; + }; + } + ]; + }; +} diff --git a/modules/nixvim/opts.nix b/modules/nixvim/opts.nix new file mode 100644 index 0000000..cb36614 --- /dev/null +++ b/modules/nixvim/opts.nix @@ -0,0 +1,65 @@ +{pkgs, ...}: { + programs.nixvim = { + opts = { + # Show line numbers + number = true; + # You can also add relative line numbers, to help with jumping. + # Experiment for yourself to see if you like it! + #relativenumber = true + + # Enable mouse mode, can be useful for resizing splits for example! + mouse = "a"; + + # Don't show the mode, since it's already in the statusline + showmode = false; + + # Enable break indent + breakindent = true; + + # Save undo history + undofile = true; + + # Case-insensitive searching UNLESS \C or one or more capital letters in the search term + ignorecase = true; + smartcase = true; + + # Keep signcolumn on by default + signcolumn = "yes"; + + # Decrease update time + updatetime = 250; + + # Decrease mapped sequence wait time + # Displays which-key popup sooner + timeoutlen = 300; + + # Configure how new splits should be opened + splitright = true; + splitbelow = true; + + # Sets how neovim will display certain whitespace characters in the editor + # See `:help 'list'` + # and `:help 'listchars'` + list = true; + # NOTE: .__raw here means that this field is raw lua code + listchars.__raw = "{ tab = '» ', trail = '·', nbsp = '␣' }"; + + # Preview substitutions live, as you type! + inccommand = "split"; + + # Show which line your cursor is on + cursorline = true; + + # Minimal number of screen lines to keep above and below the cursor. + scrolloff = 10; + + # if performing an operation that would fail due to unsaved changes in the buffer (like `:q`), + # instead raise a dialog asking if you wish to save the current file(s) + # See `:help 'confirm'` + confirm = true; + + # See `:help hlsearch` + hlsearch = true; + }; + }; +} diff --git a/modules/nixvim/plugins/default.nix b/modules/nixvim/plugins/default.nix new file mode 100644 index 0000000..e69de29