From 9ef80b2ace26369578af85a0aaf16524f9766ef2 Mon Sep 17 00:00:00 2001 From: juanito87 Date: Sun, 21 Apr 2024 18:10:11 -0300 Subject: [PATCH] Separating plugin manager instalation from configuration --- init.lua | 3 ++- lua/{lazy.lua => lazy-config.lua} | 13 +++---------- lua/lazy-install.lua | 8 ++++++++ 3 files changed, 13 insertions(+), 11 deletions(-) rename lua/{lazy.lua => lazy-config.lua} (98%) create mode 100644 lua/lazy-install.lua diff --git a/init.lua b/init.lua index b032bdc5..80640821 100644 --- a/init.lua +++ b/init.lua @@ -103,4 +103,5 @@ require 'keymaps' require 'autocommands' -- [[ Lazy package manager ]] -require 'lazy' +require 'lazy-install' +require 'lazy-config' diff --git a/lua/lazy.lua b/lua/lazy-config.lua similarity index 98% rename from lua/lazy.lua rename to lua/lazy-config.lua index 13cb64fd..179e2f1f 100644 --- a/lua/lazy.lua +++ b/lua/lazy-config.lua @@ -1,13 +1,6 @@ --- [[ Install `lazy.nvim` plugin manager ]] --- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info -local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' -if not vim.loop.fs_stat(lazypath) then - local lazyrepo = 'https://github.com/folke/lazy.nvim.git' - vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } -end ---@diagnostic disable-next-line: undefined-field -vim.opt.rtp:prepend(lazypath) - -- [[ Configure and install plugins ]] +-- Definitions +local autocmd = vim.api.nvim_create_autocmd -- -- To check the current status of your plugins, run -- :Lazy @@ -249,7 +242,7 @@ require('lazy').setup({ -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this -- function will be executed to configure the current buffer autocmd('LspAttach', { - group = augroup('kickstart-lsp-attach', { clear = true }), + group = vim.api.nvim_create_augroup('lsp-attach', { clear = true }), callback = function(event) -- NOTE: Remember that Lua is a real programming language, and as such it is possible -- to define small helper and utility functions so you don't have to repeat yourself. diff --git a/lua/lazy-install.lua b/lua/lazy-install.lua new file mode 100644 index 00000000..0e208332 --- /dev/null +++ b/lua/lazy-install.lua @@ -0,0 +1,8 @@ +-- [[ Install `lazy.nvim` plugin manager ]] +-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info +local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim' +if not vim.loop.fs_stat(lazypath) then + local lazyrepo = 'https://github.com/folke/lazy.nvim.git' + vim.fn.system { 'git', 'clone', '--filter=blob:none', '--branch=stable', lazyrepo, lazypath } +end ---@diagnostic disable-next-line: undefined-field +vim.opt.rtp:prepend(lazypath)