diff --git a/flake.lock b/flake.lock index 9a66708..68ff334 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "advanced-git-search-nvim": { + "flake": false, + "locked": { + "lastModified": 1677794481, + "narHash": "sha256-7G0WNcaIH1/4Zs4282UdWfRExdlAz6AHzqBlSu/qioQ=", + "owner": "aaronhallaert", + "repo": "advanced-git-search.nvim", + "rev": "e36797ade1af3d0404e14db83fd09db4e619e8dc", + "type": "github" + }, + "original": { + "owner": "aaronhallaert", + "repo": "advanced-git-search.nvim", + "type": "github" + } + }, "agenix": { "inputs": { "darwin": "darwin", @@ -840,6 +856,7 @@ }, "root": { "inputs": { + "advanced-git-search-nvim": "advanced-git-search-nvim", "agenix": "agenix", "arkenfox-userjs": "arkenfox-userjs", "asus-touchpad-numpad-driver": "asus-touchpad-numpad-driver", diff --git a/flake.nix b/flake.nix index 6d7c237..4aceb5d 100644 --- a/flake.nix +++ b/flake.nix @@ -87,6 +87,11 @@ flake = false; }; + advanced-git-search-nvim = { + url = "github:aaronhallaert/advanced-git-search.nvim"; + flake = false; + }; + attic = { url = "github:zhaofengli/attic"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/lib/default.nix b/lib/default.nix index 988c2a5..da1b552 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -13,4 +13,34 @@ lib.makeExtensible (self: rec { rev = input.shortRev or "dirty"; in "unstable-${date}_${rev}"; + + mapModules = f: dir: + let + filter = name: type: + let + isPublic = !(lib.hasPrefix "_" name); + isSomething = type != null; + isModule = + let + path = "${toString dir}/${name}"; + isDefault = type == "directory" && builtins.pathExists "${path}/default.nix"; + isFile = type == "regular" && lib.hasSuffix ".nix" name && name != "default.nix"; + in + isDefault || isFile; + in + isPublic && isSomething && isModule; + + mkModule = name: _: + let + path = "${toString dir}/${name}"; + normalizedName = + if name == "default.nix" + then name + else lib.removeSuffix ".nix" name; + in + lib.nameValuePair normalizedName (f path); + in + lib.mapAttrs' mkModule (lib.filterAttrs filter (builtins.readDir dir)); + + mapModules' = f: dir: lib.attrValues (mapModules f dir); }) diff --git a/modules/programs/hyprland/config.nix b/modules/programs/hyprland/config.nix index 1657d1b..3b75257 100644 --- a/modules/programs/hyprland/config.nix +++ b/modules/programs/hyprland/config.nix @@ -85,12 +85,12 @@ in bezier = circ, 0.785, 0.135, 0.15, 0.86 bezier = back, 0.68, -0.55, 0.265, 1.55 - - animation = windows, 1, 3, circ - animation = windowsOut, 1, 2, quint + animation = windows, 1, 4, default, slide + animation = windowsIn, 1, 4, circ, slide + animation = windowsOut, 1, 4, circ, slide animation = border, 1, 2, sine - animation = fade, 1, 2, sine - animation = workspaces, 1, 5, circ + animation = fade, 1, 4, sine + animation = workspaces, 1, 5, circ, fade } dwindle { diff --git a/modules/programs/nvim/default.nix b/modules/programs/nvim/default.nix index f971062..3a32217 100644 --- a/modules/programs/nvim/default.nix +++ b/modules/programs/nvim/default.nix @@ -1,7 +1,6 @@ { config , lib , pkgs -, inputs , ... }: @@ -9,12 +8,18 @@ with lib; let cfg = config.my.programs.nvim; - mkPlugin = name: { - plugin = pkgs.vimPlugins.${name}; - type = "lua"; - config = lib.readFile (./plugins + "/${name}.lua"); - }; - + mkPlugin = fileName: + let + path = ./plugins + "/${fileName}"; + pluginName = lib.removeSuffix ".lua" fileName; + in + { + plugin = pkgs.vimPlugins.${pluginName}; + type = "lua"; + config = lib.readFile path; + }; + pluginFileNames = builtins.attrNames (builtins.readDir ./plugins); + pluginsWithConfig = builtins.map mkPlugin pluginFileNames; in { options.my.programs.nvim.enable = mkEnableOption "nvim"; @@ -53,29 +58,7 @@ in taplo yamlfmt ]; - plugins = builtins.map mkPlugin [ - "catppuccin-nvim" - "comment-nvim" - "copilot-lua" - "dashboard-nvim" - "formatter-nvim" - "gitsigns-nvim" - "lualine-nvim" - "noice-nvim" - "nvim-autopairs" - "nvim-lastplace" - "nvim-surround" - "nvim-tree-lua" - "nvim-treesitter-textsubjects" - "nvim-ts-context-commentstring" - "orgmode" - "smartcolumn-nvim" - "telescope-fzf-native-nvim" - "telescope-nvim" - "telescope-zoxide" - "which-key-nvim" - "todo-comments-nvim" - ] ++ (with pkgs.vimPlugins; [ + plugins = with pkgs.vimPlugins; [ cmp-nvim-lsp cmp_luasnip copilot-cmp @@ -86,17 +69,18 @@ in lspsaga-nvim-original lualine-lsp-progress luasnip - nui-nvim # for noice-nvim + nui-nvim nvim-cmp nvim-lspconfig nvim-treesitter.withAllGrammars nvim-ufo - nvim-web-devicons # for dashboard-nvim - plenary-nvim # for telescope, neogit + nvim-web-devicons + plenary-nvim popup-nvim promise-async + vim-fugitive vim-lion - ]); + ] ++ pluginsWithConfig; }; }; }; diff --git a/modules/programs/nvim/plugins/advanced-git-search-nvim.lua b/modules/programs/nvim/plugins/advanced-git-search-nvim.lua new file mode 100644 index 0000000..9959064 --- /dev/null +++ b/modules/programs/nvim/plugins/advanced-git-search-nvim.lua @@ -0,0 +1,18 @@ +require("telescope").load_extension("advanced_git_search") +local advanced_git_search = require("telescope").extensions.advanced_git_search +vim.api.nvim_create_user_command( + "DiffCommitLine", + "lua require('telescope').extensions.advanced_git_search.diff_commit_line()", + { range = true } +) +require("which-key").register({ + g = { + name = "git", + b = { advanced_git_search.diff_branch_file, "diff branch file" }, + l = { vim.cmd.DiffCommitLine, "diff commit line", mode = "v" }, + f = { advanced_git_search.diff_commit_file, "diff commit file" }, + c = { advanced_git_search.search_log_content, "search log content" }, + C = { advanced_git_search.search_log_content_file, "search log content current file" }, + r = { advanced_git_search.checkout_reflog, "checkout reflog" }, + }, +}, { prefix = "" }) diff --git a/overlays/default.nix b/overlays/default.nix index b8da5c5..e3d2d4d 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,9 +1,4 @@ { inputs, lib }: -lib.composeManyExtensions [ - (import ./channels.nix { inherit inputs lib; }) - (import ./packages.nix { inherit inputs lib; }) - (import ./vimPlugins.nix { inherit inputs lib; }) - (import ./wayland.nix { inherit inputs lib; }) - (import ./lib.nix { inherit inputs lib; }) -] +lib.composeManyExtensions + (lib.my.mapModules' (file: import file { inherit inputs lib; }) ./.) diff --git a/overlays/vimPlugins.nix b/overlays/vimPlugins.nix index 6efbecd..b9b6a4c 100644 --- a/overlays/vimPlugins.nix +++ b/overlays/vimPlugins.nix @@ -25,5 +25,11 @@ with lib.my; version = mkVersionInput inputs.lspsaga-nvim; src = inputs.lspsaga-nvim; }); + + advanced-git-search-nvim = prev.vimUtils.buildVimPluginFrom2Nix { + pname = "advanced-git-search-nvim"; + version = mkVersionInput inputs.advanced-git-search-nvim; + src = inputs.advanced-git-search-nvim; + }; }; }