From 1f7f453fc316da7332e63e5f9e0d26068e0c2a7d Mon Sep 17 00:00:00 2001 From: Kabbone Date: Sat, 20 Apr 2024 19:07:07 +0200 Subject: [PATCH] nvim: initial config --- flake.nix | 9 +++- hosts/default.nix | 5 ++- hosts/desktop/default.nix | 3 +- modules/editors/nvim/config/bufferline.nix | 5 +++ modules/editors/nvim/config/default.nix | 16 +++++++ modules/editors/nvim/config/highlight.nix | 8 ++++ modules/editors/nvim/config/keymaps.nix | 8 ++++ modules/editors/nvim/config/options.nix | 14 ++++++ modules/editors/nvim/config/plugins.nix | 51 ++++++++++++++++++++++ 9 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 modules/editors/nvim/config/bufferline.nix create mode 100644 modules/editors/nvim/config/default.nix create mode 100644 modules/editors/nvim/config/highlight.nix create mode 100644 modules/editors/nvim/config/keymaps.nix create mode 100644 modules/editors/nvim/config/options.nix create mode 100644 modules/editors/nvim/config/plugins.nix diff --git a/flake.nix b/flake.nix index 5b26430..920e6f6 100644 --- a/flake.nix +++ b/flake.nix @@ -55,9 +55,14 @@ url = "github:nix-community/lanzaboote/v0.3.0"; inputs.nixpkgs.follows = "nixpkgs"; }; + + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, nixos-hardware, home-manager, home-manager-unstable, nur, agenix, jovian-nixos, microvm, impermanence, lanzaboote, ... }: # Function that tells my flake which to use and what do what to do with the dependencies. + outputs = inputs @ { self, nixpkgs, nixpkgs-unstable, nixos-hardware, home-manager, home-manager-unstable, nur, agenix, jovian-nixos, microvm, impermanence, lanzaboote, nixvim, ... }: # Function that tells my flake which to use and what do what to do with the dependencies. let # Variables that can be used in the config files user = "kabbone"; userdmz = "diablo"; @@ -68,7 +73,7 @@ nixosConfigurations = ( # NixOS configurations import ./hosts { # Imports ./hosts/default.nix inherit (nixpkgs) lib; - inherit inputs nixpkgs nixpkgs-unstable nixos-hardware home-manager home-manager-unstable nur user userdmz userserver location agenix jovian-nixos microvm impermanence lanzaboote; # Also inherit home-manager so it does not need to be defined here. + inherit inputs nixpkgs nixpkgs-unstable nixos-hardware home-manager home-manager-unstable nur user userdmz userserver location agenix jovian-nixos microvm impermanence lanzaboote nixvim; # Also inherit home-manager so it does not need to be defined here. nix.allowedUsers = [ "@wheel" ]; security.sudo.execWheelOnly = true; } diff --git a/hosts/default.nix b/hosts/default.nix index 3047ce7..2aedc48 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -11,7 +11,7 @@ # └─ ./home.nix # -{ lib, inputs, nixpkgs, nixpkgs-unstable, nixos-hardware, home-manager, home-manager-unstable, nur, user, userdmz, userserver, location, agenix, jovian-nixos, microvm, impermanence, lanzaboote, ... }: +{ lib, inputs, nixpkgs, nixpkgs-unstable, nixos-hardware, home-manager, home-manager-unstable, nur, user, userdmz, userserver, location, agenix, jovian-nixos, microvm, impermanence, lanzaboote, nixvim, ... }: let system = "x86_64-linux"; # System architecture @@ -28,12 +28,13 @@ in { desktop = lib.nixosSystem { # Desktop profile inherit system; - specialArgs = { inherit inputs user location nixos-hardware nur agenix microvm nixpkgs lanzaboote; }; + specialArgs = { inherit inputs user location nixos-hardware nur agenix microvm nixpkgs lanzaboote nixvim; }; modules = [ agenix.nixosModules.default nur.nixosModules.nur microvm.nixosModules.host lanzaboote.nixosModules.lanzaboote + nixvim.nixosModules.nixvim ./desktop ./configuration_desktop.nix ../modules/hardware/remoteBuilder.nix diff --git a/hosts/desktop/default.nix b/hosts/desktop/default.nix index 83723f3..661d96e 100644 --- a/hosts/desktop/default.nix +++ b/hosts/desktop/default.nix @@ -17,13 +17,14 @@ # └─ default.nix # -{ config, nixpkgs, pkgs, user, lib, ... }: +{ config, nixpkgs, pkgs, user, lib, nixvim, ... }: { imports = # For now, if applying to other system, swap files [(import ./hardware-configuration.nix)] ++ # Current system hardware config @ /etc/nixos/hardware-configuration.nix #[(import ../../modules/desktop/hyprland/default.nix)] ++ # Window Manager [(import ../../modules/desktop/sway/default.nix)] ++ # Window Manager + #[(import ../../modules/editors/nvim/config/default.nix)] ++ # Window Manager (import ../../modules/desktop/virtualisation) ++ # Docker (import ../../modules/hardware); # Hardware devices diff --git a/modules/editors/nvim/config/bufferline.nix b/modules/editors/nvim/config/bufferline.nix new file mode 100644 index 0000000..fe5cf05 --- /dev/null +++ b/modules/editors/nvim/config/bufferline.nix @@ -0,0 +1,5 @@ +{ + plugins.bufferline = { + enable = true; + }; +} diff --git a/modules/editors/nvim/config/default.nix b/modules/editors/nvim/config/default.nix new file mode 100644 index 0000000..99e52af --- /dev/null +++ b/modules/editors/nvim/config/default.nix @@ -0,0 +1,16 @@ +{ nvim, ... }: +{ + # Import all your configuration modules here + programs.nixvim = { + enable = true; + colorschemes.gruvbox.enable = true; + + imports = [ + ./bufferline.nix + ./plugins.nix + ./options.nix + ./keymaps.nix + ./highlight.nix + ]; + }; +} diff --git a/modules/editors/nvim/config/highlight.nix b/modules/editors/nvim/config/highlight.nix new file mode 100644 index 0000000..2612647 --- /dev/null +++ b/modules/editors/nvim/config/highlight.nix @@ -0,0 +1,8 @@ +{ + highlight = { + Comment.fg = "#ff00ff"; + Comment.bg = "#000000"; + Comment.underline = true; + Comment.bold = true; + }; +} diff --git a/modules/editors/nvim/config/keymaps.nix b/modules/editors/nvim/config/keymaps.nix new file mode 100644 index 0000000..cb19475 --- /dev/null +++ b/modules/editors/nvim/config/keymaps.nix @@ -0,0 +1,8 @@ +{ + keymaps = [ + { + action = "Telescope live_grep"; + key = "g"; + } + ]; +} diff --git a/modules/editors/nvim/config/options.nix b/modules/editors/nvim/config/options.nix new file mode 100644 index 0000000..cdfab64 --- /dev/null +++ b/modules/editors/nvim/config/options.nix @@ -0,0 +1,14 @@ +{ + config = { + globals.mapleader = " "; + viAlias = true; + vimAlias = true; + + opts = { + number = true; # Show line numbers + relativenumber = true; # Show relative line numbers + + shiftwidth = 2; # Tab width should be 2 + }; + }; +} diff --git a/modules/editors/nvim/config/plugins.nix b/modules/editors/nvim/config/plugins.nix new file mode 100644 index 0000000..d075bdf --- /dev/null +++ b/modules/editors/nvim/config/plugins.nix @@ -0,0 +1,51 @@ +{ + plugins = { + lualine.enable = true; + + cmp = { + enable = true; + autoEnableSources = true; + settings = { + sources = [ + {name = "nvim_lsp";} + {name = "path";} + {name = "buffer";} + {name = "luasnip";} + ]; + + mapping = { + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.close()"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})"; + "" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})"; + }; + }; + }; + + lsp = { + enable = true; + + servers = { + tsserver.enable = true; + + lua-ls = { + enable = true; + settings.telemetry.enable = false; + }; +# rust-analyzer = { +# enable = true; +# installCargo = true; +# }; + }; + }; + + telescope.enable = true; + + treesitter.enable = true; + + luasnip.enable = true; + }; +}