From 497c580c124891772a33715efb4aa12423b150aa Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Tue, 24 Aug 2021 16:12:16 -0700 Subject: [PATCH] Add startify config and local require --- neovim/.gitignore | 1 + neovim/lua/plugins.lua | 12 ++++++++++++ neovim/lua/utils.lua | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 neovim/.gitignore diff --git a/neovim/.gitignore b/neovim/.gitignore new file mode 100644 index 0000000..cc34038 --- /dev/null +++ b/neovim/.gitignore @@ -0,0 +1 @@ +*_local.lua diff --git a/neovim/lua/plugins.lua b/neovim/lua/plugins.lua index f73365b..01f4c23 100644 --- a/neovim/lua/plugins.lua +++ b/neovim/lua/plugins.lua @@ -254,6 +254,18 @@ return require('packer').startup(function() config = config_dark_notify, requires = { "hoob3rt/lualine.nvim" }, } + use { + 'mhinz/vim-startify', + config = function() + vim.g.startify_list_order = { + { ' My Bookmarks'}, 'bookmarks', + { ' Most recently used files in the current directory' }, 'dir', + { ' Most recently used files' }, 'files', + { ' My Sessions' }, 'sessions' + } + require("utils").maybe_require("plugins.startify_local") + end, + } -- LSP use { diff --git a/neovim/lua/utils.lua b/neovim/lua/utils.lua index 950ebc9..3de72b0 100644 --- a/neovim/lua/utils.lua +++ b/neovim/lua/utils.lua @@ -48,4 +48,36 @@ function M.env_default(name, def) return val == nil and def or val end +-- Checks to see if a package can be required +function M.can_require(name) + if package.loaded[name] then + return false + else + for _, searcher in ipairs(package.searchers or package.loaders) do + local loader = searcher(name) + if type(loader) == 'function' then + package.preload[name] = loader + return true + end + end + + return false + end +end + +-- Require a package if possible +function M.maybe_require(name) + if M.can_require(name) then + return require(name) + end + + return nil +end + +-- Require a package and a "_local" suffixed one +function M.require_with_local(name) + require(name) + M.maybe_require(name .. "_local") +end + return M