From fdf6725dc902e0677a05160ad240c4a5f8eebe55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Thu, 18 Jan 2024 22:49:46 +0100 Subject: [PATCH 01/16] vim: Configure fugitive-gitlab --- hm/desktop/browser/default.nix | 1 + hm/vim/default.nix | 24 +----------------------- hm/vim/git.nix | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 23 deletions(-) create mode 100644 hm/vim/git.nix diff --git a/hm/desktop/browser/default.nix b/hm/desktop/browser/default.nix index 6aa7fef..68f0b3b 100644 --- a/hm/desktop/browser/default.nix +++ b/hm/desktop/browser/default.nix @@ -108,6 +108,7 @@ inv = invidious; nixos = "https://search.nixos.org/options?channel=${config.home.version.release}&query={}"; nixpkgs = "https://search.nixos.org/packages?channel=${config.home.version.release}&query={}"; + noogle = "https://noogle.dev/q?term={}"; npm = "https://www.npmjs.com/search?q={}"; os = nixos; pkgs = nixpkgs; diff --git a/hm/vim/default.nix b/hm/vim/default.nix index 7effdf5..1319381 100644 --- a/hm/vim/default.nix +++ b/hm/vim/default.nix @@ -52,9 +52,6 @@ gC = "commands"; gr = "lsp_references"; ge = "diagnostics"; - # ga = "lsp_code_actions"; - # gE = "lsp_workspace_diagnostics"; - # TODO Above makes nvim crash on startup, action is not provided gd = "lsp_definitions"; gs = "lsp_document_symbols"; }; @@ -83,10 +80,6 @@ undotree.enable = true; # Navigate edition history - # Git - fugitive.enable = true; # Git basics - gitsigns.enable = true; # Show changed lines in the gutter - }; extraPlugins = with pkgs.vimPlugins; [ # Search/replace @@ -96,19 +89,6 @@ # Surrounding pairs targets-vim # Better interaction with surrounding pairs - # Registers - registers-nvim # Show register content when pressing " - # TODO Doesn't work. Didn't work on Arch either - - # Tags - vim-gutentags # Generate tags - symbols-outline-nvim # Show a symbol panel on the right - # TODO Fails on startup. Same on Arch. Config issue? - - # Git - fugitive-gitlab-vim # Open files in GitLab - # TODO Connect it! - # Language-specific tcomment_vim # Language-aware (un)commenting ] ++ lib.optionals config.frogeye.extra [ @@ -129,9 +109,6 @@ command Reload source $MYVIMRC " PLUGINS - - " vim-gutentags - let g:gutentags_cache_dir = expand('~/.cache/nvim/tags') '' + lib.optionalString config.frogeye.extra '' " languagetool let g:languagetool_cmd = "${pkgs.languagetool}/bin/languagetool-commandline" @@ -189,6 +166,7 @@ ./code.nix ./completion.nix ./decoration.nix + ./git.nix ./lsp.nix ]; } diff --git a/hm/vim/git.nix b/hm/vim/git.nix new file mode 100644 index 0000000..ee7047c --- /dev/null +++ b/hm/vim/git.nix @@ -0,0 +1,26 @@ +{ pkgs, lib, config, ... }: +{ + config = { + programs.nixvim = { + extraConfigVim = '' + let g:fugitive_gitlab_domains = [${ + lib.strings.concatStringsSep ", " ( + map (d: "'${d}'") config.frogeye.vim.fugitive.gitlab_domains + )}] + ''; + extraPlugins = with pkgs.vimPlugins; [ + fugitive-gitlab-vim # Open files in GitLab + ]; + plugins = { + fugitive.enable = true; # Git basics + gitsigns.enable = true; # Show changed lines in the gutter + }; + }; + }; + options.frogeye.vim.fugitive = { + gitlab_domains = lib.mkOption { + default = { }; + type = lib.types.listOf lib.types.str; + }; + }; +} From eac22be09510e42d2bfea792e9dcfb463a23f242 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Thu, 18 Jan 2024 23:09:18 +0100 Subject: [PATCH 02/16] No Ansible by default --- hm/vim/default.nix | 3 ++- options.nix | 1 - os/geoffrey.nix | 4 +++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hm/vim/default.nix b/hm/vim/default.nix index 1319381..55a19af 100644 --- a/hm/vim/default.nix +++ b/hm/vim/default.nix @@ -97,7 +97,8 @@ vim-pandoc # Pandoc-specific stuff because there's no LSP for it vim-pandoc-syntax ] ++ lib.optionals config.frogeye.dev.ansible [ - ansible-vim # TODO Doesn't have snippets + ansible-vim + # Doesn't generate snippets, but those are for UltiSnip anyways ]; extraConfigLua = builtins.readFile ./symbols-outline-nvim.lua; extraConfigVim = '' diff --git a/options.nix b/options.nix index 222912a..a4ca176 100644 --- a/options.nix +++ b/options.nix @@ -47,7 +47,6 @@ config = { frogeye = { dev = { - ansible = lib.mkDefault true; python = lib.mkDefault true; }; }; diff --git a/os/geoffrey.nix b/os/geoffrey.nix index df0159b..29b4f36 100644 --- a/os/geoffrey.nix +++ b/os/geoffrey.nix @@ -19,7 +19,9 @@ home-manager = { users.geoffrey = { pkgs, ... }: { - frogeye = config.frogeye; + frogeye = lib.mkDefault config.frogeye; + # Propagating options that way doesn't seem to conserve priority info, + # this is not great. Hopefully mkDefault resolve conflicts. }; # Makes VMs able to re-run useUserPackages = true; From 55756e4ae7730cfc90ec14c07582447689141d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Fri, 19 Jan 2024 22:50:01 +0100 Subject: [PATCH 03/16] English is a programming language, fight me --- flake.lock | 139 ++++++++++++++++++++++++++++++-- flake.nix | 5 +- hm/dev/default.nix | 1 + hm/dev/prose.nix | 23 ++++++ hm/extra.nix | 6 -- hm/vim/default.nix | 11 --- hm/vim/lsp.nix | 21 +---- hm/vim/symbols-outline-nvim.lua | 19 ----- options.nix | 2 + 9 files changed, 165 insertions(+), 62 deletions(-) create mode 100644 hm/dev/prose.nix delete mode 100644 hm/vim/symbols-outline-nvim.lua diff --git a/flake.lock b/flake.lock index bde4188..53b7082 100644 --- a/flake.lock +++ b/flake.lock @@ -311,6 +311,56 @@ "type": "github" } }, + "nix-formatter-pack": { + "inputs": { + "nixpkgs": [ + "nix-on-droid", + "nixpkgs" + ], + "nmd": "nmd", + "nmt": "nmt" + }, + "locked": { + "lastModified": 1666720474, + "narHash": "sha256-iWojjDS1D19zpeZXbBdjWb9MiKmVVFQCqtJmtTXgPx8=", + "owner": "Gerschtli", + "repo": "nix-formatter-pack", + "rev": "14876cc8fe94a3d329964ecb073b4c988c7b61f5", + "type": "github" + }, + "original": { + "owner": "Gerschtli", + "repo": "nix-formatter-pack", + "type": "github" + } + }, + "nix-on-droid": { + "inputs": { + "home-manager": [ + "home-manager" + ], + "nix-formatter-pack": "nix-formatter-pack", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-for-bootstrap": "nixpkgs-for-bootstrap", + "nmd": "nmd_2" + }, + "locked": { + "lastModified": 1688144254, + "narHash": "sha256-8KL1l/7eP2Zm1aJjdVaSOk0W5kTnJo9kcgW03gqWuiI=", + "owner": "nix-community", + "repo": "nix-on-droid", + "rev": "2301e01d48c90b60751005317de7a84a51a87eb6", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.05", + "repo": "nix-on-droid", + "type": "github" + } + }, "nixgl": { "inputs": { "flake-utils": "flake-utils", @@ -361,6 +411,22 @@ "type": "indirect" } }, + "nixpkgs-for-bootstrap": { + "locked": { + "lastModified": 1686921029, + "narHash": "sha256-J1bX9plPCFhTSh6E3TWn9XSxggBh/zDD4xigyaIQBy8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c7ff1b9b95620ce8728c0d7bd501c458e6da9e04", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c7ff1b9b95620ce8728c0d7bd501c458e6da9e04", + "type": "github" + } + }, "nixpkgs-stable": { "locked": { "lastModified": 1685801374, @@ -386,17 +452,78 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { + "dirtyRev": "c96d7b46d05a78e695ed1c725d1596b65509b4f9-dirty", + "dirtyShortRev": "c96d7b46-dirty", "lastModified": 1702044539, - "narHash": "sha256-TNmEd6MipLxsrWromxqNfU4y17MoBr15QF7iEOagPy8=", + "narHash": "sha256-YAWtzc+5KDOHDGz/NBB7ysIusXbYYKtsbDOsRhSWKYk=", + "type": "git", + "url": "file:/home/geoffrey/nixvim" + }, + "original": { + "type": "git", + "url": "file:/home/geoffrey/nixvim" + } + }, + "nmd": { + "flake": false, + "locked": { + "lastModified": 1666190571, + "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", + "owner": "rycee", + "repo": "nmd", + "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", + "type": "gitlab" + }, + "original": { + "owner": "rycee", + "repo": "nmd", + "type": "gitlab" + } + }, + "nmd_2": { + "flake": false, + "locked": { + "lastModified": 1666190571, + "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", + "owner": "rycee", + "repo": "nmd", + "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", + "type": "gitlab" + }, + "original": { + "owner": "rycee", + "repo": "nmd", + "type": "gitlab" + } + }, + "nmt": { + "flake": false, + "locked": { + "lastModified": 1648075362, + "narHash": "sha256-u36WgzoA84dMVsGXzml4wZ5ckGgfnvS0ryzo/3zn/Pc=", + "owner": "rycee", + "repo": "nmt", + "rev": "d83601002c99b78c89ea80e5e6ba21addcfe12ae", + "type": "gitlab" + }, + "original": { + "owner": "rycee", + "repo": "nmt", + "type": "gitlab" + } + }, + "nur": { + "locked": { + "lastModified": 1705693547, + "narHash": "sha256-/6rVfbj1oaycjvYJeZRqL+ApzNL2FNf6pmfWuk+9Bhs=", "owner": "nix-community", - "repo": "nixvim", - "rev": "c96d7b46d05a78e695ed1c725d1596b65509b4f9", + "repo": "NUR", + "rev": "868aa9b52241ad7c8cb89cdd207f8d0149ebf95b", "type": "github" }, "original": { "owner": "nix-community", - "repo": "nixvim", - "rev": "c96d7b46d05a78e695ed1c725d1596b65509b4f9", + "repo": "NUR", "type": "github" } }, @@ -429,10 +556,12 @@ "inputs": { "disko": "disko", "home-manager": "home-manager", + "nix-on-droid": "nix-on-droid", "nixgl": "nixgl", "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", "nixvim": "nixvim", + "nur": "nur", "stylix": "stylix" } }, diff --git a/flake.nix b/flake.nix index 6d536d9..cf0b4fc 100644 --- a/flake.nix +++ b/flake.nix @@ -25,8 +25,9 @@ inputs.nixpkgs.follows = "nixpkgs"; }; nixvim = { - url = "github:nix-community/nixvim/c96d7b46d05a78e695ed1c725d1596b65509b4f9"; - # 24.05 Anything after this commit works + url = "github:GeoffreyFrogeye/nixvim/frogeye-23.11"; + # 24.05 Ensure merged: https://github.com/nix-community/nixvim/pull/953 + # url = "github:nix-community/nixvim"; inputs.nixpkgs.follows = "nixpkgs"; }; nixgl = { diff --git a/hm/dev/default.nix b/hm/dev/default.nix index a71e778..9cb97f7 100644 --- a/hm/dev/default.nix +++ b/hm/dev/default.nix @@ -4,6 +4,7 @@ ./common.nix ./go.nix ./node.nix + ./prose.nix ./python.nix ]; } diff --git a/hm/dev/prose.nix b/hm/dev/prose.nix new file mode 100644 index 0000000..5c68cc8 --- /dev/null +++ b/hm/dev/prose.nix @@ -0,0 +1,23 @@ +# Prose is a programming language, fight me +{ pkgs, lib, config, ... }: +{ + config = lib.mkIf config.frogeye.dev.prose { + home = { + packages = with pkgs; [ + hunspell + hunspellDicts.en_GB-ize + hunspellDicts.en_US + hunspellDicts.fr-moderne + hunspellDicts.nl_NL + # TODO libreoffice-extension-languagetool or libreoffice-extension-grammalecte-fr + ]; + }; + programs.nixvim.plugins.none-ls = { + enable = true; + sources = { + code_actions.ltrs.enable = true; + diagnostics.ltrs.enable = true; + }; + }; + }; +} diff --git a/hm/extra.nix b/hm/extra.nix index 84002cf..6257482 100644 --- a/hm/extra.nix +++ b/hm/extra.nix @@ -34,12 +34,6 @@ # TODO Convert existing LaTeX documents into using Nix build system # texlive is big and not that much used, sooo pdftk - hunspell - hunspellDicts.en_GB-ize - hunspellDicts.en_US - hunspellDicts.fr-moderne - hunspellDicts.nl_NL - # TODO libreoffice-extension-languagetool or libreoffice-extension-grammalecte-fr ] ++ lib.optionals config.frogeye.desktop.xorg [ diff --git a/hm/vim/default.nix b/hm/vim/default.nix index 55a19af..b4d862d 100644 --- a/hm/vim/default.nix +++ b/hm/vim/default.nix @@ -91,8 +91,6 @@ # Language-specific tcomment_vim # Language-aware (un)commenting - ] ++ lib.optionals config.frogeye.extra [ - vim-LanguageTool # Check grammar for human languages ] ++ lib.optionals config.programs.pandoc.enable [ vim-pandoc # Pandoc-specific stuff because there's no LSP for it vim-pandoc-syntax @@ -100,7 +98,6 @@ ansible-vim # Doesn't generate snippets, but those are for UltiSnip anyways ]; - extraConfigLua = builtins.readFile ./symbols-outline-nvim.lua; extraConfigVim = '' " GENERAL @@ -110,11 +107,6 @@ command Reload source $MYVIMRC " PLUGINS - '' + lib.optionalString config.frogeye.extra '' - " languagetool - let g:languagetool_cmd = "${pkgs.languagetool}/bin/languagetool-commandline" - " TODO Doesn't work - '' + lib.optionalString config.programs.pandoc.enable '' " vim-pandox let g:pandoc#modules#disabled = ["folding"] @@ -153,9 +145,6 @@ # PLUGINS - # symbols-outline-nvim - { key = "s"; action = "SymbolsOutline"; options = { silent = true; }; } - # undotree { key = "u"; action = "UndotreeToggle"; options = { silent = true; }; } diff --git a/hm/vim/lsp.nix b/hm/vim/lsp.nix index a1c085f..03df26e 100644 --- a/hm/vim/lsp.nix +++ b/hm/vim/lsp.nix @@ -12,25 +12,6 @@ lsp_signature-nvim # Show argument definition when typing a function ]; keymaps = [ - # barbar - { key = ""; action = "BufferPrevious"; options = { silent = true; }; } - { key = ""; action = "BufferNext"; options = { silent = true; }; } - # TODO https://www.reddit.com/r/neovim/comments/mbj8m5/how_to_setup_ctrlshiftkey_mappings_in_neovim_and/ - { key = ""; action = "BufferMovePrevious"; options = { silent = true; }; } - { key = ""; action = "BufferMoveNext"; options = { silent = true; }; } - # TODO gotos don't work - { key = ""; action = "BufferGoto 1"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 2"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 3"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 4"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 5"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 6"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 7"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 8"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 9"; options = { silent = true; }; } - { key = ""; action = "BufferLast"; options = { silent = true; }; } - { key = "gb"; action = "BufferPick"; options = { silent = true; }; } - # TODO Other useful options? ]; plugins = { # Language Server @@ -44,6 +25,7 @@ "]e" = "goto_next"; }; lspBuf = { + # TODO Include the Telescope ones in this file "gD" = "declaration"; "K" = "hover"; "gi" = "implementation"; @@ -55,6 +37,7 @@ # Also makes nvim crash like this, so uncommented "D" = "type_definition"; "rn" = "rename"; + "ca" = "code_action"; "f" = "format"; # TODO Full thing was function() vim.lsp.buf.format { async = true } end, so async while this isn't # Maybe replace this with lsp-format? diff --git a/hm/vim/symbols-outline-nvim.lua b/hm/vim/symbols-outline-nvim.lua deleted file mode 100644 index 4649eb7..0000000 --- a/hm/vim/symbols-outline-nvim.lua +++ /dev/null @@ -1,19 +0,0 @@ -vim.g.symbols_outline = { - highlight_hovered_item = true, - show_guides = true, - auto_preview = true, - position = 'right', - show_numbers = false, - show_relative_numbers = false, - show_symbol_details = true, - keymaps = { - close = "", - goto_location = "", - focus_location = "o", - hover_symbol = "", - rename_symbol = "r", - code_actions = "a", - }, - lsp_blacklist = {}, -} --- TODO Should be hierarchical, doesn't seem to be :/ diff --git a/options.nix b/options.nix index a4ca176..0f9f151 100644 --- a/options.nix +++ b/options.nix @@ -40,6 +40,7 @@ node = lib.mkEnableOption "NodeJS dev stuff"; perl = lib.mkEnableOption "Perl dev stuff"; php = lib.mkEnableOption "PHP dev stuff"; + prose = lib.mkEnableOption "Writing stuff"; python = lib.mkEnableOption "Python dev stuff"; }; }; @@ -47,6 +48,7 @@ config = { frogeye = { dev = { + prose = lib.mkDefault true; python = lib.mkDefault true; }; }; From 97a3e5f6e4ab2c6bfd699a620ac9d69f10091b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 20 Jan 2024 19:04:06 +0100 Subject: [PATCH 04/16] vim: Fix Reload command --- hm/desktop/default.nix | 2 ++ hm/vim/default.nix | 6 ++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hm/desktop/default.nix b/hm/desktop/default.nix index fa2fd34..c5ef06a 100644 --- a/hm/desktop/default.nix +++ b/hm/desktop/default.nix @@ -144,6 +144,8 @@ in # misc gnome.gedit + xfce.thunar + nomacs feh zbar zathura diff --git a/hm/vim/default.nix b/hm/vim/default.nix index b4d862d..a963a13 100644 --- a/hm/vim/default.nix +++ b/hm/vim/default.nix @@ -104,8 +104,6 @@ " Avoid showing message extra message when using completion set shortmess+=c - command Reload source $MYVIMRC - " PLUGINS '' + lib.optionalString config.programs.pandoc.enable '' " vim-pandox @@ -120,8 +118,8 @@ ]; userCommands = { - # Reload = { command = "source $MYVIRMC"; }; - # TODO Is not working, options is set to nil even though it shouldn't + Reload = { command = "source ${config.xdg.configHome}/nvim/init.lua"; force = false; }; + # 24.05 force=false was for https://github.com/nix-community/nixvim/issues/954 }; keymaps = [ From a57c6527cecd33b16d5eb4c89d116e7082266238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 20 Jan 2024 19:24:04 +0100 Subject: [PATCH 05/16] vim: Fix lsp todos --- hm/vim/default.nix | 4 ---- hm/vim/lsp.nix | 37 +++++++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/hm/vim/default.nix b/hm/vim/default.nix index a963a13..1107ea6 100644 --- a/hm/vim/default.nix +++ b/hm/vim/default.nix @@ -50,10 +50,6 @@ gH = "command_history"; gS = "search_history"; gC = "commands"; - gr = "lsp_references"; - ge = "diagnostics"; - gd = "lsp_definitions"; - gs = "lsp_document_symbols"; }; defaults = { vimgrep_arguments = [ diff --git a/hm/vim/lsp.nix b/hm/vim/lsp.nix index 03df26e..54b8271 100644 --- a/hm/vim/lsp.nix +++ b/hm/vim/lsp.nix @@ -12,6 +12,28 @@ lsp_signature-nvim # Show argument definition when typing a function ]; keymaps = [ + { + mode = "n"; + key = "wl"; + lua = true; + action = '' + function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end + ''; + options.silent = true; + } + { + mode = "n"; + key = "f"; + lua = true; + action = '' + function() + vim.lsp.buf.format { async = true } + end + ''; + options.silent = true; + } ]; plugins = { # Language Server @@ -25,25 +47,24 @@ "]e" = "goto_next"; }; lspBuf = { - # TODO Include the Telescope ones in this file "gD" = "declaration"; "K" = "hover"; "gi" = "implementation"; "" = "signature_help"; "wa" = "add_workspace_folder"; "wr" = "remove_workspace_folder"; - # "wl" = "list_workspace_folder"; - # TODO Full thing was function() print(vim.inspect(vim.lsp.buf.list_workspace_folder())) end but not sure I'm ever really using this - # Also makes nvim crash like this, so uncommented "D" = "type_definition"; "rn" = "rename"; - "ca" = "code_action"; - "f" = "format"; - # TODO Full thing was function() vim.lsp.buf.format { async = true } end, so async while this isn't - # Maybe replace this with lsp-format? + "ca" = "code_action"; # Reference has a binding for visual mode, but it doesn't work }; }; }; + telescope.keymaps = { + gr = "lsp_references"; + ge = "diagnostics"; + gd = "lsp_definitions"; + gs = "lsp_document_symbols"; + }; nvim-lightbulb = { # Shows a lightbulb whenever a codeAction is available under the cursor enable = true; From 7cd77af9bf72cc2d417581f63d6cd7ea71470565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 20 Jan 2024 19:30:46 +0100 Subject: [PATCH 06/16] vim: Move more things to prose --- hm/dev/prose.nix | 25 ++++++++++++++++++++----- hm/vim/default.nix | 17 ----------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/hm/dev/prose.nix b/hm/dev/prose.nix index 5c68cc8..f271c6d 100644 --- a/hm/dev/prose.nix +++ b/hm/dev/prose.nix @@ -12,11 +12,26 @@ # TODO libreoffice-extension-languagetool or libreoffice-extension-grammalecte-fr ]; }; - programs.nixvim.plugins.none-ls = { - enable = true; - sources = { - code_actions.ltrs.enable = true; - diagnostics.ltrs.enable = true; + programs.nixvim = { + autoCmd = [ + # vim-easy-align: Align Markdown tables with | + { event = "FileType"; pattern = "markdown"; command = "vmap :EasyAlign*"; } + ]; + extraPlugins = with pkgs.vimPlugins; lib.optionals config.programs.pandoc.enable [ + vim-pandoc # Pandoc-specific stuff because there's no LSP for it + vim-pandoc-syntax + ]; + extraConfigVim = lib.optionalString config.programs.pandoc.enable '' + let g:pandoc#modules#disabled = ["folding"] + let g:pandoc#spell#enabled = 0 + let g:pandoc#syntax#conceal#use = 0 + ''; + plugins.none-ls = { + enable = true; + sources = { + code_actions.ltrs.enable = true; + diagnostics.ltrs.enable = true; + }; }; }; }; diff --git a/hm/vim/default.nix b/hm/vim/default.nix index 1107ea6..125fe37 100644 --- a/hm/vim/default.nix +++ b/hm/vim/default.nix @@ -87,31 +87,14 @@ # Language-specific tcomment_vim # Language-aware (un)commenting - ] ++ lib.optionals config.programs.pandoc.enable [ - vim-pandoc # Pandoc-specific stuff because there's no LSP for it - vim-pandoc-syntax ] ++ lib.optionals config.frogeye.dev.ansible [ ansible-vim # Doesn't generate snippets, but those are for UltiSnip anyways ]; extraConfigVim = '' - " GENERAL - " Avoid showing message extra message when using completion set shortmess+=c - - " PLUGINS - '' + lib.optionalString config.programs.pandoc.enable '' - " vim-pandox - let g:pandoc#modules#disabled = ["folding"] - let g:pandoc#spell#enabled = 0 - let g:pandoc#syntax#conceal#use = 0 - ''; - autoCmd = [ - # vim-easy-align: Align Markdown tables - { event = "FileType"; pattern = "markdown"; command = "vmap :EasyAlign*"; } - ]; userCommands = { Reload = { command = "source ${config.xdg.configHome}/nvim/init.lua"; force = false; }; From 09b201ca24b33789948b11cc767f85b23c31cf81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Mon, 22 Jan 2024 00:02:13 +0100 Subject: [PATCH 07/16] Change status line Time spent on writing Nix config: 5%: Testing new shiny things 7%: Debugging issues 88%: Gettings the colors and theming juuuuuust right Help, my sleep schedule is dying --- hm/vim/code.nix | 7 +- hm/vim/decoration.nix | 106 +++++++++++++++++++++++++-- hm/vim/feline.lua | 165 ------------------------------------------ 3 files changed, 106 insertions(+), 172 deletions(-) delete mode 100644 hm/vim/feline.lua diff --git a/hm/vim/code.nix b/hm/vim/code.nix index e577957..bc7d93a 100644 --- a/hm/vim/code.nix +++ b/hm/vim/code.nix @@ -44,6 +44,12 @@ in showbreak = "↪"; }; plugins = { + # Underline all instances of the underlined word + cursorline = { + enable = true; + cursorline.enable = false; + }; + # Catches attention when cursor changed position specs = { enable = true; @@ -61,7 +67,6 @@ in }; # indent = true; # Not very working last time I tried apparently }; - # TODO Investigate https://github.com/nvim-treesitter/nvim-treesitter-textobjects indent-blankline.enable = true; # Show indent guides rainbow-delimiters.enable = true; # Randomly colore paired brackets diff --git a/hm/vim/decoration.nix b/hm/vim/decoration.nix index 6dc2d47..6975e5d 100644 --- a/hm/vim/decoration.nix +++ b/hm/vim/decoration.nix @@ -7,12 +7,8 @@ { event = "InsertEnter"; pattern = "*"; command = "set norelativenumber"; } { event = "InsertLeave"; pattern = "*"; command = "set relativenumber"; } ]; - extraConfigLua = builtins.readFile ./feline.lua; extraPlugins = with pkgs.vimPlugins; [ nvim-scrollview # Scroll bar - # Status line - feline-nvim # Customizable status line. - # TODO Abandonned. Maybe use lualine? ]; keymaps = [ # barbar @@ -36,13 +32,111 @@ # TODO Other useful options? ]; options = { - title = true; + showmode = false; number = true; relativenumber = true; + title = true; }; plugins = { - # Tabline + # Tablinee barbar.enable = true; + # TODO Investigate bufferline? + # Status line + lualine = with config.lib.stylix.colors.withHashtag; let + normal = { fg = base05; bg = base01; }; + inverted = { fg = base00; bg = base03; }; + normal_ina = { fg = base02; bg = base01; }; + inverted_ina = { fg = base00; bg = base02; }; + in + rec { + enable = true; + inactiveSections = sections; + sections = { + lualine_a = [ + { + name = ''string.format('%d', vim.fn.line('$'))''; + } + "location" + ]; + lualine_b = [ + "mode" + ]; + lualine_c = [{ + name = "filename"; + extraConfig = { + path = 1; # Relative path + symbols = { + modified = "●"; + newfile = "󰻭"; + readonly = "󰏯"; + unnamed = "󱀶"; + }; + }; + }]; + lualine_x = (lib.mapAttrsToList + (diag_name: diag_color: { + name = "diagnostics"; + extraConfig = { + color.bg = diag_color; + colored = false; + separator = { left = ""; right = ""; }; + sections = [ diag_name ]; + }; + }) + { + error = base08; + warn = base0A; + hint = base0C; + info = base0B; + }); + lualine_y = [{ + name = "diff"; + extraConfig = { + diff_color = { + added.fg = base0B; + modified.fg = base0A; + removed.fg = base08; + }; + symbols = { + added = " "; + modified = " "; + removed = " "; + }; + }; + } + "branch"]; + lualine_z = [ + "filetype" + "fileformat" + "encoding" + ]; + }; + theme = (lib.mapAttrs + (mode_name: mode_color: { + a = inverted; + b = inverted // { bg = mode_color; gui = "bold"; }; + c = normal; + x = inverted; + y = inverted; + z = inverted // { bg = mode_color; }; + }) + { + normal = base0D; + insert = base0B; + visual = base0F; + replace = base08; + command = base0E; + }) // { + inactive = { + a = inverted_ina; + b = normal_ina // { bg = base00; gui = "bold"; }; + c = normal_ina; + x = inverted_ina; + y = inverted_ina; + z = normal_ina // { bg = base00; }; + }; + }; + }; }; }; }; diff --git a/hm/vim/feline.lua b/hm/vim/feline.lua deleted file mode 100644 index 41460d4..0000000 --- a/hm/vim/feline.lua +++ /dev/null @@ -1,165 +0,0 @@ -vim.cmd([[ - set noshowmode - set laststatus=2 -]]) -local base16_colors = require('base16-colorscheme').colors -local vi_mode_utils = require('feline.providers.vi_mode') -local lsp = require('feline.providers.lsp') -require('feline').setup({ - default_bg = 'base01', - default_fg = 'base04', - theme = { - base00 = base16_colors.base00, - base01 = base16_colors.base01, - base02 = base16_colors.base02, - base03 = base16_colors.base03, - base04 = base16_colors.base04, - base05 = base16_colors.base05, - base06 = base16_colors.base06, - base07 = base16_colors.base07, - base08 = base16_colors.base08, - base09 = base16_colors.base09, - base0A = base16_colors.base0A, - base0B = base16_colors.base0B, - base0C = base16_colors.base0C, - base0D = base16_colors.base0D, - base0E = base16_colors.base0E, - base0F = base16_colors.base0F, - }, - components = { - active = { - { - { - provider = function() return string.format(' %d ', vim.fn.line('$')) end, - -- If you can, make it depend on the actual bar size - left_sep = { - {str = 'block', fg = 'base05'} - }, - hl = { - fg = 'base01', - bg = 'base04', - }, - }, - { - provider = 'vi_mode', - hl = function() - return { - name = vi_mode_utils.get_mode_highlight_name(), - bg = vi_mode_utils.get_mode_color(), - fg = 'white', - style = 'bold', - } - end, - left_sep = {'█'}, - right_sep = {'█'}, - }, - { - provider='', - hl = function() - return { - bg = vi_mode_utils.get_mode_color(), - fg = (vim.bo.modified and 'base09') or 'base0D', - } - end, - }, - { - provider = 'file_info', - type = 'relative', - hl = function() - return { - fg = 'base06', - bg = (vim.bo.modified and 'base09') or 'base0D', - style = 'bold', - } - end, - left_sep = {'█'}, - right_sep = {'█'}, - }, - { - provider='', - hl = function() - return { - bg = 'base02', - fg = (vim.bo.modified and 'base09') or 'base0D', - } - end, - }, - { - provider = 'position', - hl = { fg = 'base05', bg = 'base02' }, - right_sep = {'█'}, - }, - -- If it miraculously became easy to do, add LSP position here - { - provider='', - hl = { bg = 'base01', fg = 'base02' }, - }, - }, - { - { - provider='', - hl = { bg = 'base03', fg = 'base01', }, - }, - { - provider='z', - enabled = function() return next(vim.lsp.buf_get_clients()) == nil end, - hl = { bg = 'base03', fg = 'base01', }, - left_sep = '█', - }, - { - provider = 'diagnostic_errors', - enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.ERROR) end, - hl = { fg = 'red', bg = 'base03', }, - left_sep = '█', - }, - { - provider = 'diagnostic_warnings', - enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.WARN) end, - hl = { fg = 'yellow', bg = 'base03', }, - left_sep = '█', - }, - { - provider = 'diagnostic_hints', - enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.HINT) end, - hl = { fg = 'cyan', bg = 'base03', }, - left_sep = '█', - }, - { - provider = 'diagnostic_info', - enabled = function() return lsp.diagnostics_exist(vim.diagnostic.severity.INFO) end, - hl = { fg = 'skyblue', bg = 'base03', }, - left_sep = '█', - }, - { - provider='█', - hl = { bg = 'base02', fg = 'base03', }, - }, - { - provider = 'git_diff_added', - hl = { fg = 'green', bg = 'base02', }, - left_sep = '█', - enabled = function() return vim.b.gitsigns_status_dict end, - }, - { - provider = 'git_diff_changed', - hl = { fg = 'orange', bg = 'base02', }, - left_sep = '█', - enabled = function() return vim.b.gitsigns_status_dict end, - }, - { - provider = 'git_diff_removed', - hl = { fg = 'red', bg = 'base02', }, - left_sep = '█', - enabled = function() return vim.b.gitsigns_status_dict end, - }, - { - provider = 'git_branch', - hl = { fg = 'base05', bg = 'base02', style = 'bold', }, - right_sep = '█', - left_sep = '█', - enabled = function() return vim.b.gitsigns_status_dict end, - }, - } - }, - } -}) From dfc8d68495eb73cddd3ec791a173756fa0cb3369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Tue, 23 Jan 2024 23:38:48 +0100 Subject: [PATCH 08/16] vim/decoration: Small adjustments --- hm/vim/decoration.nix | 35 ++++++++++++++++++++++++----------- hm/vim/default.nix | 2 ++ hm/vim/git.nix | 1 + 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/hm/vim/decoration.nix b/hm/vim/decoration.nix index 6975e5d..b5f51bc 100644 --- a/hm/vim/decoration.nix +++ b/hm/vim/decoration.nix @@ -38,7 +38,7 @@ title = true; }; plugins = { - # Tablinee + # Tabline barbar.enable = true; # TODO Investigate bufferline? # Status line @@ -52,17 +52,21 @@ enable = true; inactiveSections = sections; sections = { - lualine_a = [ - { - name = ''string.format('%d', vim.fn.line('$'))''; - } - "location" - ]; + lualine_a = [{ + name = ''string.format('%d', vim.fn.line('$'))''; + }]; lualine_b = [ "mode" ]; lualine_c = [{ name = "filename"; + color = { + __raw = '' + function(section) + return { fg = vim.bo.modified and '${base08}' or '${normal.fg}' } + end + ''; + }; extraConfig = { path = 1; # Relative path symbols = { @@ -72,8 +76,12 @@ unnamed = "󱀶"; }; }; - }]; - lualine_x = (lib.mapAttrsToList + } + "location"]; + lualine_x = [{ + name = ''(next(vim.lsp.buf_get_clients()) == nil) and "󰒲 " or ""''; + extraConfig.separator = { left = ""; right = ""; }; + }] ++ (lib.mapAttrsToList (diag_name: diag_color: { name = "diagnostics"; extraConfig = { @@ -117,7 +125,7 @@ b = inverted // { bg = mode_color; gui = "bold"; }; c = normal; x = inverted; - y = inverted; + y = normal; z = inverted // { bg = mode_color; }; }) { @@ -132,11 +140,16 @@ b = normal_ina // { bg = base00; gui = "bold"; }; c = normal_ina; x = inverted_ina; - y = inverted_ina; + y = normal_ina; z = normal_ina // { bg = base00; }; }; }; }; + # Show context on top if scrolled out + treesitter-context = { + enable = true; + maxLines = 5; + }; }; }; }; diff --git a/hm/vim/default.nix b/hm/vim/default.nix index 125fe37..e067dce 100644 --- a/hm/vim/default.nix +++ b/hm/vim/default.nix @@ -70,6 +70,8 @@ overrideGenericSorter = true; }; }; + # TODO Go to any symbol in the current working directory, for when LSP doesn't support it. + # Or at least something to live_grep the curent word. # Surrounding pairs surround.enable = true; # Change surrounding pairs (e.g. brackets, quotes) diff --git a/hm/vim/git.nix b/hm/vim/git.nix index ee7047c..7c8706f 100644 --- a/hm/vim/git.nix +++ b/hm/vim/git.nix @@ -10,6 +10,7 @@ ''; extraPlugins = with pkgs.vimPlugins; [ fugitive-gitlab-vim # Open files in GitLab + # TODO Investigate gitlinker instead ]; plugins = { fugitive.enable = true; # Git basics From 5b3c887b41ca515a524fa56a79bee28d68e40d5c Mon Sep 17 00:00:00 2001 From: Geoffrey Preud'homme Date: Thu, 25 Jan 2024 13:03:30 +0100 Subject: [PATCH 09/16] git-sync: Only push when there's something to push --- hm/git/default.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hm/git/default.nix b/hm/git/default.nix index 36b8acf..8ffcc66 100644 --- a/hm/git/default.nix +++ b/hm/git/default.nix @@ -14,9 +14,10 @@ else ( cd "${r.path}" - ${pkgs.git}/bin/git diff --quiet || echo "Repository is dirty!" + ${pkgs.git}/bin/git --no-optional-locks diff --quiet || echo "Repository is dirty!" ${pkgs.git}/bin/git pull || true - ${pkgs.git}/bin/git push || true + # Only push if there's something to push. Also prevents from trying to push on repos where we don't have rights. + (${pkgs.git}/bin/git --no-optional-locks status --porcelain -b --ignore-submodules | grep ' \[ahead [0-9]\+\]' && ${pkgs.git}/bin/git push) || true ) fi '') From 0bb5981f3aafb554f07e67101b7823251edc3dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Thu, 25 Jan 2024 23:53:59 +0100 Subject: [PATCH 10/16] vim: Fix tabline bindings --- hm/vim/decoration.nix | 283 +++++++++++++++++++++--------------------- 1 file changed, 143 insertions(+), 140 deletions(-) diff --git a/hm/vim/decoration.nix b/hm/vim/decoration.nix index b5f51bc..a80e8b4 100644 --- a/hm/vim/decoration.nix +++ b/hm/vim/decoration.nix @@ -1,154 +1,157 @@ { pkgs, lib, config, ... }: { config = { - programs.nixvim = { - autoCmd = [ - # Turn off relativenumber only for insert mode - { event = "InsertEnter"; pattern = "*"; command = "set norelativenumber"; } - { event = "InsertLeave"; pattern = "*"; command = "set relativenumber"; } - ]; - extraPlugins = with pkgs.vimPlugins; [ - nvim-scrollview # Scroll bar - ]; - keymaps = [ - # barbar - { key = ""; action = "BufferPrevious"; options = { silent = true; }; } - { key = ""; action = "BufferNext"; options = { silent = true; }; } - # TODO https://www.reddit.com/r/neovim/comments/mbj8m5/how_to_setup_ctrlshiftkey_mappings_in_neovim_and/ - { key = ""; action = "BufferMovePrevious"; options = { silent = true; }; } - { key = ""; action = "BufferMoveNext"; options = { silent = true; }; } - # TODO gotos don't work - { key = ""; action = "BufferGoto 1"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 2"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 3"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 4"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 5"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 6"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 7"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 8"; options = { silent = true; }; } - { key = ""; action = "BufferGoto 9"; options = { silent = true; }; } - { key = ""; action = "BufferLast"; options = { silent = true; }; } - { key = "gb"; action = "BufferPick"; options = { silent = true; }; } - # TODO Other useful options? - ]; - options = { - showmode = false; - number = true; - relativenumber = true; - title = true; - }; - plugins = { - # Tabline - barbar.enable = true; - # TODO Investigate bufferline? - # Status line - lualine = with config.lib.stylix.colors.withHashtag; let - normal = { fg = base05; bg = base01; }; - inverted = { fg = base00; bg = base03; }; - normal_ina = { fg = base02; bg = base01; }; - inverted_ina = { fg = base00; bg = base02; }; - in - rec { - enable = true; - inactiveSections = sections; - sections = { - lualine_a = [{ - name = ''string.format('%d', vim.fn.line('$'))''; - }]; - lualine_b = [ - "mode" - ]; - lualine_c = [{ - name = "filename"; - color = { - __raw = '' - function(section) - return { fg = vim.bo.modified and '${base08}' or '${normal.fg}' } - end - ''; - }; - extraConfig = { - path = 1; # Relative path - symbols = { - modified = "●"; - newfile = "󰻭"; - readonly = "󰏯"; - unnamed = "󱀶"; + programs = { + # https://www.reddit.com/r/neovim/comments/mbj8m5/how_to_setup_ctrlshiftkey_mappings_in_neovim_and/ + alacritty.settings.key_bindings = [ + { key = "H"; mods = "Control|Shift"; chars = "\\x1b[72;5u"; } + { key = "L"; mods = "Control|Shift"; chars = "\\x1b[76;5u"; } + ] ++ (map + (n: { key = "Key${builtins.toString n}"; mods = "Control"; chars = "\\x1b[${builtins.toString (48+n)};5u"; }) + (lib.lists.range 0 9)); + # Ctrl+ doesn't get interpreted, but Ctrl+Shift+ does, so let's use that + nixvim = { + autoCmd = [ + # Turn off relativenumber only for insert mode + { event = "InsertEnter"; pattern = "*"; command = "set norelativenumber"; } + { event = "InsertLeave"; pattern = "*"; command = "set relativenumber"; } + ]; + extraPlugins = with pkgs.vimPlugins; [ + nvim-scrollview # Scroll bar + ]; + keymaps = + let + options = { silent = true; }; + in + [ + # barbar + { key = "gb"; action = "BufferPick"; inherit options; } + { key = ""; action = "BufferPrevious"; inherit options; } + { key = ""; action = "BufferNext"; inherit options; } + { key = ""; action = "BufferMovePrevious"; inherit options; } + { key = ""; action = "BufferMoveNext"; inherit options; } + { key = ""; action = "BufferLast"; inherit options; } + ] ++ (map + (n: { key = ""; action = "BufferGoto ${builtins.toString n}"; inherit options; }) + (lib.lists.range 1 9)); + options = { + showmode = false; + number = true; + relativenumber = true; + title = true; + }; + plugins = { + # Tabline + barbar.enable = true; + # Status line + lualine = with config.lib.stylix.colors.withHashtag; let + normal = { fg = base05; bg = base01; }; + inverted = { fg = base00; bg = base03; }; + normal_ina = { fg = base02; bg = base01; }; + inverted_ina = { fg = base00; bg = base02; }; + in + rec { + enable = true; + inactiveSections = sections; + sections = { + lualine_a = [{ + name = ''string.format('%d', vim.fn.line('$'))''; + }]; + lualine_b = [ + "mode" + ]; + lualine_c = [{ + name = "filename"; + color = { + __raw = '' + function(section) + return { fg = vim.bo.modified and '${base08}' or '${normal.fg}' } + end + ''; }; - }; - } - "location"]; - lualine_x = [{ - name = ''(next(vim.lsp.buf_get_clients()) == nil) and "󰒲 " or ""''; - extraConfig.separator = { left = ""; right = ""; }; - }] ++ (lib.mapAttrsToList - (diag_name: diag_color: { - name = "diagnostics"; extraConfig = { - color.bg = diag_color; - colored = false; - separator = { left = ""; right = ""; }; - sections = [ diag_name ]; + path = 1; # Relative path + symbols = { + modified = "●"; + newfile = "󰻭"; + readonly = "󰏯"; + unnamed = "󱀶"; + }; }; + } + "location"]; + lualine_x = [{ + name = ''(next(vim.lsp.buf_get_clients()) == nil) and "󰒲 " or ""''; + extraConfig.separator = { left = ""; right = ""; }; + }] ++ (lib.mapAttrsToList + (diag_name: diag_color: { + name = "diagnostics"; + extraConfig = { + color.bg = diag_color; + colored = false; + separator = { left = ""; right = ""; }; + sections = [ diag_name ]; + }; + }) + { + error = base08; + warn = base0A; + hint = base0C; + info = base0B; + }); + lualine_y = [{ + name = "diff"; + extraConfig = { + diff_color = { + added.fg = base0B; + modified.fg = base0A; + removed.fg = base08; + }; + symbols = { + added = " "; + modified = " "; + removed = " "; + }; + }; + } + "branch"]; + lualine_z = [ + "filetype" + "fileformat" + "encoding" + ]; + }; + theme = (lib.mapAttrs + (mode_name: mode_color: { + a = inverted; + b = inverted // { bg = mode_color; gui = "bold"; }; + c = normal; + x = inverted; + y = normal; + z = inverted // { bg = mode_color; }; }) { - error = base08; - warn = base0A; - hint = base0C; - info = base0B; - }); - lualine_y = [{ - name = "diff"; - extraConfig = { - diff_color = { - added.fg = base0B; - modified.fg = base0A; - removed.fg = base08; - }; - symbols = { - added = " "; - modified = " "; - removed = " "; - }; + normal = base0D; + insert = base0B; + visual = base0F; + replace = base08; + command = base0E; + }) // { + inactive = { + a = inverted_ina; + b = normal_ina // { bg = base00; gui = "bold"; }; + c = normal_ina; + x = inverted_ina; + y = normal_ina; + z = normal_ina // { bg = base00; }; }; - } - "branch"]; - lualine_z = [ - "filetype" - "fileformat" - "encoding" - ]; - }; - theme = (lib.mapAttrs - (mode_name: mode_color: { - a = inverted; - b = inverted // { bg = mode_color; gui = "bold"; }; - c = normal; - x = inverted; - y = normal; - z = inverted // { bg = mode_color; }; - }) - { - normal = base0D; - insert = base0B; - visual = base0F; - replace = base08; - command = base0E; - }) // { - inactive = { - a = inverted_ina; - b = normal_ina // { bg = base00; gui = "bold"; }; - c = normal_ina; - x = inverted_ina; - y = normal_ina; - z = normal_ina // { bg = base00; }; }; }; - }; - # Show context on top if scrolled out - treesitter-context = { - enable = true; - maxLines = 5; + # Show context on top if scrolled out + treesitter-context = { + enable = true; + maxLines = 5; + }; }; }; }; From ca2dc262b79e825e507bdfdbe9d10f2b3248c48a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Fri, 26 Jan 2024 00:23:52 +0100 Subject: [PATCH 11/16] gpg: Fancy pinentry --- hm/gpg/default.nix | 4 ++++ os/desktop.nix | 3 +++ 2 files changed, 7 insertions(+) diff --git a/hm/gpg/default.nix b/hm/gpg/default.nix index e299d01..612aebe 100644 --- a/hm/gpg/default.nix +++ b/hm/gpg/default.nix @@ -34,6 +34,10 @@ services.gpg-agent = { enableBashIntegration = true; enableZshIntegration = true; + pinentryFlavor = "gnome3"; + # gnome3 is nicer, but requires gcr as a dbus package. + # Which is in my NixOS config, and on non-NixOS too. + # It will fall back to ncurses when running in non-graphics mode. }; }; } diff --git a/os/desktop.nix b/os/desktop.nix index d836976..2708944 100644 --- a/os/desktop.nix +++ b/os/desktop.nix @@ -41,5 +41,8 @@ pulseaudio.enable = true; # TODO Try pipewire }; + + # So we can use gnome3 pinentry flavour + services.dbus.packages = [ pkgs.gcr ]; }; } From ffd871299b614419fdfcbb21e66941615e87262d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Fri, 26 Jan 2024 18:37:56 +0100 Subject: [PATCH 12/16] Update nixpkgs --- flake.lock | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/flake.lock b/flake.lock index 53b7082..c586b0e 100644 --- a/flake.lock +++ b/flake.lock @@ -398,11 +398,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1705183652, - "narHash": "sha256-rnfkyUH0x72oHfiSDhuCHDHg3gFgF+lF8zkkg5Zihsw=", + "lastModified": 1706098335, + "narHash": "sha256-r3dWjT8P9/Ah5m5ul4WqIWD8muj5F+/gbCdjiNVBKmU=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "428544ae95eec077c7f823b422afae5f174dee4b", + "rev": "a77ab169a83a4175169d78684ddd2e54486ac651", "type": "github" }, "original": { @@ -452,16 +452,18 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "dirtyRev": "c96d7b46d05a78e695ed1c725d1596b65509b4f9-dirty", - "dirtyShortRev": "c96d7b46-dirty", - "lastModified": 1702044539, + "lastModified": 1705700164, "narHash": "sha256-YAWtzc+5KDOHDGz/NBB7ysIusXbYYKtsbDOsRhSWKYk=", - "type": "git", - "url": "file:/home/geoffrey/nixvim" + "owner": "GeoffreyFrogeye", + "repo": "nixvim", + "rev": "2e5f7781fccba0472277cad5d383d10d50772234", + "type": "github" }, "original": { - "type": "git", - "url": "file:/home/geoffrey/nixvim" + "owner": "GeoffreyFrogeye", + "ref": "frogeye-23.11", + "repo": "nixvim", + "type": "github" } }, "nmd": { From 85cd61d206d09e85606b94d927604f907d40c98c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Fri, 26 Jan 2024 18:38:11 +0100 Subject: [PATCH 13/16] thefuck: Added Mostly as an experiment for now. --- hm/common.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hm/common.nix b/hm/common.nix index 6c7a1da..e455af5 100644 --- a/hm/common.nix +++ b/hm/common.nix @@ -58,6 +58,11 @@ newestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | tail''; oldestFile = ''${pkgs.findutils}/bin/find -type f -printf '%T+ %p\n' | sort | head''; }; + thefuck = { + enable = true; + enableBashIntegration = true; + enableZshIntegration = true; + }; lsd = { enable = true; settings = { From 9c6a2f69f02acb4a5c5a51a2d9109b411821e529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Fri, 26 Jan 2024 22:02:25 +0100 Subject: [PATCH 14/16] vim/git: Use gitlinker --- hm/vim/git.nix | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/hm/vim/git.nix b/hm/vim/git.nix index 7c8706f..bd6fa9d 100644 --- a/hm/vim/git.nix +++ b/hm/vim/git.nix @@ -2,26 +2,30 @@ { config = { programs.nixvim = { - extraConfigVim = '' - let g:fugitive_gitlab_domains = [${ - lib.strings.concatStringsSep ", " ( - map (d: "'${d}'") config.frogeye.vim.fugitive.gitlab_domains - )}] - ''; - extraPlugins = with pkgs.vimPlugins; [ - fugitive-gitlab-vim # Open files in GitLab - # TODO Investigate gitlinker instead + keymaps = [ + { + mode = [ "n" ]; + key = "gG"; + action = ''lua require"gitlinker".get_buf_range_url("n")''; + } + { + mode = [ "v" ]; + key = "gG"; + action = ''lua require"gitlinker".get_buf_range_url("v")''; + } ]; plugins = { fugitive.enable = true; # Git basics gitsigns.enable = true; # Show changed lines in the gutter + gitlinker = { + enable = true; # Copy URL of forge corresponding to cursor + callbacks = { + "code.techinc.nl" = "get_gitea_type_url"; + "git.frogeye.fr" = "get_gitea_type_url"; + }; + mappings = null; # This option doesn't work, hence manual mappings + }; }; }; }; - options.frogeye.vim.fugitive = { - gitlab_domains = lib.mkOption { - default = { }; - type = lib.types.listOf lib.types.str; - }; - }; } From 5bba711d3c145020a4a011ac343224c61a5fb622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 27 Jan 2024 00:23:38 +0100 Subject: [PATCH 15/16] Plymouth! Yeah yeah I know... --- curacao/os.nix | 3 +-- flake.nix | 1 + hm/theme/default.nix | 1 + os/default.nix | 1 + os/style/bg.svg | 25 +++++++++++++++++++++++++ os/style/default.nix | 24 ++++++++++++++++++++++++ os/style/flower.svg | 8 ++++++++ 7 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 os/style/bg.svg create mode 100644 os/style/default.nix create mode 100644 os/style/flower.svg diff --git a/curacao/os.nix b/curacao/os.nix index f7b7312..9b66fd8 100644 --- a/curacao/os.nix +++ b/curacao/os.nix @@ -1,4 +1,4 @@ -{ ... }: +{ pkgs, lib, config, ... }: { imports = [ ./options.nix @@ -9,7 +9,6 @@ networking.hostName = "curacao"; boot = { - initrd.luks.reusePassphrases = true; loader = { efi.efiSysMountPoint = "/efi"; }; diff --git a/flake.nix b/flake.nix index cf0b4fc..d0d78dc 100644 --- a/flake.nix +++ b/flake.nix @@ -82,6 +82,7 @@ ./os disko.nixosModules.disko home-manager.nixosModules.home-manager + stylix.nixosModules.stylix ]; }; nixOnDroidModules.dotfiles = { diff --git a/hm/theme/default.nix b/hm/theme/default.nix index e9122f4..b85b992 100644 --- a/hm/theme/default.nix +++ b/hm/theme/default.nix @@ -11,6 +11,7 @@ in stylix = { base16Scheme = "${pkgs.base16-schemes}/share/themes/${basetheme}-${config.frogeye.polarity}.yaml"; + polarity = config.frogeye.polarity; fonts = { monospace = { package = pkgs.nerdfonts.override { diff --git a/os/default.nix b/os/default.nix index 6cfe943..1b40690 100644 --- a/os/default.nix +++ b/os/default.nix @@ -8,6 +8,7 @@ ./desktop.nix ./gaming ./geoffrey.nix + ./style ./wireless.nix ]; } diff --git a/os/style/bg.svg b/os/style/bg.svg new file mode 100644 index 0000000..db83be1 --- /dev/null +++ b/os/style/bg.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/os/style/default.nix b/os/style/default.nix new file mode 100644 index 0000000..bc441a3 --- /dev/null +++ b/os/style/default.nix @@ -0,0 +1,24 @@ +{ pkgs, lib, config, ... }: +{ + config = { + boot = { + plymouth.enable = true; + initrd.systemd.enable = true; + }; + stylix = { + base16Scheme = "${pkgs.base16-schemes}/share/themes/solarized-${config.stylix.polarity}.yaml"; + image = builtins.fetchurl { + url = "https://get.wallhere.com/photo/sunlight-abstract-minimalism-green-simple-circle-light-leaf-wave-material-line-wing-computer-wallpaper-font-close-up-macro-photography-124350.png"; + sha256 = "sha256:1zfq3f3v34i45mi72pkfqphm8kbhczsg260xjfl6dbydy91d7y93"; + }; + homeManagerIntegration.autoImport = false; # Makes config reuse easier + polarity = "dark"; + targets.plymouth.logo = pkgs.runCommand "flower.png" { } "${pkgs.inkscape}/bin/inkscape ${pkgs.substituteAll { + src = ./flower.svg; + color = config.lib.stylix.colors.withHashtag.base07; + }} -w 256 -o $out"; + # UPST Default grub font is sansSerif, which doesn't work. + # Maybe because people patch mono with nerdfonts and that isn't compatible? + }; + }; +} diff --git a/os/style/flower.svg b/os/style/flower.svg new file mode 100644 index 0000000..e95bf57 --- /dev/null +++ b/os/style/flower.svg @@ -0,0 +1,8 @@ + + + + + + + + From c936d859c7c59d81971afe0b1c8363a1ac2dd82a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 27 Jan 2024 14:23:26 +0100 Subject: [PATCH 16/16] Frogarized! --- common/frogarized/default.nix | 22 ++++++ common/frogarized/frogarized.py | 112 ++++++++++++++++++++++++++++++ hm/default.nix | 1 + hm/desktop/background/default.nix | 5 -- hm/theme/default.nix | 9 --- hm/vim/decoration.nix | 1 + hm/vim/default.nix | 3 + os/default.nix | 1 + os/style/default.nix | 5 -- 9 files changed, 140 insertions(+), 19 deletions(-) create mode 100644 common/frogarized/default.nix create mode 100755 common/frogarized/frogarized.py diff --git a/common/frogarized/default.nix b/common/frogarized/default.nix new file mode 100644 index 0000000..571c67b --- /dev/null +++ b/common/frogarized/default.nix @@ -0,0 +1,22 @@ +{ pkgs, lib, config, ... }: +let + generator = pkgs.writers.writePython3 "frogarized" + { + libraries = [ pkgs.python3Packages.colorspacious ]; + } + (builtins.readFile ./frogarized.py); + frogarized_json = polarity: pkgs.runCommand "frogarized-${polarity}.json" { } "${generator} --polarity ${polarity} --output json > $out"; + frogarized_nix = polarity: builtins.fromJSON (builtins.readFile (frogarized_json polarity)); +in +{ + config = { + stylix = { + base16Scheme = frogarized_nix config.stylix.polarity; + # On purpose also enable without a DE because stylix complains otherwise + image = builtins.fetchurl { + url = "https://get.wallhere.com/photo/sunlight-abstract-minimalism-green-simple-circle-light-leaf-wave-material-line-wing-computer-wallpaper-font-close-up-macro-photography-124350.png"; + sha256 = "sha256:1zfq3f3v34i45mi72pkfqphm8kbhczsg260xjfl6dbydy91d7y93"; + }; + }; + }; +} diff --git a/common/frogarized/frogarized.py b/common/frogarized/frogarized.py new file mode 100755 index 0000000..c3aec87 --- /dev/null +++ b/common/frogarized/frogarized.py @@ -0,0 +1,112 @@ +import argparse +import json + +import colorspacious +import numpy as np + +# Original values for the Solarized color scheme, +# created by Ethan Schoonover (https://ethanschoonover.com/solarized/) +SOLARIZED_LAB = np.array( + [ + [15, -12, -12], + [20, -12, -12], + [45, -7, -7], + [50, -7, -7], + [60, -6, -3], + [65, -5, -2], + [92, -0, 10], + [97, 0, 10], + [50, 65, 45], + [50, 50, 55], + [60, 10, 65], + [60, -20, 65], + [60, -35, -5], + [55, -10, -45], + [50, 15, -45], + [50, 65, -5], + ] +) + +# I couldn't get a perfect translation of Solarized L*a*b values into sRGB, +# so here is upstream's translation for reference +SOLARIZED_RGB = np.array( + [ + [0, 43, 54], + [7, 54, 66], + [88, 110, 117], + [101, 123, 131], + [131, 148, 150], + [147, 161, 161], + [238, 232, 213], + [253, 246, 227], + [220, 50, 47], + [203, 75, 22], + [181, 137, 0], + [133, 153, 0], + [42, 161, 152], + [38, 139, 210], + [108, 113, 196], + [211, 54, 130], + ] +) + +# Parse arguments +parser = argparse.ArgumentParser( + description="Generate a base16-theme based derived from Solarized" +) +parser.add_argument("--source", choices=["lab", "rgb"], default="lab") +parser.add_argument("--lightness_factor", type=float, default=1.0) +parser.add_argument("--chroma-factor", type=float, default=1.0) +parser.add_argument("--hue_shift", type=float, default=-75.0) +parser.add_argument("--polarity", choices=["dark", "light"], default="dark") +parser.add_argument( + "--output", choices=["json", "truecolor"], default="truecolor" +) +args = parser.parse_args() + +# Convert source to JCh color space +if args.source == "lab": + solarized_jch = colorspacious.cspace_convert( + SOLARIZED_LAB, "CIELab", "JCh" + ) +elif args.source == "rgb": + solarized_jch = colorspacious.cspace_convert( + SOLARIZED_RGB, "sRGB255", "JCh" + ) + +# Build frogarized theme +jch_factor = [args.lightness_factor, args.chroma_factor, 1] +jch_shift = [0, 0, args.hue_shift] +frogarzied_jch = np.vstack( + [solarized_jch[:8] * jch_factor + jch_shift, solarized_jch[8:]] +) + +# Convert frogarized to RGB +frogarized_srgb = colorspacious.cspace_convert( + frogarzied_jch, "JCh", "sRGB255" +) +frogarized_rgb = np.uint8(np.rint(np.clip(frogarized_srgb, 0, 255))) +if args.polarity == "light": + frogarized_rgb = np.vstack([frogarized_rgb[7::-1], frogarized_rgb[8:]]) + +# Output +palette = dict() +for i in range(16): + rgb = frogarized_rgb[i] + r, g, b = rgb + hex = f"#{r:02x}{g:02x}{b:02x}" + palette[f"base{i:02X}"] = hex + if args.output == "truecolor": + print(f"\033[48;2;{r};{g};{b}m{hex}\033[0m") # ]] + # treesitter is silly and will consider brackets in strings + # as indentation, hence the comment above +if args.output == "json": + scheme = palette.copy() + scheme.update( + { + "slug": f"frogarized-{args.polarity}", + "scheme": f"Frogarized {args.polarity.title()}", + "author": "Geoffrey Frogeye (with work from Ethan Schoonover)", + } + ) + print(json.dumps(scheme, indent=4)) diff --git a/hm/default.nix b/hm/default.nix index 9f28122..04061d8 100644 --- a/hm/default.nix +++ b/hm/default.nix @@ -1,6 +1,7 @@ { ... }: { imports = [ + ../common/frogarized ../options.nix ./brightness ./common.nix diff --git a/hm/desktop/background/default.nix b/hm/desktop/background/default.nix index 37767e6..6587f27 100644 --- a/hm/desktop/background/default.nix +++ b/hm/desktop/background/default.nix @@ -1,11 +1,6 @@ { pkgs, config, lib, ... }: { config = { - # On purpose also enable without a DE because stylix complains otherwise - stylix.image = builtins.fetchurl { - url = "https://get.wallhere.com/photo/sunlight-abstract-minimalism-green-simple-circle-light-leaf-wave-material-line-wing-computer-wallpaper-font-close-up-macro-photography-124350.png"; - sha256 = "sha256:1zfq3f3v34i45mi72pkfqphm8kbhczsg260xjfl6dbydy91d7y93"; - }; # This correctly sets the background on some occasions, below does the rest programs.autorandr.hooks.postswitch = { background = "${pkgs.feh}/bin/feh --no-fehbg --bg-fill ${config.stylix.image}"; diff --git a/hm/theme/default.nix b/hm/theme/default.nix index b85b992..76463b1 100644 --- a/hm/theme/default.nix +++ b/hm/theme/default.nix @@ -1,16 +1,7 @@ { pkgs, config, lib, ... }: -let - basetheme = "solarized"; -in { config = { - # Setting a custom base16 theme via nixvim is required so feline works, and - # because stylix makes a config that otherwise only works with dark - # polarity. - programs.nixvim.colorschemes.base16.colorscheme = "${basetheme}-${config.frogeye.polarity}"; - stylix = { - base16Scheme = "${pkgs.base16-schemes}/share/themes/${basetheme}-${config.frogeye.polarity}.yaml"; polarity = config.frogeye.polarity; fonts = { monospace = { diff --git a/hm/vim/decoration.nix b/hm/vim/decoration.nix index a80e8b4..cbb7457 100644 --- a/hm/vim/decoration.nix +++ b/hm/vim/decoration.nix @@ -43,6 +43,7 @@ plugins = { # Tabline barbar.enable = true; + # TODO Reload make it use the preset colorscheme # Status line lualine = with config.lib.stylix.colors.withHashtag; let normal = { fg = base05; bg = base01; }; diff --git a/hm/vim/default.nix b/hm/vim/default.nix index e067dce..d50453f 100644 --- a/hm/vim/default.nix +++ b/hm/vim/default.nix @@ -12,6 +12,9 @@ vim = "nvim"; }; programs.nixvim = { + # Required, otherwise light mode becomes a default dark theme. + colorschemes.base16.colorscheme = "solarized-${config.stylix.polarity}"; + options = { ignorecase = true; smartcase = true; diff --git a/os/default.nix b/os/default.nix index 1b40690..28bd391 100644 --- a/os/default.nix +++ b/os/default.nix @@ -2,6 +2,7 @@ { imports = [ ../options.nix + ../common/frogarized ./battery.nix ./ccc ./common.nix diff --git a/os/style/default.nix b/os/style/default.nix index bc441a3..ab0fa91 100644 --- a/os/style/default.nix +++ b/os/style/default.nix @@ -6,11 +6,6 @@ initrd.systemd.enable = true; }; stylix = { - base16Scheme = "${pkgs.base16-schemes}/share/themes/solarized-${config.stylix.polarity}.yaml"; - image = builtins.fetchurl { - url = "https://get.wallhere.com/photo/sunlight-abstract-minimalism-green-simple-circle-light-leaf-wave-material-line-wing-computer-wallpaper-font-close-up-macro-photography-124350.png"; - sha256 = "sha256:1zfq3f3v34i45mi72pkfqphm8kbhczsg260xjfl6dbydy91d7y93"; - }; homeManagerIntegration.autoImport = false; # Makes config reuse easier polarity = "dark"; targets.plymouth.logo = pkgs.runCommand "flower.png" { } "${pkgs.inkscape}/bin/inkscape ${pkgs.substituteAll {