From 85ebcee9bac1550d841dc7cc0a517749360f9154 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Thu, 21 Dec 2023 16:21:14 +0100 Subject: [PATCH] Move more neovim plugins to nix --- flake.lock | 107 +++-- flake.nix | 2 + home/features/desktop/wezterm/default.nix | 2 +- home/features/neovim/config/ftplugin/nix.lua | 2 +- home/features/neovim/config/lazy-lock.json | 35 +- .../config/lua/my/abbreviations/unicode.lua | 2 + .../features/neovim/config/lua/my/helpers.lua | 19 - .../neovim/config/lua/my/helpers/env.lua | 56 --- .../neovim/config/lua/my/helpers/string.lua | 13 - .../themes/helpers.lua => helpers/theme.lua} | 7 +- .../features/neovim/config/lua/my/keymaps.lua | 35 +- home/features/neovim/config/lua/my/lazy.lua | 73 ++-- .../neovim/config/lua/my/plugins/clue.lua | 99 ----- .../neovim/config/lua/my/plugins/cmp.lua | 122 ------ .../config/lua/my/plugins/dashboard.lua | 21 +- .../neovim/config/lua/my/plugins/firenvim.lua | 9 +- .../neovim/config/lua/my/plugins/gitsigns.lua | 97 ----- .../neovim/config/lua/my/plugins/init.lua | 109 +---- .../config/lua/my/plugins/lspconfig.lua | 11 +- .../neovim/config/lua/my/plugins/luasnip.lua | 35 -- .../neovim/config/lua/my/plugins/null-ls.lua | 30 -- .../config/lua/my/plugins/themes/bluloco.lua | 5 +- .../lua/my/plugins/themes/catppuccin.lua | 7 +- .../config/lua/my/plugins/themes/init.lua | 5 - .../config/lua/my/plugins/themes/rosepine.lua | 2 +- .../config/lua/my/plugins/treesitter.lua | 105 ----- .../neovim/config/lua/my/plugins/venn.lua | 85 ++-- .../neovim/config/lua/my/plugins/whichkey.lua | 5 +- .../lua/my/{runtime.lua => tempest.lua} | 114 ++++- home/features/neovim/default.nix | 401 ++++++++++++++++-- home/features/neovim/plugins/cmp.lua | 88 ++++ modules/common/lua-colorscheme.nix | 2 +- modules/common/lua-encoders.nix | 10 +- modules/common/neovim.nix | 128 ++++-- 34 files changed, 882 insertions(+), 961 deletions(-) delete mode 100644 home/features/neovim/config/lua/my/helpers.lua delete mode 100644 home/features/neovim/config/lua/my/helpers/env.lua delete mode 100644 home/features/neovim/config/lua/my/helpers/string.lua rename home/features/neovim/config/lua/my/{plugins/themes/helpers.lua => helpers/theme.lua} (51%) delete mode 100644 home/features/neovim/config/lua/my/plugins/clue.lua delete mode 100644 home/features/neovim/config/lua/my/plugins/cmp.lua delete mode 100644 home/features/neovim/config/lua/my/plugins/gitsigns.lua delete mode 100644 home/features/neovim/config/lua/my/plugins/luasnip.lua delete mode 100644 home/features/neovim/config/lua/my/plugins/null-ls.lua delete mode 100644 home/features/neovim/config/lua/my/plugins/themes/init.lua delete mode 100644 home/features/neovim/config/lua/my/plugins/treesitter.lua rename home/features/neovim/config/lua/my/{runtime.lua => tempest.lua} (56%) create mode 100644 home/features/neovim/plugins/cmp.lua diff --git a/flake.lock b/flake.lock index 8b6cce5..bd6496e 100644 --- a/flake.lock +++ b/flake.lock @@ -1413,7 +1413,7 @@ }, "home-manager_4": { "inputs": { - "nixpkgs": "nixpkgs_8" + "nixpkgs": "nixpkgs_9" }, "locked": { "lastModified": 1700392168, @@ -1583,6 +1583,24 @@ "type": "github" } }, + "korora": { + "inputs": { + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1702807380, + "narHash": "sha256-ifI0zueeh8dKZeTWgqOYTedICWeqUjgDnI5ntsAWMDk=", + "owner": "adisbladis", + "repo": "korora", + "rev": "3c3e941f596a20c87068640376f07590451507f9", + "type": "github" + }, + "original": { + "owner": "adisbladis", + "repo": "korora", + "type": "github" + } + }, "lib-aggregate": { "inputs": { "flake-utils": "flake-utils_6", @@ -1837,7 +1855,7 @@ "inputs": { "flake-parts": "flake-parts_6", "nix-github-actions": "nix-github-actions", - "nixpkgs": "nixpkgs_7", + "nixpkgs": "nixpkgs_8", "treefmt-nix": "treefmt-nix" }, "locked": { @@ -1899,7 +1917,7 @@ "nixd": { "inputs": { "flake-parts": "flake-parts_5", - "nixpkgs": "nixpkgs_5" + "nixpkgs": "nixpkgs_6" }, "locked": { "lastModified": 1695137077, @@ -2134,6 +2152,22 @@ } }, "nixpkgs_10": { + "locked": { + "lastModified": 1700403855, + "narHash": "sha256-Q0Uzjik9kUTN9pd/kp52XJi5kletBhy29ctBlAG+III=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0c5678df521e1407884205fe3ce3cf1d7df297db", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_11": { "locked": { "lastModified": 1685865905, "narHash": "sha256-XJZ/o17eOd2sEsGif+/MQBnfa2DKmndWgJyc7CWajFc=", @@ -2149,7 +2183,7 @@ "type": "github" } }, - "nixpkgs_11": { + "nixpkgs_12": { "locked": { "lastModified": 1685866647, "narHash": "sha256-4jKguNHY/edLYImB+uL8jKPL/vpfOvMmSlLAGfxSrnY=", @@ -2165,7 +2199,7 @@ "type": "github" } }, - "nixpkgs_12": { + "nixpkgs_13": { "locked": { "lastModified": 1689261696, "narHash": "sha256-LzfUtFs9MQRvIoQ3MfgSuipBVMXslMPH/vZ+nM40LkA=", @@ -2181,7 +2215,7 @@ "type": "github" } }, - "nixpkgs_13": { + "nixpkgs_14": { "locked": { "lastModified": 1685865905, "narHash": "sha256-XJZ/o17eOd2sEsGif+/MQBnfa2DKmndWgJyc7CWajFc=", @@ -2197,7 +2231,7 @@ "type": "github" } }, - "nixpkgs_14": { + "nixpkgs_15": { "locked": { "lastModified": 1685866647, "narHash": "sha256-4jKguNHY/edLYImB+uL8jKPL/vpfOvMmSlLAGfxSrnY=", @@ -2213,7 +2247,7 @@ "type": "github" } }, - "nixpkgs_15": { + "nixpkgs_16": { "locked": { "lastModified": 1689261696, "narHash": "sha256-LzfUtFs9MQRvIoQ3MfgSuipBVMXslMPH/vZ+nM40LkA=", @@ -2262,6 +2296,20 @@ } }, "nixpkgs_4": { + "locked": { + "lastModified": 1702272962, + "narHash": "sha256-D+zHwkwPc6oYQ4G3A1HuadopqRwUY/JkMwHz1YF7j4Q=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e97b3e4186bcadf0ef1b6be22b8558eab1cdeb5d", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "nixpkgs_5": { "locked": { "lastModified": 1681358109, "narHash": "sha256-eKyxW4OohHQx9Urxi7TQlFBTDWII+F+x2hklDOQPB50=", @@ -2277,7 +2325,7 @@ "type": "github" } }, - "nixpkgs_5": { + "nixpkgs_6": { "locked": { "lastModified": 1686398752, "narHash": "sha256-nGWNQVhSw4VSL+S0D0cbrNR9vs9Bq7rlYR+1K5f5j6w=", @@ -2293,7 +2341,7 @@ "type": "github" } }, - "nixpkgs_6": { + "nixpkgs_7": { "locked": { "lastModified": 1701952659, "narHash": "sha256-TJv2srXt6fYPUjxgLAL0cy4nuf1OZD4KuA1TrCiQqg0=", @@ -2309,7 +2357,7 @@ "type": "github" } }, - "nixpkgs_7": { + "nixpkgs_8": { "locked": { "lastModified": 1701847270, "narHash": "sha256-ttPWHy1NZwJzSzY7OmofFNyrm9kWc+RFFHpJGeQ4kWw=", @@ -2325,7 +2373,7 @@ "type": "github" } }, - "nixpkgs_8": { + "nixpkgs_9": { "locked": { "lastModified": 1687466461, "narHash": "sha256-oupXI7g7RPzlpGUfAu1xG4KBK53GrZH8/xeKgKDB4+Q=", @@ -2341,22 +2389,6 @@ "type": "github" } }, - "nixpkgs_9": { - "locked": { - "lastModified": 1700403855, - "narHash": "sha256-Q0Uzjik9kUTN9pd/kp52XJi5kletBhy29ctBlAG+III=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "0c5678df521e1407884205fe3ce3cf1d7df297db", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-23.05", - "repo": "nixpkgs", - "type": "github" - } - }, "nur": { "locked": { "lastModified": 1702130780, @@ -2391,7 +2423,7 @@ "openapi-code-generator_2": { "inputs": { "autodocodec": "autodocodec_3", - "nixpkgs": "nixpkgs_10", + "nixpkgs": "nixpkgs_11", "pre-commit-hooks": "pre-commit-hooks_2", "safe-coloured-text": "safe-coloured-text_2", "sydtest": "sydtest_2", @@ -2414,7 +2446,7 @@ "openapi-code-generator_3": { "inputs": { "autodocodec": "autodocodec_5", - "nixpkgs": "nixpkgs_13", + "nixpkgs": "nixpkgs_14", "pre-commit-hooks": "pre-commit-hooks_4", "safe-coloured-text": "safe-coloured-text_4", "sydtest": "sydtest_4", @@ -2461,7 +2493,7 @@ "flake-compat": "flake-compat_4", "flake-utils": "flake-utils_7", "gitignore": "gitignore_2", - "nixpkgs": "nixpkgs_11", + "nixpkgs": "nixpkgs_12", "nixpkgs-stable": "nixpkgs-stable_3" }, "locked": { @@ -2483,7 +2515,7 @@ "flake-compat": "flake-compat_5", "flake-utils": "flake-utils_8", "gitignore": "gitignore_3", - "nixpkgs": "nixpkgs_12", + "nixpkgs": "nixpkgs_13", "nixpkgs-stable": "nixpkgs-stable_4" }, "locked": { @@ -2505,7 +2537,7 @@ "flake-compat": "flake-compat_7", "flake-utils": "flake-utils_10", "gitignore": "gitignore_4", - "nixpkgs": "nixpkgs_14", + "nixpkgs": "nixpkgs_15", "nixpkgs-stable": "nixpkgs-stable_5" }, "locked": { @@ -2527,7 +2559,7 @@ "flake-compat": "flake-compat_8", "flake-utils": "flake-utils_11", "gitignore": "gitignore_5", - "nixpkgs": "nixpkgs_15", + "nixpkgs": "nixpkgs_16", "nixpkgs-stable": "nixpkgs-stable_6" }, "locked": { @@ -2575,12 +2607,13 @@ "hyprland-contrib": "hyprland-contrib", "impermanence": "impermanence", "intray": "intray", + "korora": "korora", "matui": "matui", "neovim-nightly-overlay": "neovim-nightly-overlay", "nix-index-database": "nix-index-database", "nixd": "nixd", "nixos-hardware": "nixos-hardware", - "nixpkgs": "nixpkgs_6", + "nixpkgs": "nixpkgs_7", "nixpkgs-stable": "nixpkgs-stable_2", "nixpkgs-unstable": "nixpkgs-unstable", "nixpkgs-wayland": "nixpkgs-wayland", @@ -2613,7 +2646,7 @@ "rust-overlay": { "inputs": { "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_4" + "nixpkgs": "nixpkgs_5" }, "locked": { "lastModified": 1694571081, @@ -2823,7 +2856,7 @@ "linkcheck": "linkcheck_2", "looper": "looper", "mergeful": "mergeful", - "nixpkgs": "nixpkgs_9", + "nixpkgs": "nixpkgs_10", "openapi-code-generator": "openapi-code-generator_2", "pre-commit-hooks": "pre-commit-hooks_3", "safe-coloured-text": "safe-coloured-text_3", diff --git a/flake.nix b/flake.nix index b659083..0b902d0 100644 --- a/flake.nix +++ b/flake.nix @@ -46,6 +46,8 @@ nix-index-database.url = "github:Mic92/nix-index-database"; nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; + korora.url = "github:adisbladis/korora"; + # Nix language server # [the docs](https://github.com/nix-community/nixd/blob/main/docs/user-guide.md#installation) # tell me not to override the nixpkgs input. diff --git a/home/features/desktop/wezterm/default.nix b/home/features/desktop/wezterm/default.nix index 38fddc3..6411285 100644 --- a/home/features/desktop/wezterm/default.nix +++ b/home/features/desktop/wezterm/default.nix @@ -5,7 +5,7 @@ xdg.configFile."wezterm/nix".source = config.satellite.lib.lua.writeFile "." "colorscheme" - config.satellite.colorscheme.lua; + "return ${config.satellite.colorscheme.lua}"; xdg.configFile."wezterm/wezterm.lua".source = config.satellite.dev.path "home/features/desktop/wezterm/wezterm.lua"; } diff --git a/home/features/neovim/config/ftplugin/nix.lua b/home/features/neovim/config/ftplugin/nix.lua index 991dbac..c49ab7f 100644 --- a/home/features/neovim/config/ftplugin/nix.lua +++ b/home/features/neovim/config/ftplugin/nix.lua @@ -1,6 +1,6 @@ -- Use _lg_ to fetchgit stuff vim.keymap.set("n", "lg", function() - require("my.helpers").saveCursor(function() + require("my.tempest").withSavedCursor(function() vim.cmd(":%!update-nix-fetchgit") end) end, { buffer = true, desc = "Update all fetchgit calls" }) diff --git a/home/features/neovim/config/lazy-lock.json b/home/features/neovim/config/lazy-lock.json index 48e1bb1..feac94c 100644 --- a/home/features/neovim/config/lazy-lock.json +++ b/home/features/neovim/config/lazy-lock.json @@ -3,36 +3,37 @@ "alpha-nvim": { "branch": "main", "commit": "29074eeb869a6cbac9ce1fbbd04f5f5940311b32" }, "catppuccin": { "branch": "main", "commit": "079500a625f3ae5aa6efb758f1a17fe4c7a57e52" }, "clipboard-image": { "branch": "main", "commit": "485de5493d196154db30f85665f8ac480ce116a2" }, + "cmp": { "branch": "main", "commit": "538e37ba87284942c1d76ed38dd497e54e65b891" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, + "cmp-digraphs": { "branch": "master", "commit": "5efc1f0078d7c5f3ea1c8e3aad04da3fd6e081a9" }, "cmp-emoji": { "branch": "main", "commit": "19075c36d5820253d32e2478b6aaf3734aeaafa0" }, "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, "conform": { "branch": "master", "commit": "48bc9996ebfe90e7766f46338360f75fd6ecb174" }, "crates": { "branch": "main", "commit": "b8ea20fda2e1029fbbb1bae7a9eab35c84037ca0" }, - "dhall-vim": { "branch": "master", "commit": "68500ef46ff3706f46c99db3be7a0c8abcf6a3ae" }, "discord-rich-presence": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" }, "edit-code-block": { "branch": "main", "commit": "5e4e31012eafa113216cb5894f696682833f8e7f" }, - "fidget.nvim": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, + "fidget": { "branch": "main", "commit": "0ba1e16d07627532b6cae915cc992ecac249fb97" }, "flash": { "branch": "main", "commit": "48817af25f51c0590653bbc290866e4890fe1cbe" }, "ftft": { "branch": "master", "commit": "09a72f9adf8ee7c824c517ef8408c9e687453039" }, - "github-actions-yaml.vim": { "branch": "master", "commit": "f2f16243447cea174daa6b4a9ffd3ff9213814ef" }, + "github-actions": { "branch": "master", "commit": "f2f16243447cea174daa6b4a9ffd3ff9213814ef" }, "gitlinker": { "branch": "master", "commit": "cc59f732f3d043b626c8702cb725c82e54d35c25" }, - "gitsigns.nvim": { "branch": "main", "commit": "87640f5a877b18bdd49884dbcac220fed924b867" }, + "gitsigns": { "branch": "main", "commit": "d195f0c35ced5174d3ecce1c4c8ebb3b5bc23fa9" }, "harpoon": { "branch": "master", "commit": "867e212ac153e793f95b316d1731f3ca1894625e" }, "haskell-tools": { "branch": "master", "commit": "92e097c6832405fb64e4c44a7ce8bebe7836cae6" }, "hydra.nvim": { "branch": "master", "commit": "3ced42c0b6a6c85583ff0f221635a7f4c1ab0dd0" }, - "hyprland-vim-syntax": { "branch": "main", "commit": "8488a24b50882da969979103b4d668c70e7995b9" }, + "hyprland": { "branch": "main", "commit": "be665459a21730a6acdfaa9c6352cda5e4763af6" }, "idris": { "branch": "main", "commit": "8bff02984a33264437e70fd9fff4359679d910da" }, "inc-rename.nvim": { "branch": "main", "commit": "a48c7cec5c4f00d7438dce5fadb55f4d715ef9f2" }, "indent-blankline": { "branch": "master", "commit": "7206c77cb931f79885fc47f88ae18f99148392eb" }, - "kmonad-vim": { "branch": "master", "commit": "37978445197ab00edeb5b731e9ca90c2b141723f" }, - "kotlin-vim": { "branch": "master", "commit": "53fe045906df8eeb07cb77b078fc93acda6c90b8" }, "lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" }, "lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" }, "lean": { "branch": "main", "commit": "a5daac8ebccb93af25ace2a2041b503f18ff3dcb" }, + "live-command": { "branch": "main", "commit": "d460067d47948725a6f25b20f31ea8bbfdfe4622" }, "lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, + "luasnip": { "branch": "master", "commit": "118263867197a111717b5f13d954cd1ab8124387" }, "mini.comment": { "branch": "main", "commit": "3d9c8009615857e982f09bc5357fc95f2a2175f3" }, "mini.files": { "branch": "main", "commit": "173d73f5d0b2a9abbb2d6533a3770fdbbd0c4dcc" }, "mini.operators": { "branch": "main", "commit": "7a97e2528a4c274e9da8953d3ba22f493c360a9f" }, @@ -44,32 +45,28 @@ "neogit": { "branch": "master", "commit": "761e9be2aa7cc4c8ca87f10c8c37108a687b928e" }, "nui": { "branch": "main", "commit": "c9b4de623d19a85b353ff70d2ae9c77143abe69c" }, "nui.nvim": { "branch": "main", "commit": "c9b4de623d19a85b353ff70d2ae9c77143abe69c" }, - "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, + "null-ls": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, "nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" }, - "nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" }, "nvim-lspconfig": { "branch": "master", "commit": "511609ae0311abfcfaed3c398429a147e895ce2c" }, "nvim-tree": { "branch": "master", "commit": "7d1760f892951dd6a118dae1d7a1d8df5f029edf" }, - "nvim-treesitter": { "branch": "master", "commit": "180e1ca385442e35e1d18420221a148c5e045671" }, - "nvim-treesitter-context": { "branch": "master", "commit": "cfa8ee19ac9bae9b7fb2958eabe2b45b70c56ccb" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "ec1c5bdb3d87ac971749fa6c7dbc2b14884f1f6a" }, "nvim-web-devicons": { "branch": "master", "commit": "5efb8bd06841f91f97c90e16de85e96d57e9c862" }, - "nvim_context_vt": { "branch": "master", "commit": "a14f9292b4bd68ceed433fc513f287641816dc6d" }, "paperlanes": { "branch": "master", "commit": "bd52c54c36ad2e9ac563ae1c6a4f6ed1f5faacd2" }, "plenary": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, "plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" }, - "purescript-vim": { "branch": "main", "commit": "82348352e6568fcc0385bd7c99a8ead3a479feea" }, - "rasi.vim": { "branch": "main", "commit": "eac9969cf935cd4380987dc99bfa10d69d3f34a6" }, "rust-tools": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, "rust-tools.nvim": { "branch": "master", "commit": "0cc8adab23117783a0292a0c8a2fbed1005dc645" }, - "scrap.nvim": { "branch": "main", "commit": "0f833d8dccaabe49c1ed7a2b24cfd887d9d5003f" }, + "scrap": { "branch": "main", "commit": "0f833d8dccaabe49c1ed7a2b24cfd887d9d5003f" }, "smart-splits.nvim": { "branch": "master", "commit": "c970c7a3cc7ba635fd73d43c81b40f04c00f5058" }, "ssr": { "branch": "main", "commit": "bb323ba621ac647b4ac5638b47666e3ef3c279e1" }, "telescope": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" }, - "typst.vim": { "branch": "main", "commit": "5b11b42de1703838ca1bb31dc66e73c002698e49" }, + "treesitter-top-context": { "branch": "master", "commit": "c9f2b429a1d63023f7a33b5404616f4cd2a109c5" }, + "treesitter-virtual-context": { "branch": "master", "commit": "a14f9292b4bd68ceed433fc513f287641816dc6d" }, + "typst": { "branch": "main", "commit": "308e7737d09de8c1100320ddc6bc270615ae791a" }, "undotree": { "branch": "master", "commit": "36ff7abb6b60980338344982ad4cdf03f7961ecd" }, - "vim-teal": { "branch": "master", "commit": "d2aa107b257879e774680792a2aebaf9cd5742e0" }, + "venn.nvim": { "branch": "main", "commit": "e4d68341a73dd56c64955058821a58295fb337b1" }, "wakatime": { "branch": "master", "commit": "8c8856327815a077cbebeba8c7456312a3d2c39c" }, "web-devicons": { "branch": "master", "commit": "5efb8bd06841f91f97c90e16de85e96d57e9c862" }, - "winbar": { "branch": "main", "commit": "13739fdb31be51a1000486189662596f07a59a31" }, - "yuck.vim": { "branch": "master", "commit": "9b5e0370f70cc30383e1dabd6c215475915fe5c3" } + "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, + "winbar": { "branch": "main", "commit": "13739fdb31be51a1000486189662596f07a59a31" } } \ No newline at end of file diff --git a/home/features/neovim/config/lua/my/abbreviations/unicode.lua b/home/features/neovim/config/lua/my/abbreviations/unicode.lua index 7d70556..91c4486 100644 --- a/home/features/neovim/config/lua/my/abbreviations/unicode.lua +++ b/home/features/neovim/config/lua/my/abbreviations/unicode.lua @@ -135,6 +135,8 @@ M.unicode = { { "iinf", "∞" }, { "star", "⋆" }, { "diamond", "⋄" }, + { "tto", "→" }, + { "ttoo", "⟶" }, -- }}} -- {{{ Brackets { "langle", "⟨" }, diff --git a/home/features/neovim/config/lua/my/helpers.lua b/home/features/neovim/config/lua/my/helpers.lua deleted file mode 100644 index e9158b5..0000000 --- a/home/features/neovim/config/lua/my/helpers.lua +++ /dev/null @@ -1,19 +0,0 @@ -local M = {} - -function M.mergeTables(t1, t2) - local t3 = {} - - if t1 ~= nil then for k, v in pairs(t1) do t3[k] = v end end - - if t2 ~= nil then for k, v in pairs(t2) do t3[k] = v end end - - return t3 -end - -function M.saveCursor(callback) - local cursor = vim.api.nvim_win_get_cursor(0) - callback() - vim.api.nvim_win_set_cursor(0, cursor) -end - -return M diff --git a/home/features/neovim/config/lua/my/helpers/env.lua b/home/features/neovim/config/lua/my/helpers/env.lua deleted file mode 100644 index 9f98732..0000000 --- a/home/features/neovim/config/lua/my/helpers/env.lua +++ /dev/null @@ -1,56 +0,0 @@ -local function makeEnv(cond) - return { - -- I am doing this to get type hints! - active = function() - return cond() - end, - not_active = function() - return not cond() - end, - unless = function(f) - if not cond() then - f() - end - end, - when = function(f) - if cond() then - f() - end - end, - } -end - -local M = { - vscode = makeEnv(function() - return vim.g.vscode ~= nil - end), - neovide = makeEnv(function() - return vim.g.neovide ~= nil or vim.g.nix_neovim_app == "neovide" - end), - firenvim = makeEnv(function() - return vim.g.started_by_firenvim ~= nil - or vim.g.nix_neovim_app == "firenvim" - end), - _and = function(a, b) - return makeEnv(function() - return a.active() and b.active() - end) - end, - _or = function(a, b) - return makeEnv(function() - return a.active() or b.active() - end) - end, -} - -M.blacklist = function(list) - for _, key in pairs(list) do - if M[key].active() then - return false - end - end - - return true -end - -return M diff --git a/home/features/neovim/config/lua/my/helpers/string.lua b/home/features/neovim/config/lua/my/helpers/string.lua deleted file mode 100644 index fbd9dd9..0000000 --- a/home/features/neovim/config/lua/my/helpers/string.lua +++ /dev/null @@ -1,13 +0,0 @@ -local M = {} - -function M.split(text, sep) - ---@diagnostic disable-next-line: redefined-local - local sep, fields = sep or ":", {} - local pattern = string.format("([^%s]+)", sep) - text:gsub(pattern, function(c) - fields[#fields + 1] = c - end) - return fields -end - -return M diff --git a/home/features/neovim/config/lua/my/plugins/themes/helpers.lua b/home/features/neovim/config/lua/my/helpers/theme.lua similarity index 51% rename from home/features/neovim/config/lua/my/plugins/themes/helpers.lua rename to home/features/neovim/config/lua/my/helpers/theme.lua index 01b65a5..39c595f 100644 --- a/home/features/neovim/config/lua/my/plugins/themes/helpers.lua +++ b/home/features/neovim/config/lua/my/helpers/theme.lua @@ -1,14 +1,15 @@ -local theme = require("nix.theme").name +local theme = vim.g.nix_theme local M = {} +M.theme = theme function M.theme_contains(name) - return string.find(theme, name) ~= nil + return string.find(theme.name, name) ~= nil end function M.variant(name) -- +1 for 1-indexed strings and +1 for the space between name and variant - return string.lower(string.sub(theme, string.len(name) + 2)) + return string.lower(string.sub(theme.name, string.len(name) + 2)) end return M diff --git a/home/features/neovim/config/lua/my/keymaps.lua b/home/features/neovim/config/lua/my/keymaps.lua index ef53462..fae8005 100644 --- a/home/features/neovim/config/lua/my/keymaps.lua +++ b/home/features/neovim/config/lua/my/keymaps.lua @@ -1,5 +1,4 @@ -local helpers = require("my.helpers") - +-- TODO: operator for wrapping motion with fold local M = {} -- {{{ Helpers @@ -18,9 +17,13 @@ end ---@param from string ---@param to string ---@param name string ----@param perhapsOpts table|nil -function M.delimitedTextobject(from, to, name, perhapsOpts) - local opts = helpers.mergeTables(perhapsOpts or {}, { desc = name }) +---@param opts table|nil +function M.delimitedTextobject(from, to, name, opts) + opts = opts or {} + + if opts.desc == nil then + opts.desc = name + end vim.keymap.set({ "v", "o" }, "i" .. from, "i" .. to, opts) vim.keymap.set({ "v", "o" }, "a" .. from, "a" .. to, opts) @@ -111,7 +114,7 @@ function M.setup() end, }) -- }}} - -- -- {{{ Winblend + -- {{{ Winblend vim.api.nvim_create_autocmd("FileType", { pattern = { "*" }, group = vim.api.nvim_create_augroup("WinblendSettings", {}), @@ -119,7 +122,25 @@ function M.setup() vim.opt.winblend = 0 end, }) - -- -- }}} + -- }}} + -- {{{ Manage cmdheight + vim.api.nvim_create_autocmd("CmdlineEnter", { + group = vim.api.nvim_create_augroup("SetCmdheightCmdlineEnter", {}), + callback = function() + if not vim.g.inside_venn then + vim.opt.cmdheight = 1 + end + end, + }) + vim.api.nvim_create_autocmd("CmdlineLeave", { + group = vim.api.nvim_create_augroup("SetCmdheightCmdlineLeave", {}), + callback = function() + if not vim.g.inside_venn then + vim.opt.cmdheight = 0 + end + end, + }) + -- }}} end return M diff --git a/home/features/neovim/config/lua/my/lazy.lua b/home/features/neovim/config/lua/my/lazy.lua index e5daf3b..d8bd7fd 100644 --- a/home/features/neovim/config/lua/my/lazy.lua +++ b/home/features/neovim/config/lua/my/lazy.lua @@ -5,45 +5,46 @@ local function importFrom(p) end function M.setup() - require("lazy").setup( - { importFrom("my.plugins"), importFrom("nix.plugins") }, - { - defaults = { lazy = true }, - install = { - -- install missing plugins on startup. This doesn't increase startup time. - missing = true, - -- try to load one of these colorschemes when starting an installation during startup - colorscheme = { "rose-pine", "catpuccin" }, - }, - change_detection = { - enabled = false, - notify = false, - }, - dev = { - -- Fallback to git when local plugin doesn't exist - fallback = true, + require("lazy").setup({ + importFrom("my.plugins"), + importFrom("nix.plugins"), + importFrom("my.plugins.themes"), + }, { + defaults = { lazy = true }, + install = { + -- install missing plugins on startup. this doesn't increase startup time. + missing = true, + -- try to load one of these colorschemes when starting an installation during startup + colorscheme = { "rose-pine", "catpuccin" }, + }, + change_detection = { + enabled = false, + notify = false, + }, + dev = { + -- Fallback to git when local plugin doesn't exist + fallback = true, - -- Directory where I store my local plugin projects - path = vim.g.nix_projects_path, - patterns = { "Mateiadrielrafael" }, - }, - performance = { - rtp = { - paths = { vim.g.nix_extra_runtime }, - disabled_plugins = { - "gzip", - "matchit", - "matchparen", - "netrwPlugin", - "tarPlugin", - "tohtml", - "tutor", - "zipPlugin", - }, + -- Directory where I store my local plugin projects + path = vim.g.nix_projects_path, + patterns = { "Mateiadrielrafael" }, + }, + performance = { + rtp = { + paths = { vim.g.nix_extra_runtime }, + disabled_plugins = { + "gzip", + "matchit", + "matchparen", + "netrwPlugin", + "tarPlugin", + "tohtml", + "tutor", + "zipPlugin", }, }, - } - ) + }, + }) end vim.keymap.set("n", "L", "Lazy", { desc = "[L]azy ui" }) diff --git a/home/features/neovim/config/lua/my/plugins/clue.lua b/home/features/neovim/config/lua/my/plugins/clue.lua deleted file mode 100644 index da40204..0000000 --- a/home/features/neovim/config/lua/my/plugins/clue.lua +++ /dev/null @@ -1,99 +0,0 @@ -local M = { - "echasnovski/mini.clue", - lazy = false, -} - -function M.config() - local miniclue = require("mini.clue") - miniclue.setup({ - triggers = { - -- Leader triggers - { mode = "n", keys = "" }, - { mode = "x", keys = "" }, - { mode = "v", keys = "" }, - }, - clues = { - -- Enhance this by adding descriptions for mapping groups - miniclue.gen_clues.builtin_completion(), - miniclue.gen_clues.g(), - miniclue.gen_clues.marks(), - miniclue.gen_clues.registers(), - miniclue.gen_clues.windows(), - miniclue.gen_clues.z(), - { - mode = "n", - keys = "f", - desc = "[F]iles", - }, - { - mode = "n", - keys = "g", - desc = "[G]o to", - }, - { - mode = "n", - keys = "r", - desc = "[R]ename / [R]eplace / [R]eload", - }, - { - mode = "n", - keys = "l", - desc = "[L]ocal", - }, - { - mode = "n", - keys = "w", - desc = "[W]orkspace", - }, - { - mode = "n", - keys = "y", - desc = "[Y]ank", - }, - { - mode = "n", - keys = "s", - desc = "[S]ettings", - }, - { - mode = "n", - keys = "v", - desc = "[V]imux", - }, - { - mode = "n", - keys = "h", - desc = "git [h]hunks", - }, - { - mode = "n", - keys = "VH", - postkeys = "V", - }, - { - mode = "n", - keys = "VJ", - postkeys = "V", - }, - { - mode = "n", - keys = "VK", - postkeys = "V", - }, - { - mode = "n", - keys = "VL", - postkeys = "V", - }, - { - mode = "n", - keys = "Vf", - postkeys = "V", - }, - }, - }) - - require("my.keymaps").nmap("Q", ":wqa", "Save all files and [q]uit") -end - -return {} diff --git a/home/features/neovim/config/lua/my/plugins/cmp.lua b/home/features/neovim/config/lua/my/plugins/cmp.lua deleted file mode 100644 index 8d60f4b..0000000 --- a/home/features/neovim/config/lua/my/plugins/cmp.lua +++ /dev/null @@ -1,122 +0,0 @@ -local env = require("my.helpers.env") - -local M = { - "hrsh7th/nvim-cmp", - event = "InsertEnter", - dependencies = { - "onsails/lspkind.nvim", -- show icons in lsp completion menus - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-emoji", - "hrsh7th/cmp-cmdline", - "hrsh7th/cmp-path", - "saadparwaiz1/cmp_luasnip", - "L3MON4D3/LuaSnip", -- snippeting engine - }, - cond = env.vscode.not_active(), -} - -local function has_words_before() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 - and vim.api - .nvim_buf_get_lines(0, line - 1, line, true)[1] - :sub(col, col) - :match("%s") - == nil -end - -function M.config() - vim.o.completeopt = "menuone,noselect" - - local cmp = require("cmp") - local lspkind = require("lspkind") - - local options = { - window = { - documentation = cmp.config.window.bordered(), - completion = cmp.config.window.bordered({ - winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None", - col_offset = -3, - side_padding = 0, - completeopt = "menu,menuone,noinsert", - }), - }, - formatting = { - fields = { "kind", "abbr", "menu" }, - format = function(entry, vim_item) - local kind = lspkind.cmp_format({ - mode = "symbol", - maxwidth = 50, - symbol_map = { - Text = ".", - }, - })(entry, vim_item) - local strings = vim.split(kind.kind, "%s", { trimempty = true }) - - -- Rust analyzer sometimes has this be nil when working with lifetime arguments. - if strings[1] ~= nil then - kind.kind = " " .. strings[1] .. " " - end - - kind.menu = "" - - return kind - end, - }, - snippet = { - -- REQUIRED - you must specify a snippet engine - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, - mapping = { - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, { "i", "s" }), - [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - }, - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffers" }, - { name = "emoji" }, - { name = "path" }, - -- { name = 'omni' }, - }), - } - - cmp.setup(options) - - -- Use buffer source for `/` - cmp.setup.cmdline("/", { - mapping = cmp.mapping.preset.cmdline(), - sources = { - { name = "buffer" }, - }, - }) - - -- Use cmdline & path source for ':' - cmp.setup.cmdline(":", { - mapping = cmp.mapping.preset.cmdline(), - sources = cmp.config.sources({ - { name = "path" }, - { name = "cmdline" }, - }), - }) -end - -return M diff --git a/home/features/neovim/config/lua/my/plugins/dashboard.lua b/home/features/neovim/config/lua/my/plugins/dashboard.lua index 8439929..624b6aa 100644 --- a/home/features/neovim/config/lua/my/plugins/dashboard.lua +++ b/home/features/neovim/config/lua/my/plugins/dashboard.lua @@ -1,4 +1,4 @@ -local env = require("my.helpers.env") +local runtime = require("my.tempest") local header_string = [[ ███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗ ██████╗ @@ -9,7 +9,7 @@ local header_string = [[ ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ]] -local header = require("my.helpers.string").split(header_string, "\n") +local header = runtime.helpers.split(header_string, "\n") local M = { "goolord/alpha-nvim", @@ -23,23 +23,24 @@ local M = { -- See [the header generator](https://patorjk.com/software/taag/#p=display&v=0&f=ANSI%20Shadow&t=NEOVim%20%3A3) theme.section.header.opts.hl = "AlphaHeader" theme.section.header.val = header + local version = vim.version() local footer = function() - local version = "🚀 " - .. vim.version().major + local versionString = "🚀 " + .. version.major .. "." - .. vim.version().minor + .. version.minor .. "." - .. vim.version().patch + .. version.patch local lazy_ok, lazy = pcall(require, "lazy") if lazy_ok then local total_plugins = lazy.stats().count .. " Plugins" local startuptime = ( math.floor(lazy.stats().startuptime * 100 + 0.5) / 100 ) - return version - .. " — 🧰 " + return versionString + .. " — 🧰 " .. total_plugins - .. " — 🕐 " + .. " — 🕐 " .. startuptime .. "ms" else @@ -63,7 +64,7 @@ local M = { require("alpha").setup(theme.config) end, lazy = false, - cond = env.vscode.not_active() and env.firenvim.not_active(), + cond = runtime.blacklist({ "vscode", "firenvim" }), } return M diff --git a/home/features/neovim/config/lua/my/plugins/firenvim.lua b/home/features/neovim/config/lua/my/plugins/firenvim.lua index 56dedb0..0d037b9 100644 --- a/home/features/neovim/config/lua/my/plugins/firenvim.lua +++ b/home/features/neovim/config/lua/my/plugins/firenvim.lua @@ -1,10 +1,10 @@ -local env = require("my.helpers.env") +local runtime = require("my.tempest") local K = require("my.keymaps") local M = { "glacambre/firenvim", -- vim inside chrome lazy = false, - cond = env.firenvim.active(), + cond = runtime.whitelist("firenvim"), } M.localSettings = {} @@ -53,9 +53,4 @@ function M.config() -- }}} end -function M.setup() - M.config() - print(vim.inspect(M.localSettings)) -end - return M diff --git a/home/features/neovim/config/lua/my/plugins/gitsigns.lua b/home/features/neovim/config/lua/my/plugins/gitsigns.lua deleted file mode 100644 index 76a7a8b..0000000 --- a/home/features/neovim/config/lua/my/plugins/gitsigns.lua +++ /dev/null @@ -1,97 +0,0 @@ -local env = require("my.helpers.env") - -local M = { - "lewis6991/gitsigns.nvim", - event = "BufReadPost", - cond = env.firenvim.not_active() and env.vscode.not_active(), - opts = { - on_attach = function(bufnr) - local gs = package.loaded.gitsigns - - -- {{{ Helpers - local function map(mode, from, to, desc, expr) - vim.keymap.set( - mode, - from, - to, - { expr = expr, silent = true, buffer = bufnr, desc = desc } - ) - end - - local function exprmap(from, to, desc) - map("n", from, to, desc, true) - end - -- }}} - -- {{{ Navigation - exprmap("]c", function() - if vim.wo.diff then - return "]c" - end - - vim.schedule(function() - gs.next_hunk() - end) - - return "" - end, "Navigate to next hunk") - - exprmap("[c", function() - if vim.wo.diff then - return "[c" - end - - vim.schedule(function() - gs.prev_hunk() - end) - - return "" - end, "Navigate to previous hunk") - -- }}} - -- {{{ Actions - local prefix = "h" - - -- require("which-key").register({ - -- [""] = { h = { name = "gitsigns" } }, - -- }) - - -- {{{ Normal mode - map("n", prefix .. "s", gs.stage_hunk, "[s]tage hunk") - map("n", prefix .. "r", gs.reset_hunk, "[r]eset hunk") - map("n", prefix .. "S", gs.stage_buffer, "[s]tage buffer") - map("n", prefix .. "u", gs.undo_stage_hunk, "[u]ndo hunk staging") - map("n", prefix .. "R", gs.reset_buffer, "[r]eset buffer") - map("n", prefix .. "p", gs.preview_hunk, "[p]review hunk") - map("n", prefix .. "b", function() - gs.blame_line({ full = true }) - end, "[b]lame line") - map("n", prefix .. "d", gs.diffthis, "[d]iff this") - map("n", prefix .. "D", function() - gs.diffthis("~") - end, "[d]iff file (?)") - -- }}} - -- {{{ Toggles - map( - "n", - prefix .. "tb", - gs.toggle_current_line_blame, - "[t]oggle line [b]laming" - ) - map("n", prefix .. "td", gs.toggle_deleted, "[t]oggle [d]eleted") - -- }}} - -- {{{ Visual - map("v", prefix .. "s", function() - gs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) - end, "stage visual hunk") - map("v", prefix .. "r", function() - gs.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) - end, "reset visual hunk") - -- }}} - -- }}} - -- {{{ Text objects - map({ "o", "x" }, "ih", ":Gitsigns select_hunk", "Inside hunk") - -- }}} - end, - }, -} - -return M diff --git a/home/features/neovim/config/lua/my/plugins/init.lua b/home/features/neovim/config/lua/my/plugins/init.lua index 35cdf19..c06ccad 100644 --- a/home/features/neovim/config/lua/my/plugins/init.lua +++ b/home/features/neovim/config/lua/my/plugins/init.lua @@ -1,72 +1,10 @@ -local env = require("my.helpers.env") +local runtime = require("my.tempest") -if env.neovide.active() then +if runtime.whitelist("neovide") then require("my.neovide").setup() end return { - --{{{ Language support - { - "purescript-contrib/purescript-vim", - ft = "purescript", - cond = env.vscode.not_active(), - }, - - { - "elkowar/yuck.vim", - ft = "yuck", - cond = env.vscode.not_active(), - }, - - { - "Fymyte/rasi.vim", - ft = "rasi", - cond = env.vscode.not_active(), - }, - - { - "teal-language/vim-teal", - ft = "teal", - cond = env.vscode.not_active(), - }, - - { - "udalov/kotlin-vim", - ft = "kotlin", - cond = env.vscode.not_active(), - }, - - { - "kmonad/kmonad-vim", - ft = "kbd", - cond = env.vscode.not_active(), - }, - - { - "vmchale/dhall-vim", - ft = "dhall", - cond = env.vscode.not_active(), - }, - - { - "yasuhiroki/github-actions-yaml.vim", - ft = { "yml", "yaml" }, - cond = env.vscode.not_active(), - }, - - { - "kaarmu/typst.vim", - ft = "typst", - cond = env.vscode.not_active(), - }, - - { - "theRealCarneiro/hyprland-vim-syntax", - ft = "hypr", - cond = env.vscode.not_active(), - }, - --}}} - { -- Better ui for inputs/selects "stevearc/dressing.nvim", @@ -84,7 +22,7 @@ return { return vim.ui.input(...) end end, - cond = env.vscode.not_active(), + cond = runtime.blacklist("vscode"), enabled = false, }, @@ -95,45 +33,4 @@ return { require("nvim-autopairs").setup() end, }, - - { - "mateiadrielrafael/scrap.nvim", - event = "InsertEnter", - config = function() - require("my.abbreviations").setup() - end, - }, -- vim-abolish rewrite - - { - -- easly switch between tmux and vim panes - "christoomey/vim-tmux-navigator", - keys = { "", "", "", "" }, - cond = env.vscode.not_active() - and env.neovide.not_active() - and env.firenvim.not_active() - and false, - }, - - { - -- show progress for lsp stuff - "j-hui/fidget.nvim", - tag = "legacy", - event = "BufReadPre", - cond = env.vscode.not_active(), - config = true, - }, - - -- Live command preview for stuff like :norm - { - "smjonas/live-command.nvim", - config = function() - require("live-command").setup({ - commands = { - Norm = { cmd = "norm" }, - }, - }) - end, - event = "VeryLazy", - cond = false, - }, } diff --git a/home/features/neovim/config/lua/my/plugins/lspconfig.lua b/home/features/neovim/config/lua/my/plugins/lspconfig.lua index 475dd7f..885b94e 100644 --- a/home/features/neovim/config/lua/my/plugins/lspconfig.lua +++ b/home/features/neovim/config/lua/my/plugins/lspconfig.lua @@ -1,5 +1,4 @@ -local helpers = require("my.helpers") -local env = require("my.helpers.env") +local runtime = require("my.tempest") local lspconfig = { "neovim/nvim-lspconfig", @@ -12,7 +11,7 @@ local lspconfig = { }, "simrat39/rust-tools.nvim", }, - cond = env.vscode.not_active(), + cond = runtime.blacklist("vscode"), } local M = { @@ -23,7 +22,7 @@ local M = { opts = { input_buffer_type = "dressing", }, - cond = env.vscode.not_active(), + cond = runtime.blacklist("vscode"), }, } @@ -53,9 +52,11 @@ function M.on_attach(client, bufnr) nmap("c", vim.lsp.buf.code_action, "[C]ode actions") nmap("li", "LspInfo", "[L]sp [i]nfo") + local expropts = opts("[R]e[n]ame") + expropts.expr = true vim.keymap.set("n", "rn", function() return ":IncRename " .. vim.fn.expand("") - end, helpers.mergeTables(opts("[R]e[n]ame"), { expr = true })) + end, expropts) vim.keymap.set( "v", diff --git a/home/features/neovim/config/lua/my/plugins/luasnip.lua b/home/features/neovim/config/lua/my/plugins/luasnip.lua deleted file mode 100644 index e589e80..0000000 --- a/home/features/neovim/config/lua/my/plugins/luasnip.lua +++ /dev/null @@ -1,35 +0,0 @@ -local env = require("my.helpers.env") - -local M = { - "L3MON4D3/LuaSnip", -- snippeting engine - version = "v2", - cond = env.vscode.not_active(), -} - -local function reload() - require("luasnip.loaders.from_vscode").lazy_load() -end - -function M.config() - local luasnip = require("luasnip") - - vim.keymap.set("i", "", function() - if luasnip.jumpable(1) then - return "lua require('luasnip').jump(1)" - else - return "" - end - end, { expr = true }) - - vim.keymap.set("i", "", function() - luasnip.jump(-1) - end) - - vim.keymap.set("n", "rs", reload, { - desc = "[R]eload [s]nippets", - }) - - reload() -end - -return M diff --git a/home/features/neovim/config/lua/my/plugins/null-ls.lua b/home/features/neovim/config/lua/my/plugins/null-ls.lua deleted file mode 100644 index c48e316..0000000 --- a/home/features/neovim/config/lua/my/plugins/null-ls.lua +++ /dev/null @@ -1,30 +0,0 @@ -local env = require("my.helpers.env") - -local M = { - "jose-elias-alvarez/null-ls.nvim", -- generic language server - event = "BufReadPre", - dependencies = "neovim/nvim-lspconfig", - cond = env.vscode.not_active(), - enable = false, -} - -function M.config() - local lspconfig = require("my.plugins.lspconfig") - local null_ls = require("null-ls") - - local sources = { - -- {{{ Python - -- Diagnostics - null_ls.builtins.diagnostics.ruff, -- Linting - -- null_ls.builtins.diagnostics.mypy, -- Type checking - -- }}} - } - - null_ls.setup({ - sources = sources, - on_attach = lspconfig.on_attach, - debug = true, - }) -end - -return M diff --git a/home/features/neovim/config/lua/my/plugins/themes/bluloco.lua b/home/features/neovim/config/lua/my/plugins/themes/bluloco.lua index ba898f0..b6b942d 100644 --- a/home/features/neovim/config/lua/my/plugins/themes/bluloco.lua +++ b/home/features/neovim/config/lua/my/plugins/themes/bluloco.lua @@ -1,5 +1,4 @@ -local H = require("my.plugins.themes.helpers") -local T = require("nix.theme") +local H = require("my.helpers.theme") local M = { "uloco/bluloco.nvim", @@ -12,7 +11,7 @@ function M.config() local bluloco = require("bluloco") bluloco.setup({ - transparent = T.opacity.terminal < 1.0, + transparent = H.theme.opacity.terminal < 1.0, style = H.variant("Bluloco"), }) diff --git a/home/features/neovim/config/lua/my/plugins/themes/catppuccin.lua b/home/features/neovim/config/lua/my/plugins/themes/catppuccin.lua index be74934..fcacbf3 100644 --- a/home/features/neovim/config/lua/my/plugins/themes/catppuccin.lua +++ b/home/features/neovim/config/lua/my/plugins/themes/catppuccin.lua @@ -1,5 +1,4 @@ -local H = require("my.plugins.themes.helpers") -local T = require("nix.theme") +local H = require("my.helpers.theme") local M = { "catppuccin/nvim", @@ -13,7 +12,7 @@ function M.config() vim.g.catppuccin_flavour = H.variant("Catppuccin") catppuccin.setup({ - transparent_background = T.transparent.terminal, + transparent_background = H.theme.transparent.terminal, integrations = { nvimtree = true, telescope = true, @@ -26,7 +25,7 @@ function M.config() vim.cmd("colorscheme catppuccin") - if T.transparent.terminal then + if H.theme.transparent.terminal then vim.cmd([[highlight FloatBorder blend=0 guibg=NONE]]) -- vim.cmd([[highlight MiniStatuslineInactive blend=0 guibg=NONE]]) vim.cmd([[highlight MiniStatuslineFilename blend=0 guibg=NONE]]) diff --git a/home/features/neovim/config/lua/my/plugins/themes/init.lua b/home/features/neovim/config/lua/my/plugins/themes/init.lua deleted file mode 100644 index 2afd73d..0000000 --- a/home/features/neovim/config/lua/my/plugins/themes/init.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - require("my.plugins.themes.catppuccin"), - require("my.plugins.themes.rosepine"), - require("my.plugins.themes.bluloco"), -} diff --git a/home/features/neovim/config/lua/my/plugins/themes/rosepine.lua b/home/features/neovim/config/lua/my/plugins/themes/rosepine.lua index a2b9d00..407ac1f 100644 --- a/home/features/neovim/config/lua/my/plugins/themes/rosepine.lua +++ b/home/features/neovim/config/lua/my/plugins/themes/rosepine.lua @@ -1,4 +1,4 @@ -local H = require("my.plugins.themes.helpers") +local H = require("my.helpers.theme") local M = { "rose-pine/neovim", diff --git a/home/features/neovim/config/lua/my/plugins/treesitter.lua b/home/features/neovim/config/lua/my/plugins/treesitter.lua deleted file mode 100644 index 8e8f9de..0000000 --- a/home/features/neovim/config/lua/my/plugins/treesitter.lua +++ /dev/null @@ -1,105 +0,0 @@ -local env = require("my.helpers.env") - -local M = { - { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - event = "BufReadPost", - dependencies = { - "nvim-treesitter/nvim-treesitter-textobjects", - }, - config = function() - require("nvim-treesitter.configs").setup({ - --{{{Languages - ensure_installed = { - "bash", - "c", - "cpp", - "css", - "dockerfile", - "elixir", - "fish", - "html", - "javascript", - "json", - "jsonc", - "latex", - "lua", - "markdown", - "markdown_inline", - "nix", - "python", - "rust", - "scss", - "toml", - "tsx", - "typescript", - "vim", - "yaml", - }, - sync_install = false, - --}}} - --{{{ Highlighting - highlight = { - enable = true, - disable = { "kotlin" }, - additional_vim_regex_highlighting = false, - }, - --}}} - textobjects = { - --{{{ Select - select = { - enable = true, - lookahead = true, - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - }, - }, - --}}} - --{{{ Move - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - ["]f"] = "@function.outer", - ["]t"] = "@class.outer", - }, - goto_next_end = { - ["]F"] = "@function.outer", - ["]T"] = "@class.outer", - }, - goto_previous_start = { - ["[f"] = "@function.outer", - ["[t"] = "@class.outer", - }, - goto_previous_end = { - ["[F"] = "@function.outer", - ["[T"] = "@class.outer", - }, - }, - --}}} - }, - indent = { enable = true }, - }) - end, - }, - { - -- show context on closing parenthesis - "haringsrob/nvim_context_vt", - event = "BufReadPost", - cond = env.vscode.not_active(), - }, - { - -- show context at top of file - "nvim-treesitter/nvim-treesitter-context", - event = "BufReadPost", - cond = env.vscode.not_active(), - opts = { enable = true }, - }, -} - -return M diff --git a/home/features/neovim/config/lua/my/plugins/venn.lua b/home/features/neovim/config/lua/my/plugins/venn.lua index 0bc37ad..0ca1a4a 100644 --- a/home/features/neovim/config/lua/my/plugins/venn.lua +++ b/home/features/neovim/config/lua/my/plugins/venn.lua @@ -28,46 +28,53 @@ local venn_hint = H.concat_many_h({ }, 3).value function M.config() - local r = "V" - vim.keymap.set("n", r .. "H", "h:VBox", { desc = "left" }) - vim.keymap.set("n", r .. "J", "j:VBox", { desc = "down" }) - vim.keymap.set("n", r .. "K", "k:VBox", { desc = "up" }) - vim.keymap.set("n", r .. "L", "l:VBox", { desc = "right" }) - vim.keymap.set("v", r .. "f", ":VBox", { desc = "box" }) + -- local r = "V" + -- vim.keymap.set("n", r .. "H", "h:VBox", { desc = "left" }) + -- vim.keymap.set("n", r .. "J", "j:VBox", { desc = "down" }) + -- vim.keymap.set("n", r .. "K", "k:VBox", { desc = "up" }) + -- vim.keymap.set("n", r .. "L", "l:VBox", { desc = "right" }) + -- vim.keymap.set("v", r .. "f", ":VBox", { desc = "box" }) - -- local Hydra = require("hydra") - -- - -- Hydra({ - -- name = "Draw Diagram", - -- hint = venn_hint, - -- config = { - -- color = "pink", - -- invoke_on_body = true, - -- hint = { - -- border = "single", - -- }, - -- on_enter = function() - -- vim.o.virtualedit = "all" - -- end, - -- }, - -- mode = "n", - -- desc = "[V]enn mode", - -- body = "V", - -- heads = { - -- { "H", "h:VBox" }, - -- { "J", "j:VBox" }, - -- { "K", "k:VBox" }, - -- { "L", "l:VBox" }, - -- { "f", ":VBox", { mode = "v" } }, - -- { "", nil, { exit = true } }, - -- }, - -- }) + local Hydra = require("hydra") + + Hydra({ + name = "Draw Diagram", + hint = venn_hint, + config = { + color = "pink", + invoke_on_body = true, + hint = { + border = "single", + }, + on_enter = function() + vim.opt.virtualedit = "all" + vim.g.inside_venn = true + vim.opt.cmdheight = 1 + end, + on_exit = function() + vim.opt.virtualedit = "" + vim.g.inside_venn = false + vim.opt.cmdheight = 0 + end, + desc = "[V]enn mode", + }, + mode = "n", + body = "V", + heads = { + { "H", "h:VBox", { silent = true, desc = "test description" } }, + { "J", "j:VBox", { silent = true, desc = "test description" } }, + { "K", "k:VBox", { silent = true, desc = "test description" } }, + { "L", "l:VBox", { silent = true, desc = "test description" } }, + { "f", "VBox", { mode = "v" } }, + { "", nil, { exit = true } }, + }, + }) end --- function M.init() --- require("which-key").register({ --- ["V"] = { name = "[V]enn mode" }, --- }) --- end +function M.init() + require("which-key").register({ + ["V"] = { name = "[V]enn mode" }, + }) +end -return {} +return M diff --git a/home/features/neovim/config/lua/my/plugins/whichkey.lua b/home/features/neovim/config/lua/my/plugins/whichkey.lua index a7dea3c..b77d064 100644 --- a/home/features/neovim/config/lua/my/plugins/whichkey.lua +++ b/home/features/neovim/config/lua/my/plugins/whichkey.lua @@ -1,6 +1,9 @@ +local runtime = require("my.tempest") + local M = { "folke/which-key.nvim", event = "VeryLazy", + cond = runtime.blacklist("vscode"), } function M.config() @@ -28,4 +31,4 @@ function M.config() }) end -return {} +return M diff --git a/home/features/neovim/config/lua/my/runtime.lua b/home/features/neovim/config/lua/my/tempest.lua similarity index 56% rename from home/features/neovim/config/lua/my/runtime.lua rename to home/features/neovim/config/lua/my/tempest.lua index 2761083..18c6e72 100644 --- a/home/features/neovim/config/lua/my/runtime.lua +++ b/home/features/neovim/config/lua/my/tempest.lua @@ -1,7 +1,18 @@ local M = {} +local H = {} +M.helpers = H -- {{{ General helpers -local function string_chars(str) +function H.with_default(default, given) + if given == nil then + return default + else + return given + end +end + +-- {{{ Strings +function H.string_chars(str) local chars = {} for i = 1, #str do table.insert(chars, str:sub(i, i)) @@ -9,14 +20,36 @@ local function string_chars(str) return chars end -local function with_default(default, given) - if given == nil then - return default - else - return given - end +function H.split(text, sep) + ---@diagnostic disable-next-line: redefined-local + local sep, fields = sep or ":", {} + local pattern = string.format("([^%s]+)", sep) + text:gsub(pattern, function(c) + fields[#fields + 1] = c + end) + return fields end -- }}} +-- {{{ Tables +function H.mergeTables(t1, t2) + local t3 = {} + + if t1 ~= nil then + for k, v in pairs(t1) do + t3[k] = v + end + end + + if t2 ~= nil then + for k, v in pairs(t2) do + t3[k] = v + end + end + + return t3 +end +-- }}} +-- }}} -- {{{ API wrappers -- {{{ Keymaps function M.set_keymap(opts, context) @@ -30,15 +63,23 @@ function M.set_keymap(opts, context) buffer = context.bufnr end + local action = opts.action + + if type(opts.action) == "function" then + action = function() + opts.action(context) + end + end + vim.keymap.set( - string_chars(with_default("n", opts.mode)), + H.string_chars(H.with_default("n", opts.mode)), opts.mapping, - opts.action, + action, { desc = opts.desc, - buffer = with_default(buffer, opts.buffer), + buffer = H.with_default(buffer, opts.buffer), expr = opts.expr, - silent = with_default(true, opts.silent), + silent = H.with_default(true, opts.silent), } ) end @@ -77,6 +118,10 @@ local function recursive_assign(source, destination) end function M.configure(opts, context) + if type(opts.mk_context) == "function" then + context = opts.mk_context(context) + end + if type(opts.vim) == "table" then recursive_assign(opts.vim, vim) end @@ -130,6 +175,53 @@ function M.configure(opts, context) opts.callback(context) end end + +M.lazy = function(lazy, opts, spec) + return M.configure(spec, { lazy = lazy, opts = opts }) +end +-- }}} +-- {{{ Neovim env handling +local envs = { + vscode = vim.g.vscode ~= nil, + neovide = vim.g.neovide ~= nil or vim.g.nix_neovim_app == "neovide", + firenvim = vim.g.started_by_firenvim ~= nil + or vim.g.nix_neovim_app == "firenvim", +} + +M.blacklist = function(list) + if type(list) == "string" then + list = { list } + end + + for _, key in pairs(list) do + if envs[key] then + return false + end + end + + return true +end + +M.whitelist = function(list) + if type(list) == "string" then + list = { list } + end + + for _, key in pairs(list) do + if not envs[key] then + return false + end + end + + return true +end +-- }}} +-- {{{ Other misc thingies +function M.withSavedCursor(callback) + local cursor = vim.api.nvim_win_get_cursor(0) + callback() + vim.api.nvim_win_set_cursor(0, cursor) +end -- }}} return M diff --git a/home/features/neovim/default.nix b/home/features/neovim/default.nix index 1885882..d510990 100644 --- a/home/features/neovim/default.nix +++ b/home/features/neovim/default.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, config, inputs, ... }: +{ upkgs, pkgs, lib, config, inputs, ... }: let # {{{ extraPackages extraPackages = with pkgs; [ @@ -11,7 +11,6 @@ let inputs.nixd.packages.${system}.nixd # nix texlab # latex nodePackages_latest.vscode-langservers-extracted # web stuff - typst-lsp # typst # haskell-language-server # haskell # Formatters @@ -19,7 +18,6 @@ let nodePackages_latest.purs-tidy # Purescript nodePackages_latest.prettier # Js & friends nodePackages_latest.prettier_d_slim # Js & friends - typst-fmt # Typst # Linters ruff # Python linter @@ -31,8 +29,6 @@ let # Others fd # file finder update-nix-fetchgit # Useful for nix stuff - tree-sitter # Syntax highlighting - libstdcxx5 # Required by treesitter aparently # Latex setup # texlive.combined.scheme-full # Latex stuff @@ -41,12 +37,6 @@ let # }}} # {{{ extraRuntime extraRuntimePaths = [ - # Base16 theme - (config.satellite.lib.lua.writeFile - "lua/nix" "theme" - config.satellite.colorscheme.lua - ) - # Experimental nix module generation config.satellite.neovim.generated.lazySingleFile ]; @@ -69,9 +59,11 @@ let # I cannot just install those dirs using the builtin package support because # my package manager (lazy.nvim) disables those. wrapClient = { base, name, binName ? name, extraArgs ? "" }: - let startupScript = pkgs.writeText "startup.lua" /* lua */'' + let startupScript = config.satellite.lib.lua.writeFile + "." "startup" /* lua */ '' vim.g.nix_extra_runtime = ${nlib.encode extraRuntime} vim.g.nix_projects_dir = ${nlib.encode config.xdg.userDirs.extraConfig.XDG_PROJECTS_DIR} + vim.g.nix_theme = ${config.satellite.colorscheme.lua} -- Provide hints as to what app we are running in -- (Useful because neovide does not provide the info itself right away) vim.g.nix_neovim_app = ${nlib.encode name} @@ -84,7 +76,7 @@ let postBuild = '' wrapProgram $out/bin/${binName} \ --prefix PATH : ${lib.makeBinPath extraPackages} \ - --add-flags ${lib.escapeShellArg ''--cmd "lua dofile('${startupScript}')"''} \ + --add-flags ${lib.escapeShellArg ''--cmd "lua dofile('${startupScript}/startup.lua')"''} \ ${extraArgs} ''; }; @@ -182,9 +174,8 @@ in # {{{ Plugins satellite.lua.styluaConfig = ../../../stylua.toml; satellite.neovim.runtime = { - env = "my.helpers.env"; languageServerOnAttach = "my.plugins.lspconfig"; - tempest = "my.runtime"; + tempest = "my.tempest"; }; # {{{ libraries @@ -201,6 +192,9 @@ in # {{{ web-devicons satellite.neovim.lazy.web-devicons.package = "nvim-tree/nvim-web-devicons"; # }}} + # {{{ Scrap + satellite.neovim.lazy.scrap.package = "mateiadrielrafael/scrap.nvim"; + # }}} # }}} # {{{ ui # {{{ nvim-tree @@ -323,6 +317,7 @@ in dependencies.lua = [ lazy.plenary.package ]; env.blacklist = [ "vscode" "firenvim" ]; + cmd = "Neogit"; # We sometimes spawn this directly from fish using a keybind keys = { mapping = ""; action = "Neogit"; @@ -342,7 +337,7 @@ in satellite.neovim.lazy.telescope = { package = "nvim-telescope/telescope.nvim"; version = "0.1.x"; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; # {{{ Dependencies dependencies = { @@ -372,14 +367,14 @@ in "Find ${tag} files"; in [ - (keymap "" "find_files" "Find files") - (keymap "d" "diagnostics" "Diagnostics") + (keymap "" "find_files" "File finder [p]alette") + (keymap "d" "diagnostics" "[D]iagnostics") (keymap "" "live_grep" "[F]ind in project") (keymap "t" "builtin" "[T]elescope pickers") # {{{ Files by extension (findFilesByExtension "tx" "tex" "[t]ex") (findFilesByExtension "ts" "ts" "[t]ypescript") - (findFilesByExtension "ty" "typst" "[t]ypst") + (findFilesByExtension "ty" "typ" "[t]ypst") (findFilesByExtension "l" "lua" "[l]ua") (findFilesByExtension "n" "nix" "[n]ua") (findFilesByExtension "p" "purs" "[p]urescript") @@ -423,18 +418,125 @@ in main = "ibl"; setup = true; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; event = "BufReadPost"; }; # }}} + # {{{ live-command + # Live command preview for commands like :norm + satellite.neovim.lazy.live-command = { + package = "smjonas/live-command.nvim"; + version = "remote"; # https://github.com/smjonas/live-command.nvim/pull/29 + main = "live-command"; + + event = "CmdlineEnter"; + opts.commands.Norm.cmd = "norm"; + opts.commands.G.cmd = "g"; + + keys = { + mode = "v"; + mapping = "N"; + action = ":Norm "; + desc = "Map lines in [n]ormal mode"; + }; + }; # }}} - # {{{ editing - # {{{ text navigation + # {{{ fidget + satellite.neovim.lazy.fidget = { + package = "j-hui/fidget.nvim"; + tag = "legacy"; + + env.blacklist = "vscode"; + event = "BufReadPre"; + setup = true; + }; + # }}} + # {{{ treesitter + satellite.neovim.lazy.treesitter = { + # REASON: more grammars + dir = upkgs.vimPlugins.nvim-treesitter.withAllGrammars; + dependencies.lua = [ "nvim-treesitter/nvim-treesitter-textobjects" ]; + dependencies.nix = [ pkgs.tree-sitter ]; + + env.blacklist = "vscode"; + event = "BufReadPost"; + + #{{{ Highlighting + opts.highlight = { + enable = true; + disable = [ "kotlin" ]; # This one seemed a bit broken + additional_vim_regex_highlighting = false; + }; + #}}} + # {{{ Textobjects + opts.textobjects = { + #{{{ Select + select = { + enable = true; + lookahead = true; + keymaps = { + # You can use the capture groups defined in textobjects.scm + af = "@function.outer"; + "if" = "@function.inner"; + ac = "@class.outer"; + ic = "@class.inner"; + }; + }; + #}}} + #{{{ Move + move = { + enable = true; + set_jumps = true; # whether to set jumps in the jumplist + goto_next_start = { + "]f" = "@function.outer"; + "]t" = "@class.outer"; + }; + goto_next_end = { + "]F" = "@function.outer"; + "]T" = "@class.outer"; + }; + goto_previous_start = { + "[f" = "@function.outer"; + "[t" = "@class.outer"; + }; + goto_previous_end = { + "[F" = "@function.outer"; + "[T" = "@class.outer"; + }; + }; + #}}} + }; + # }}} + opts.indent.enable = true; + }; + # }}} + # {{{ treesitter context + # Show context at the of closing delimiters + satellite.neovim.lazy.treesitter-virtual-context = { + package = "haringsrob/nvim_context_vt"; + dependencies.lua = [ lazy.treesitter.name ]; + + env.blacklist = "vscode"; + event = "BufReadPost"; + }; + + # show context at top of file + satellite.neovim.lazy.treesitter-top-context = { + package = "nvim-treesitter/nvim-treesitter-context"; + dependencies.lua = [ lazy.treesitter.name ]; + + env.blacklist = "vscode"; + event = "BufReadPost"; + opts.enable = true; + }; + # }}} + # }}} + # {{{ editing {{{ text navigation # {{{ flash satellite.neovim.lazy.flash = { package = "folke/flash.nvim"; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; keys = let keybind = mode: mapping: action: desc: { inherit mapping desc mode; @@ -457,7 +559,7 @@ in satellite.neovim.lazy.ftft = { package = "gukz/ftFT.nvim"; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; keys = [ "f" "F" "t" "T" ]; setup = true; }; @@ -467,7 +569,7 @@ in satellite.neovim.lazy.clipboard-image = { package = "postfen/clipboard-image.nvim"; - env.blacklist = [ "firenvim" ]; + env.blacklist = "firenvim"; cmd = "PasteImg"; keys = { @@ -491,7 +593,7 @@ in satellite.neovim.lazy.lastplace = { package = "ethanholz/nvim-lastplace"; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; event = "BufReadPre"; opts.lastplace_ignore_buftype = [ "quickfix" "nofile" "help" ]; @@ -501,7 +603,7 @@ in satellite.neovim.lazy.undotree = { package = "mbbill/undotree"; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; cmd = "UndotreeToggle"; keys = { mapping = "u"; @@ -514,7 +616,7 @@ in satellite.neovim.lazy.ssr = { package = "cshuaimin/ssr.nvim"; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; keys = { mode = "nx"; mapping = "rt"; @@ -528,10 +630,10 @@ in # {{{ edit-code-block (edit injections in separate buffers) satellite.neovim.lazy.edit-code-block = { package = "dawsers/edit-code-block.nvim"; - dependencies.lua = [ "nvim-treesitter/nvim-treesitter" ]; + dependencies.lua = [ lazy.treesitter.name ]; main = "ecb"; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; setup = true; keys = { mapping = "e"; @@ -616,13 +718,63 @@ in ]; }; # }}} + # {{{ luasnip + # snippeting engine + satellite.neovim.lazy.luasnip = + let reload = /* lua */ ''require("luasnip.loaders.from_vscode").lazy_load()''; + in + { + package = "L3MON4D3/LuaSnip"; + version = "v2"; + + env.blacklist = "vscode"; + setup.callback = nlib.thunk reload; + + # {{{ Keybinds + keys = [ + { + mapping = "rs"; + action = nlib.thunk reload; + desc = "[R]eload [s]nippets"; + } + { + mode = "i"; + expr = true; + mapping = ""; + action = nlib.thunk /* lua */ '' + local luasnip = require("luasnip") + + if not luasnip.jumpable(1) then + return "" + end + + vim.schedule(function() + luasnip.jump(1) + end) + + return "" + ''; + desc = "Jump to next snippet tabstop"; + } + { + mode = "i"; + mapping = ""; + action = nlib.thunk /* lua */ '' + require("luasnip").jump(-1) + ''; + desc = "Jump to previous snippet tabstop"; + } + ]; + # }}} + }; + # }}} # }}} # {{{ ide # {{{ conform satellite.neovim.lazy.conform = { package = "stevearc/conform.nvim"; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; event = "BufReadPost"; opts.format_on_save.lsp_fallback = true; @@ -654,15 +806,149 @@ in }; }; # }}} + # {{{ null-ls + satellite.neovim.lazy.null-ls = { + package = "jose-elias-alvarez/null-ls.nvim"; + dependencies.lua = [ "neovim/nvim-lspconfig" ]; + + env.blacklist = "vscode"; + event = "BufReadPre"; + + opts = nlib.thunk /* lua */ '' + local p = require("null-ls") + return { + on_attach = require("my.plugins.lspconfig").on_attach, + sources = { + p.builtins.diagnostics.ruff + } + } + ''; + }; + # }}} + # {{{ gitsigns + satellite.neovim.lazy.gitsigns = { + package = "lewis6991/gitsigns.nvim"; + + env.blacklist = [ "vscode" "firenvim" ]; + event = "BufReadPost"; + + opts.on_attach = nlib.tempest { + mkContext = /* lua */ ''function(bufnr) return { bufnr = bufnr } end''; + keys = + let + prefix = m: "h${m}"; + gs = "package.loaded.gitsigns"; + + # {{{ nmap helper + nmap = mapping: action: desc: { + inherit desc; + mapping = prefix "mapping"; + action = "${gs}.action"; + }; + # }}} + # {{{ exprmap helper + exprmap = mapping: action: desc: { + inherit mapping desc; + action = nlib.thunk /* lua */ '' + if vim.wo.diff then + return "${mapping}" + end + + vim.schedule(function() + ${gs}.${action}() + end) + + return "" + ''; + expr = true; + }; + # }}} + in + [ + # {{{ navigation + (exprmap "]c" "next_hunk" "Navigate to next hunk") + (exprmap "[c" "prev_hunk" "Navigate to previous hunk") + # }}} + # {{{ actions + (nmap "s" "stage_hunk" "[s]tage hunk") + (nmap "r" "reset_hunk" "[s]tage hunk") + (nmap "S" "stage_buffer" "[s]tage hunk") + (nmap "u" "undo_stage_hunk" "[s]tage hunk") + (nmap "R" "reset_buffer" "[s]tage hunk") + (nmap "p" "preview_hunk" "[s]tage hunk") + (nmap "d" "diffthis" "[s]tage hunk") + { + mapping = prefix "D"; + action = nlib.thunk '' + ${gs}.diffthis("~") + ''; + desc = "[d]iff file (?)"; + } + { + mapping = prefix "b"; + action = nlib.thunk '' + ${gs}.blame_line({ full = true }) + ''; + desc = "[b]lame line"; + } + # }}} + # {{{ Toggles + (nmap "tb" "toggle_current_line_blame" "[t]oggle line [b]laming") + (nmap "td" "toggle_deleted" "[t]oggle [d]eleted") + # }}} + # {{{ visual mappings + { + mode = "v"; + mapping = prefix "s"; + action = nlib.thunk /* lua */ '' + ${gs}.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + ''; + desc = "stage visual hunk"; + } + { + mode = "v"; + mapping = prefix "r"; + action = nlib.thunk /* lua */ '' + ${gs}.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) + ''; + desc = "reset visual hunk"; + } + # }}} + ]; + }; + }; + # }}} + # {{{ cmp + satellite.neovim.lazy.cmp = { + package = "hrsh7th/nvim-cmp"; + dependencies.lua = [ + # {{{ Completion sources + "hrsh7th/cmp-nvim-lsp" + "hrsh7th/cmp-buffer" + "hrsh7th/cmp-emoji" + "hrsh7th/cmp-cmdline" + "hrsh7th/cmp-path" + "saadparwaiz1/cmp_luasnip" + "dmitmel/cmp-digraphs" + # }}} + "onsails/lspkind.nvim" # show icons in lsp completion menus + lazy.luasnip.package + ]; + + env.blacklist = "vscode"; + event = [ "InsertEnter" "CmdlineEnter" ]; + setup = (nlib.import ./plugins/cmp.lua "config").value; + }; + # }}} # }}} # {{{ language support - # {{{ haskell + # {{{ haskell support satellite.neovim.lazy.haskell-tools = { package = "mrcjkb/haskell-tools.nvim"; dependencies.lua = [ lazy.plenary.package ]; version = "^2"; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; ft = [ "haskell" "lhaskell" "cabal" "cabalproject" ]; setup.vim.g.haskell_tools = { @@ -682,13 +968,13 @@ in }; }; # }}} - # {{{ rust + # {{{ rust support # {{{ rust-tools satellite.neovim.lazy.rust-tools = { package = "simrat39/rust-tools.nvim"; dependencies.nix = [ pkgs.rust-analyzer pkgs.rustfmt ]; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; ft = "rust"; opts.server.on_attach = nlib.languageServerOnAttach { @@ -705,7 +991,7 @@ in package = "saecki/crates.nvim"; dependencies.lua = [ lazy.plenary.package ]; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; event = "BufReadPost Cargo.toml"; # {{{ Set up null_ls source @@ -732,7 +1018,7 @@ in group = "CargoKeybinds"; pattern = "Cargo.toml"; # # {{{ Register which-key info - # callback.callback = nlib.contextThunk /* lua */ '' + # action.callback = nlib.contextThunk /* lua */ '' # require("which-key").register({ # ["lc"] = { # name = "[l]ocal [c]rates", @@ -775,17 +1061,16 @@ in }; # }}} # }}} - # {{{ lean + # {{{ lean support satellite.neovim.lazy.lean = { package = "Julian/lean.nvim"; name = "lean"; dependencies.lua = [ lazy.plenary.package "neovim/nvim-lspconfig" - "hrsh7th/nvim-cmp" ]; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; ft = "lean"; opts = { @@ -804,7 +1089,7 @@ in }; }; # }}} - # {{{ idris + # {{{ idris support satellite.neovim.lazy.idris = { package = "ShinKage/idris2-nvim"; name = "idris"; @@ -813,7 +1098,7 @@ in "neovim/nvim-lspconfig" ]; - env.blacklist = [ "vscode" ]; + env.blacklist = "vscode"; ft = [ "idris2" "lidris2" "ipkg" ]; opts = { @@ -841,6 +1126,38 @@ in }; }; # }}} + # {{{ github actions + satellite.neovim.lazy.github-actions = { + package = "yasuhiroki/github-actions-yaml.vim"; + + env.blacklist = "vscode"; + ft = [ "yml" "yaml" ]; + }; + # }}} + # {{{ typst support + satellite.neovim.lazy.typst = { + package = "kaarmu/typst.vim"; + dependencies.nix = [ pkgs.typst-lsp pkgs.typst-fmt ]; + + env.blacklist = "vscode"; + ft = "typst"; + }; + # }}} + # {{{ hyprland + satellite.neovim.lazy.hyprland = { + package = "theRealCarneiro/hyprland-vim-syntax"; + + env.blacklist = "vscode"; + ft = "hypr"; + + setup.autocmds = { + event = "BufRead"; + group = "DetectHyprlandConfig"; + pattern = "hyprland.conf"; + action.vim.opt.ft = "hypr"; + }; + }; + # }}} # }}} # {{{ external # These plugins integrate neovim with external services diff --git a/home/features/neovim/plugins/cmp.lua b/home/features/neovim/plugins/cmp.lua new file mode 100644 index 0000000..ae66de7 --- /dev/null +++ b/home/features/neovim/plugins/cmp.lua @@ -0,0 +1,88 @@ +local M = {} + +function M.config() + local cmp = require("cmp") + local opts = { + -- {{{ window + window = { + documentation = cmp.config.window.bordered(), + completion = cmp.config.window.bordered({ + winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,Search:None", + col_offset = -3, + side_padding = 0, + completeopt = "menu,menuone,noinsert", + }), + }, + -- }}} + -- {{{ formatting + formatting = { + fields = { "kind", "abbr", "menu" }, + format = require("lspkind").cmp_format({ + mode = "symbol", + maxwidth = 50, + symbol_map = { + Text = " ", + }, + }), + }, + -- }}} + -- {{{ snippet + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + -- }}} + -- {{{ mappings + mapping = { + [""] = cmp.mapping(function() + if cmp.visible() then + cmp.select_next_item() + else + cmp.complete() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { "i", "s" }), + -- `select` makes it so this also works if no completions have been selected + [""] = cmp.mapping.confirm({ select = true }), + }, + -- }}} + -- {{{ sources + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffers" }, + { name = "emoji" }, + { name = "path" }, + { name = "digraphs" }, + }), + -- }}} + } + + local searchOpts = { + mapping = cmp.mapping.preset.cmdline(), + sources = { + { name = "buffer" }, + }, + } + + local cmdlineOpts = { + mapping = cmp.mapping.preset.cmdline(), + sources = cmp.config.sources({ + { name = "path" }, + { name = "cmdline" }, + }), + } + + cmp.setup(opts) + cmp.setup.cmdline("/", searchOpts) + cmp.setup.cmdline(":", cmdlineOpts) +end + +return M diff --git a/modules/common/lua-colorscheme.nix b/modules/common/lua-colorscheme.nix index 37bc9f1..810fa76 100644 --- a/modules/common/lua-colorscheme.nix +++ b/modules/common/lua-colorscheme.nix @@ -52,5 +52,5 @@ }; }; in - "return ${config.satellite.lib.lua.encoders.anything theme}"; + config.satellite.lib.lua.encoders.anything theme; } diff --git a/modules/common/lua-encoders.nix b/modules/common/lua-encoders.nix index 818fdb4..d621bb3 100644 --- a/modules/common/lua-encoders.nix +++ b/modules/common/lua-encoders.nix @@ -67,7 +67,7 @@ let # This is the most rudimentary (and currently only) way of handling paths. luaImportOr = tag: luaEncoders.conditional lib.isPath - (path: "dofile(${luaEncoders.string path}).${tag}"); + (path: "dofile(${luaEncoders.string "${path}"}).${tag}"); # Accepts both tagged and untagged strings of lua code. luaString = luaEncoders.luaCodeOr luaEncoders.identity; # This simply combines the above combinators into one. @@ -82,6 +82,7 @@ let if l == "nil" then r else if r == "nil" then l else "${l} and ${r}"; + all = lib.foldr luaEncoders.conjunction luaEncoders.nil; # }}} # {{{ Lists listOf = encoder: list: @@ -113,9 +114,12 @@ let # }}} # {{{ Attrsets attrName = s: - let forbiddenChars = lib.stringToCharacters "<>'\".,;"; # This list *is* incomplete + let + # These list *are* incomplete + forbiddenChars = lib.stringToCharacters "<>[]{}()'\".,;"; + keywords = [ "if" "then" "else" "do" "for" "local" "" ]; in - if lib.any (c: lib.hasInfix c s) forbiddenChars then + if lib.any (c: lib.hasInfix c s) forbiddenChars || lib.elem s keywords then "[${luaEncoders.string s}]" else s; diff --git a/modules/common/neovim.nix b/modules/common/neovim.nix index e7a862a..2ca4de8 100644 --- a/modules/common/neovim.nix +++ b/modules/common/neovim.nix @@ -12,10 +12,12 @@ let oneOrMany = t: types.either t (types.listOf t); zeroOrMore = t: types.nullOr (myTypes.oneOrMany t); + neovimEnv = types.enum [ "firenvim" "vscode" "neovide" ]; + # {{{ Lua code luaCode = types.nullOr (types.oneOf [ - types.str types.path + types.str myTypes.luaLiteral ]); @@ -41,36 +43,46 @@ let types.str (types.submodule { - options.mapping = lib.mkOption { - type = types.str; - description = "The lhs of the neovim mapping"; - }; + options = { + mapping = lib.mkOption { + type = types.str; + description = "The lhs of the neovim mapping"; + }; - options.action = lib.mkOption { - default = null; - type = types.nullOr (types.oneOf [ - types.str - myTypes.luaLiteral - ]); - description = "The rhs of the neovim mapping"; - }; + action = lib.mkOption { + default = null; + type = types.nullOr (types.oneOf [ + types.str + myTypes.luaLiteral + ]); + description = "The rhs of the neovim mapping"; + }; - options.ft = lib.mkOption { - default = null; - type = myTypes.zeroOrMore types.str; - description = "Filetypes on which this keybind should take effect"; - }; + ft = lib.mkOption { + default = null; + type = myTypes.zeroOrMore types.str; + description = "Filetypes on which this keybind should take effect"; + }; - options.mode = lib.mkOption { - default = null; - type = types.nullOr types.str; - description = "The vim modes the mapping should take effect in"; - }; + mode = lib.mkOption { + default = null; + type = types.nullOr types.str; + description = "The vim modes the mapping should take effect in"; + }; - options.desc = lib.mkOption { - default = null; - type = types.nullOr types.str; - description = "Description for the current keymapping"; + desc = lib.mkOption { + default = null; + type = types.nullOr types.str; + description = "Description for the current keymapping"; + }; + + + expr = lib.mkOption { + default = null; + example = true; + type = types.nullOr types.bool; + description = "If set to `true`, the mapping is treated as an action factory"; + }; }; }) ]; @@ -282,11 +294,17 @@ let }; env.blacklist = lib.mkOption { - default = [ ]; - type = types.listOf (types.enum [ "firenvim" "vscode" "neovide" ]); + default = null; + type = myTypes.zeroOrMore myTypes.neovimEnv; description = "Environments to blacklist plugin on"; }; + env.whitelist = lib.mkOption { + default = null; + type = myTypes.zeroOrMore myTypes.neovimEnv; + description = "Environments to whitelist plugin on"; + }; + setup = lib.mkOption { default = null; type = types.nullOr (types.oneOf [ @@ -403,7 +421,7 @@ in }; import = lib.mkOption { - default = path: tag: cfg.lib.lua "dofile(${e.string path}).${tag}"; + default = path: tag: cfg.lib.lua (e.luaCode tag path); type = types.functionTo (types.functionTo myTypes.luaLiteral); description = "import some identifier from some module"; }; @@ -439,6 +457,7 @@ in cfg.lib.encodeTempestConfiguration e.luaString; }); + mk_context = e.const (e.nullOr e.luaString (given.mkContext or null)); } given; type = types.functionTo types.str; @@ -463,7 +482,6 @@ in description = "Wrap a lua expression into a lua function"; }; - contextThunk = lib.mkOption { default = given: cfg.lib.lua /* lua */ '' function(context) ${e.luaString given} end @@ -471,6 +489,31 @@ in type = types.functionTo myTypes.luaLiteral; description = "Wrap a lua expression into a lua function taking an argument named `context`"; }; + + lazy = lib.mkOption { + default = given: cfg.lib.thunk "return ${e.luaCodeOr e.anything given}"; + type = types.functionTo myTypes.luaLiteral; + description = "Wrap a lua expression into a function returning said expression"; + }; + + withContext = lib.mkOption { + default = given: cfg.lib.contextThunk "return ${e.luaCodeOr e.anything given}"; + type = types.functionTo myTypes.luaLiteral; + description = "Wrap a lua expression into a lua function taking an argument named `context` and returning said expression"; + }; + + tempest = lib.mkOption { + default = given: cfg.lib.lua /* lua */ '' + function(context) + require(${e.string cfg.runtime.tempest}).configure( + ${cfg.lib.encodeTempestConfiguration given}, + context + ) + end + ''; + type = types.functionTo myTypes.luaLiteral; + description = "Wrap a lua expression into a lua function taking an argument named `context`"; + }; # }}} # {{{ Language server on attach languageServerOnAttach = lib.mkOption { @@ -490,12 +533,6 @@ in # }}} # {{{ Neovim runtime module paths runtime = { - env = lib.mkOption { - type = types.str; - example = "my.helpers.env"; - description = "Module to import env flags from"; - }; - tempest = lib.mkOption { type = types.str; example = "my.runtime.tempest"; @@ -525,6 +562,7 @@ in lib.strings.stringToCharacters (e.listAsOneOrMany e.string)); desc = e.nullOr e.string; + expr = e.nullOr e.bool; ft = e.zeroOrMany e.string; }); # }}} @@ -546,19 +584,23 @@ in main = e.nullOr e.string; dependencies = e.map (d: d.lua) (e.tryNonemptyList (e.stringOr lazyObjectEncoder)); lazy = e.nullOr e.bool; - cond = e.conjunction + cond = e.all [ (e.nullOr (e.luaCode "cond")) - (e.filter (_: opts.env.blacklist != [ ]) + (e.filter (_: opts.env.blacklist != [ ] && opts.env.blacklist != null) (e.const /* lua */ '' - require(${e.string cfg.runtime.env}).blacklist(${e.listOf e.string opts.env.blacklist}) - '')); + require(${e.string cfg.runtime.tempest}).blacklist(${e.oneOrMany e.string opts.env.blacklist}) + '')) + (e.filter (_: opts.env.whitelist != [ ] && opts.env.whitelist != null) + (e.const /* lua */ '' + require(${e.string cfg.runtime.tempest}).whitelist(${e.oneOrMany e.string opts.env.blacklist}) + '')) + ]; config = _: let wrap = given: /* lua */'' function(lazy, opts) - require(${e.string cfg.runtime.tempest}).configure(${given}, - { lazy = lazy; opts = opts; }) + require(${e.string cfg.runtime.tempest}).lazy(lazy, opts, ${given}) end ''; in