From b9ca0de56b4b8f82d2fcf0c09c8368158d13d81d Mon Sep 17 00:00:00 2001 From: oddlama Date: Sat, 4 Nov 2023 19:53:05 +0100 Subject: [PATCH] chore(nixvim): test out nixvim --- flake.lock | 95 +++++++++++++++++- flake.nix | 9 +- modules/config/home-manager.nix | 2 +- modules/default.nix | 1 + users/myuser/neovim/default.nix | 165 ++++++++++++++++++++++++++++---- 5 files changed, 248 insertions(+), 24 deletions(-) diff --git a/flake.lock b/flake.lock index 7de1bc2..c013bf6 100644 --- a/flake.lock +++ b/flake.lock @@ -217,6 +217,29 @@ "type": "github" } }, + "beautysh": { + "inputs": { + "nixpkgs": [ + "nixvim", + "nixpkgs" + ], + "poetry2nix": "poetry2nix", + "utils": "utils" + }, + "locked": { + "lastModified": 1680308980, + "narHash": "sha256-aUEHV0jk2qIFP3jlsWYWhBbm+w/N9gzH3e4I5DcdB5s=", + "owner": "lovesegfault", + "repo": "beautysh", + "rev": "9845efc3ea3e86cc0d41465d720a47f521b2799c", + "type": "github" + }, + "original": { + "owner": "lovesegfault", + "repo": "beautysh", + "type": "github" + } + }, "crane": { "inputs": { "flake-compat": "flake-compat_2", @@ -1000,6 +1023,60 @@ "type": "github" } }, + "nixvim": { + "inputs": { + "beautysh": "beautysh", + "flake-utils": [ + "flake-utils" + ], + "nixpkgs": [ + "nixpkgs" + ], + "pre-commit-hooks": [ + "pre-commit-hooks" + ] + }, + "locked": { + "lastModified": 1699089411, + "narHash": "sha256-IhhzLIQW/cKQQfkQ7B7urgAzQiPHlLKgMeJbSBV02F8=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "1aecd4c2035b46c49b7f4548e0255b986d59410f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "poetry2nix": { + "inputs": { + "flake-utils": [ + "nixvim", + "beautysh", + "utils" + ], + "nixpkgs": [ + "nixvim", + "beautysh", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1658665240, + "narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=", + "owner": "nix-community", + "repo": "poetry2nix", + "rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "poetry2nix", + "type": "github" + } + }, "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat", @@ -1101,6 +1178,7 @@ "nixpkgs": "nixpkgs", "nixpkgs-wayland": "nixpkgs-wayland", "nixseparatedebuginfod": "nixseparatedebuginfod", + "nixvim": "nixvim", "pre-commit-hooks": "pre-commit-hooks_3", "stylix": "stylix", "templates": "templates", @@ -1294,6 +1372,21 @@ } }, "utils": { + "locked": { + "lastModified": 1678901627, + "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "utils_2": { "locked": { "lastModified": 1652776076, "narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=", @@ -1314,7 +1407,7 @@ "nixpkgs": [ "nixpkgs" ], - "utils": "utils" + "utils": "utils_2" }, "locked": { "lastModified": 1697336859, diff --git a/flake.nix b/flake.nix index a642019..10beb7a 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = " ❄️ oddlama's nix config and dotfiles"; + description = "❄️ oddlama's nix config and dotfiles"; inputs = { agenix = { @@ -73,6 +73,13 @@ inputs.flake-utils.follows = "flake-utils"; }; + nixvim = { + url = "github:nix-community/nixvim"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.flake-utils.follows = "flake-utils"; + inputs.pre-commit-hooks.follows = "pre-commit-hooks"; + }; + microvm = { url = "github:astro/microvm.nix"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/modules/config/home-manager.nix b/modules/config/home-manager.nix index 7595eb0..4528cf7 100644 --- a/modules/config/home-manager.nix +++ b/modules/config/home-manager.nix @@ -16,7 +16,7 @@ } ]; extraSpecialArgs = { - inherit minimal; + inherit inputs minimal; }; }; diff --git a/modules/default.nix b/modules/default.nix index b2f6f60..b2f31e7 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -50,6 +50,7 @@ nixpkgs.overlays = [ inputs.microvm.overlay inputs.nixpkgs-wayland.overlay + inputs.nixvim.overlays.default inputs.wired-notify.overlays.default ]; } diff --git a/users/myuser/neovim/default.nix b/users/myuser/neovim/default.nix index e5c62e1..bb7571a 100644 --- a/users/myuser/neovim/default.nix +++ b/users/myuser/neovim/default.nix @@ -1,29 +1,152 @@ { - config, + lib, pkgs, ... }: { - programs.neovim-custom = { - config = { - withPython3 = false; - withRuby = false; - withNodeJs = false; - #extraPython3Packages = p: []; - plugins = with pkgs.vimPlugins; [ - { - plugin = neo-tree-nvim; - config = - /* - lua - */ - '' - require("neo-tree").setup {} - ''; - } - ]; + #programs.neovim-custom = { + # config = { + # withPython3 = false; + # withRuby = false; + # withNodeJs = false; + # #extraPython3Packages = p: []; + # plugins = with pkgs.vimPlugins; [ + # { + # plugin = neo-tree-nvim; + # config = + # /* + # lua + # */ + # '' + # require("neo-tree").setup {} + # ''; + # } + # ]; + # }; + # init = builtins.readFile ./aaa/init.lua; + #}; + + home.shellAliases.nixvim = lib.getExe (pkgs.nixvim.makeNixvimWithModule { + package = pkgs.neovim-unwrapped.overrideAttrs (_final: prev: { + nativeBuildInputs = (prev.nativeBuildInputs or []) ++ [pkgs.makeWrapper]; + postInstall = + (prev.postInstall or "") + + '' + wrapProgram $out/bin/nvim --add-flags "--clean" + ''; + }); + + colorschemes = { + catppuccin = { + enable = true; + flavour = "mocha"; + }; }; - init = builtins.readFile ./aaa/init.lua; - }; + + globals.mapleader = ","; + + # Hide line numbers in terminal windows + autoCmd = [ + { + event = ["BufEnter" "BufWinEnter"]; + pattern = ["term://*"]; + callback = { + __raw = '' + function() + vim.bo.number = false + end + ''; + }; + } + ]; + + options = { + # ---------------------------------------------------------------------------------------------------- + # -- General + # ---------------------------------------------------------------------------------------------------- + + undolevels = 1000000; # Set maximum undo levels + undofile = true; # Enable persistent undo which persists undo history across vim sessions + updatetime = 300; # Save swap file after 300ms + mouse = "a"; # Enable full mouse support + + # ---------------------------------------------------------------------------------------------------- + # -- Editor visuals + # ---------------------------------------------------------------------------------------------------- + + termguicolors = true; # Enable true color in terminals + + splitkeep = "screen"; # Try not to move text when opening/closing splits + wrap = false; # Do not wrap text longer than the window's width + scrolloff = 2; # Keep 2 lines above and below the cursor. + sidescrolloff = 2; # Keep 2 lines left and right of the cursor. + + number = true; # Show line numbers + cursorline = true; # Enable cursorline, colorscheme only shows this in number column + wildmode = ["list" "full"]; # Only complete the longest common prefix and list all results + fillchars = {stlnc = "─";}; # Show separators in inactive window statuslines + + # FIXME: disabled because this really fucks everything up in the terminal. + title = false; # Sets the window title + # titlestring = "%t%( %M%)%( (%{expand(\"%:~:.:h\")})%) - nvim"; # The format for the window title + + # ---------------------------------------------------------------------------------------------------- + # -- Editing behavior + # ---------------------------------------------------------------------------------------------------- + + whichwrap = ""; # Never let the curser switch to the next line when reaching line end + ignorecase = true; # Ignore case in search by default + smartcase = true; # Be case sensitive when an upper-case character is included + + expandtab = false; + tabstop = 4; # Set indentation of tabs to be equal to 4 spaces. + shiftwidth = 4; + softtabstop = 4; + shiftround = true; # Round indentation commands to next multiple of shiftwidth + + # r = insert comment leader when hitting in insert mode + # q = allow explicit formatting with gq + # j = remove comment leaders when joining lines if it makes sense + formatoptions = "rqj"; + + # Allow the curser to be positioned on cells that have no actual character; + # Like moving beyond EOL or on any visual 'space' of a tab character + virtualedit = "all"; + selection = "old"; # Do not include line ends in past the-line selections + smartindent = true; # Use smart auto indenting for all file types + + timeoutlen = 20; # Only wait 20 milliseconds for characters to arrive (see :help timeout) + ttimeoutlen = 20; + timeout = false; # Disable timeout, but enable ttimeout (only timeout on keycodes) + ttimeout = true; + + grepprg = "rg --vimgrep --smart-case --follow"; # Replace grep with ripgrep + }; + + plugins = { + #alpha.enable = true; + #comment-nvim.enable = true; + diffview.enable = true; + fugitive.enable = true; + gitsigns = { + enable = true; + currentLineBlame = true; + }; + lsp-format.enable = true; + #markdown-preview.enable = true; + # mini.enable = true; + #navbuddy.enable = true; + #neorg.enable = true; + neo-tree.enable = true; + notify.enable = true; + #sniprun.enable = true; + #surround.enable = true; + telescope.enable = true; + treesitter.enable = true; + treesitter-context.enable = true; + #trouble.enable = true; + #which-key.enable = true; + }; + }); home.packages = let nvimConfig = pkgs.neovimUtils.makeNeovimConfig {