From c629518866824d88311f08e1c1113e3eb0f794c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Mon, 28 Aug 2023 20:09:39 +0200 Subject: [PATCH 01/24] feat: add builder --- modules/profiles/personal.nix | 19 +++++++++++++++++++ secrets/nordvpn.age | Bin 906 -> 0 bytes secrets/secrets.nix | 12 ++++++------ secrets/spotifyd.age | 17 ----------------- secrets/ssh-builder.age | 10 ++++++++++ 5 files changed, 35 insertions(+), 23 deletions(-) delete mode 100644 secrets/nordvpn.age delete mode 100644 secrets/spotifyd.age create mode 100644 secrets/ssh-builder.age diff --git a/modules/profiles/personal.nix b/modules/profiles/personal.nix index bfea3e2..dbb2944 100644 --- a/modules/profiles/personal.nix +++ b/modules/profiles/personal.nix @@ -69,5 +69,24 @@ in }; }; }; + nix.buildMachines = [{ + hostName = "builder"; + systems = [ "aarch64-linux" "x86_64-linux" ]; + protocol = "ssh-ng"; + maxJobs = 1; + speedFactor = 1; + supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; + mandatoryFeatures = [ ]; + }]; + nix.distributedBuilds = true; + # optional, useful when the builder has a faster internet connection than yours + nix.extraOptions = '' + builders-use-substitutes = true + ''; + age.secrets."ssh-builder" = { + file = ../../secrets/ssh-builder.age; + owner = "0"; + path = "/root/.ssh/config"; + }; }; } diff --git a/secrets/nordvpn.age b/secrets/nordvpn.age deleted file mode 100644 index 4f0074eeae020738feed80ef911cf772bde4f2a0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 906 zcmZ9_JCEB0003abXsHsXBJmn9g_gnOY{zz-a8-rlIDW*j6FZI{W%29$iXX9ajuR&6 zf&{vis{{fuAysX~gpd#&Di8x*ka!H8p(;XGmM&FW#G3C9e0Jcs{LC#k#VX3P{k#m| z8UdMcbh8aAPvBQ5UwYEexc1q zxn9SiN4m~LkZsY1AYMvx`-tYYF{ktw2|!5*Zp@?<*_O0WO>n2{1x*erK zFm8@l%>Z0g`a)nQDu#(Q65~08Idnn5$QrdE&NeV>Z~974pVAq=3^aMYfSiRg(McYW4J#L!PK*Fv*-Mx~2g8O{ zlGV;c8o7oEC8!Z-@QU+=h}H3$hz?Vl+1)&yccxPi*R^0-TCQM*1`Z?cbe<(z8AMrb zr3^DJQk`=SS9YDN3DEVtDx?d`<3>~|(0+}LH7Qlhs9**o%G*6SxfKNnoN^58OicJ#C@J{zB0 JeDjwd{sX2#HuV4i diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 09e13f4..7c7267c 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -12,16 +12,16 @@ let hosts-work = [ nixos-work scadspc25 ]; hosts = hosts-personal ++ hosts-work; + personal = [ moritz ] ++ hosts-personal; all = users ++ hosts; in { "github.age".publicKeys = all; - "nordvpn.age".publicKeys = all; - "spotifyd.age".publicKeys = all; - "ssh-home.age".publicKeys = all; - "uni-vpn.age".publicKeys = all; - "wireguard-preshared-key.age".publicKeys = all; - "wireguard-private-key.age".publicKeys = all; + "ssh-home.age".publicKeys = personal; + "ssh-builder.age".publicKeys = personal; + "uni-vpn.age".publicKeys = personal; + "wireguard-preshared-key.age".publicKeys = personal; + "wireguard-private-key.age".publicKeys = personal; "webis.age".publicKeys = hosts-personal ++ [ scadspc25 moritz ]; "webis-ssh.age".publicKeys = hosts-personal ++ [ scadspc25 moritz ]; } diff --git a/secrets/spotifyd.age b/secrets/spotifyd.age deleted file mode 100644 index f564d39..0000000 --- a/secrets/spotifyd.age +++ /dev/null @@ -1,17 +0,0 @@ -age-encryption.org/v1 --> ssh-ed25519 CjuqfA /YCi+4iCBCJc2+n5DfEi6yFqYiC6WKyKqMQTC3dxYTM -TXnSGexVJPzsxV3GBoxujBPy4sYFK7tTzpgZd+tL7PY --> ssh-ed25519 QRYDmg 7ol/1aYbVuD1peL4kMHFifxtfj1LJPQ7ByMgmoIiLG0 -LJyz1aoBxOnxcy/x9yXCcMDG1CM8XSGTIvklShHsLr8 --> ssh-ed25519 wG6LYg LvuMCPIaXP8gDriTDVIXak2dLUTDgyA+ADnsFDEtpX4 -PSsM5NsSVhsV1xtZPs3VZbJopfkDQg7Gxjkrnf+I5VI --> ssh-ed25519 ZYd7Zg jt4zPtq1gv/SQ8Zqy2kFQZTUHo57d3BcBOusafU5TwE -FCifF8kUwHqlvokMMhJ/A2zCutshBg9K22gZPeYyK5s --> ssh-ed25519 as9VYQ 2w+TXKZGnMQ5nRqVPfDiXAjGPLjMQcDzuZ42tXD81zE -GHVNnPD1QrRfjlxymtkIvW/fSH8280ye4ojag/RrL6Y --> ssh-ed25519 dWIbQQ vFV8rbuDIUhVuWlp1zLKbSZkxWwBpjLGAHZ7TZmlpxA -2qq8R8eGQHMAtTAKJxv7ouXwbw9h9LnoipQ+dtq0bOk --> eLqn-grease -s21qb67X34dXu+DeHZV4IA9mvegTyQSulJuWZXUyGmlxQT4N7pDAjAgrlrsT8zI ---- ogDMsipm47a5cDUlzX1zPmeakFaqXecpvYfPILf5PGA -;(+\"`qnC:6V싄t0\2o<*?J\TϢV_ \ No newline at end of file diff --git a/secrets/ssh-builder.age b/secrets/ssh-builder.age new file mode 100644 index 0000000..ba15122 --- /dev/null +++ b/secrets/ssh-builder.age @@ -0,0 +1,10 @@ +age-encryption.org/v1 +-> ssh-ed25519 wG6LYg 5umyOPP+KaUaQckEZYnh+nyX2RIMDp/KtJraFuATQBM +qsS9JiY0qxR7IMwpH2x1VWF5A5/wrAkbeOzuMcf1fS0 +-> ssh-ed25519 ZYd7Zg L9EJulnOPk7fEcmrWU8mVRbEN80dHCji1n4bnwGJigk +KTnk+Ku96gJ7Tj2egXyqX6UIuytHTuMFM1ygDXoIDxg +-> XQ.ai[-grease a ) r]>2~U +7CDc3c+1EZaEB15RE8JMzmdbr2WmQeP2ivIh4qgYTnKImHxJaJEhgScd0EzyEXVP +NZxuP+0 +--- CE/X6hjRUWT1ya1ySIjFBnLdmPkVbL4ugDwYv9XGYoo +߉38e:ImF?U~83NCzAM]0fkuFLl Date: Mon, 28 Aug 2023 20:14:47 +0200 Subject: [PATCH 02/24] fix: do not build bigger stuff on builder --- modules/profiles/personal.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/profiles/personal.nix b/modules/profiles/personal.nix index dbb2944..d56b796 100644 --- a/modules/profiles/personal.nix +++ b/modules/profiles/personal.nix @@ -75,7 +75,7 @@ in protocol = "ssh-ng"; maxJobs = 1; speedFactor = 1; - supportedFeatures = [ "nixos-test" "benchmark" "big-parallel" "kvm" ]; + supportedFeatures = [ "nixos-test" "benchmark" "kvm" ]; mandatoryFeatures = [ ]; }]; nix.distributedBuilds = true; From c121eae7a1cf83f5cedf4c3463164d5614de113c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Tue, 29 Aug 2023 08:52:27 +0200 Subject: [PATCH 03/24] feat(git): auto setup remote on push --- modules/programs/git.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/programs/git.nix b/modules/programs/git.nix index c3995dc..6216899 100644 --- a/modules/programs/git.nix +++ b/modules/programs/git.nix @@ -53,6 +53,7 @@ in init.defaultBranch = "main"; merge.conflictstyle = "zdiff3"; diff.external = getExe pkgs.difftastic; + push.autoSetupRemote = true; }; signing = mkIf cfg.signing { key = "0x970C6E89EB0547A9"; From 5596c21e7f7209216591e0f4cc743d6f1cb504d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 08:35:43 +0200 Subject: [PATCH 04/24] feat!: remove unused comma --- modules/profiles/base.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index aefaac4..830069d 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -149,7 +149,6 @@ in # nix (nom-system-command "nixos-boot" "sudo nixos-rebuild boot --flake ~/.dotfiles") (nom-system-command "nixos-switch" "sudo nixos-rebuild switch --flake ~/.dotfiles") - comma manix nix-index nix-output-monitor From 97320fbec17c1b50e702a12f7dfce9a944488606 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 08:36:16 +0200 Subject: [PATCH 05/24] feat: set nixpkgs env variable --- modules/programs/nix.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/programs/nix.nix b/modules/programs/nix.nix index 39b47a2..c358dbc 100644 --- a/modules/programs/nix.nix +++ b/modules/programs/nix.nix @@ -24,6 +24,8 @@ in }; config.nix = { + nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; + package = pkgs.nix-super; extraOptions = "experimental-features = nix-command flakes"; From 736249a74d5abe3594f7c9ad153709cde5cbc943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 08:43:03 +0200 Subject: [PATCH 06/24] feat(nvim): add actions-preview.nvim --- flake.lock | 17 +++++++++++++++++ flake.nix | 3 +++ modules/programs/nvim/plugins/default.nix | 1 + .../programs/nvim/plugins/nvim-lspconfig.lua | 2 +- overlays/vimPlugins.nix | 6 ++++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/flake.lock b/flake.lock index e03935e..6a8f108 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "actions-preview-nvim": { + "flake": false, + "locked": { + "lastModified": 1692778077, + "narHash": "sha256-5HzyrYWGTdorG4JXMv0iQNj9EM702+8g7E18Oct1JiY=", + "owner": "aznhe21", + "repo": "actions-preview.nvim", + "rev": "5650c76abfb84d6498330dd045657ba630ecdbba", + "type": "github" + }, + "original": { + "owner": "aznhe21", + "repo": "actions-preview.nvim", + "type": "github" + } + }, "agenix": { "inputs": { "darwin": "darwin", @@ -840,6 +856,7 @@ }, "root": { "inputs": { + "actions-preview-nvim": "actions-preview-nvim", "agenix": "agenix", "arkenfox-userjs": "arkenfox-userjs", "asus-touchpad-numpad-driver": "asus-touchpad-numpad-driver", diff --git a/flake.nix b/flake.nix index 91ccddd..8cdd81d 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,9 @@ hmts-nvim.flake = false; hmts-nvim.url = "github:calops/hmts.nvim"; + actions-preview-nvim.flake = false; + actions-preview-nvim.url = "github:aznhe21/actions-preview.nvim"; + # Hyprland hypr-contrib.url = "github:hyprwm/contrib"; hyprland.url = "github:hyprwm/Hyprland"; diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index 8fcc9e1..6d22f61 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -148,6 +148,7 @@ with builtins; } ]; } + { plugin = actions-preview-nvim; } ]; } { diff --git a/modules/programs/nvim/plugins/nvim-lspconfig.lua b/modules/programs/nvim/plugins/nvim-lspconfig.lua index 0c44ceb..afb7ea0 100644 --- a/modules/programs/nvim/plugins/nvim-lspconfig.lua +++ b/modules/programs/nvim/plugins/nvim-lspconfig.lua @@ -34,7 +34,7 @@ local on_attach_def = function(client, bufnr) l = { name = "lsp", d = { vim.diagnostic.open_float, "Open diagnostic window" }, - c = { vim.lsp.buf.code_action, "Code action" }, + c = { require("actions-preview").code_actions, "Code action", mode = { "v", "n" } }, r = { function() return ":IncRename " .. vim.fn.expand("") diff --git a/overlays/vimPlugins.nix b/overlays/vimPlugins.nix index eba8e54..75fa6b3 100644 --- a/overlays/vimPlugins.nix +++ b/overlays/vimPlugins.nix @@ -27,5 +27,11 @@ with lib.my; version = mkVersionInput inputs.hmts-nvim; src = inputs.hmts-nvim; }; + + actions-preview-nvim = prev.vimUtils.buildVimPluginFrom2Nix { + pname = "actions-preview-nvim"; + version = mkVersionInput inputs.actions-preview-nvim; + src = inputs.actions-preview-nvim; + }; }; } From c0112661ad4480ca4135235813d61e0d6b799b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 08:58:23 +0200 Subject: [PATCH 07/24] feat: update vimPlugins --- flake.lock | 36 +++++++++++++++++++++++++++--------- flake.nix | 9 ++++++--- overlays/vimPlugins.nix | 16 ++++++++++------ 3 files changed, 43 insertions(+), 18 deletions(-) diff --git a/flake.lock b/flake.lock index 6a8f108..e8e5f02 100644 --- a/flake.lock +++ b/flake.lock @@ -799,19 +799,20 @@ "type": "github" } }, - "nvim-treesitter-textsubjects": { + "nvim-treesitter": { "flake": false, "locked": { - "lastModified": 1691029837, - "narHash": "sha256-O57pMYtDR713ItAeUfdkcl2IfBLQcLEa2sb+AXhaqDs=", - "owner": "RRethy", - "repo": "nvim-treesitter-textsubjects", - "rev": "df75fcec548014f158cda6498ac38c4622c221e1", + "lastModified": 1691831669, + "narHash": "sha256-1Iuvq0hVQ7LyBYOkJ5d07NkwbGcR1K61ZZmAAA7ABGs=", + "owner": "nvim-treesitter", + "repo": "nvim-treesitter", + "rev": "63260da18bf273c76b8e2ea0db84eb901cab49ce", "type": "github" }, "original": { - "owner": "RRethy", - "repo": "nvim-treesitter-textsubjects", + "owner": "nvim-treesitter", + "ref": "v0.9.1", + "repo": "nvim-treesitter", "type": "github" } }, @@ -871,12 +872,13 @@ "nil": "nil", "nix-super": "nix-super", "nixpkgs": "nixpkgs_6", - "nvim-treesitter-textsubjects": "nvim-treesitter-textsubjects", + "nvim-treesitter": "nvim-treesitter", "pre-commit-hooks": "pre-commit-hooks", "rofi-wayland": "rofi-wayland", "smartcolumn-nvim": "smartcolumn-nvim", "stable": "stable", "telekasten-nvim": "telekasten-nvim", + "telescope-nvim": "telescope-nvim", "timers": "timers" } }, @@ -1028,6 +1030,22 @@ "type": "github" } }, + "telescope-nvim": { + "flake": false, + "locked": { + "lastModified": 1693850759, + "narHash": "sha256-309GezR93SVOD7/B8dDJIEidYziepc1s46CIRkhND1k=", + "owner": "nvim-telescope", + "repo": "telescope.nvim", + "rev": "20a37e43bb43c74c6091f9fea6551af0964ad45a", + "type": "github" + }, + "original": { + "owner": "nvim-telescope", + "repo": "telescope.nvim", + "type": "github" + } + }, "timers": { "inputs": { "naersk": "naersk", diff --git a/flake.nix b/flake.nix index 8cdd81d..5060b8c 100644 --- a/flake.nix +++ b/flake.nix @@ -35,15 +35,18 @@ # Neovim neovim-nightly-overlay.url = "github:nix-community/neovim-nightly-overlay"; - nvim-treesitter-textsubjects.flake = false; - nvim-treesitter-textsubjects.url = "github:RRethy/nvim-treesitter-textsubjects"; - smartcolumn-nvim.flake = false; smartcolumn-nvim.url = "github:m4xshen/smartcolumn.nvim"; telekasten-nvim.flake = false; telekasten-nvim.url = "github:renerocksai/telekasten.nvim"; + telescope-nvim.flake = false; + telescope-nvim.url = "github:nvim-telescope/telescope.nvim"; + + nvim-treesitter.flake = false; + nvim-treesitter.url = "github:nvim-treesitter/nvim-treesitter/v0.9.1"; # NOTE: to fix weird latest issues + hmts-nvim.flake = false; hmts-nvim.url = "github:calops/hmts.nvim"; diff --git a/overlays/vimPlugins.nix b/overlays/vimPlugins.nix index 75fa6b3..7cafdf5 100644 --- a/overlays/vimPlugins.nix +++ b/overlays/vimPlugins.nix @@ -4,12 +4,6 @@ _: prev: with lib.my; { vimPlugins = prev.vimPlugins // { - nvim-treesitter-textsubjects = prev.vimUtils.buildVimPluginFrom2Nix { - pname = "nvim-treesitter-textsubjects"; - version = mkVersionInput inputs.nvim-treesitter-textsubjects; - src = inputs.nvim-treesitter-textsubjects; - }; - smartcolumn-nvim = prev.vimUtils.buildVimPluginFrom2Nix { pname = "smartcolumn-nvim"; version = mkVersionInput inputs.smartcolumn-nvim; @@ -33,5 +27,15 @@ with lib.my; version = mkVersionInput inputs.actions-preview-nvim; src = inputs.actions-preview-nvim; }; + + telescope-nvim = prev.vimPlugins.telescope-nvim.overrideAttrs (_: { + version = mkVersionInput inputs.telescope-nvim; + src = inputs.telescope-nvim; + }); + + nvim-treesitter = prev.vimPlugins.nvim-treesitter.overrideAttrs (_: { + version = mkVersionInput inputs.nvim-treesitter; + src = inputs.nvim-treesitter; + }); }; } From dfa93f98dfea42fd2f190cdf4734014fec2d4d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 09:19:32 +0200 Subject: [PATCH 08/24] Revert "feat(nvim): add coq-nvim" This reverts commit e2aff57d7236018257bc0a5ee6c14c2dfe9b3a04. --- modules/programs/nvim/plugins/codeium-vim.lua | 2 - modules/programs/nvim/plugins/coq-nvim.lua | 6 -- .../programs/nvim/plugins/coq-thirdparty.lua | 4 -- modules/programs/nvim/plugins/default.nix | 42 +++++++------ modules/programs/nvim/plugins/nvim-cmp.lua | 63 +++++++++++++++++++ .../programs/nvim/plugins/nvim-lspconfig.lua | 13 ++-- 6 files changed, 93 insertions(+), 37 deletions(-) delete mode 100644 modules/programs/nvim/plugins/codeium-vim.lua delete mode 100644 modules/programs/nvim/plugins/coq-nvim.lua delete mode 100644 modules/programs/nvim/plugins/coq-thirdparty.lua create mode 100644 modules/programs/nvim/plugins/nvim-cmp.lua diff --git a/modules/programs/nvim/plugins/codeium-vim.lua b/modules/programs/nvim/plugins/codeium-vim.lua deleted file mode 100644 index 72cd968..0000000 --- a/modules/programs/nvim/plugins/codeium-vim.lua +++ /dev/null @@ -1,2 +0,0 @@ --- dont show ghost text -vim.g.codeium_render = false diff --git a/modules/programs/nvim/plugins/coq-nvim.lua b/modules/programs/nvim/plugins/coq-nvim.lua deleted file mode 100644 index 63536a8..0000000 --- a/modules/programs/nvim/plugins/coq-nvim.lua +++ /dev/null @@ -1,6 +0,0 @@ -vim.g.coq_settings = { - auto_start = "shut-up", - keymap = { - jump_to_mark = "", - }, -} diff --git a/modules/programs/nvim/plugins/coq-thirdparty.lua b/modules/programs/nvim/plugins/coq-thirdparty.lua deleted file mode 100644 index ec1e05c..0000000 --- a/modules/programs/nvim/plugins/coq-thirdparty.lua +++ /dev/null @@ -1,4 +0,0 @@ -require("coq_3p")({ - { src = "orgmode", short_name = "ORG" }, - { src = "codeium", short_name = "COD" }, -}) diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index 6d22f61..7aa5eb0 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -74,6 +74,28 @@ with builtins; { plugin = nvim-web-devicons; } ]; } + { + plugin = nvim-cmp; + conf = readFile ./nvim-cmp.lua; + 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; } + ]; + } { plugin = todo-comments-nvim; event = [ "BufReadPost" "BufNewFile" ]; @@ -241,26 +263,6 @@ with builtins; plugin = markdown-preview-nvim; ft = [ "md" ]; } - { - plugin = coq_nvim; - event = [ "BufReadPost" "BufNewFile" ]; - init = builtins.readFile ./coq-nvim.lua; - dependencies = [ - { - plugin = coq-thirdparty; - conf = builtins.readFile ./coq-thirdparty.lua; - dependencies = [ - { - plugin = codeium-vim; - init = builtins.readFile ./codeium-vim.lua; - } - ]; - } - { - plugin = coq-artifacts; - } - ]; - } { plugin = nvim-surround; event = [ "BufReadPost" "BufNewFile" ]; 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/plugins/nvim-lspconfig.lua b/modules/programs/nvim/plugins/nvim-lspconfig.lua index afb7ea0..3690f1d 100644 --- a/modules/programs/nvim/plugins/nvim-lspconfig.lua +++ b/modules/programs/nvim/plugins/nvim-lspconfig.lua @@ -5,8 +5,9 @@ vim.diagnostic.config({ virtual_text = false, }) -local capabilities = vim.lsp.protocol.make_client_capabilities() --- NOTE for nvim-ufo +-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers.. +local capabilities = require("cmp_nvim_lsp").default_capabilities() + -- Tell the server the capability of foldingRange, -- Neovim hasn't added foldingRange to default capabilities, users must add it manually capabilities.textDocument.foldingRange = { @@ -100,6 +101,9 @@ end local lspconfig_default_options = { on_attach = on_attach_def, capabilities = capabilities, + flags = { + debounce_text_changes = 100, + }, } ---function to add default options to lspconfig @@ -107,9 +111,8 @@ local lspconfig_default_options = { ---@param options table ---@return nil local function lspconfig_setup(lsp, options) - local coq_options = require("coq").lsp_ensure_capabilities({}) - local merged_options = vim.tbl_deep_extend("force", coq_options, lspconfig_default_options, options) - lspconfig[lsp].setup(merged_options) + local final_options = vim.tbl_deep_extend("force", lspconfig_default_options, options) + lspconfig[lsp].setup(final_options) end local servers = { From 7f336c2a900d7273884ff1b2a6fdf11747c2f4e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 17:45:31 +0200 Subject: [PATCH 09/24] feat(nvim): add codeium completion --- flake.lock | 47 +++++++++++++++++++--- flake.nix | 3 ++ modules/programs/nvim/plugins/default.nix | 15 ++++--- modules/programs/nvim/plugins/nvim-cmp.lua | 44 +++++++++++++------- overlays/vimPlugins.nix | 2 + 5 files changed, 84 insertions(+), 27 deletions(-) diff --git a/flake.lock b/flake.lock index e8e5f02..acb5e01 100644 --- a/flake.lock +++ b/flake.lock @@ -71,6 +71,27 @@ "type": "github" } }, + "codeium-nvim": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1693966170, + "narHash": "sha256-maRkkUCzjSXK04ts+Io0WFBV1MxR7dCw8I6TV03Dpbs=", + "owner": "jcdickinson", + "repo": "codeium.nvim", + "rev": "6a8cbce54c41e0c305b5f77721f61b2ddd4b6c6d", + "type": "github" + }, + "original": { + "owner": "jcdickinson", + "repo": "codeium.nvim", + "type": "github" + } + }, "darwin": { "inputs": { "nixpkgs": [ @@ -203,6 +224,21 @@ } }, "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { "inputs": { "systems": "systems" }, @@ -220,7 +256,7 @@ "type": "github" } }, - "flake-utils_2": { + "flake-utils_3": { "inputs": { "systems": "systems_3" }, @@ -238,7 +274,7 @@ "type": "github" } }, - "flake-utils_3": { + "flake-utils_4": { "inputs": { "systems": "systems_4" }, @@ -530,7 +566,7 @@ }, "neovim-flake": { "inputs": { - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils_3", "nixpkgs": [ "neovim-nightly-overlay", "nixpkgs" @@ -819,7 +855,7 @@ "pre-commit-hooks": { "inputs": { "flake-compat": "flake-compat_3", - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_4", "gitignore": "gitignore", "nixpkgs": "nixpkgs_7", "nixpkgs-stable": "nixpkgs-stable" @@ -861,7 +897,8 @@ "agenix": "agenix", "arkenfox-userjs": "arkenfox-userjs", "asus-touchpad-numpad-driver": "asus-touchpad-numpad-driver", - "flake-utils": "flake-utils", + "codeium-nvim": "codeium-nvim", + "flake-utils": "flake-utils_2", "hmts-nvim": "hmts-nvim", "home-manager": "home-manager_2", "hypr-contrib": "hypr-contrib", diff --git a/flake.nix b/flake.nix index 5060b8c..f3bc896 100644 --- a/flake.nix +++ b/flake.nix @@ -53,6 +53,9 @@ actions-preview-nvim.flake = false; actions-preview-nvim.url = "github:aznhe21/actions-preview.nvim"; + codeium-nvim.url = "github:jcdickinson/codeium.nvim"; + codeium-nvim.inputs.nixpkgs.follows = "nixpkgs"; + # Hyprland hypr-contrib.url = "github:hyprwm/contrib"; hyprland.url = "github:hyprwm/Hyprland"; diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index 7aa5eb0..d916f00 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -80,19 +80,18 @@ with builtins; event = [ "InsertEnter" ]; dependencies = [ { plugin = cmp-async-path; } + { plugin = cmp-buffer; } + { plugin = cmp-cmdline; } { 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 = codeium-nvim; + conf = /* lua */ '' + require("codeium").setup({}) + ''; } { plugin = friendly-snippets; } + { plugin = lspkind-nvim; } { plugin = luasnip; } ]; } diff --git a/modules/programs/nvim/plugins/nvim-cmp.lua b/modules/programs/nvim/plugins/nvim-cmp.lua index 0533cb7..0c06f77 100644 --- a/modules/programs/nvim/plugins/nvim-cmp.lua +++ b/modules/programs/nvim/plugins/nvim-cmp.lua @@ -1,14 +1,6 @@ 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 = { @@ -17,7 +9,7 @@ cmp.setup({ 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 = "", + Codeium = "", }, }), }, @@ -52,12 +44,36 @@ cmp.setup({ end end, { "i", "s" }), }), - sources = default_sources, + sources = { + { name = "async_path", priority = 1 }, + { name = "buffer", priority = 1 }, + { name = "luasnip", priority = 2 }, + { name = "codeium", priority = 3 }, + { name = "nvim_lsp", priority = 4 }, + }, }) -cmp.setup.filetype("org", { - sources = vim.tbl_deep_extend("force", default_sources, { - { name = "buffer", priority = 1 }, - { name = "orgmode", priority = 3 }, +-- Set configuration for specific filetype. +cmp.setup.filetype("gitcommit", { + sources = cmp.config.sources({ + { name = "buffer" }, + }), +}) + +-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline({ "/", "?" }, { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, +}) + +-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). +cmp.setup.cmdline(":", { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "async_path" }, + }, { + { name = "cmdline" }, }), }) diff --git a/overlays/vimPlugins.nix b/overlays/vimPlugins.nix index 7cafdf5..39f81d4 100644 --- a/overlays/vimPlugins.nix +++ b/overlays/vimPlugins.nix @@ -4,6 +4,8 @@ _: prev: with lib.my; { vimPlugins = prev.vimPlugins // { + inherit (inputs.codeium-nvim.packages.${prev.system}.vimPlugins) codeium-nvim; + smartcolumn-nvim = prev.vimUtils.buildVimPluginFrom2Nix { pname = "smartcolumn-nvim"; version = mkVersionInput inputs.smartcolumn-nvim; From abdb620c8307e30825aff25027c4e4e38b53b761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 17:46:29 +0200 Subject: [PATCH 10/24] feat(nvim)!: remove org mode --- modules/programs/nvim/plugins/default.nix | 4 ---- modules/programs/nvim/plugins/nvim-treesitter.lua | 5 ----- modules/programs/nvim/plugins/orgmode.lua | 4 ---- 3 files changed, 13 deletions(-) delete mode 100644 modules/programs/nvim/plugins/orgmode.lua diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index d916f00..b29f0ed 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -124,10 +124,6 @@ with builtins; ''; dependencies = [ { plugin = nvim-ts-context-commentstring; } - { - plugin = orgmode; - conf = readFile ./orgmode.lua; - } ]; } { diff --git a/modules/programs/nvim/plugins/nvim-treesitter.lua b/modules/programs/nvim/plugins/nvim-treesitter.lua index 0c13317..e221fdd 100644 --- a/modules/programs/nvim/plugins/nvim-treesitter.lua +++ b/modules/programs/nvim/plugins/nvim-treesitter.lua @@ -1,13 +1,8 @@ --- 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" }, }, context_commentstring = { enable = true, diff --git a/modules/programs/nvim/plugins/orgmode.lua b/modules/programs/nvim/plugins/orgmode.lua deleted file mode 100644 index 789eb0a..0000000 --- a/modules/programs/nvim/plugins/orgmode.lua +++ /dev/null @@ -1,4 +0,0 @@ -require("orgmode").setup({ - org_agenda_files = { "~/Notes/org" }, - org_default_notes_file = "~/Notes/org/refile.org", -}) From 4322977115c9368c2addcda2c8033cda7b199f85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 17:46:54 +0200 Subject: [PATCH 11/24] feat(nvim): make modes a list for lazy keybinds --- modules/programs/nvim/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index f39da7c..c4859e5 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -26,7 +26,7 @@ let ); descString = optionalString (desc != null) "desc = ${quote desc},"; in - ''{ ${quote key}, ${cmdString}, mode = ${quote mode}, ${descString} }''; + ''{ ${quote key}, ${cmdString}, mode = ${listToStringOneLine quote mode}, ${descString} }''; lazySpecFromPlugin = { plugin, dependencies, init, conf, lazy, event, enabled, cmd, ft, priority, keys }: listToStringMultiLine' @@ -161,8 +161,8 @@ in ''; }; mode = mkOption { - type = str; - default = "n"; + type = listOf str; + default = [ "n" ]; description = '' Mode to bind the key in. ''; From 6ae954d3c6cc6e9e729596d9fc01f364c56aad11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 17:48:54 +0200 Subject: [PATCH 12/24] feat(nvim): add lsp signature plugin --- modules/programs/nvim/plugins/default.nix | 1 + modules/programs/nvim/plugins/nvim-lspconfig.lua | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index b29f0ed..73a300c 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -131,6 +131,7 @@ with builtins; event = [ "BufRead" "BufNewFile" ]; conf = readFile ./nvim-lspconfig.lua; dependencies = [ + { plugin = lsp_signature-nvim; } { plugin = null-ls-nvim; conf = readFile ./null-ls-nvim.lua; diff --git a/modules/programs/nvim/plugins/nvim-lspconfig.lua b/modules/programs/nvim/plugins/nvim-lspconfig.lua index 3690f1d..bba7726 100644 --- a/modules/programs/nvim/plugins/nvim-lspconfig.lua +++ b/modules/programs/nvim/plugins/nvim-lspconfig.lua @@ -96,6 +96,13 @@ local on_attach_def = function(client, bufnr) vim.lsp.inlay_hint(bufnr, true) end, timeout) end + + require("lsp_signature").on_attach({ + bind = true, -- This is mandatory, otherwise border config won't get registered. + handler_opts = { + border = "rounded", + }, + }, bufnr) end local lspconfig_default_options = { From d3f5d2e9bd07484763887fdd54271291592f2f7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 17:49:31 +0200 Subject: [PATCH 13/24] feat(nvim): better next/prev tab keybinds --- modules/programs/nvim/plugins/which-key-nvim.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/programs/nvim/plugins/which-key-nvim.lua b/modules/programs/nvim/plugins/which-key-nvim.lua index 8adb863..09f227f 100644 --- a/modules/programs/nvim/plugins/which-key-nvim.lua +++ b/modules/programs/nvim/plugins/which-key-nvim.lua @@ -34,11 +34,17 @@ require("which-key").register({ [""] = { name = "tab", [""] = { "tabnew", "New tab" }, - n = { "tabnext", "Next tab" }, - p = { "tabprevious", "Previous tab" }, d = { "tabclose", "Close tab" }, }, }, { prefix = "" }) +require("which-key").register({ + ["["] = { + t = { "tabprevious", "Previous tab" }, + }, + ["]"] = { + t = { "tabnext", "Next tab" }, + }, +}) -- file require("which-key").register({ From b945255e596c7b42fb07842f51799720b25a40ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 17:50:16 +0200 Subject: [PATCH 14/24] build: bump inputs --- flake.lock | 104 ++++++++++++++++++++++++++--------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/flake.lock b/flake.lock index acb5e01..dafb7f2 100644 --- a/flake.lock +++ b/flake.lock @@ -41,11 +41,11 @@ "arkenfox-userjs": { "flake": false, "locked": { - "lastModified": 1691983650, - "narHash": "sha256-oA1bIpPc27Kk89n3JGpni7RkcIDRVAsTjUfjRHbKS24=", + "lastModified": 1693196107, + "narHash": "sha256-t6qvPFJIF+De2KqMfCI5DEA40BwWeu4AFRWOzKeEVE0=", "owner": "arkenfox", "repo": "user.js", - "rev": "915f39959c7e077f00477e6ce34a0f9f9e3e7c6b", + "rev": "ba173d49205ee927ed62e81e606569d98f531d38", "type": "github" }, "original": { @@ -170,11 +170,11 @@ ] }, "locked": { - "lastModified": 1690933134, - "narHash": "sha256-ab989mN63fQZBFrkk4Q8bYxQCktuHmBIBqUG1jl6/FQ=", + "lastModified": 1693611461, + "narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "59cf3f1447cfc75087e7273b04b31e689a8599fb", + "rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca", "type": "github" }, "original": { @@ -374,11 +374,11 @@ "hmts-nvim": { "flake": false, "locked": { - "lastModified": 1692743873, - "narHash": "sha256-lfqJVj1HbFJ5H4mo6rKYrexaosqSh17+PQ9BWpcuxZI=", + "lastModified": 1693226725, + "narHash": "sha256-jUuztOqNBltC3axa7s3CPJz9Cmukfwkf846+Z/gAxCU=", "owner": "calops", "repo": "hmts.nvim", - "rev": "34b825bd1c9ec1b6e2952c111753e2eb286c9e07", + "rev": "14fd941d7ec2bb98314a1aacaa2573d97f1629ab", "type": "github" }, "original": { @@ -415,11 +415,11 @@ ] }, "locked": { - "lastModified": 1692763155, - "narHash": "sha256-qMrGKZ8c/q/mHO3ZdrcBPwiVVXPLLgXjY98Ejqb5kAA=", + "lastModified": 1693972774, + "narHash": "sha256-Dt9UZs0/DaIex598quYRYFuGabUbvFdNrHuvGc6HjBc=", "owner": "nix-community", "repo": "home-manager", - "rev": "6a20e40acaebf067da682661aa67da8b36812606", + "rev": "b22d7bab30076bbb73744867d6c5bf7d6380570c", "type": "github" }, "original": { @@ -433,11 +433,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1690635289, - "narHash": "sha256-ec77Yf7mqusmGkxrmYXEG4D0DqEcNRA3vFextWVQOVA=", + "lastModified": 1693839821, + "narHash": "sha256-ha9Cxqb81Yni217SoM/zFxE0nNz8IMtreTw4SlXw/D4=", "owner": "hyprwm", "repo": "contrib", - "rev": "bef073cff65917ba2d888aa4dc39bd9868e2b0a4", + "rev": "74aa6b02ff4bd48aaee4da461a16c4cbaaa0ca7e", "type": "github" }, "original": { @@ -455,11 +455,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1692871050, - "narHash": "sha256-OJ/OkOLFn546rcXmj/3VEGlsPYjdXWAhEmjqdc6re6k=", + "lastModified": 1693944974, + "narHash": "sha256-kWa86ahIQvQIgo3GYFJShlBuKTXfggVbrZjkbdjct7U=", "owner": "hyprwm", "repo": "Hyprland", - "rev": "90c03e5bd2204ba6d1a0167c68f65b7a9231bef4", + "rev": "c3a83daa1e61285a418c39a1d9f29427c2c9a2c3", "type": "github" }, "original": { @@ -529,11 +529,11 @@ }, "master": { "locked": { - "lastModified": 1692893187, - "narHash": "sha256-Hbbp6bWQykkLsvzi7yo2KQme0oXCZkCdz9bBorcSKH4=", + "lastModified": 1693980916, + "narHash": "sha256-J7JJCpNiHbXb3D7pb1JkeOTUEpJJXiGI6BngfbnhiIM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "d240553dcc2180fe486155bea8a846d5941e168c", + "rev": "6485865ec300c7baf9e51ad5d64c30355ee511e7", "type": "github" }, "original": { @@ -574,11 +574,11 @@ }, "locked": { "dir": "contrib", - "lastModified": 1692744130, - "narHash": "sha256-Iod6+KGeWnX1SV4owXpSoC17iImCJjTq2iqEp6IRBZc=", + "lastModified": 1693954768, + "narHash": "sha256-DIyHgdfhmftTN2aHVEmJ1q/W2o0Slild0McAf4sEa8U=", "owner": "neovim", "repo": "neovim", - "rev": "6462ee1c10f9f1aa66ffc4d4fe1b7b3d9f0f91af", + "rev": "2ef7b6a433c61837bcef0fca297a665551835423", "type": "github" }, "original": { @@ -597,11 +597,11 @@ "nixpkgs": "nixpkgs_5" }, "locked": { - "lastModified": 1692749096, - "narHash": "sha256-XyFSBw3WMf5cTG9ImL6S/v9Aoawr38h/Fr1XIi7peEs=", + "lastModified": 1693958686, + "narHash": "sha256-UgdB+EXYbi90vm2fam4tYgY9hYGwxSk0sxG96jIyeg4=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "83d68ba72f3308b5c90b12fb40044c870903e6ee", + "rev": "14defe836200c45acf14f3616d7ba20959028cf8", "type": "github" }, "original": { @@ -621,11 +621,11 @@ "rust-overlay": "rust-overlay" }, "locked": { - "lastModified": 1691372739, - "narHash": "sha256-fZ8KfBMcIFO/R7xaWtB85SFeuUjb9SCH8fxYBnY8068=", + "lastModified": 1693724255, + "narHash": "sha256-+Ucv/aBN9wwRE62sUJEBocI+9no7PV4KRDNuFQgygzU=", "owner": "oxalica", "repo": "nil", - "rev": "97abe7d3d48721d4e0fcc1876eea83bb4247825b", + "rev": "4bdcfcfe38cfcb386142e043392afbfa542665dd", "type": "github" }, "original": { @@ -644,11 +644,11 @@ "nixpkgs-regression": "nixpkgs-regression" }, "locked": { - "lastModified": 1691953666, - "narHash": "sha256-HxgMSgoM19OnDb4h47nrxI2lRGsDo+4Y4JEHeCoWB+Q=", + "lastModified": 1692913762, + "narHash": "sha256-WIz/rGYBUdRtkZx5BPbE9DXHfUCKlYuKkPzDsP4u77w=", "owner": "privatevoid-net", "repo": "nix-super", - "rev": "65e8abac80cc06f9f05147b51908a47549e9342e", + "rev": "0007178284d0247631af40931b7039d42bfc0da5", "type": "github" }, "original": { @@ -725,11 +725,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1692638711, - "narHash": "sha256-J0LgSFgJVGCC1+j5R2QndadWI1oumusg6hCtYAzLID4=", + "lastModified": 1693158576, + "narHash": "sha256-aRTTXkYvhXosGx535iAFUaoFboUrZSYb1Ooih/auGp0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "91a22f76cd1716f9d0149e8a5c68424bb691de15", + "rev": "a999c1cc0c9eb2095729d5aa03e0d8f7ed256780", "type": "github" }, "original": { @@ -773,11 +773,11 @@ }, "nixpkgs_5": { "locked": { - "lastModified": 1692557222, - "narHash": "sha256-TCOtZaioLf/jTEgfa+nyg0Nwq5Uc610Z+OFV75yUgGw=", + "lastModified": 1693844670, + "narHash": "sha256-t69F2nBB8DNQUWHD809oJZJVE+23XBrth4QZuVd6IE0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0b07d4957ee1bd7fd3bdfd12db5f361bd70175a6", + "rev": "3c15feef7770eb5500a4b8792623e2d6f598c9c1", "type": "github" }, "original": { @@ -789,11 +789,11 @@ }, "nixpkgs_6": { "locked": { - "lastModified": 1692808169, - "narHash": "sha256-x9Opq06rIiwdwGeK2Ykj69dNc2IvUH1fY55Wm7atwrE=", + "lastModified": 1693844670, + "narHash": "sha256-t69F2nBB8DNQUWHD809oJZJVE+23XBrth4QZuVd6IE0=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9201b5ff357e781bf014d0330d18555695df7ba8", + "rev": "3c15feef7770eb5500a4b8792623e2d6f598c9c1", "type": "github" }, "original": { @@ -947,11 +947,11 @@ "smartcolumn-nvim": { "flake": false, "locked": { - "lastModified": 1692020684, - "narHash": "sha256-lNEsAkKRpMgdO6Og0odpTn/t4qkzO7EuTjC5ABJhvXc=", + "lastModified": 1693669522, + "narHash": "sha256-SfIbbrAFv/md9EgsJvO0RfDnc6oP5RYz8C5Icual1bU=", "owner": "m4xshen", "repo": "smartcolumn.nvim", - "rev": "4aa00ad766f3c0f0e2561e0eb42df3ea3743c135", + "rev": "d01b99355c7fab13233f48d0f28dc097e68a03f7", "type": "github" }, "original": { @@ -962,11 +962,11 @@ }, "stable": { "locked": { - "lastModified": 1692794066, - "narHash": "sha256-H0aG8r16dj0x/Wz6wQhQxc9V7AsObOiHPaKxQgH6Y08=", + "lastModified": 1693771906, + "narHash": "sha256-32EnPCaVjOiEERZ+o/2Ir7JH9pkfwJZJ27SKHNvt4yk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "fc944919f743bb22379dddf18dcb72db6cff84aa", + "rev": "da5adce0ffaff10f6d0fee72a02a5ed9d01b52fc", "type": "github" }, "original": { @@ -1125,18 +1125,18 @@ "flake": false, "locked": { "host": "gitlab.freedesktop.org", - "lastModified": 1691073628, - "narHash": "sha256-LlxE3o3UzRY7APYVLGNKM30DBMcDifCRIQiMVSbYLIc=", + "lastModified": 1692976565, + "narHash": "sha256-eBKkG7tMxg92NskEn8dHRFY245JwjirWRoOZzW6DnUw=", "owner": "wlroots", "repo": "wlroots", - "rev": "c74f89d4f84bfed0284d3908aee5d207698c70c5", + "rev": "717ded9bb0191ea31bf4368be32e7a15fe1b8294", "type": "gitlab" }, "original": { "host": "gitlab.freedesktop.org", "owner": "wlroots", "repo": "wlroots", - "rev": "c74f89d4f84bfed0284d3908aee5d207698c70c5", + "rev": "717ded9bb0191ea31bf4368be32e7a15fe1b8294", "type": "gitlab" } }, From 78bad0191497397f6019a50437f3fb9fd60d1d7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 7 Sep 2023 08:02:32 +0200 Subject: [PATCH 15/24] feat(nvim): lazy load vim fugitive --- modules/programs/nvim/plugins/default.nix | 26 ++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index 73a300c..cb75135 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -176,7 +176,31 @@ with builtins; } { plugin = vim-fugitive; - event = [ "VeryLazy" ]; + cmd = [ + "G" + "Git" + "Ggrep" + "Glgrep" + "Gclog" + "Gllog" + "Gcd" + "Glcd" + "Gedit" + "Gsplit" + "Gvsplit" + "Gtabedit" + "Gpedit" + "Gdrop" + "Gread" + "Gwrite" + "Gwq" + "Gdiffsplit" + "Gvdiffsplit" + "GMove" + "GRename" + "GDelete" + "GBrowse" + ]; } { plugin = vim-tmux-navigator; From 116fc30524cb220e9d8cbf7f47c4fa4e39352e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 7 Sep 2023 08:39:43 +0200 Subject: [PATCH 16/24] feat(nvim)!: use nvim autopairs instead of mini --- modules/programs/nvim/plugins/default.nix | 6 ++++++ modules/programs/nvim/plugins/mini-nvim.lua | 1 - modules/programs/nvim/plugins/nvim-cmp.lua | 24 +++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index cb75135..f4a6780 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -79,6 +79,12 @@ with builtins; conf = readFile ./nvim-cmp.lua; event = [ "InsertEnter" ]; dependencies = [ + { + plugin = nvim-autopairs; + conf = /* lua */ '' + require("nvim-autopairs").setup({}) + ''; + } { plugin = cmp-async-path; } { plugin = cmp-buffer; } { plugin = cmp-cmdline; } diff --git a/modules/programs/nvim/plugins/mini-nvim.lua b/modules/programs/nvim/plugins/mini-nvim.lua index e89e7a3..f2c42d3 100644 --- a/modules/programs/nvim/plugins/mini-nvim.lua +++ b/modules/programs/nvim/plugins/mini-nvim.lua @@ -1,6 +1,5 @@ require("mini.align").setup() require("mini.move").setup() -require("mini.pairs").setup() require("mini.starter").setup() require("mini.statusline").setup({ diff --git a/modules/programs/nvim/plugins/nvim-cmp.lua b/modules/programs/nvim/plugins/nvim-cmp.lua index 0c06f77..500a3a9 100644 --- a/modules/programs/nvim/plugins/nvim-cmp.lua +++ b/modules/programs/nvim/plugins/nvim-cmp.lua @@ -77,3 +77,27 @@ cmp.setup.cmdline(":", { { name = "cmdline" }, }), }) +-- If you want insert `(` after select function or method item +local cmp_autopairs = require("nvim-autopairs.completion.cmp") +local handlers = require("nvim-autopairs.completion.handlers") + +cmp.event:on( + "confirm_done", + cmp_autopairs.on_confirm_done({ + filetypes = { + -- "*" is a alias to all filetypes + ["*"] = { + ["("] = { + kind = { + cmp.lsp.CompletionItemKind.Function, + cmp.lsp.CompletionItemKind.Method, + }, + handler = handlers["*"], + }, + }, + -- Disable for functional languages + haskell = false, + nix = false, + }, + }) +) From 12a5420ee928e05fddb522aad77a8a52874e52b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 7 Sep 2023 08:45:50 +0200 Subject: [PATCH 17/24] feat(nvim): disable cmp for IncRename --- modules/programs/nvim/plugins/nvim-cmp.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/programs/nvim/plugins/nvim-cmp.lua b/modules/programs/nvim/plugins/nvim-cmp.lua index 500a3a9..1a8a070 100644 --- a/modules/programs/nvim/plugins/nvim-cmp.lua +++ b/modules/programs/nvim/plugins/nvim-cmp.lua @@ -76,6 +76,17 @@ cmp.setup.cmdline(":", { }, { { name = "cmdline" }, }), + enabled = function() + -- Set of commands where cmp will be disabled + local disabled = { + IncRename = true, + } + -- Get first word of cmdline + local cmd = vim.fn.getcmdline():match("%S+") + -- Return true if cmd isn't disabled + -- else call/return cmp.close(), which returns false + return not disabled[cmd] or cmp.close() + end, }) -- If you want insert `(` after select function or method item local cmp_autopairs = require("nvim-autopairs.completion.cmp") From 8f0a066e3342f269f5550eb88dc2d0f89012cc66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 7 Sep 2023 09:08:18 +0200 Subject: [PATCH 18/24] feat(nvim): toggle diagnostics with lsp lines --- modules/programs/nvim/plugins/nvim-lspconfig.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/programs/nvim/plugins/nvim-lspconfig.lua b/modules/programs/nvim/plugins/nvim-lspconfig.lua index bba7726..7aa6dd7 100644 --- a/modules/programs/nvim/plugins/nvim-lspconfig.lua +++ b/modules/programs/nvim/plugins/nvim-lspconfig.lua @@ -52,7 +52,17 @@ local on_attach_def = function(client, bufnr) }, }, t = { - l = { lsp_lines.toggle, "LSP lines" }, + l = { + function() + lsp_lines.toggle() + if vim.diagnostic.is_disabled() then + vim.diagnostic.enable() + else + vim.diagnostic.disable() + end + end, + "LSP lines", + }, i = { function() vim.lsp.inlay_hint(bufnr, nil) From d4be10dddacf1a120eca310461f2051a0d5ffc6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Thu, 7 Sep 2023 09:09:12 +0200 Subject: [PATCH 19/24] feat(nvim): improve zen mode --- modules/programs/nvim/plugins/default.nix | 26 ++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index f4a6780..76aebc8 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -316,8 +316,32 @@ with builtins; keys = [ { key = "tz"; cmd = "ZenMode"; desc = "Zen mode"; } ]; + conf = /* lua */ '' + require("zen-mode").setup({ + plugins = { + tmux = { + enabled = true, + }, + }, + }) + ''; dependencies = [ - { plugin = twilight-nvim; } + { + plugin = twilight-nvim; + conf = /* lua */ '' + require("twilight").setup({ + context = 20, + expand = { -- for treesitter, we we always try to expand to the top-most ancestor with these types + "function", + "function_definition", + "if_statement", + "method", + "method_definition", + "table", + }, + }) + ''; + } ]; } ]; From 6a125a1df6f15207af68176dc4d7a1e2556d2e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sun, 10 Sep 2023 13:30:29 +0200 Subject: [PATCH 20/24] refactor(nvim)!: add opts option --- modules/programs/nvim/default.nix | 142 +++++++---- .../nvim/plugins/{default.nix => coding.nix} | 221 +++++++----------- modules/programs/nvim/plugins/copilot-lua.lua | 5 - .../plugins/{ => lua}/catppuccin-nvim.lua | 0 .../nvim/plugins/{ => lua}/formatter-nvim.lua | 0 .../nvim/plugins/{ => lua}/gitsigns-nvim.lua | 0 .../nvim/plugins/{ => lua}/mini-nvim.lua | 0 .../nvim/plugins/{ => lua}/neodev-nvim.lua | 0 .../nvim/plugins/{ => lua}/noice-nvim.lua | 0 .../nvim/plugins/{ => lua}/null-ls-nvim.lua | 1 - .../nvim/plugins/{ => lua}/nvim-cmp.lua | 0 .../nvim/plugins/{ => lua}/nvim-lspconfig.lua | 0 .../nvim-treesitter-textsubjects.lua | 0 .../plugins/{ => lua}/nvim-treesitter.lua | 0 .../nvim/plugins/{ => lua}/nvim-ufo.lua | 0 .../nvim/plugins/{ => lua}/statuscol-nvim.lua | 0 .../nvim/plugins/{ => lua}/telescope.lua | 0 .../plugins/{ => lua}/vim-startuptime.lua | 0 .../nvim/plugins/{ => lua}/which-key-nvim.lua | 38 +-- .../plugins/{ => lua}/zettelkasten-nvim.lua | 0 .../programs/nvim/plugins/nvim-lastplace.lua | 5 - modules/programs/nvim/plugins/oil-nvim.lua | 4 - .../nvim/plugins/smartcolumn-nvim.lua | 4 - .../nvim/plugins/todo-comments-nvim.lua | 1 - modules/programs/nvim/plugins/treesitter.nix | 42 ++++ .../programs/nvim/plugins/trouble-nvim.lua | 1 - modules/programs/nvim/plugins/ui.nix | 47 ++++ 27 files changed, 273 insertions(+), 238 deletions(-) rename modules/programs/nvim/plugins/{default.nix => coding.nix} (51%) delete mode 100644 modules/programs/nvim/plugins/copilot-lua.lua rename modules/programs/nvim/plugins/{ => lua}/catppuccin-nvim.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/formatter-nvim.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/gitsigns-nvim.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/mini-nvim.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/neodev-nvim.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/noice-nvim.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/null-ls-nvim.lua (93%) rename modules/programs/nvim/plugins/{ => lua}/nvim-cmp.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/nvim-lspconfig.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/nvim-treesitter-textsubjects.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/nvim-treesitter.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/nvim-ufo.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/statuscol-nvim.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/telescope.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/vim-startuptime.lua (100%) rename modules/programs/nvim/plugins/{ => lua}/which-key-nvim.lua (66%) rename modules/programs/nvim/plugins/{ => lua}/zettelkasten-nvim.lua (100%) delete mode 100644 modules/programs/nvim/plugins/nvim-lastplace.lua delete mode 100644 modules/programs/nvim/plugins/oil-nvim.lua delete mode 100644 modules/programs/nvim/plugins/smartcolumn-nvim.lua delete mode 100644 modules/programs/nvim/plugins/todo-comments-nvim.lua create mode 100644 modules/programs/nvim/plugins/treesitter.nix delete mode 100644 modules/programs/nvim/plugins/trouble-nvim.lua create mode 100644 modules/programs/nvim/plugins/ui.nix diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index c4859e5..4d95a7b 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -1,57 +1,90 @@ -{ config -, lib -, pkgs -, ... -}: +{ config, lib, pkgs, ... }: with lib; let cfg = config.my.programs.nvim; - boolToString = bool: if bool then "true" else "false"; - quote = str: ''"${toString str}"''; - id = x: x; - listToString = sep: f: list: ''{ ${concatStringsSep sep (map f list)} }''; - listToStringOneLine = listToString ", "; - listToStringMultiLine' = listToString ",\n" id; + toLua = value: with builtins; + if value == null then "nil" else + if isBool value then boolToString value else + if isInt value || isFloat value then toString value else + if isString value then string value else + if isAttrs value then attrs value else + if isList value then list value else + abort "should never happen (value = ${value})"; + + string = str: ''"${toString str}"''; + attrs = set: + let + toKeyword = name: value: "${name} = ${toLua value}"; + keywords = concatStringsSep ", " (mapAttrsToList toKeyword set); + in + "{ " + keywords + " }"; + + listContent = values: concatStringsSep ", " (map toLua values); + list = values: "{ " + listContent values + " }"; + + luaList = values: "{" + (concatStringsSep ", " values) + "}"; + keybinding = { key, cmd, func, mode, desc }: let cmdString = - if cmd != null - then quote cmd - else - ( - if func != null - then func - else abort "Either cmd or function must be set" - ); - descString = optionalString (desc != null) "desc = ${quote desc},"; + if cmd != null then toLua cmd else + if func != null then func else + abort "Either cmd or function must be set"; + descString = optionalString (desc != null) "desc = ${toLua desc},"; in - ''{ ${quote key}, ${cmdString}, mode = ${listToStringOneLine quote mode}, ${descString} }''; + ''{ ${toLua key}, ${cmdString}, mode = ${toLua mode}, ${descString} }''; + lazySpecFromPlugin = - { plugin, dependencies, init, conf, lazy, event, enabled, cmd, ft, priority, keys }: - listToStringMultiLine' + { cmd + , conf + , dependencies + , enabled + , event + , ft + , init + , keys + , lazy + , opts + , plugin + , priority + }: + + luaList ([ - "dir = ${quote plugin}" - "name = ${quote (getName plugin)}" + "dir = ${string plugin}" + "name = ${toLua (getName plugin)}" ] - ++ (optional (lazy != null) "lazy = ${boolToString lazy}") - ++ (optional (!enabled) "enabled = ${boolToString enabled}") - ++ (optional (dependencies != [ ]) "dependencies = ${listToStringMultiLine' (map lazySpecFromPlugin dependencies)}") - ++ (optional (init != null) "init = function(plugin)\n${toString init}\nend") - ++ (optional (conf != null) "config = function(plugin, opts)\n${toString conf}\nend") - ++ (optional (keys != [ ]) "keys = ${listToStringMultiLine' (map keybinding keys)}") - ++ (optional (event != [ ]) "event = ${listToStringOneLine quote event}") - ++ (optional (cmd != [ ]) "cmd = ${listToStringOneLine quote cmd}") - ++ (optional (ft != [ ]) "ft = ${listToStringOneLine quote ft}") - ++ (optional (priority != null) "priority = ${toString priority}") + ++ (optional (opts != null) "opts = ${toLua opts}") + ++ (optional (lazy != null) "lazy = ${toLua lazy}") + ++ (optional (!enabled) "enabled = ${toLua enabled}") + ++ (optional (dependencies != [ ]) "dependencies = ${luaList (map lazySpecFromPlugin dependencies)}") + ++ (optional (init != null) "init = function(plugin)\n${init}\nend") + ++ (optional (conf != null) "config = function(plugin, opts)\n${conf}\nend") + ++ (optional (keys != [ ]) "keys = ${luaList (map keybinding keys)}") + ++ (optional (event != [ ]) "event = ${toLua event}") + ++ (optional (cmd != [ ]) "cmd = ${toLua cmd}") + ++ (optional (ft != [ ]) "ft = ${toLua ft}") + ++ (optional (priority != null) "priority = ${toLua priority}") ); - lazySpecs = listToStringMultiLine' (map lazySpecFromPlugin cfg.plugins); + lazySpecs = luaList (map lazySpecFromPlugin cfg.plugins); lazy = /* lua */ '' require("lazy").setup(${lazySpecs}) ''; + + initLua = + let + text = lib.concatLines [ (builtins.readFile ./options.lua) lazy ]; + in + pkgs.runCommand "init.lua" { inherit text; } '' + touch $out + echo -n "$text" > $out + ${getExe pkgs.stylua} $out + ''; + in { - imports = [ ./plugins ]; + imports = lib.my.listModulesRec ./plugins; options.my.programs.nvim = { enable = mkEnableOption "nvim"; @@ -71,6 +104,27 @@ in Lua function to be executed when the plugin is loaded. ''; }; + opts = mkOption { + type = + let + valueType = nullOr + (oneOf [ + str + bool + int + float + (listOf valueType) + (attrsOf valueType) + ]) // { + description = "Lua value"; + }; + in + nullOr (attrsOf valueType); + default = null; + description = '' + Lua table to be passed to te plugin config function. + ''; + }; dependencies = mkOption { type = listOf sub; default = [ ]; @@ -195,17 +249,9 @@ in else neovide ) ]; - xdg.configFile."nvim/init.lua" = { - source = - let - text = lib.concatLines [ (builtins.readFile ./options.lua) lazy ]; - in - pkgs.runCommand "init.lua" { inherit text; } '' - touch $out - echo -n "$text" > $out - ${getExe pkgs.stylua} $out - ''; - }; + + xdg.configFile."nvim/init.lua".source = initLua; + programs.neovim = { enable = true; package = pkgs.neovim-nightly; diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/coding.nix similarity index 51% rename from modules/programs/nvim/plugins/default.nix rename to modules/programs/nvim/plugins/coding.nix index f4a6780..801f9f0 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/coding.nix @@ -1,30 +1,24 @@ -{ lib, pkgs, ... }: +{ pkgs, ... }: with builtins; { config.my.programs.nvim.plugins = with pkgs.vimPlugins; [ - { - plugin = which-key-nvim; - lazy = false; - conf = readFile ./which-key-nvim.lua; - } - { - plugin = catppuccin-nvim; - conf = readFile ./catppuccin-nvim.lua; - lazy = false; - priority = 99; - } { plugin = formatter-nvim; + cmd = [ "Format" "Fmt" ]; keys = [ - { key = "="; cmd = "Format"; desc = "format (formatter)"; } + { + key = "="; + cmd = "Format"; + desc = "format (formatter)"; + } ]; - conf = readFile ./formatter-nvim.lua; + conf = readFile ./lua/formatter-nvim.lua; } { plugin = oil-nvim; lazy = false; - conf = readFile ./oil-nvim.lua; + opts = { }; dependencies = [ { plugin = which-key-nvim; } { plugin = nvim-web-devicons; } @@ -33,7 +27,7 @@ with builtins; { plugin = mini-nvim; lazy = false; - conf = readFile ./mini-nvim.lua; + conf = readFile ./lua/mini-nvim.lua; } { plugin = trouble-nvim; @@ -44,31 +38,35 @@ with builtins; { 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 = "ft"; cmd = "TodoTelescope"; desc = "Todo"; } { key = "[q"; - func = /* lua */ ''function() - if require("trouble").is_open() then - require("trouble").previous({ skip_groups = true, jump = true }) - else - vim.cmd.cprev() - end - end''; + func = /* lua */ '' + 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 = /* lua */ ''function() - if require("trouble").is_open() then - require("trouble").next({ skip_groups = true, jump = true }) - else - vim.cmd.cnext() - end - end''; + func = /* lua */ '' + 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; + opts = { }; dependencies = [ { plugin = which-key-nvim; } { plugin = nvim-web-devicons; } @@ -76,14 +74,12 @@ with builtins; } { plugin = nvim-cmp; - conf = readFile ./nvim-cmp.lua; + conf = readFile ./lua/nvim-cmp.lua; event = [ "InsertEnter" ]; dependencies = [ { plugin = nvim-autopairs; - conf = /* lua */ '' - require("nvim-autopairs").setup({}) - ''; + opts = { }; } { plugin = cmp-async-path; } { plugin = cmp-buffer; } @@ -92,55 +88,26 @@ with builtins; { plugin = cmp_luasnip; } { plugin = codeium-nvim; - conf = /* lua */ '' - require("codeium").setup({}) - ''; + opts = { }; } { plugin = friendly-snippets; } { plugin = lspkind-nvim; } { plugin = luasnip; } ]; } - { - plugin = todo-comments-nvim; - event = [ "BufReadPost" "BufNewFile" ]; - conf = readFile ./todo-comments-nvim.lua; - dependencies = [{ plugin = plenary-nvim; }]; - } { plugin = direnv-vim; lazy = false; } - { - plugin = nvim-treesitter; - event = [ "BufReadPost" "BufNewFile" ]; - conf = - let - parserDir = pkgs.symlinkJoin { - name = "tresitter-grammars-all"; - paths = lib.attrValues (lib.filterAttrs (_: builtins.isAttrs) nvim-treesitter-parsers); - }; - in - readFile ./nvim-treesitter.lua + '' - vim.opt.runtimepath:append("${parserDir}") - - require'nvim-treesitter.configs'.setup { - parser_install_dir = "${parserDir}", - } - ''; - dependencies = [ - { plugin = nvim-ts-context-commentstring; } - ]; - } { plugin = nvim-lspconfig; event = [ "BufRead" "BufNewFile" ]; - conf = readFile ./nvim-lspconfig.lua; + conf = readFile ./lua/nvim-lspconfig.lua; dependencies = [ { plugin = lsp_signature-nvim; } { plugin = null-ls-nvim; - conf = readFile ./null-ls-nvim.lua; + conf = readFile ./lua/null-ls-nvim.lua; dependencies = [ { plugin = which-key-nvim; } { plugin = plenary-nvim; } @@ -150,36 +117,27 @@ with builtins; { plugin = lsp_lines-nvim; } { plugin = nvim-ufo; - conf = readFile ./nvim-ufo.lua; + conf = readFile ./lua/nvim-ufo.lua; dependencies = [ { plugin = promise-async; } ]; } { plugin = neodev-nvim; - conf = readFile ./neodev-nvim.lua; + conf = readFile ./lua/neodev-nvim.lua; } { plugin = inc-rename-nvim; - conf = /* lua */ '' - require("inc_rename").setup { - input_buffer_type = "dressing", - } - ''; + opts = { + input_buffer_type = "dressing"; + }; dependencies = [ - { - plugin = dressing-nvim; - } + { plugin = dressing-nvim; } ]; } { plugin = actions-preview-nvim; } ]; } - { - plugin = statuscol-nvim; - event = [ "VeryLazy" ]; - conf = readFile ./statuscol-nvim.lua; - } { plugin = vim-fugitive; cmd = [ @@ -212,44 +170,25 @@ with builtins; plugin = vim-tmux-navigator; event = [ "VeryLazy" ]; } - { - plugin = gitsigns-nvim; - event = [ "BufReadPost" "BufNewFile" ]; - conf = readFile ./gitsigns-nvim.lua; - dependencies = [{ plugin = which-key-nvim; }]; - } { plugin = nvim-lastplace; event = [ "BufReadPost" "BufNewFile" ]; - conf = readFile ./nvim-lastplace.lua; - } - { - plugin = nvim-treesitter-textsubjects; - event = [ "BufReadPost" "BufNewFile" ]; - conf = readFile ./nvim-treesitter-textsubjects.lua; - } - { - plugin = smartcolumn-nvim; - event = [ "BufReadPost" "BufNewFile" ]; - conf = readFile ./smartcolumn-nvim.lua; + opts = { + lastplace_ignore_buftype = [ "quickfix" "nofile" "help" ]; + lastplace_ignore_filetype = [ "gitcommit" "gitrebase" "svn" "hgcommit" ]; + lastplace_open_folds = true; + }; } { plugin = telescope-nvim; cmd = [ "Telescope" ]; - conf = builtins.readFile ./telescope.lua; + conf = builtins.readFile ./lua/telescope.lua; 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 = "fl"; cmd = "Telescope current_buffer_fuzzy_find"; desc = "Search lines"; } + { key = "fg"; cmd = "Telescope live_grep"; desc = "Live grep"; } + { key = "fh"; cmd = "Telescope help_tags"; desc = "Help tags"; } ]; dependencies = [ { plugin = plenary-nvim; } @@ -260,7 +199,7 @@ with builtins; { plugin = vim-startuptime; cmd = [ "StartupTime" ]; - conf = readFile ./vim-startuptime.lua; + conf = readFile ./lua/vim-startuptime.lua; } { plugin = typst-vim; @@ -269,47 +208,28 @@ with builtins; { plugin = comment-nvim; event = [ "BufReadPost" "BufNewFile" ]; - conf = /* lua */ '' - require("Comment").setup() - ''; + opts = { }; } { plugin = telekasten-nvim; dependencies = [ { plugin = telescope-nvim; } { plugin = which-key-nvim; } + { + plugin = markdown-preview-nvim; + ft = [ "md" ]; + } ]; cmd = [ "Telekasten" ]; keys = [ { key = "z"; cmd = "Telekasten"; desc = "zettelkasten"; } ]; - conf = builtins.readFile ./zettelkasten-nvim.lua; - } - { - plugin = markdown-preview-nvim; - ft = [ "md" ]; + conf = builtins.readFile ./lua/zettelkasten-nvim.lua; } { plugin = nvim-surround; event = [ "BufReadPost" "BufNewFile" ]; - conf = /* lua */ '' - require("nvim-surround").setup({}) - ''; - } - { - plugin = nvim-treesitter-context; - event = [ "BufReadPost" "BufNewFile" ]; - conf = /* lua */ '' - require("treesitter-context").setup({}) - ''; - } - { - plugin = dressing-nvim; - event = [ "VeryLazy" ]; - } - { - plugin = hmts-nvim; - ft = [ "nix" ]; + opts = { }; } { plugin = zen-mode-nvim; @@ -320,5 +240,30 @@ with builtins; { plugin = twilight-nvim; } ]; } + { + plugin = refactoring-nvim; + keys = [ + { key = "re"; cmd = ": Refactor eextract "; desc = "Extract"; mode = [ "x" ]; } + { key = "rf"; cmd = ": Refactor extract_to_file "; desc = "Extract to file"; mode = [ "x" ]; } + { key = "rv"; cmd = ": Refactor extract_var "; desc = "Extract variable"; mode = [ "x" ]; } + { key = "ri"; cmd = ": Refactor inline_var"; desc = "Inline variable"; mode = [ "n" "x" ]; } + { key = "rI"; cmd = ": Refactor inline_func"; desc = "Inline function"; mode = [ "n" "x" ]; } + { key = "rb"; cmd = ": Refactor extract_block"; desc = "Extract block"; mode = [ "n" ]; } + { key = "rbf"; cmd = ": Refactor extract_block_to_file"; desc = "Extract block to file"; mode = [ "n" ]; } + ]; + dependencies = [ + { plugin = which-key-nvim; } + { plugin = plenary-nvim; } + { plugin = nvim-lspconfig; } + ]; + init = /* lua */ '' + require("which-key").register({ + ["r"] = { + name = "refactoring", + }, + }) + ''; + opts = { }; + } ]; } diff --git a/modules/programs/nvim/plugins/copilot-lua.lua b/modules/programs/nvim/plugins/copilot-lua.lua deleted file mode 100644 index f9799dc..0000000 --- a/modules/programs/nvim/plugins/copilot-lua.lua +++ /dev/null @@ -1,5 +0,0 @@ -require("copilot").setup({ - suggestion = { enabled = false }, - panel = { enabled = false }, -}) -vim.cmd("Copilot disable") diff --git a/modules/programs/nvim/plugins/catppuccin-nvim.lua b/modules/programs/nvim/plugins/lua/catppuccin-nvim.lua similarity index 100% rename from modules/programs/nvim/plugins/catppuccin-nvim.lua rename to modules/programs/nvim/plugins/lua/catppuccin-nvim.lua diff --git a/modules/programs/nvim/plugins/formatter-nvim.lua b/modules/programs/nvim/plugins/lua/formatter-nvim.lua similarity index 100% rename from modules/programs/nvim/plugins/formatter-nvim.lua rename to modules/programs/nvim/plugins/lua/formatter-nvim.lua diff --git a/modules/programs/nvim/plugins/gitsigns-nvim.lua b/modules/programs/nvim/plugins/lua/gitsigns-nvim.lua similarity index 100% rename from modules/programs/nvim/plugins/gitsigns-nvim.lua rename to modules/programs/nvim/plugins/lua/gitsigns-nvim.lua diff --git a/modules/programs/nvim/plugins/mini-nvim.lua b/modules/programs/nvim/plugins/lua/mini-nvim.lua similarity index 100% rename from modules/programs/nvim/plugins/mini-nvim.lua rename to modules/programs/nvim/plugins/lua/mini-nvim.lua diff --git a/modules/programs/nvim/plugins/neodev-nvim.lua b/modules/programs/nvim/plugins/lua/neodev-nvim.lua similarity index 100% rename from modules/programs/nvim/plugins/neodev-nvim.lua rename to modules/programs/nvim/plugins/lua/neodev-nvim.lua diff --git a/modules/programs/nvim/plugins/noice-nvim.lua b/modules/programs/nvim/plugins/lua/noice-nvim.lua similarity index 100% rename from modules/programs/nvim/plugins/noice-nvim.lua rename to modules/programs/nvim/plugins/lua/noice-nvim.lua diff --git a/modules/programs/nvim/plugins/null-ls-nvim.lua b/modules/programs/nvim/plugins/lua/null-ls-nvim.lua similarity index 93% rename from modules/programs/nvim/plugins/null-ls-nvim.lua rename to modules/programs/nvim/plugins/lua/null-ls-nvim.lua index c689fad..6701630 100644 --- a/modules/programs/nvim/plugins/null-ls-nvim.lua +++ b/modules/programs/nvim/plugins/lua/null-ls-nvim.lua @@ -3,7 +3,6 @@ local null_ls = require("null-ls") null_ls.setup({ sources = { -- Code actions - null_ls.builtins.code_actions.gitsigns, null_ls.builtins.code_actions.shellcheck, null_ls.builtins.code_actions.statix, -- Completion diff --git a/modules/programs/nvim/plugins/nvim-cmp.lua b/modules/programs/nvim/plugins/lua/nvim-cmp.lua similarity index 100% rename from modules/programs/nvim/plugins/nvim-cmp.lua rename to modules/programs/nvim/plugins/lua/nvim-cmp.lua diff --git a/modules/programs/nvim/plugins/nvim-lspconfig.lua b/modules/programs/nvim/plugins/lua/nvim-lspconfig.lua similarity index 100% rename from modules/programs/nvim/plugins/nvim-lspconfig.lua rename to modules/programs/nvim/plugins/lua/nvim-lspconfig.lua diff --git a/modules/programs/nvim/plugins/nvim-treesitter-textsubjects.lua b/modules/programs/nvim/plugins/lua/nvim-treesitter-textsubjects.lua similarity index 100% rename from modules/programs/nvim/plugins/nvim-treesitter-textsubjects.lua rename to modules/programs/nvim/plugins/lua/nvim-treesitter-textsubjects.lua diff --git a/modules/programs/nvim/plugins/nvim-treesitter.lua b/modules/programs/nvim/plugins/lua/nvim-treesitter.lua similarity index 100% rename from modules/programs/nvim/plugins/nvim-treesitter.lua rename to modules/programs/nvim/plugins/lua/nvim-treesitter.lua diff --git a/modules/programs/nvim/plugins/nvim-ufo.lua b/modules/programs/nvim/plugins/lua/nvim-ufo.lua similarity index 100% rename from modules/programs/nvim/plugins/nvim-ufo.lua rename to modules/programs/nvim/plugins/lua/nvim-ufo.lua diff --git a/modules/programs/nvim/plugins/statuscol-nvim.lua b/modules/programs/nvim/plugins/lua/statuscol-nvim.lua similarity index 100% rename from modules/programs/nvim/plugins/statuscol-nvim.lua rename to modules/programs/nvim/plugins/lua/statuscol-nvim.lua diff --git a/modules/programs/nvim/plugins/telescope.lua b/modules/programs/nvim/plugins/lua/telescope.lua similarity index 100% rename from modules/programs/nvim/plugins/telescope.lua rename to modules/programs/nvim/plugins/lua/telescope.lua diff --git a/modules/programs/nvim/plugins/vim-startuptime.lua b/modules/programs/nvim/plugins/lua/vim-startuptime.lua similarity index 100% rename from modules/programs/nvim/plugins/vim-startuptime.lua rename to modules/programs/nvim/plugins/lua/vim-startuptime.lua diff --git a/modules/programs/nvim/plugins/which-key-nvim.lua b/modules/programs/nvim/plugins/lua/which-key-nvim.lua similarity index 66% rename from modules/programs/nvim/plugins/which-key-nvim.lua rename to modules/programs/nvim/plugins/lua/which-key-nvim.lua index 09f227f..aa3c8a9 100644 --- a/modules/programs/nvim/plugins/which-key-nvim.lua +++ b/modules/programs/nvim/plugins/lua/which-key-nvim.lua @@ -1,14 +1,16 @@ vim.o.timeout = true vim.o.timeoutlen = 500 --- buffer +-- Delete require("which-key").register({ - b = { - name = "buffer", - b = { "Telescope buffers", "List buffers" }, - d = { "bd", "Delete buffer" }, + d = { + name = "delete", + b = { "bd", "Delete buffer" }, + w = { "c", "Delete window" }, }, }, { prefix = "" }) + +-- buffer require("which-key").register({ ["["] = { b = { "bprevious", "Previous buffer" }, @@ -25,32 +27,6 @@ require("which-key").register({ ["|"] = { "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" }, - d = { "tabclose", "Close tab" }, - }, -}, { prefix = "" }) -require("which-key").register({ - ["["] = { - t = { "tabprevious", "Previous tab" }, - }, - ["]"] = { - t = { "tabnext", "Next tab" }, - }, -}) - --- file -require("which-key").register({ - f = { - name = "file/find", - n = { "enew", "New file" }, }, }, { prefix = "" }) diff --git a/modules/programs/nvim/plugins/zettelkasten-nvim.lua b/modules/programs/nvim/plugins/lua/zettelkasten-nvim.lua similarity index 100% rename from modules/programs/nvim/plugins/zettelkasten-nvim.lua rename to modules/programs/nvim/plugins/lua/zettelkasten-nvim.lua diff --git a/modules/programs/nvim/plugins/nvim-lastplace.lua b/modules/programs/nvim/plugins/nvim-lastplace.lua deleted file mode 100644 index d97700f..0000000 --- a/modules/programs/nvim/plugins/nvim-lastplace.lua +++ /dev/null @@ -1,5 +0,0 @@ -require("nvim-lastplace").setup({ - lastplace_ignore_buftype = { "quickfix", "nofile", "help" }, - lastplace_ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" }, - lastplace_open_folds = true, -}) diff --git a/modules/programs/nvim/plugins/oil-nvim.lua b/modules/programs/nvim/plugins/oil-nvim.lua deleted file mode 100644 index 6c9c81e..0000000 --- a/modules/programs/nvim/plugins/oil-nvim.lua +++ /dev/null @@ -1,4 +0,0 @@ -require("oil").setup() -require("which-key").register({ - d = { require("oil").toggle_float, "Directory (oil)" }, -}, { prefix = "t" }) diff --git a/modules/programs/nvim/plugins/smartcolumn-nvim.lua b/modules/programs/nvim/plugins/smartcolumn-nvim.lua deleted file mode 100644 index c095401..0000000 --- a/modules/programs/nvim/plugins/smartcolumn-nvim.lua +++ /dev/null @@ -1,4 +0,0 @@ -require("smartcolumn").setup({ - colorcolumn = "120", - disabled_filetypes = { "help", "text", "markdown", "dashboard" }, -}) diff --git a/modules/programs/nvim/plugins/todo-comments-nvim.lua b/modules/programs/nvim/plugins/todo-comments-nvim.lua deleted file mode 100644 index 57fce71..0000000 --- a/modules/programs/nvim/plugins/todo-comments-nvim.lua +++ /dev/null @@ -1 +0,0 @@ -require("todo-comments").setup() diff --git a/modules/programs/nvim/plugins/treesitter.nix b/modules/programs/nvim/plugins/treesitter.nix new file mode 100644 index 0000000..d4c3cf0 --- /dev/null +++ b/modules/programs/nvim/plugins/treesitter.nix @@ -0,0 +1,42 @@ +{ lib, pkgs, ... }: + +with builtins; +{ + config.my.programs.nvim.plugins = with pkgs.vimPlugins; [ + { + plugin = nvim-treesitter; + event = [ "BufReadPost" "BufNewFile" ]; + conf = + let + parserDir = pkgs.symlinkJoin { + name = "tresitter-grammars-all"; + paths = lib.attrValues (lib.filterAttrs (_: builtins.isAttrs) nvim-treesitter-parsers); + }; + in + readFile ./lua/nvim-treesitter.lua + '' + vim.opt.runtimepath:append("${parserDir}") + + require'nvim-treesitter.configs'.setup { + parser_install_dir = "${parserDir}", + } + ''; + dependencies = [ + { plugin = nvim-ts-context-commentstring; } + ]; + } + { + plugin = nvim-treesitter-textsubjects; + event = [ "BufReadPost" "BufNewFile" ]; + conf = readFile ./lua/nvim-treesitter-textsubjects.lua; + } + { + plugin = nvim-treesitter-context; + event = [ "BufReadPost" "BufNewFile" ]; + opts = { }; + } + { + plugin = hmts-nvim; + ft = [ "nix" ]; + } + ]; +} diff --git a/modules/programs/nvim/plugins/trouble-nvim.lua b/modules/programs/nvim/plugins/trouble-nvim.lua deleted file mode 100644 index 38ef1e9..0000000 --- a/modules/programs/nvim/plugins/trouble-nvim.lua +++ /dev/null @@ -1 +0,0 @@ -require("trouble").setup() diff --git a/modules/programs/nvim/plugins/ui.nix b/modules/programs/nvim/plugins/ui.nix new file mode 100644 index 0000000..0e535c4 --- /dev/null +++ b/modules/programs/nvim/plugins/ui.nix @@ -0,0 +1,47 @@ +{ pkgs, ... }: + +with builtins; +{ + config.my.programs.nvim.plugins = with pkgs.vimPlugins; [ + { + plugin = which-key-nvim; + lazy = false; + conf = readFile ./lua/which-key-nvim.lua; + } + { + plugin = catppuccin-nvim; + conf = readFile ./lua/catppuccin-nvim.lua; + lazy = false; + priority = 99; + } + { + plugin = todo-comments-nvim; + event = [ "BufReadPost" "BufNewFile" ]; + dependencies = [{ plugin = plenary-nvim; }]; + opts = { }; + } + { + plugin = statuscol-nvim; + event = [ "VeryLazy" ]; + conf = readFile ./lua/statuscol-nvim.lua; + } + { + plugin = smartcolumn-nvim; + event = [ "BufReadPost" "BufNewFile" ]; + opts = { + colorcolumn = "120"; + disabled_filetypes = [ "help" "text" "markdown" "dashboard" ]; + }; + } + { + plugin = dressing-nvim; + event = [ "VeryLazy" ]; + } + { + plugin = gitsigns-nvim; + event = [ "BufReadPost" "BufNewFile" ]; + conf = readFile ./lua/gitsigns-nvim.lua; + dependencies = [{ plugin = which-key-nvim; }]; + } + ]; +} From cc72c96512ba6decb4bf0202c005ce02173fbbd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sun, 10 Sep 2023 13:35:01 +0200 Subject: [PATCH 21/24] feat(base): add nixos-test command --- modules/profiles/base.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index 830069d..459a65d 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -149,6 +149,7 @@ in # nix (nom-system-command "nixos-boot" "sudo nixos-rebuild boot --flake ~/.dotfiles") (nom-system-command "nixos-switch" "sudo nixos-rebuild switch --flake ~/.dotfiles") + (nom-system-command "nixos-test" "sudo nixos-rebuild test --flake ~/.dotfiles") manix nix-index nix-output-monitor From d6ad8105680fe53708e1705d61a412c4a40b6b7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sun, 10 Sep 2023 13:35:13 +0200 Subject: [PATCH 22/24] feat(nvim): add harpoon --- modules/programs/nvim/plugins/coding.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/modules/programs/nvim/plugins/coding.nix b/modules/programs/nvim/plugins/coding.nix index 0242af5..79a94bc 100644 --- a/modules/programs/nvim/plugins/coding.nix +++ b/modules/programs/nvim/plugins/coding.nix @@ -289,5 +289,17 @@ with builtins; ''; opts = { }; } + { + plugin = harpoon; + keys = [ + { key = "ha"; cmd = "lua require('harpoon.mark').add_file()"; desc = "Add file"; } + { key = "hh"; cmd = "lua require('harpoon.ui').toggle_quick_menu()"; desc = "Harpoon"; } + { key = "h1"; cmd = "lua require('harpoon.ui').nav_file(1)"; desc = "Harpoon file 1"; } + { key = "h2"; cmd = "lua require('harpoon.ui').nav_file(2)"; desc = "Harpoon file 2"; } + { key = "h3"; cmd = "lua require('harpoon.ui').nav_file(3)"; desc = "Harpoon file 3"; } + { key = "h4"; cmd = "lua require('harpoon.ui').nav_file(4)"; desc = "Harpoon file 4"; } + ]; + opts = { }; + } ]; } From 749e2cf67d5c5515cf304a26ac51f7c597712066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sun, 10 Sep 2023 15:05:56 +0200 Subject: [PATCH 23/24] refactor: remove hyrpland overlay --- flake.nix | 1 - modules/programs/hyprland/default.nix | 3 ++- overlays/packages.nix | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 91ccddd..4ba9684 100644 --- a/flake.nix +++ b/flake.nix @@ -86,7 +86,6 @@ overlays = [ inputs.hypr-contrib.overlays.default - inputs.hyprland.overlays.default inputs.neovim-nightly-overlay.overlay overlay ]; diff --git a/modules/programs/hyprland/default.nix b/modules/programs/hyprland/default.nix index e208565..7c1cefa 100644 --- a/modules/programs/hyprland/default.nix +++ b/modules/programs/hyprland/default.nix @@ -9,7 +9,8 @@ with lib; let cfg = config.my.programs.hyprland; - hyprland = pkgs.hyprland.override { enableNvidiaPatches = cfg.nvidiaSupport; }; + hyprland-nvidia = pkgs.hyprland.override { enableNvidiaPatches = true; }; + hyprland = if cfg.nvidiaSupport then hyprland-nvidia else pkgs.hyprland; in { options.my.programs.hyprland = { diff --git a/overlays/packages.nix b/overlays/packages.nix index 66b2624..973523e 100644 --- a/overlays/packages.nix +++ b/overlays/packages.nix @@ -11,6 +11,7 @@ final: prev: version = lib.my.mkVersionInput inputs.rofi-wayland; }); timers = inputs.timers.packages.${prev.system}.default; + hyprland = inputs.hyprland.packages.${prev.system}.default; fzf1 = final.writeShellApplication { name = "fzf1"; From 372ee5985abdb43b4e2caff4ecc241a833766c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sun, 10 Sep 2023 15:07:55 +0200 Subject: [PATCH 24/24] refactor: small changes --- modules/profiles/base.nix | 66 +++++++++++++++++++------------- modules/programs/fish.nix | 9 +++-- modules/services/openconnect.nix | 2 +- overlays/builders.nix | 63 +++++++++++++++++++----------- 4 files changed, 86 insertions(+), 54 deletions(-) diff --git a/modules/profiles/base.nix b/modules/profiles/base.nix index aefaac4..b22c622 100644 --- a/modules/profiles/base.nix +++ b/modules/profiles/base.nix @@ -34,42 +34,54 @@ let which-nix = pkgs.writeFishApplication { name = "which-nix"; - runtimeInputs = with pkgs; [ which coreutils-full ]; + runtimeInputs = with pkgs; [ which coreutils-full procps ]; text = /* fish */ '' - readlink -f (which $argv) + function recurse -a path; + if not test -f "$path" + return + end + + echo $path + if test -L $path + recurse (readlink $path) + end + end + + for arg in $argv + recurse (which $arg) + end ''; completions = /* fish */ '' complete -c which-nix -fa '(__fish_complete_command)' ''; }; - gi = pkgs.writeFishApplication - { - name = "gi"; - runtimeInputs = with pkgs; [ fzf gum curl ]; - text = /* fish */ '' - set url https://www.gitignore.io/api + gi = pkgs.writeFishApplication { + name = "gi"; + runtimeInputs = with pkgs; [ fzf gum curl ]; + text = /* fish */ '' + set url https://www.gitignore.io/api - if test (count $argv) -eq 0 - set choice ( curl -sL $url/list \ - | string split "," \ - | fzf -m \ - | string join "," ) - else - set choice (string join "," $argv[1..]) - end + if test (count $argv) -eq 0 + set choice ( curl -sL $url/list \ + | string split "," \ + | fzf -m \ + | string join "," ) + else + set choice (string join "," $argv[1..]) + end - if gum confirm "Overwrite current .gitignore?" - curl -sL $url/$choice > .gitignore - else - curl -sL $url/$choice >> .gitignore - end - ''; - completions = /* fish */ '' - set args (curl -sL https://www.gitignore.io/api/list | string split ",") - complete -c gi -fa "$args" - ''; - }; + if gum confirm "Overwrite current .gitignore?" + curl -sL $url/$choice > .gitignore + else + curl -sL $url/$choice >> .gitignore + end + ''; + completions = /* fish */ '' + set args (curl -sL https://www.gitignore.io/api/list | string split ",") + complete -c gi -fa "$args" + ''; + }; in { users.users.moritz = { diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index de683ab..f6e8c92 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -8,9 +8,12 @@ with lib; let cfg = config.my.programs.fish; shellConfig = config.my.shell; - exportVariables = - lib.mapAttrsToList (n: v: ''set -x ${n} "${v}"'') shellConfig.variables; - exportedVariables = lib.concatStringsSep "\n" exportVariables; + exportedVariables = + let + exportVariables = + lib.mapAttrsToList (n: v: ''set -x ${n} "${v}"'') shellConfig.variables; + in + lib.concatStringsSep "\n" exportVariables; in { options.my.programs.fish.enable = mkEnableOption "fish"; diff --git a/modules/services/openconnect.nix b/modules/services/openconnect.nix index 87c37a1..6eddd64 100644 --- a/modules/services/openconnect.nix +++ b/modules/services/openconnect.nix @@ -17,7 +17,7 @@ in gateway = "vpn.uni-leipzig.de"; protocol = "anyconnect"; user = "mb18cele@uni-leipzig.de"; - # NOTE file content as follows: + # NOTE: file content as follows: # # "1-Standard-Uni" or "2-Spezial-Alles" # Explanation: diff --git a/overlays/builders.nix b/overlays/builders.nix index 813b7d3..359a4af 100644 --- a/overlays/builders.nix +++ b/overlays/builders.nix @@ -2,7 +2,33 @@ _: final: _: with final.lib; -{ +rec { + fishFile = + { name + , destination + , content + , checkPhase ? null + }: + final.writeTextFile { + inherit name destination; + executable = true; + allowSubstitutes = true; + preferLocalBuild = false; + text = '' + #!${getExe final.fish} + + ${content} + ''; + + checkPhase = + if checkPhase == null then '' + runHook preCheck + ${getExe final.fish} -n "$target" + runHook postCheck + '' + else checkPhase; + }; + writeFishApplication = { name , text @@ -11,30 +37,21 @@ with final.lib; , checkPhase ? null }: let - fishFile = destination: content: final.writeTextFile { - inherit name destination; - executable = true; - allowSubstitutes = true; - preferLocalBuild = false; - text = '' - #!${getExe final.fish} + runtimeHeader = optionalString (runtimeInputs != [ ]) + ''export PATH="${makeBinPath runtimeInputs}:$PATH"''; - ${optionalString (runtimeInputs != [ ]) ''export PATH="${makeBinPath runtimeInputs}:$PATH"''} - - ${content} - ''; - - checkPhase = - if checkPhase == null then '' - runHook preCheck - ${getExe final.fish} -n "$target" - runHook postCheck - '' - else checkPhase; + script = fishFile { + inherit checkPhase; + name = "${name}_script"; + destination = "/bin/${name}"; + content = concatLines [ runtimeHeader text ]; + }; + completions_file = fishFile { + inherit checkPhase; + name = "${name}_completions"; + destination = "/share/fish/vendor_completions.d/${name}.fish"; + content = concatLines [ runtimeHeader completions ]; }; - - script = fishFile "/bin/${name}" text; - completions_file = fishFile "/share/fish/vendor_completions.d/${name}.fish" completions; in final.symlinkJoin { inherit name;