From fc731f1d63e9e07161755887b9bcfcbe0a063c47 Mon Sep 17 00:00:00 2001 From: Fernando Schauenburg Date: Sun, 6 Aug 2023 19:48:11 +0200 Subject: [PATCH] vim: move lazy config to its own file --- config/nvim/lua/user/init.lua | 21 +-------------------- config/nvim/lua/user/lazy.lua | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 20 deletions(-) create mode 100644 config/nvim/lua/user/lazy.lua diff --git a/config/nvim/lua/user/init.lua b/config/nvim/lua/user/init.lua index 3305cb6..daedf00 100644 --- a/config/nvim/lua/user/init.lua +++ b/config/nvim/lua/user/init.lua @@ -6,24 +6,5 @@ require 'user.options' require 'user.keymap' require 'user.autocmds' require 'user.filetypes' - -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - vim.fn.system { - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", - lazypath, - } -end -vim.opt.rtp:prepend(lazypath) - -require('lazy').setup('user.plugins', { - dev = { - path = '~/Projects/nvim-plugins', - fallback = true, - }, -}) +require 'user.lazy' diff --git a/config/nvim/lua/user/lazy.lua b/config/nvim/lua/user/lazy.lua new file mode 100644 index 0000000..35b90f8 --- /dev/null +++ b/config/nvim/lua/user/lazy.lua @@ -0,0 +1,29 @@ +local get_lazy = function() + local path = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' + if not vim.loop.fs_stat(path) then + vim.fn.system { + 'git', + 'clone', + '--filter=blob:none', + '--branch=stable', + 'https://github.com/folke/lazy.nvim.git', + path, + } + end + vim.opt.rtp:prepend(path) + local _, lazy = pcall(require, 'lazy') + return lazy +end + +local lazy = get_lazy() +if lazy then + lazy.setup('user.plugins', { + dev = { + path = '~/Projects/nvim-plugins', + fallback = true, + }, + }) +else + vim.notify('Lazy not installed and failed to bootstrap!', vim.log.levels.ERROR) +end +