From 7546dc46d3e4a3195c97583d93a39f61bd26a1cd Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Fri, 3 Feb 2023 15:42:45 +0300 Subject: [PATCH] feat: add alpha and dashboard-nvim for dashboard options --- modules/dashboard/alpha.nix | 24 +++ modules/dashboard/dashboard-nvim.nix | 23 +-- modules/dashboard/default.nix | 3 +- modules/dashboard/startify.nix | 236 +++++++++++++++++++++++++++ modules/lib/types-plugin.nix | 1 + 5 files changed, 265 insertions(+), 22 deletions(-) create mode 100644 modules/dashboard/alpha.nix create mode 100644 modules/dashboard/startify.nix diff --git a/modules/dashboard/alpha.nix b/modules/dashboard/alpha.nix new file mode 100644 index 0000000..aa0b49c --- /dev/null +++ b/modules/dashboard/alpha.nix @@ -0,0 +1,24 @@ +{ + pkgs, + config, + lib, + ... +}: +with lib; +with builtins; let + cfg = config.vim.dashboard.alpha; +in { + options.vim.dashboard.alpha = { + enable = mkEnableOption "alpha"; + }; + + config = mkIf cfg.enable { + vim.startPlugins = [ + "alpha-nvim" + ]; + + vim.luaConfigRC.alpha = nvim.dag.entryAnywhere '' + require'alpha'.setup(require'alpha.themes.startify'.config) + ''; + }; +} diff --git a/modules/dashboard/dashboard-nvim.nix b/modules/dashboard/dashboard-nvim.nix index 2683926..de7d2d6 100644 --- a/modules/dashboard/dashboard-nvim.nix +++ b/modules/dashboard/dashboard-nvim.nix @@ -17,28 +17,9 @@ in { "dashboard-nvim" ]; - # vim.nnoremap = { - # "bn" = ":BufferLineCycleNext"; - # "bp" = ":BufferLineCyclePrev"; - # "bc" = ":BufferLinePick"; - # "bse" = ":BufferLineSortByExtension"; - # "bsd" = ":BufferLineSortByDirectory"; - # "bsi" = ":lua require'bufferline'.sort_buffers_by(function (buf_a, buf_b) return buf_a.id < buf_b.id end)"; - # "bmn" = ":BufferLineMoveNext"; - # "bmp" = ":BufferLineMovePrev"; - # "b1" = "BufferLineGoToBuffer 1"; - # "b2" = "BufferLineGoToBuffer 2"; - # "b3" = "BufferLineGoToBuffer 3"; - # "b4" = "BufferLineGoToBuffer 4"; - # "b5" = "BufferLineGoToBuffer 5"; - # "b6" = "BufferLineGoToBuffer 6"; - # "b7" = "BufferLineGoToBuffer 7"; - # "b8" = "BufferLineGoToBuffer 8"; - # "b9" = "BufferLineGoToBuffer 9"; - # }; - vim.luaConfigRC.dashboard-nvim = nvim.dag.entryAnywhere '' - require("dashboard-nvim").setup{} + require("dashboard").setup{ + } ''; }; } diff --git a/modules/dashboard/default.nix b/modules/dashboard/default.nix index 3b7e636..bdee0db 100644 --- a/modules/dashboard/default.nix +++ b/modules/dashboard/default.nix @@ -5,7 +5,8 @@ ... }: { imports = [ - #./alpha-nvim.nix + ./alpha.nix ./dashboard-nvim.nix + ./startify.nix ]; } diff --git a/modules/dashboard/startify.nix b/modules/dashboard/startify.nix new file mode 100644 index 0000000..a5fb405 --- /dev/null +++ b/modules/dashboard/startify.nix @@ -0,0 +1,236 @@ +{ + pkgs, + config, + lib, + ... +}: +with builtins; +with lib; let + cfg = config.vim.dashboard.startify; + + mkVimBool = val: + if val + then "1" + else "0"; +in { + options.vim.dashboard.startify = { + enable = mkEnableOption "Enable startify"; + + bookmarks = mkOption { + default = []; + description = ''List of book marks to disaply on start page''; + type = with types; listOf attrs; + example = {"c" = "~/.vimrc";}; + }; + + changeToDir = mkOption { + default = true; + description = "Should vim change to the directory of the file you open"; + type = types.bool; + }; + + changeToVCRoot = mkOption { + default = false; + description = "Should vim change to the version control root when opening a file"; + type = types.bool; + }; + + changeDirCmd = mkOption { + default = "lcd"; + description = "Command to change the current window with. Can be cd, lcd or tcd"; + type = types.enum ["cd" "lcd" "tcd"]; + }; + + customHeader = mkOption { + default = []; + description = "Text to place in the header"; + type = with types; listOf str; + }; + + customFooter = mkOption { + default = []; + description = "Text to place in the footer"; + type = with types; listOf str; + }; + + lists = mkOption { + default = [ + { + type = "files"; + header = ["MRU"]; + } + { + type = "dir"; + header = ["MRU Current Directory"]; + } + { + type = "sessions"; + header = ["Sessions"]; + } + { + type = "bookmarks"; + header = ["Bookmarks"]; + } + { + type = "commands"; + header = ["Commands"]; + } + ]; + description = "Specify the lists and in what order they are displayed on startify."; + type = with types; listOf attrs; + }; + + skipList = mkOption { + default = []; + description = "List of regex patterns to exclude from MRU lists"; + type = with types; listOf str; + }; + + updateOldFiles = mkOption { + default = false; + description = "Set if you want startify to always update and not just when neovim closes"; + type = types.bool; + }; + + sessionAutoload = mkOption { + default = false; + description = "Make startify auto load Session.vim files from the current directory"; + type = types.bool; + }; + + commands = mkOption { + default = []; + description = "Commands that are presented to the user on startify page"; + type = with types; listOf (oneOf [str attrs (listOf str)]); + }; + + filesNumber = mkOption { + default = 10; + description = "How many files to list"; + type = types.int; + }; + + customIndices = mkOption { + default = []; + description = "Specify a list of default charecters to use instead of numbers"; + type = with types; listOf str; + }; + + disableOnStartup = mkOption { + default = false; + description = "Prevent startify from opening on startup but can be called with :Startify"; + type = types.bool; + }; + + unsafe = mkOption { + default = false; + description = "Turns on unsafe mode for Startify. Stops resolving links, checking files are readable and filtering bookmark list"; + type = types.bool; + }; + + paddingLeft = mkOption { + default = 3; + description = "Number of spaces used for left padding."; + type = types.int; + }; + + useEnv = mkOption { + default = false; + description = "Show environment variables in path if name is shorter than value"; + type = types.bool; + }; + + sessionBeforeSave = mkOption { + default = []; + description = "Commands to run before saving a session"; + type = with types; listOf str; + }; + + sessionPersistence = mkOption { + default = false; + description = "Persist session before leaving vim or switching session"; + type = types.bool; + }; + + sessionDeleteBuffers = mkOption { + default = true; + description = "Delete all buffers when loading or closing a session"; + type = types.bool; + }; + + sessionDir = mkOption { + default = "~/.vim/session"; + description = "Directory to save and load sessions from"; + type = types.str; + }; + + skipListServer = mkOption { + default = []; + description = "List of vim servers to not load startify for"; + type = with types; listOf str; + }; + + sessionRemoveLines = mkOption { + default = []; + description = "Patterns to remove from session files"; + type = with types; listOf str; + }; + + sessionSavevars = mkOption { + default = []; + description = "List of variables to save into a session file."; + type = with types; listOf str; + }; + + sessionSavecmds = mkOption { + default = []; + description = "List of commands to run when loading a session."; + type = with types; listOf str; + }; + + sessionSort = mkOption { + default = false; + description = "Set if you want items sorted by date rather than alphabetically"; + type = types.bool; + }; + }; + + config = mkIf (cfg.enable) { + vim.startPlugins = with pkgs.neovimPlugins; [vim-startify]; + + vim.globals = { + "startify_custom_header" = + if cfg.customHeader == [] + then null + else cfg.customHeader; + "startify_custom_footer" = + if cfg.customFooter == [] + then null + else cfg.customFooter; + "startify_bookmarks" = cfg.bookmarks; + "startify_lists" = cfg.lists; + "startify_change_to_dir" = mkVimBool cfg.changeToDir; + "startify_change_to_vcs_root" = mkVimBool cfg.changeToVCRoot; + "startify_change_cmd" = cfg.changeDirCmd; + "startify_skiplist" = cfg.skipList; + "startify_update_oldfiles" = mkVimBool cfg.updateOldFiles; + "startify_session_autoload" = mkVimBool cfg.sessionAutoload; + "startify_commands" = cfg.commands; + "startify_files_number" = cfg.filesNumber; + "startify_custom_indices" = cfg.customIndices; + "startify_disable_at_vimenter" = mkVimBool cfg.disableOnStartup; + "startify_enable_unsafe" = mkVimBool cfg.unsafe; + "startify_padding_left" = cfg.paddingLeft; + "startify_use_env" = mkVimBool cfg.useEnv; + "startify_session_before_save" = cfg.sessionBeforeSave; + "startify_session_persistence" = mkVimBool cfg.sessionPersistence; + "startify_session_delete_buffers" = mkVimBool cfg.sessionDeleteBuffers; + "startify_session_dir" = cfg.sessionDir; + "startify_skiplist_server" = cfg.skipListServer; + "startify_session_remove_lines" = cfg.sessionRemoveLines; + "startify_session_savevars" = cfg.sessionSavevars; + "startify_session_savecmds" = cfg.sessionSavecmds; + "startify_session_sort" = mkVimBool cfg.sessionSort; + }; + }; +} diff --git a/modules/lib/types-plugin.nix b/modules/lib/types-plugin.nix index 151da31..c591897 100644 --- a/modules/lib/types-plugin.nix +++ b/modules/lib/types-plugin.nix @@ -42,6 +42,7 @@ with lib; let "catppuccin" "minimap-vim" "dashboard-nvim" + "alpha-nvim" ]; pluginsType = with types; listOf (nullOr (either (enum availablePlugins) package));