diff --git a/plugins/default.nix b/plugins/default.nix index 8c3f905a..4ae9ace7 100644 --- a/plugins/default.nix +++ b/plugins/default.nix @@ -13,6 +13,7 @@ ./git/fugitive.nix ./git/gitgutter.nix + ./git/neogit.nix ./languages/ledger.nix ./languages/nix.nix @@ -45,5 +46,7 @@ ./utils/startify.nix ./utils/surround.nix ./utils/undotree.nix + ./utils/dashboard.nix + ./utils/emmet.nix ]; } diff --git a/plugins/git/neogit.nix b/plugins/git/neogit.nix new file mode 100644 index 00000000..99d3de05 --- /dev/null +++ b/plugins/git/neogit.nix @@ -0,0 +1,228 @@ +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.programs.nixvim.plugins.neogit; + helpers = import ../helpers.nix { inherit lib; }; + + sectionDefaultsModule = types.submodule { + options = { + folded = mkOption { + type = types.nullOr types.bool; + default = null; + }; + }; + }; +in +{ + options = { + programs.nixvim.plugins.neogit = { + enable = mkEnableOption "Enable neogit"; + + disableSigns = mkOption { + description = "Disable signs"; + type = types.nullOr types.bool; + default = null; + }; + + disableHint = mkOption { + description = "Disable hint"; + type = types.nullOr types.bool; + default = null; + }; + + disableContextHighlighting = mkOption { + description = "Disable the context highlighting"; + type = types.nullOr types.bool; + default = null; + }; + + disableCommitConfirmation = mkOption { + description = "Disable the commit confirmation prompt"; + type = types.nullOr types.bool; + default = null; + }; + + autoRefresh = mkOption { + description = "Enable Auto Refresh"; + type = types.nullOr types.bool; + default = null; + }; + + disableBuiltinNotifications = mkOption { + description = "Disable builtin notifications"; + type = types.nullOr types.bool; + default = null; + }; + + useMagitKeybindings = mkOption { + description = "Enable Magit keybindings"; + type = types.nullOr types.bool; + default = null; + }; + + commitPopup = mkOption { + description = "Commit popup configuration"; + type = types.submodule { + options = { + kind = mkOption { + type = types.nullOr types.str; + default = null; + }; + }; + }; + default = { }; + }; + + kind = mkOption { + description = "The way of opening neogit"; + type = types.nullOr types.str; + default = null; + }; + + signs = mkOption { + description = "Customize displayed signs"; + type = types.submodule { + options = { + section = mkOption { + description = "Cosed and opened signs for sections"; + type = types.nullOr (types.listOf types.str); + default = null; + }; + + item = mkOption { + description = "Cosed and opened signs for items"; + type = types.nullOr (types.listOf types.str); + default = null; + }; + + hunk = mkOption { + description = "Cosed and opened signs for hunks"; + type = types.nullOr (types.listOf types.str); + default = null; + }; + }; + }; + default = { }; + }; + + integrations = mkOption { + description = "Tools integration"; + type = types.submodule { + options = { + diffview = mkOption { + description = "Enable diff popup"; + type = types.bool; + default = false; + }; + }; + }; + default = { }; + }; + + sections = mkOption { + description = "Section configuration"; + type = types.submodule { + options = { + untracked = mkOption { + description = "Options for untracked section"; + type = types.nullOr sectionDefaultsModule; + default = null; + }; + unstaged = mkOption { + description = "Options for unstaged section"; + type = types.nullOr sectionDefaultsModule; + default = null; + }; + staged = mkOption { + description = "Options for staged section"; + type = types.nullOr sectionDefaultsModule; + default = null; + }; + stashes = mkOption { + description = "Options for stashes section"; + type = types.nullOr sectionDefaultsModule; + default = null; + }; + unpulled = mkOption { + description = "Options for unpulled section"; + type = types.nullOr sectionDefaultsModule; + default = null; + }; + unmerged = mkOption { + description = "Options for unmerged section"; + type = types.nullOr sectionDefaultsModule; + default = null; + }; + recent = mkOption { + description = "Options for recent commits section"; + type = types.nullOr sectionDefaultsModule; + default = null; + }; + }; + }; + default = { }; + }; + + mappings = mkOption { + description = "Custom mappings"; + type = types.submodule { + options = { + status = mkOption { + type = types.nullOr (types.attrsOf (types.enum [ + "Close" + "Depth1" + "Depth2" + "Depth3" + "Depth4" + "Toggle" + "Discard" + "Stage" + "StageUnstaged" + "StageAll" + "GoToFile" + "Unstaged" + "UnstagedStage" + "CommandHistory" + "RefreshBuffer" + "HelpPopup" + "PullPopup" + "PushPopup" + "CommitPopup" + "LogPopup" + "StashPopup" + "BranchPopup" + ])); + default = null; + }; + }; + }; + default = { }; + }; + }; + }; + + config = let + setupOptions = with cfg; helpers.toLuaObject { + inherit kind integrations signs sections mappings; + disable_signs = disableSigns; + disable_hint = disableHint; + disable_context_highlighting = disableContextHighlighting; + disable_commit_confirmation = disableCommitConfirmation; + auto_refresh = autoRefresh; + disable_builtin_notifications = disableBuiltinNotifications; + use_magit_keybindings = useMagitKeybindings; + commit_popup = commitPopup; + }; + in mkIf cfg.enable { + programs.nixvim = { + extraPlugins = with pkgs.vimPlugins; [ + neogit + plenary-nvim + ] ++ optional cfg.integrations.diffview diffview-nvim; + + extraConfigLua = '' + require('neogit').setup(${setupOptions}) + ''; + }; + }; +} diff --git a/plugins/utils/dashboard.nix b/plugins/utils/dashboard.nix new file mode 100644 index 00000000..cb340315 --- /dev/null +++ b/plugins/utils/dashboard.nix @@ -0,0 +1,149 @@ +{ config, lib, pkgs, ... }: +with lib; +let + cfg = config.programs.nixvim.plugins.dashboard; +in +{ + options = { + programs.nixvim.plugins.dashboard = { + enable = mkEnableOption "Enable dashboard"; + + executive = mkOption { + description = "Select the fuzzy search plugin"; + type = types.nullOr (types.enum [ "clap" "fzf" "telescope" ]); + default = null; + }; + + shortcuts = mkOption { + description = "Set the fuzzy search keymaps"; + type = types.nullOr (types.attrsOf types.str); + default = null; + }; + + shortcutsIcon = mkOption { + description = "Icons for shortcuts"; + type = types.nullOr (types.attrsOf types.str); + default = null; + }; + + header = mkOption { + description = "Header text"; + type = with types; nullOr (listOf str); + default = null; + }; + + footer = mkOption { + description = "Footer text"; + type = with types; nullOr (listOf str); + default = null; + }; + + sessionDirectory = mkOption { + description = "Set the session folder"; + type = types.nullOr types.str; + default = null; + }; + + sections = mkOption { + description = "Set your own sections"; + type = types.nullOr (types.attrsOf (types.submodule { + options = { + description = mkOption { + description = "String shown in Dashboard buffer"; + type = types.str; + }; + + command = mkOption { + description = "Command or funcref"; + type = types.str; + }; + }; + })); + default = { }; + }; + + preview = mkOption { + description = "Preview options"; + type = types.submodule { + options = { + command = mkOption { + description = "Command that can print output to neovim built-in terminal"; + type = types.nullOr types.str; + default = null; + }; + + pipeline = mkOption { + description = "Pipeline command"; + type = types.nullOr types.str; + default = null; + }; + + file = mkOption { + description = "Path to preview file"; + type = types.nullOr types.str; + default = null; + }; + + height = mkOption { + description = "The height of the preview file"; + type = types.nullOr types.int; + default = null; + }; + + width = mkOption { + description = "The width of the preview file"; + type = types.nullOr types.int; + default = null; + }; + }; + }; + default = { }; + }; + + fzf = mkOption { + description = "Some options for fzf"; + type = types.submodule { + options = { + float = mkOption { + description = "Fzf floating window mode"; + type = types.nullOr types.int; + default = null; + }; + + engine = mkOption { + description = "Grep tool to fzf use"; + type = types.nullOr (types.enum [ "rg" "ag" ]); + default = null; + }; + }; + }; + default = { }; + }; + }; + }; + + config = mkIf cfg.enable { + programs.nixvim = { + extraPlugins = [ pkgs.vimPlugins.dashboard-nvim ]; + extraPackages = if (cfg.fzf.engine == "ag") then [ pkgs.silver-searcher ] + else [ pkgs.ripgrep ]; + + globals = { + dashboard_default_executive = mkIf (!isNull cfg.executive) cfg.executive; + dashboard_custom_shortcut = mkIf (!isNull cfg.shortcuts) cfg.shortcuts; + dashboard_custom_shortcut_icon = mkIf (!isNull cfg.shortcutsIcon) cfg.shortcutsIcon; + dashboard_custom_header = mkIf (!isNull cfg.header) cfg.header; + dashboard_custom_footer = mkIf (!isNull cfg.footer) cfg.footer; + dashboard_session_directory = mkIf (!isNull cfg.sessionDirectory) cfg.sessionDirectory; + dashboard_custom_sections = mkIf (!isNull cfg.sections) cfg.sections; + dashboard_preview_command = mkIf (!isNull cfg.preview.command) cfg.preview.command; + dashboard_preview_pipeline = mkIf (!isNull cfg.preview.pipeline) cfg.preview.pipeline; + dashboard_preview_file = mkIf (!isNull cfg.preview.file) cfg.preview.file; + dashboard_preview_file_height = mkIf (!isNull cfg.preview.height) cfg.preview.height; + dashboard_preview_file_width = mkIf (!isNull cfg.preview.width) cfg.preview.width; + dashboard_fzf_float = mkIf (!isNull cfg.fzf.float) cfg.fzf.float; + dashboard_fzf_engine = mkIf (!isNull cfg.fzf.engine) cfg.fzf.engine; + }; + }; + }; +} diff --git a/plugins/utils/emmet.nix b/plugins/utils/emmet.nix new file mode 100644 index 00000000..2ac08fe4 --- /dev/null +++ b/plugins/utils/emmet.nix @@ -0,0 +1,34 @@ +{ lib, pkgs, ... }@attrs: +with lib; +let + helpers = import ../helpers.nix { inherit lib; }; + + eitherAttrsStrInt = with types; let + strInt = either str int; + in either strInt (attrsOf (either strInt (attrsOf strInt))); +in with helpers; +mkPlugin attrs { + name = "emmet"; + description = "Enable emmet"; + extraPlugins = [ pkgs.vimPlugins.emmet-vim ]; + + options = { + mode = mkDefaultOpt { + type = types.enum [ "i" "n" "v" "a" ]; + global = "user_emmet_mode"; + description = "Mode where emmet will enable"; + }; + + leader = mkDefaultOpt { + type = types.str; + global = "user_emmet_leader_key"; + description = "Set leader key"; + }; + + settings = mkDefaultOpt { + type = types.attrsOf (types.attrsOf eitherAttrsStrInt); + global = "user_emmet_settings"; + description = "Emmet settings"; + }; + }; +}