From 11fcef7c939dce8da976b2af33e5552a3fa3b10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Gro=C3=9Fmann?= Date: Tue, 7 Nov 2023 21:16:39 +0100 Subject: [PATCH] feat: continue nixvim implementation --- .gitignore | 1 - README.md | 2 + hosts/desktopnix/default.nix | 2 +- hosts/patricknix/default.nix | 2 +- pkgs/default.nix | 8 ++ users/common/programs/nvim/default.nix | 84 +++++++++++++++-- users/common/programs/nvim/nixvim/options.nix | 79 ++++++++++++++++ users/common/shells/pager.nix | 92 +++++++++++++------ 8 files changed, 228 insertions(+), 42 deletions(-) create mode 100644 users/common/programs/nvim/nixvim/options.nix diff --git a/.gitignore b/.gitignore index adebacb..6ba9cff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ .pre-commit-config.yaml .direnv -todo* diff --git a/README.md b/README.md index b542c35..f8655e9 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ - `graphical.nix` configuration for users utilizing a graphical interface - `/` configuration for users - `impermanence.nix` users persistence configuration +- `keys` collection of yubikeys public key parts for decryption +- `img` images, encrypted to not break any copyright by redistribution ## Hosts - `patricknix` Patricks main laptop diff --git a/hosts/desktopnix/default.nix b/hosts/desktopnix/default.nix index 06fe998..6c55c13 100644 --- a/hosts/desktopnix/default.nix +++ b/hosts/desktopnix/default.nix @@ -44,6 +44,6 @@ }; system.activationScripts.decryptKey.text = '' - ln -s ${../../keys/PatC.key} /run/decrypt.key.pub + ln -f -s ${../../keys/PatC.key} /run/decrypt.key.pub ''; } diff --git a/hosts/patricknix/default.nix b/hosts/patricknix/default.nix index ee5266a..64c2083 100644 --- a/hosts/patricknix/default.nix +++ b/hosts/patricknix/default.nix @@ -51,6 +51,6 @@ }; }; system.activationScripts.decryptKey.text = '' - ln -s ${../../keys/PatC.key} /run/decrypt.key.pub + ln -f -s ${../../keys/PatC.key} /run/decrypt.key.pub ''; } diff --git a/pkgs/default.nix b/pkgs/default.nix index 63062d5..0640eea 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4,6 +4,14 @@ zsh-histdb-skim = super.callPackage ./zsh-histdb-skim.nix {}; zsh-histdb = super.callPackage ./zsh-histdb.nix {}; deploy = super.callPackage ./deploy.nix {}; + neovim-clean = super.neovim-unwrapped.overrideAttrs (_neovimFinal: neovimPrev: { + nativeBuildInputs = (neovimPrev.nativeBuildInputs or []) ++ [super.makeWrapper]; + postInstall = + (neovimPrev.postInstall or "") + + '' + wrapProgram $out/bin/nvim --add-flags "--clean" + ''; + }); formats = super.formats // { diff --git a/users/common/programs/nvim/default.nix b/users/common/programs/nvim/default.nix index bf58e8f..788bb9e 100644 --- a/users/common/programs/nvim/default.nix +++ b/users/common/programs/nvim/default.nix @@ -34,15 +34,81 @@ ".cache/nvim" ]; home.shellAliases.nixvim = lib.getExe (pkgs.nixvim.makeNixvim { - package = pkgs.neovim-unwrapped.overrideAttrs (_final: prev: { - nativeBuildInputs = (prev.nativeBuildInputs or []) ++ [pkgs.makeWrapper]; - postInstall = - (prev.postInstall or "") - + '' - wrapProgram $out/bin/nvim --add-flags "--clean" - ''; - }); - colorscheme = "onedark"; + package = pkgs.neovim-clean; colorschemes.onedark.enable = true; + options = import ./nixvim/options.nix; + glkbals.mapleader = " "; + keymaps = let + options = { + noremap = true; + silent = true; + }; + in [ + { + key = ""; + action = ""; + inherit options; + } + { + key = ""; + action = ""; + inherit options; + } + { + key = ""; + action = ""; + inherit options; + } + { + key = ""; + action = ""; + inherit options; + } + + { + key = ""; + action = ""; + inherit options; + } + { + key = ""; + action = ""; + inherit options; + } + { + key = ""; + action = ""; + inherit options; + } + { + key = ""; + action = ""; + inherit options; + } + + # scroll with cursor lock + { + key = ""; + action = ""; + inherit options; + } + { + key = ""; + action = ""; + inherit options; + } + { + key = ""; + action = "a"; + inherit options; + mode = "i"; + } + { + key = ""; + action = "a"; + inherit options; + mode = "i"; + } + ]; }); } diff --git a/users/common/programs/nvim/nixvim/options.nix b/users/common/programs/nvim/nixvim/options.nix new file mode 100644 index 0000000..75f5c95 --- /dev/null +++ b/users/common/programs/nvim/nixvim/options.nix @@ -0,0 +1,79 @@ +{ + # Set maximum undo levels + undolevels = 1000000; + # Persistent Undo + undofile = true; + undodir = "~/.cache/nvim/undo"; + + # swap file save interval + updatetime = 300; + + # Ignore *.o and *~ files in wildmenu + wildignore = "*.o,*~"; + # Only complete the longest common prefix and list all results. + # You can use the cursor keys to select an item in this list + wildmode = ["list" "full"]; + + # set case handling + ignorecase = true; + smartcase = true; + + # ╓──────────────────╖ + # ║ Editor visuals ║ + # ╙──────────────────╜ + + # Enable true color in terminals + termguicolors = true; + # set font + guifont = "FiraCode Nerd Font Mono:h10.5"; + # full mouse support + mouse = "a"; + + # Do not wrap text longer than the window's width + wrap = false; + + # Show line numbers + number = true; + relativenumber = false; + + # Keep 2 lines around the cursor. + scrolloff = 2; + sidescrolloff = 2; + + # Set indentation of tabs to be equal to 4 spaces. + tabstop = 4; + shiftwidth = 4; + softtabstop = 4; + #round indentation to shifwidth + shiftround = true; + + # ╓────────────────────╖ + # ║ Editing behavior ║ + # ╙────────────────────╜ + + # 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"; + + # Do not include line ends in past the-line selections + selection = "old"; + + # Use smart auto indenting for all file types + smartindent = true; + + # Only wait 20 milliseconds for characters to arrive (see :help timeout) + timeoutlen = 20; + ttimeoutlen = 20; + + # Disable timeout, set ttimeout (only timeout on keycodes) + timeout = false; + ttimeout = true; + + # replace grep with ripgrep + grepprg = "rg --vimgrep --smartcase --follow"; +} diff --git a/users/common/shells/pager.nix b/users/common/shells/pager.nix index bd8f2ac..f964e75 100644 --- a/users/common/shells/pager.nix +++ b/users/common/shells/pager.nix @@ -1,33 +1,65 @@ -{pkgs, ...}: let - initLua = pkgs.writeText "init.lua" '' - vim.opt.buftype = "nowrite" - vim.opt.backup = false - vim.opt.modeline = false - vim.opt.shelltemp = false - vim.opt.swapfile = false - vim.opt.undofile = false - vim.opt.writebackup = false - vim.opt.shadafile = vim.fn.stdpath "state" .. "/shada/man.shada" - vim.opt.virtualedit = "all" - vim.opt.splitkeep = "screen" +{ + pkgs, + lib, + ... +}: { + home.sessionVariables.MANPAGER = lib.getExe (pkgs.nixvim.makeNixvim { + package = pkgs.neovim-clean; - vim.opt.termguicolors = false - - vim.keymap.set('n', '', '', {silent = true, desc = "Jump to tag under cursor"}) - vim.keymap.set('n', '', ':pop', {silent = true, desc = "Jump to tag under cursor"}) - vim.keymap.set('n', '', ':pop', {silent = true, desc = "Jump to tag under cursor"}) - vim.keymap.set('n', '', ':tag', {silent = true, desc = "Jump to tag under cursor"}) - ''; - nvimPager = pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped neovimConfig; - neovimConfig = - pkgs.neovimUtils.makeNeovimConfig { - wrapRc = false; - withPython3 = false; - withRuby = false; - } - // { - wrapperArgs = ["--add-flags" "--clean -u ${initLua}"]; + options = { + buftype = "nowrite"; + backup = false; + modeline = false; + shelltemp = false; + swapfile = false; + undofile = false; + writebackup = false; + virtualedit = "all"; + splitkeep = "screen"; + termguicolors = false; }; -in { - home.sessionVariables.MANPAGER = "${nvimPager}/bin/nvim '+Man!'"; + + extraConfigLua = '' + vim.opt.shadafile = vim.fn.stdpath "state" .. "/shada/man.shada"; + ''; + + keymaps = [ + { + action = ""; + key = ""; + mode = ["n"]; + options = { + silent = true; + desc = "Jump to tag under cursor"; + }; + } + { + action = ":pop"; + key = ""; + mode = ["n"]; + options = { + silent = true; + desc = "Jump to previous tag in stack"; + }; + } + { + action = ":pop"; + key = ""; + mode = ["n"]; + options = { + silent = true; + desc = "Jump to previous tag in stack"; + }; + } + { + action = ":tag"; + key = ""; + mode = ["n"]; + options = { + silent = true; + desc = "Jump to next tag in stack"; + }; + } + ]; + }); }