From 87a21720f25ddec276393aa85531515757de54f1 Mon Sep 17 00:00:00 2001 From: Alex Davies Date: Tue, 11 Jun 2024 16:44:13 -0300 Subject: [PATCH] nixvim most of the way there --- flake.lock | 21 +++++ flake.nix | 4 + home-manager/traverseda/home.nix | 130 ++++++++++++++++++++----------- nixos/configuration.nix | 1 + nixos/work.nix | 1 + 5 files changed, 113 insertions(+), 44 deletions(-) diff --git a/flake.lock b/flake.lock index fd3cbbd..c210fa0 100644 --- a/flake.lock +++ b/flake.lock @@ -319,6 +319,26 @@ "type": "github" } }, + "nix-index-database": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1718011381, + "narHash": "sha256-sFXI+ZANp/OC+MwfJoZgPSf4xMdtzQMe1pS3FGti4C8=", + "owner": "nix-community", + "repo": "nix-index-database", + "rev": "88ad3d7501e22b2401dd72734b032b7baa794434", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-index-database", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1703013332, @@ -451,6 +471,7 @@ "agenix": "agenix", "home-manager": "home-manager_2", "nix-colors": "nix-colors", + "nix-index-database": "nix-index-database", "nixpkgs": "nixpkgs_2", "nixpkgs-unstable": "nixpkgs-unstable", "nixvim": "nixvim", diff --git a/flake.nix b/flake.nix index 83aebdb..a0e59f7 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,10 @@ inputs = { # Nixpkgs nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + + nix-index-database.url = "github:nix-community/nix-index-database"; + nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; + # You can access packages and modules from different nixpkgs revs # at the same time. Here's an working example: nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; diff --git a/home-manager/traverseda/home.nix b/home-manager/traverseda/home.nix index 987fb37..4e42887 100644 --- a/home-manager/traverseda/home.nix +++ b/home-manager/traverseda/home.nix @@ -3,7 +3,7 @@ { inputs, outputs, - lib, + # lib, config, pkgs, ... @@ -11,8 +11,10 @@ # You can import other home-manager modules here imports = [ inputs.nixvim.homeManagerModules.nixvim + inputs.nix-index-database.hmModules.nix-index ]; + nixpkgs = { # You can add overlays here overlays = [ @@ -40,7 +42,6 @@ }; }; - home = { username = "traverseda"; homeDirectory = "/home/traverseda"; @@ -50,6 +51,7 @@ enable = true; userName = "Alex Davies"; userEmail = "traverse.da@gmail.com"; + extraConfig = { core = { editor = "vim"; # Set default editor for Git @@ -75,47 +77,87 @@ }; }; - # programs.nixvim = { - # enable = true; - # defaultEditor = true; - # viAlias = true; - # vimAlias = true; - # plugins.bufferline.enable = true; - # plugins.which-key.enable = true; + programs.nixvim = { + enable = true; + defaultEditor = true; + viAlias = true; + vimAlias = true; + #We use bufferline for the top line + plugins.bufferline.enable = true; + #And lualine for the bottom line + plugins.lualine = { + enable = true; + sections = { + lualine_x = [ + {name= "hostname";} + ]; + }; + }; + + plugins.which-key.enable = true; + + extraPlugins = with pkgs.vimPlugins; [ + vim-suda + ]; + + plugins.cmp.enable = true; + plugins.cmp-treesitter.enable = true; + plugins.indent-blankline.enable = true; + plugins.lsp-format.enable = true; + plugins.lsp = { + enable = true; + servers = { + ruff.enable = true; + html.enable = true; + nixd.enable = true; + dockerls.enable = true; + yamlls.enable = true; + }; + }; + + colorschemes.tokyonight = { + enable = true; + settings.style = "night"; + }; + + extraConfigLua = '' + -- Automatically enter insert mode when opening a terminal + vim.api.nvim_create_autocmd("TermOpen", { + pattern = "*", + command = "startinsert" + }) + -- Open files with sudo if needed + vim.g.suda_smart_edit = 1 + ''; - # plugins.cmp-tabby = { - # enable = true; - # host = "localhost:8337"; - # }; - # - # globals.mapleader = " "; - # keymaps = [ - # { - # mode = "n"; - # key = "c"; - # options = { noremap = true; desc = "Open new terminal"; }; - # action = ":term"; - # } - # { - # mode = "n"; - # key = "x"; - # options = { noremap = true; desc = "Close tab"; }; - # action = ":bd"; - # } - # { - # mode = "n"; - # key = "s"; - # options = { noremap = true; desc = "Pick buffer"; }; - # action = ":BufferLinePick"; - # } - # { - # mode = "t"; - # key = ""; - # options = { noremap = true; }; - # action = ""; - # } - # ]; - # }; + globals.mapleader = " "; + keymaps = [ + { + mode = "n"; + key = "c"; + options = { noremap = true; desc = "Open new terminal"; }; + action = ":term"; + } + { + mode = "n"; + key = "x"; + options = { noremap = true; desc = "Close tab"; }; + action = ":bd"; + } + { + mode = "n"; + key = "s"; + options = { noremap = true; desc = "Pick buffer"; }; + action = ":BufferLinePick"; + } + { + mode = "t"; + key = ""; + options = { noremap = true; }; + action = ""; + } + ]; + }; programs.ssh = { enable = true; # Enable SSH module @@ -127,12 +169,11 @@ ''; }; - home.packages = with pkgs; [ + home.packages = [ pkgs.htop pkgs.zsh pkgs.xclip pkgs.ripgrep - pkgs.mosh pkgs.waypipe pkgs.pwgen pkgs.chezmoi @@ -167,6 +208,7 @@ enableCompletion = true; autosuggestion.enable = true; syntaxHighlighting.enable = true; + autocd = false; history.size = 10000; history.path = "${config.xdg.dataHome}/zsh/history"; diff --git a/nixos/configuration.nix b/nixos/configuration.nix index e46f312..90150d7 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -100,6 +100,7 @@ pkgs.comma pkgs.home-manager appimage-run + pkgs.linuxPackages.usbip ]; programs.git = { diff --git a/nixos/work.nix b/nixos/work.nix index b6cb32e..e290ab7 100644 --- a/nixos/work.nix +++ b/nixos/work.nix @@ -16,6 +16,7 @@ }; environment.systemPackages = with pkgs; [ + pkgs.qemu pkgs.qgroundcontrol pkgs.vscode pkgs.stdenv