From 3204ac12e79638326dc6dfe0a5e3206428ffb3c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sat, 10 Jun 2023 10:23:31 +0200 Subject: [PATCH 1/2] build: bump inputs --- flake.lock | 194 +++++++++++++++++------------------ flake.nix | 2 +- modules/profiles/desktop.nix | 6 +- modules/security/default.nix | 4 +- 4 files changed, 103 insertions(+), 103 deletions(-) diff --git a/flake.lock b/flake.lock index 288f5fb..4db0abc 100644 --- a/flake.lock +++ b/flake.lock @@ -70,11 +70,11 @@ ] }, "locked": { - "lastModified": 1683433501, - "narHash": "sha256-9L+OZeU3bcNZ55mhMINBxnqskbaEU0mhiZIMhkEtNl0=", + "lastModified": 1685309025, + "narHash": "sha256-pZxMM3AMP/ojwhrFD0A2ML4NOgehlBLGHseInnO5evc=", "owner": "zhaofengli", "repo": "attic", - "rev": "5f85e35a25085b75e1cbb6cc7291726fa4fab2ed", + "rev": "b1fb790b5f2afaaa1b2f7f18979b8318abe604bb", "type": "github" }, "original": { @@ -102,11 +102,11 @@ "copilot-lua": { "flake": false, "locked": { - "lastModified": 1683572689, - "narHash": "sha256-+dqwwBHDRh1vmbgx8o1RVMEAN7Hlr5I5L71wdagDo/o=", + "lastModified": 1685261869, + "narHash": "sha256-jBTS8MeN7Ydf0ZY7JWbrxaGo/GeDoEClfULiJVfN8Wo=", "owner": "zbirenbaum", "repo": "copilot.lua", - "rev": "653bbdc44cd569a5fd0617e5a9d3df2b1359e230", + "rev": "77e3a4907928f0813024e573b882dc879dfc0c6b", "type": "github" }, "original": { @@ -255,11 +255,11 @@ ] }, "locked": { - "lastModified": 1683560683, - "narHash": "sha256-XAygPMN5Xnk/W2c1aW0jyEa6lfMDZWlQgiNtmHXytPc=", + "lastModified": 1685662779, + "narHash": "sha256-cKDDciXGpMEjP1n6HlzKinN0H+oLmNpgeCTzYnsA2po=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "006c75898cf814ef9497252b022e91c946ba8e17", + "rev": "71fb97f0d875fd4de4994dfb849f2c75e17eb6c3", "type": "github" }, "original": { @@ -273,11 +273,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1678379998, - "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", + "lastModified": 1685546676, + "narHash": "sha256-XDbjJyAg6odX5Vj0Q22iI/gQuFvEkv9kamsSbQ+npaI=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", + "rev": "6ef2707776c6379bc727faf3f83c0dd60b06e0c6", "type": "github" }, "original": { @@ -295,11 +295,11 @@ ] }, "locked": { - "lastModified": 1678379998, - "narHash": "sha256-TZdfNqftHhDuIFwBcN9MUThx5sQXCTeZk9je5byPKRw=", + "lastModified": 1680392223, + "narHash": "sha256-n3g7QFr85lDODKt250rkZj2IFS3i4/8HBU2yKHO3tqw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "c13d60b89adea3dc20704c045ec4d50dd964d447", + "rev": "dcc36e45d054d7bb554c9cdab69093debd91a0b5", "type": "github" }, "original": { @@ -313,11 +313,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1681202837, - "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", "owner": "numtide", "repo": "flake-utils", - "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", "type": "github" }, "original": { @@ -418,16 +418,16 @@ }, "haskell-flake": { "locked": { - "lastModified": 1678138103, - "narHash": "sha256-D0lao82bV3t2gEFjHiU6RN233t+1MnkQV+bq8MEu2ic=", - "owner": "hercules-ci", + "lastModified": 1678745009, + "narHash": "sha256-ujfwSrkxThmHJozibkCnJmlXLVyxm+Cbo2Q4wXPbCS4=", + "owner": "srid", "repo": "haskell-flake", - "rev": "1e1660e6dd00838ba73bc7952e6e73be67da18d1", + "rev": "26852ade574c712bc3912ad28de52b0c4cf7d4cb", "type": "github" }, "original": { - "owner": "hercules-ci", - "ref": "0.1-extraLibraries", + "owner": "srid", + "ref": "0.2.0", "repo": "haskell-flake", "type": "github" } @@ -441,11 +441,11 @@ "pre-commit-hooks-nix": "pre-commit-hooks-nix" }, "locked": { - "lastModified": 1678446614, - "narHash": "sha256-Z6Gsba5ahn/N0QlF0vJfIEfnZgCs4qr1IZtXAqjbE7s=", + "lastModified": 1681758488, + "narHash": "sha256-RBd/RNq3wL52FvoajMwrnfyZPfq67KMzmp6rtNAx/2o=", "owner": "hercules-ci", "repo": "hercules-ci-agent", - "rev": "0b90d1a87c117a5861785cb85833dd1c9df0b6ef", + "rev": "ef296dd6211e2ffeb942f12e6232a2d9abdd488d", "type": "github" }, "original": { @@ -463,11 +463,11 @@ ] }, "locked": { - "lastModified": 1681898675, - "narHash": "sha256-nIJ7CAdiHv4i1no/VgDoeTJLzbLYwu5+/Ycoyzn0S78=", + "lastModified": 1685557007, + "narHash": "sha256-0prbgwFJeBuLGJgNdOXCXQ8/oSamzkcNZYHr04ZXI2I=", "owner": "hercules-ci", "repo": "hercules-ci-effects", - "rev": "15ff4f63e5f28070391a5b09a82f6d5c6cc5c9d0", + "rev": "6d8e62977dc34fd2c187879856ebb6cf1faabba9", "type": "github" }, "original": { @@ -504,11 +504,11 @@ ] }, "locked": { - "lastModified": 1684824189, - "narHash": "sha256-k3nCkn5Qy67rCguuw6YkGuL6hOUNRKxQoKOjnapk5sU=", + "lastModified": 1685721552, + "narHash": "sha256-ifvq/zlO7lck8q+YkC5uom/h8/MVdMcQEldOL3cDQW0=", "owner": "nix-community", "repo": "home-manager", - "rev": "58eb968c21d309a6c2b020ea8d64e25c38ceebba", + "rev": "29519461834c08395b35f840811faf8c23e3b61c", "type": "github" }, "original": { @@ -543,11 +543,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1684844798, - "narHash": "sha256-ZrMXFoEA535jOZ+eDA3s+URZ5MkVRksBgL5qGnb6Ciw=", + "lastModified": 1685729674, + "narHash": "sha256-i5+/bAZVmCbeIKmnwyd2DG3mGrP4LOJWbsU7nJ1lzuA=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "eb1f832fcec5838053c6b031b656e4f949ada57b", + "rev": "871ab24c6e9d2fb6e48cbf990ddddf0c46a950af", "type": "github" }, "original": { @@ -564,11 +564,11 @@ ] }, "locked": { - "lastModified": 1681065697, - "narHash": "sha256-QPzwwlGKX95tl6ZEshboZbEwwAXww6lNLdVYd6T9Mrc=", + "lastModified": 1684265364, + "narHash": "sha256-AxNnWbthsuNx73HDQr0eBxrcE3+yfl/WsaXZqUFmkpQ=", "owner": "hyprwm", "repo": "hyprland-protocols", - "rev": "4d29e48433270a2af06b8bc711ca1fe5109746cd", + "rev": "8c279b9fb0f2b031427dc5ef4eab53f2ed835530", "type": "github" }, "original": { @@ -582,11 +582,11 @@ "nixpkgs": "nixpkgs_3" }, "locked": { - "lastModified": 1684265311, - "narHash": "sha256-zFOShOYS7zMcyCT9bFQlWB/ZtTelAFKKGUq4XBRQLE0=", + "lastModified": 1685378141, + "narHash": "sha256-/ehJbAtSJS86NlqHVOeR2ViBKlImKH4guFVPacTmCr8=", "owner": "hyprwm", "repo": "hyprpaper", - "rev": "b82254e957cfa60124240e8d94e7368cbf6d392d", + "rev": "cd86c196f3500f20539754d347c8378349ca0974", "type": "github" }, "original": { @@ -614,11 +614,11 @@ "lspsaga-nvim": { "flake": false, "locked": { - "lastModified": 1684482876, - "narHash": "sha256-ETT0HPLTA6ZO2C51+YXQ2PTkol61Azzn9FhLhmObrr8=", + "lastModified": 1685612219, + "narHash": "sha256-Cr4BAAMX0SEPM51JejjnhOUXigMIGvyzqFYYAZ426bU=", "owner": "glepnir", "repo": "lspsaga.nvim", - "rev": "01b9633aefd010f272d6c7e3d8293c44fcfe7696", + "rev": "c475ace5b8882631b351ef7c3e8078ca9ebbb751", "type": "github" }, "original": { @@ -629,11 +629,11 @@ }, "master": { "locked": { - "lastModified": 1684857135, - "narHash": "sha256-MrX+6QO3xf+Gkm+BgU45jBB/l9XRvH/hGsLfx8fEetU=", + "lastModified": 1685770779, + "narHash": "sha256-cJd4Bf0jUOG/l/k9I83IYsq9jDFPyLAfiIw1cjErcTU=", "owner": "nixos", "repo": "nixpkgs", - "rev": "499cad7a722caf0bebb2a382a67fa39c992acebd", + "rev": "f04dbdd29e954e51e98d2a0896c13180f5247143", "type": "github" }, "original": { @@ -652,11 +652,11 @@ }, "locked": { "dir": "contrib", - "lastModified": 1684757802, - "narHash": "sha256-Uo8HJ5j33mzgfrpK2zo0N/vgzTFG8KhMBE4+M1C9oCo=", + "lastModified": 1685727707, + "narHash": "sha256-qxmSnNjRxXuFfPNaDMnTPjn8890CN2EQ1Il8XVJhkKE=", "owner": "neovim", "repo": "neovim", - "rev": "07883940b2294e0ab32fb58e6624d18d9dd1715a", + "rev": "a8ee4c7a81a8df3fe705e941e7d1c2c9e2f6194e", "type": "github" }, "original": { @@ -675,11 +675,11 @@ "nixpkgs": "nixpkgs_5" }, "locked": { - "lastModified": 1684800319, - "narHash": "sha256-cyR9g1WSX1WCPGOgL/JXjzwir0Db7k9WMWfwuMgMl5w=", + "lastModified": 1685750689, + "narHash": "sha256-ylsh7ELjDc4jHCBZgUVTD08aTD31SpXoqXnjlbGdyoQ=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "1d9dcda97f8d16214821ace2cf92f61f1cc348c3", + "rev": "b9c2089d1936a81d466de8a2ccb9d75c22b5b7fd", "type": "github" }, "original": { @@ -699,11 +699,11 @@ "rust-overlay": "rust-overlay_2" }, "locked": { - "lastModified": 1684534870, - "narHash": "sha256-QrOkY6Ei/7FZg50Ht8iC9ryqrQyBzjtnSQoftL8ZNNc=", + "lastModified": 1685532165, + "narHash": "sha256-xHH9WbE9uya2B+j5w82HzpZVeErBt03/jtmWVRox0EU=", "owner": "oxalica", "repo": "nil", - "rev": "17ed1578f3a225f2760d4da3adb440eb8677f2d3", + "rev": "dcd38b96c91a2d07552f824a6480e00dc7b4948a", "type": "github" }, "original": { @@ -722,11 +722,11 @@ ] }, "locked": { - "lastModified": 1673295039, - "narHash": "sha256-AsdYgE8/GPwcelGgrntlijMg4t3hLFJFCRF3tL5WVjA=", + "lastModified": 1680266963, + "narHash": "sha256-IW/lzbUCOcldLHWHjNSg1YoViDnZOmz0ZJL7EH9OkV8=", "owner": "LnL7", "repo": "nix-darwin", - "rev": "87b9d090ad39b25b2400029c64825fc2a8868943", + "rev": "99d4187d11be86b49baa3a1aec0530004072374f", "type": "github" }, "original": { @@ -778,11 +778,11 @@ "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1678375444, - "narHash": "sha256-XIgHfGvjFvZQ8hrkfocanCDxMefc/77rXeHvYdzBMc8=", + "lastModified": 1682879489, + "narHash": "sha256-sASwo8gBt7JDnOOstnps90K1wxmVfyhsTPPNTGBPjjg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "130fa0baaa2b93ec45523fdcde942f6844ee9f6e", + "rev": "da45bf6ec7bbcc5d1e14d3795c025199f28e0de0", "type": "github" }, "original": { @@ -811,11 +811,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1673800717, - "narHash": "sha256-SFHraUqLSu5cC6IxTprex/nTsI81ZQAtDvlBvGDWfnA=", + "lastModified": 1678872516, + "narHash": "sha256-/E1YwtMtFAu2KUQKV/1+KFuReYPANM2Rzehk84VxVoc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "2f9fd351ec37f5d479556cd48be4ca340da59b8f", + "rev": "9b8e5abb18324c7fe9f07cb100c3cd4a29cda8b8", "type": "github" }, "original": { @@ -843,11 +843,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1683014792, - "narHash": "sha256-6Va9iVtmmsw4raBc3QKvQT2KT/NGRWlvUlJj46zN8B8=", + "lastModified": 1685655444, + "narHash": "sha256-6EujQNAeaUkWvpEZZcVF8qSfQrNVWFNNGbUJxv/A5a8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1a411f23ba299db155a5b45d5e145b85a7aafc42", + "rev": "e635192892f5abbc2289eaac3a73cdb249abaefd", "type": "github" }, "original": { @@ -875,11 +875,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1678293141, - "narHash": "sha256-lLlQHaR0y+q6nd6kfpydPTGHhl1rS9nU9OQmztzKOYs=", + "lastModified": 1680213900, + "narHash": "sha256-cIDr5WZIj3EkKyCgj/6j3HBH4Jj1W296z7HTcWj1aMA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "c90c4025bb6e0c4eaf438128a3b2640314b1c58d", + "rev": "e3652e0735fbec227f342712f180f4f21f0594f2", "type": "github" }, "original": { @@ -891,11 +891,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1684724044, - "narHash": "sha256-OysG4ORx60BcUyBVClbOBVybqZ4Ep8Xh8EIDvNam4WU=", + "lastModified": 1685677062, + "narHash": "sha256-zoHF7+HNwNwne2XEomphbdc4Y8tdWT16EUxUTXpOKpQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b31c968ff28927d477eed85012e8090578c70852", + "rev": "95be94370d09f97f6af6a1df1eb9649b5260724e", "type": "github" }, "original": { @@ -907,11 +907,11 @@ }, "nixpkgs_6": { "locked": { - "lastModified": 1684759798, - "narHash": "sha256-Kpbf5yKvKcj/yPqE1zYC6gju4JwTsYxTIZEvOII0jr4=", + "lastModified": 1685677062, + "narHash": "sha256-zoHF7+HNwNwne2XEomphbdc4Y8tdWT16EUxUTXpOKpQ=", "owner": "nixos", "repo": "nixpkgs", - "rev": "c7eb65213bd7d95eafb8c5e2e181f04da103d054", + "rev": "95be94370d09f97f6af6a1df1eb9649b5260724e", "type": "github" }, "original": { @@ -962,11 +962,11 @@ "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { - "lastModified": 1684842236, - "narHash": "sha256-rYWsIXHvNhVQ15RQlBUv67W3YnM+Pd+DuXGMvCBq2IE=", + "lastModified": 1685361114, + "narHash": "sha256-4RjrlSb+OO+e1nzTExKW58o3WRwVGpXwj97iCta8aj4=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "61e567d6497bc9556f391faebe5e410e6623217f", + "rev": "ca2fdbf3edda2a38140184da6381d49f8206eaf4", "type": "github" }, "original": { @@ -989,11 +989,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1678376203, - "narHash": "sha256-3tyYGyC8h7fBwncLZy5nCUjTJPrHbmNwp47LlNLOHSM=", + "lastModified": 1680170909, + "narHash": "sha256-FtKU/edv1jFRr/KwUxWTYWXEyj9g8GBrHntC2o8oFI8=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "1a20b9708962096ec2481eeb2ddca29ed747770a", + "rev": "29dbe1efaa91c3a415d8b45d62d48325a4748816", "type": "github" }, "original": { @@ -1084,11 +1084,11 @@ ] }, "locked": { - "lastModified": 1682907601, - "narHash": "sha256-FfUAYvRJ+6s9WWjXNPdRzuuvAeu2VHIXIbUkPJr4t14=", + "lastModified": 1685413459, + "narHash": "sha256-+ELexqS2yN0wj1WnmWdF24OfjRBIgTN6Ltcpjvp2dEo=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "5eaff055dd57128c53ae373dc96af944f5849daa", + "rev": "9b3284e2412f76bd68ff46f8cf1c7af44d7ffac0", "type": "github" }, "original": { @@ -1115,16 +1115,16 @@ }, "stable": { "locked": { - "lastModified": 1684661732, - "narHash": "sha256-2/Xo/UmUUoMXc0T5tzoUsYjMLLMjEfzRWDAQB0WwtW0=", + "lastModified": 1685620773, + "narHash": "sha256-iQ+LmporQNdLz8uMJdP62TaAWeLUwl43/MYUBtWqulM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "b0671cbf1e5c443f7fbfd4941ee0f8a151435114", + "rev": "f0ba8235153dd2e25cf06cbf70d43efdd4443592", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixos-22.11", + "ref": "nixos-23.05", "repo": "nixpkgs", "type": "github" } @@ -1148,11 +1148,11 @@ "flake": false, "locked": { "host": "gitlab.freedesktop.org", - "lastModified": 1682436395, - "narHash": "sha256-GGEjkQO9m7YLYIXIXM76HWdhjg4Ye+oafOtyaFAYKI4=", + "lastModified": 1685723274, + "narHash": "sha256-mjETVZbVheaSO0VRKQHWYAHcoKwYu0WZ0vhKVN7vyRo=", "owner": "wlroots", "repo": "wlroots", - "rev": "6830bfc17fd94709e2cdd4da0af989f102a26e59", + "rev": "6668c822b3bf58ca5af5d370ef03b075be3e4d27", "type": "gitlab" }, "original": { @@ -1174,11 +1174,11 @@ ] }, "locked": { - "lastModified": 1682439384, - "narHash": "sha256-zHDa8LCZs05TZHQSIZ3ucwyMPglBGHcqTBzfkLjYXTM=", + "lastModified": 1685385764, + "narHash": "sha256-r+XMyOoRXq+hlfjayb+fyi9kq2JK48TrwuNIAXqlj7U=", "owner": "hyprwm", "repo": "xdg-desktop-portal-hyprland", - "rev": "c0e233955568fbea4e859336f6d3d14d51294d7c", + "rev": "4d9ff0c17716936e0b5ca577a39e263633901ed1", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 31149d5..4fac534 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ # Nix master.url = "github:nixos/nixpkgs"; nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - stable.url = "github:nixos/nixpkgs/nixos-22.11"; + stable.url = "github:nixos/nixpkgs/nixos-23.05"; flake-utils.url = "github:numtide/flake-utils"; diff --git a/modules/profiles/desktop.nix b/modules/profiles/desktop.nix index b909535..dafc913 100644 --- a/modules/profiles/desktop.nix +++ b/modules/profiles/desktop.nix @@ -56,9 +56,9 @@ in keepassxc nixpkgs-review pavucontrol - stable.libreoffice # HACK to fix build error - stable.signal-desktop - texlive.combined.scheme-full + stable.libreoffice # NOTE breaks often + stable.signal-desktop # NOTE breaks often + stable.texlive.combined.scheme-full # NOTE breaks often thunderbird vlc ]; diff --git a/modules/security/default.nix b/modules/security/default.nix index 6183dc5..1e67492 100644 --- a/modules/security/default.nix +++ b/modules/security/default.nix @@ -69,8 +69,8 @@ services.openssh = { settings = { # Disable ssh password login - passwordAuthentication = lib.mkDefault false; - logLevel = "VERBOSE"; + PasswordAuthentication = lib.mkDefault false; + LogLevel = "VERBOSE"; }; extraConfig = '' AllowAgentForwarding no From 80c38b5120e806b94627c391fdfabd12d53cdc36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sat, 10 Jun 2023 21:52:57 +0200 Subject: [PATCH 2/2] feat(nvim): use lazy to load plugins --- modules/programs/nvim/default.nix | 239 +++++++++++++--- modules/programs/nvim/keybinds.lua | 73 ----- modules/programs/nvim/plugins/copilot-lua.lua | 8 +- modules/programs/nvim/plugins/default.nix | 254 ++++++++++++++++++ .../programs/nvim/plugins/formatter-nvim.lua | 4 - modules/programs/nvim/plugins/nvim-cmp.lua | 63 +++++ .../{init.lua => plugins/nvim-lspconfig.lua} | 84 ------ .../programs/nvim/plugins/nvim-treesitter.lua | 12 + .../programs/nvim/plugins/telescope-nvim.lua | 22 -- .../programs/nvim/plugins/trouble-nvim.lua | 37 --- .../programs/nvim/plugins/which-key-nvim.lua | 74 +++++ 11 files changed, 604 insertions(+), 266 deletions(-) delete mode 100644 modules/programs/nvim/keybinds.lua create mode 100644 modules/programs/nvim/plugins/default.nix create mode 100644 modules/programs/nvim/plugins/nvim-cmp.lua rename modules/programs/nvim/{init.lua => plugins/nvim-lspconfig.lua} (65%) create mode 100644 modules/programs/nvim/plugins/nvim-treesitter.lua delete mode 100644 modules/programs/nvim/plugins/telescope-nvim.lua diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index ac10533..aacfb4c 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -7,22 +7,207 @@ with lib; let cfg = config.my.programs.nvim; - - mkPlugin = fileName: + boolToString = bool: if bool then "true" else "false"; + quote = str: ''"${toString str}"''; + listToString = list: ''{ ${concatStringsSep ", " (map quote list)} }''; + keybinding = + { key + , cmd + , func + , mode + , desc + }: let - path = ./plugins + "/${fileName}"; - pluginName = lib.removeSuffix ".lua" fileName; + cmdString = + if cmd != null + then quote cmd + else + ( + if func != null + then func + else abort "Either cmd or function must be set" + ); in - { - plugin = pkgs.vimPlugins.${pluginName}; - type = "lua"; - config = lib.readFile path; - }; - pluginFileNames = builtins.attrNames (builtins.readDir ./plugins); - pluginsWithConfig = builtins.map mkPlugin pluginFileNames; + ''{ ${quote key}, ${cmdString}, mode = ${quote mode}, ${optionalString (desc != null) "desc = ${quote desc},"} }''; + lazySpecFromPlugin = + { plugin + , dependencies + , init + , conf + , lazy + , event + , enabled + , cmd + , ft + , priority + , keys + }: + '' + { + dir = "${plugin}", + name = "${plugin.name}", + lazy = ${boolToString lazy}, + enabled = ${boolToString enabled}, + dependencies = { ${concatStringsSep ", " (map lazySpecFromPlugin dependencies)} }, + ${optionalString (init != null) + "init = function(plugin) + ${toString init} + end," + } + ${optionalString (conf != null) + "config = function(plugin, opts) + ${toString conf} + end," + } + keys = { ${concatStringsSep ",\n" (map keybinding keys)} }, + event = ${listToString event}, + cmd = ${listToString cmd}, + ft = ${listToString ft}, + priority = ${toString priority}, + } + ''; + lazySpecs = concatStringsSep ", " (map lazySpecFromPlugin cfg.plugins); + lazy = '' + require("lazy").setup({ + ${lazySpecs} + }) + ''; in { - options.my.programs.nvim.enable = mkEnableOption "nvim"; + imports = [ ./plugins ]; + + options.my.programs.nvim = { + enable = mkEnableOption "nvim"; + plugins = mkOption { + default = [ ]; + description = '' + List of plugins with config. + ''; + type = with types; listOf ( + let + sub = submodule { + options = { + conf = mkOption { + type = nullOr str; + default = null; + description = '' + Lua code to be executed when the plugin is loaded. + ''; + }; + dependencies = mkOption { + type = listOf sub; + default = [ ]; + description = '' + List of plugins this plugin depends on. + ''; + }; + init = mkOption { + type = nullOr str; + default = null; + description = '' + Lua code to be executed when the plugin is initialized. + ''; + }; + event = mkOption { + type = listOf str; + default = [ ]; + description = '' + Event to load the plugin on. + ''; + }; + lazy = mkOption { + type = bool; + default = false; + description = '' + Whether to load the plugin lazily. + ''; + }; + plugin = mkOption { + type = package; + description = '' + The plugin package. + ''; + }; + enabled = mkOption { + type = bool; + default = true; + description = '' + Whether to enable the plugin. + ''; + }; + cmd = mkOption { + type = listOf str; + default = [ ]; + description = '' + Command to load the plugin. + ''; + }; + ft = mkOption { + type = listOf str; + default = [ ]; + description = '' + Filetype to load the plugin on. + ''; + }; + priority = mkOption { + type = int; + default = 50; + description = '' + Priority to load the plugin. + ''; + }; + keys = mkOption { + default = [ ]; + description = '' + List of keybindings. + ''; + type = listOf (submodule { + options = { + key = mkOption { + type = str; + description = '' + Key to bind. + ''; + }; + cmd = mkOption { + type = nullOr str; + default = null; + description = '' + Command to execute. + ''; + }; + func = mkOption { + type = nullOr str; + default = null; + description = '' + Function to execute. + ''; + }; + mode = mkOption { + type = str; + default = "n"; + description = '' + Mode to bind the key in. + ''; + }; + desc = mkOption { + type = nullOr str; + default = null; + description = '' + Description of the keybinding. + ''; + }; + }; + }); + }; + }; + }; + in + sub + ); + }; + }; + config = mkIf cfg.enable { home-manager.users.moritz = { @@ -41,11 +226,7 @@ in vimdiffAlias = true; withNodeJs = true; withPython3 = true; - extraLuaConfig = lib.concatLines ( - builtins.map - builtins.readFile - [ ./options.lua ./keybinds.lua ./init.lua ] - ); + extraLuaConfig = lib.concatLines [ (builtins.readFile ./options.lua) lazy ]; extraPackages = with pkgs; [ alejandra black @@ -66,30 +247,10 @@ in yamlfmt ]; plugins = with pkgs.vimPlugins; [ - cmp-async-path - cmp-nvim-lsp - cmp_luasnip - copilot-cmp - direnv-vim - friendly-snippets - lsp_lines-nvim - lspkind-nvim - lspsaga-nvim-original - luasnip - nui-nvim - nvim-cmp - nvim-lspconfig + lazy-nvim nvim-treesitter.withAllGrammars - nvim-ufo - nvim-web-devicons - plenary-nvim - popup-nvim - promise-async - vim-fugitive - vim-tmux-navigator - ] ++ pluginsWithConfig; + ]; }; }; }; } - diff --git a/modules/programs/nvim/keybinds.lua b/modules/programs/nvim/keybinds.lua deleted file mode 100644 index 35325cc..0000000 --- a/modules/programs/nvim/keybinds.lua +++ /dev/null @@ -1,73 +0,0 @@ --- buffer -require("which-key").register({ - b = { - name = "buffer", - b = { "Telescope buffers", "List buffers" }, - d = { "bd", "Delete buffer" }, - }, -}, { prefix = "" }) -require("which-key").register({ - ["["] = { - b = { "bprevious", "Previous buffer" }, - }, - ["]"] = { - b = { "bnext", "Next buffer" }, - }, -}) - --- window -require("which-key").register({ - w = { - name = "window", - ["|"] = { "v", "Split window horizontally" }, - ["-"] = { "s", "Split window vertically" }, - w = { "w", "Switch window" }, - d = { "c", "Delete window" }, - }, -}, { prefix = "" }) - --- tab -require("which-key").register({ - [""] = { - name = "tab", - [""] = { "tabnew", "New tab" }, - n = { "tabnext", "Next tab" }, - p = { "tabprevious", "Previous tab" }, - d = { "tabclose", "Close tab" }, - }, -}, { prefix = "" }) - --- file -require("which-key").register({ - f = { - name = "file/find", - n = { "enew", "New file" }, - }, -}, { prefix = "" }) - --- better descriptions for navigation -require("which-key").register({ - [""] = { - f = { name = "file/find" }, - g = { name = "git" }, - l = { name = "lsp" }, - o = { name = "org" }, - s = { name = "search" }, - t = { name = "toggle" }, - x = { name = "diagnostics/quickfix" }, - }, - ["["] = { name = "prev" }, - ["]"] = { name = "next" }, - g = { name = "goto" }, -}) - --- Clear search with -require("which-key").register({ - [""] = { "noh", "Escape and clear hlsearch", mode = { "n", "i" } }, -}) - --- better indenting -require("which-key").register({ - ["<"] = { ""] = { ">gv", "Shift right" }, -}, { mode = "v" }) diff --git a/modules/programs/nvim/plugins/copilot-lua.lua b/modules/programs/nvim/plugins/copilot-lua.lua index 94e9600..f9799dc 100644 --- a/modules/programs/nvim/plugins/copilot-lua.lua +++ b/modules/programs/nvim/plugins/copilot-lua.lua @@ -2,10 +2,4 @@ require("copilot").setup({ suggestion = { enabled = false }, panel = { enabled = false }, }) -vim.api.nvim_create_autocmd("VimEnter", { - desc = "Disable Copilot by default on startup", - command = "Copilot disable", -}) -require("which-key").register({ - c = { "Copilot toggle", "Toggle Copilot" }, -}, { prefix = "t" }) +vim.cmd("Copilot disable") diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix new file mode 100644 index 0000000..3b40c98 --- /dev/null +++ b/modules/programs/nvim/plugins/default.nix @@ -0,0 +1,254 @@ +{ pkgs, ... }: + +with builtins; +{ + config.my.programs.nvim.plugins = with pkgs.vimPlugins; [ + { + plugin = which-key-nvim; + conf = readFile ./which-key-nvim.lua; + } + { + plugin = catppuccin-nvim; + conf = readFile ./catppuccin-nvim.lua; + priority = 99; + } + { + plugin = formatter-nvim; + lazy = true; + keys = [ + { key = "="; cmd = "Format"; desc = "format (formatter)"; } + ]; + conf = readFile ./formatter-nvim.lua; + dependencies = [{ plugin = which-key-nvim; lazy = true; }]; + } + { + plugin = oil-nvim; + conf = readFile ./oil-nvim.lua; + dependencies = [ + { plugin = which-key-nvim; lazy = true; } + { plugin = nvim-web-devicons; lazy = true; } + ]; + } + { + plugin = mini-nvim; + conf = readFile ./mini-nvim.lua; + } + { + plugin = noice-nvim; + conf = readFile ./noice-nvim.lua; + dependencies = [{ plugin = nui-nvim; lazy = true; }]; + } + { + plugin = trouble-nvim; + lazy = true; + keys = [ + { key = "xx"; cmd = "TroubleToggle document_diagnostics"; desc = "Document Diagnostics (Trouble)"; } + { key = "xX"; cmd = "TroubleToggle workspace_diagnostics"; desc = "Workspace Diagnostics (Troule)"; } + { key = "xl"; cmd = "TroubleToggle loclist"; desc = "Location List (Trouble)"; } + { key = "xq"; cmd = "TroubleToggle quickfix"; desc = "Quickfix List (Trouble)"; } + { key = "xt"; cmd = "TodoTrouble"; desc = "Todo (Trouble)"; } + { key = "xT"; cmd = "TodoTrouble keywords=TODO,FIX,FIXME"; desc = "Todo/Fix/Fixme (Trouble)"; } + { key = "st"; cmd = "TodoTelescope"; desc = "Todo"; } + { + key = "[q"; + func = ''function() + if require("trouble").is_open() then + require("trouble").previous({ skip_groups = true, jump = true }) + else + vim.cmd.cprev() + end + end''; + desc = "Previous trouble/quickfix item"; + } + { + key = "]q"; + func = ''function() + if require("trouble").is_open() then + require("trouble").next({ skip_groups = true, jump = true }) + else + vim.cmd.cnext() + end + end''; + desc = "Next trouble/quickfix item"; + } + ]; + conf = readFile ./trouble-nvim.lua; + dependencies = [ + { plugin = which-key-nvim; } + { plugin = nvim-web-devicons; lazy = true; } + ]; + } + { + plugin = nvim-cmp; + conf = readFile ./nvim-cmp.lua; + lazy = true; + event = [ "InsertEnter" ]; + dependencies = [ + { plugin = cmp-async-path; } + { plugin = cmp-nvim-lsp; } + { plugin = cmp_luasnip; } + { + plugin = copilot-cmp; + dependencies = [ + { + plugin = copilot-lua; + conf = readFile ./copilot-lua.lua; + dependencies = [{ plugin = which-key-nvim; }]; + } + ]; + } + { plugin = friendly-snippets; } + { plugin = luasnip; lazy = true; } + ]; + } + { + plugin = todo-comments-nvim; + lazy = true; + event = [ "BufReadPost" "BufNewFile" ]; + conf = readFile ./todo-comments-nvim.lua; + dependencies = [{ plugin = plenary-nvim; lazy = true; }]; + } + { + plugin = direnv-vim; + } + { + plugin = nvim-treesitter.withAllGrammars; + lazy = true; + event = [ "BufReadPost" "BufNewFile" ]; + conf = readFile ./nvim-treesitter.lua; + dependencies = [ + { + plugin = orgmode; + lazy = true; + conf = readFile ./orgmode.lua; + } + ]; + } + { + plugin = nvim-lspconfig; + lazy = true; + event = [ "BufReadPre" "BufNewFile" ]; + conf = readFile ./nvim-lspconfig.lua; + dependencies = [ + { + plugin = null-ls-nvim; + lazy = true; + conf = readFile ./null-ls-nvim.lua; + dependencies = [ + { plugin = which-key-nvim; lazy = true; } + { plugin = plenary-nvim; lazy = true; } + ]; + } + { + plugin = which-key-nvim; + lazy = true; + } + { + plugin = lspkind-nvim; + lazy = true; + } + { + plugin = lsp_lines-nvim; + lazy = true; + } + { + plugin = lspsaga-nvim-original; + lazy = true; + dependencies = [ + { plugin = nvim-web-devicons; lazy = true; } + { plugin = nvim-treesitter.withAllGrammars; lazy = true; } + ]; + } + { + plugin = nvim-ufo; + lazy = true; + dependencies = [ + { plugin = promise-async; lazy = true; } + ]; + } + ]; + } + { + event = [ "VeryLazy" ]; + lazy = true; + plugin = vim-fugitive; + } + { + plugin = vim-tmux-navigator; + } + { + plugin = gitsigns-nvim; + lazy = true; + event = [ "BufReadPost" "BufNewFile" ]; + conf = readFile ./gitsigns-nvim.lua; + dependencies = [{ plugin = which-key-nvim; }]; + } + { + plugin = nvim-lastplace; + lazy = true; + event = [ "BufReadPost" "BufNewFile" ]; + conf = readFile ./nvim-lastplace.lua; + } + { + plugin = nvim-treesitter-textsubjects; + lazy = true; + event = [ "BufReadPost" "BufNewFile" ]; + conf = readFile ./nvim-treesitter-textsubjects.lua; + dependencies = [ + { + plugin = nvim-treesitter.withAllGrammars; + lazy = true; + } + ]; + } + { + plugin = nvim-ts-context-commentstring; + lazy = true; + event = [ "BufReadPost" "BufNewFile" ]; + conf = readFile ./nvim-ts-context-commentstring.lua; + dependencies = [ + { + plugin = nvim-treesitter.withAllGrammars; + lazy = true; + } + ]; + } + { + plugin = smartcolumn-nvim; + lazy = true; + event = [ "BufReadPost" "BufNewFile" ]; + conf = readFile ./smartcolumn-nvim.lua; + } + { + plugin = telescope-fzf-native-nvim; + conf = readFile ./telescope-fzf-native-nvim.lua; + lazy = true; + keys = [ + { key = "ff"; cmd = "Telescope find_files"; desc = "Find files"; } + { key = "fb"; cmd = "Telescope buffers"; desc = "Find buffers"; } + { key = "fr"; cmd = "Telescope oldfiles"; desc = "Find recent files"; } + { key = "sl"; cmd = "Telescope current_buffer_fuzzy_find"; desc = "Search lines"; } + { key = "sg"; cmd = "Telescope live_grep"; desc = "Live grep"; } + { key = "sc"; cmd = "Telescope command_history"; desc = "Command history"; } + { key = "sC"; cmd = "Telescope commands"; desc = "Commands"; } + { key = "sd"; cmd = "Telescope diagnostics"; desc = "Diagnostics"; } + { key = "sh"; cmd = "Telescope help_tags"; desc = "Help tags"; } + { key = "sk"; cmd = "Telescope keymaps"; desc = "Keymaps"; } + { key = "ss"; cmd = "Telescope lsp_document_symbols"; desc = "Symbols (Document)"; } + { key = "sS"; cmd = "Telescope lsp_workspace_symbols"; desc = "Symbols (Workspace)"; } + { key = "gc"; cmd = "Telescope git_commits"; desc = "Commits"; } + { key = "gs"; cmd = "Telescope git_status"; desc = "Status"; } + ]; + dependencies = [ + { + plugin = telescope-nvim; + lazy = true; + dependencies = [ + { plugin = plenary-nvim; lazy = true; } + { plugin = which-key-nvim; lazy = true; } + ]; + } + ]; + } + ]; +} diff --git a/modules/programs/nvim/plugins/formatter-nvim.lua b/modules/programs/nvim/plugins/formatter-nvim.lua index b72b72a..adbdeeb 100644 --- a/modules/programs/nvim/plugins/formatter-nvim.lua +++ b/modules/programs/nvim/plugins/formatter-nvim.lua @@ -65,7 +65,3 @@ end, { return languages[vim.bo.filetype] or {} end, }) - -require("which-key").register({ - ["="] = { "Format", "format (formatter)" }, -}, { noremap = true, silent = true }) diff --git a/modules/programs/nvim/plugins/nvim-cmp.lua b/modules/programs/nvim/plugins/nvim-cmp.lua new file mode 100644 index 0000000..0533cb7 --- /dev/null +++ b/modules/programs/nvim/plugins/nvim-cmp.lua @@ -0,0 +1,63 @@ +local cmp = require("cmp") +local luasnip = require("luasnip") +require("luasnip.loaders.from_vscode").lazy_load() +require("copilot_cmp").setup() + +local default_sources = { + { name = "async_path", priority = 1 }, + { name = "copilot", priority = 2 }, + { name = "luasnip", priority = 2 }, + { name = "nvim_lsp", priority = 3 }, +} + +cmp.setup({ + formatting = { + format = require("lspkind").cmp_format({ + mode = "symbol", -- show only symbol annotations + maxwidth = 50, -- prevent the popup from showing more than provided characters + ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead + symbol_map = { + Copilot = "", + }, + }), + }, + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + sources = default_sources, +}) + +cmp.setup.filetype("org", { + sources = vim.tbl_deep_extend("force", default_sources, { + { name = "buffer", priority = 1 }, + { name = "orgmode", priority = 3 }, + }), +}) diff --git a/modules/programs/nvim/init.lua b/modules/programs/nvim/plugins/nvim-lspconfig.lua similarity index 65% rename from modules/programs/nvim/init.lua rename to modules/programs/nvim/plugins/nvim-lspconfig.lua index cb933b2..75c3e5d 100644 --- a/modules/programs/nvim/init.lua +++ b/modules/programs/nvim/plugins/nvim-lspconfig.lua @@ -1,87 +1,3 @@ -vim.loader.enable() - --- Load custom treesitter grammar for org filetype -require("orgmode").setup_ts_grammar() -require("nvim-treesitter.configs").setup({ - sync_install = false, - auto_install = false, - highlight = { - enable = true, - -- Required for spellcheck, some LaTex highlights and - -- code block highlights that do not have ts grammar - additional_vim_regex_highlighting = { "org" }, - }, -}) - --- load cmp on InsertEnter -vim.api.nvim_create_autocmd("InsertEnter", { - callback = function() - local cmp = require("cmp") - local luasnip = require("luasnip") - require("luasnip.loaders.from_vscode").lazy_load() - require("copilot_cmp").setup() - - local default_sources = { - { name = "async_path", priority = 1 }, - { name = "copilot", priority = 2 }, - { name = "luasnip", priority = 2 }, - { name = "nvim_lsp", priority = 3 }, - } - - cmp.setup({ - formatting = { - format = require("lspkind").cmp_format({ - mode = "symbol", -- show only symbol annotations - maxwidth = 50, -- prevent the popup from showing more than provided characters - ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead - symbol_map = { - Copilot = "", - }, - }), - }, - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - sources = default_sources, - }) - - cmp.setup.filetype("org", { - sources = vim.tbl_deep_extend("force", default_sources, { - { name = "buffer", priority = 1 }, - { name = "orgmode", priority = 3 }, - }), - }) - end, -}) - local lsp_lines = require("lsp_lines") lsp_lines.setup() -- Disable virtual_text since it's redundant due to lsp_lines. diff --git a/modules/programs/nvim/plugins/nvim-treesitter.lua b/modules/programs/nvim/plugins/nvim-treesitter.lua new file mode 100644 index 0000000..c856c13 --- /dev/null +++ b/modules/programs/nvim/plugins/nvim-treesitter.lua @@ -0,0 +1,12 @@ +-- Load custom treesitter grammar for org filetype +require("orgmode").setup_ts_grammar() +require("nvim-treesitter.configs").setup({ + sync_install = false, + auto_install = false, + highlight = { + enable = true, + -- Required for spellcheck, some LaTex highlights and + -- code block highlights that do not have ts grammar + additional_vim_regex_highlighting = { "org" }, + }, +}) diff --git a/modules/programs/nvim/plugins/telescope-nvim.lua b/modules/programs/nvim/plugins/telescope-nvim.lua deleted file mode 100644 index 95b228c..0000000 --- a/modules/programs/nvim/plugins/telescope-nvim.lua +++ /dev/null @@ -1,22 +0,0 @@ -require("which-key").register({ - f = { - f = { "Telescope find_files", "Find files" }, - b = { "Telescope buffers", "Find buffers" }, - r = { "Telescope oldfiles", "Find recent files" }, - }, - s = { - l = { "Telescope current_buffer_fuzzy_find", "Search lines" }, - g = { "Telescope live_grep", "Live grep" }, - c = { "Telescope command_history", "Command history" }, - C = { "Telescope commands", "Commands" }, - d = { "Telescope diagnostics", "Diagnostics" }, - h = { "Telescope help_tags", "Help tags" }, - k = { "Telescope keymaps", "Keymaps" }, - s = { "Telescope lsp_document_symbols", "Symbols (Document)" }, - S = { "Telescope lsp_workspace_symbols", "Symbols (Workspace)" }, - }, - g = { - c = { "Telescope git_commits", "Commits" }, - s = { "Telescope git_status", "Status" }, - }, -}, { prefix = "" }) diff --git a/modules/programs/nvim/plugins/trouble-nvim.lua b/modules/programs/nvim/plugins/trouble-nvim.lua index 9a98571..38ef1e9 100644 --- a/modules/programs/nvim/plugins/trouble-nvim.lua +++ b/modules/programs/nvim/plugins/trouble-nvim.lua @@ -1,38 +1 @@ require("trouble").setup() -require("which-key").register({ - x = { "TroubleToggle document_diagnostics", "Document Diagnostics (Trouble)" }, - X = { "TroubleToggle workspace_diagnostics", "Workspace Diagnostics (Troule)" }, - l = { "TroubleToggle loclist", "Location List (Trouble)" }, - q = { "TroubleToggle quickfix", "Quickfix List (Trouble)" }, - t = { "TodoTrouble", "Todo (Trouble)" }, - T = { "TodoTrouble keywords=TODO,FIX,FIXME", "Todo/Fix/Fixme (Trouble)" }, -}, { prefix = "x" }) -require("which-key").register({ - t = { "TodoTelescope", "Todo" }, -}, { prefix = "s" }) -require("which-key").register({ - ["["] = { - q = { - function() - if require("trouble").is_open() then - require("trouble").previous({ skip_groups = true, jump = true }) - else - vim.cmd.cprev() - end - end, - "Previous trouble/quickfix item", - }, - }, - ["]"] = { - q = { - function() - if require("trouble").is_open() then - require("trouble").next({ skip_groups = true, jump = true }) - else - vim.cmd.cnext() - end - end, - "Next trouble/quickfix item", - }, - }, -}) diff --git a/modules/programs/nvim/plugins/which-key-nvim.lua b/modules/programs/nvim/plugins/which-key-nvim.lua index e70fb09..82d4b90 100644 --- a/modules/programs/nvim/plugins/which-key-nvim.lua +++ b/modules/programs/nvim/plugins/which-key-nvim.lua @@ -1,2 +1,76 @@ vim.o.timeout = true vim.o.timeoutlen = 500 + +-- buffer +require("which-key").register({ + b = { + name = "buffer", + b = { "Telescope buffers", "List buffers" }, + d = { "bd", "Delete buffer" }, + }, +}, { prefix = "" }) +require("which-key").register({ + ["["] = { + b = { "bprevious", "Previous buffer" }, + }, + ["]"] = { + b = { "bnext", "Next buffer" }, + }, +}) + +-- window +require("which-key").register({ + w = { + name = "window", + ["|"] = { "v", "Split window horizontally" }, + ["-"] = { "s", "Split window vertically" }, + w = { "w", "Switch window" }, + d = { "c", "Delete window" }, + }, +}, { prefix = "" }) + +-- tab +require("which-key").register({ + [""] = { + name = "tab", + [""] = { "tabnew", "New tab" }, + n = { "tabnext", "Next tab" }, + p = { "tabprevious", "Previous tab" }, + d = { "tabclose", "Close tab" }, + }, +}, { prefix = "" }) + +-- file +require("which-key").register({ + f = { + name = "file/find", + n = { "enew", "New file" }, + }, +}, { prefix = "" }) + +-- better descriptions for navigation +require("which-key").register({ + [""] = { + f = { name = "file/find" }, + g = { name = "git" }, + l = { name = "lsp" }, + o = { name = "org" }, + s = { name = "search" }, + t = { name = "toggle" }, + x = { name = "diagnostics/quickfix" }, + }, + ["["] = { name = "prev" }, + ["]"] = { name = "next" }, + g = { name = "goto" }, +}) + +-- Clear search with +require("which-key").register({ + [""] = { "noh", "Escape and clear hlsearch", mode = { "n", "i" } }, +}) + +-- better indenting +require("which-key").register({ + ["<"] = { ""] = { ">gv", "Shift right" }, +}, { mode = "v" })