From 8b437e4177655342a052b67b0e03cfe8e8e8c6c3 Mon Sep 17 00:00:00 2001 From: krolyxon Date: Thu, 19 Jan 2023 16:06:21 +0530 Subject: [PATCH] lazy-nvim plugin and formatting --- init.lua | 16 ++--- lua/core/bootstrap.lua | 34 +++++----- lua/core/utils.lua | 44 ++++++------- lua/plugins/configs/lazy_nvim.lua | 103 ++++++++++++------------------ lua/plugins/init.lua | 66 +++++++++---------- 5 files changed, 121 insertions(+), 142 deletions(-) diff --git a/init.lua b/init.lua index 7708774..4a75fc1 100644 --- a/init.lua +++ b/init.lua @@ -4,14 +4,14 @@ require("core.utils").load_mappings() 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", -- latest stable release - lazypath, - }) + vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) end vim.opt.rtp:prepend(lazypath) require "plugins" diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua index 97ae008..8cacebb 100644 --- a/lua/core/bootstrap.lua +++ b/lua/core/bootstrap.lua @@ -1,28 +1,28 @@ local M = {} M.lazy = function(install_path) - print "Bootstrapping lazy.nvim .." + print "Bootstrapping lazy.nvim .." - vim.fn.system { - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - install_path, - } + vim.fn.system { + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + install_path, + } - vim.opt.rtp:prepend(install_path) + vim.opt.rtp:prepend(install_path) - -- install plugins + compile their configs - require "plugins" + -- install plugins + compile their configs + require "plugins" - require("lazy").load { plugins = "nvim-treesitter" } + require("lazy").load { plugins = "nvim-treesitter" } - -- install binaries from mason.nvim & tsparsers on LazySync - vim.schedule(function() - vim.cmd "bw | silent! MasonInstallAll" -- close lazy window - end, 0) + -- install binaries from mason.nvim & tsparsers on LazySync + vim.schedule(function() + vim.cmd "bw | silent! MasonInstallAll" -- close lazy window + end, 0) end return M diff --git a/lua/core/utils.lua b/lua/core/utils.lua index 8c9890d..3bcee8d 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -7,7 +7,7 @@ M.format_plugins = function(plugins) local final_table = {} final_table[#final_table + 1] = plugins[key] end - return final_table + return final_table end M.close_buffer = function(bufnr) @@ -53,31 +53,31 @@ M.load_mappings = function(section, mapping_opt) end M.lazy_load = function(plugin) - vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, { - group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}), - callback = function() - local file = vim.fn.expand "%" - local condition = file ~= "NvimTree_1" and file ~= "[lazy]" and file ~= "" + vim.api.nvim_create_autocmd({ "BufRead", "BufWinEnter", "BufNewFile" }, { + group = vim.api.nvim_create_augroup("BeLazyOnFileOpen" .. plugin, {}), + callback = function() + local file = vim.fn.expand "%" + local condition = file ~= "NvimTree_1" and file ~= "[lazy]" and file ~= "" - if condition then - vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin) + if condition then + vim.api.nvim_del_augroup_by_name("BeLazyOnFileOpen" .. plugin) - -- dont defer for treesitter as it will show slow highlighting - -- This deferring only happens only when we do "nvim filename" - if plugin ~= "nvim-treesitter" then - vim.schedule(function() - require("lazy").load { plugins = plugin } + -- dont defer for treesitter as it will show slow highlighting + -- This deferring only happens only when we do "nvim filename" + if plugin ~= "nvim-treesitter" then + vim.schedule(function() + require("lazy").load { plugins = plugin } - if plugin == "nvim-lspconfig" then - vim.cmd "silent! do FileType" + if plugin == "nvim-lspconfig" then + vim.cmd "silent! do FileType" + end + end, 0) + else + require("lazy").load { plugins = plugin } + end end - end, 0) - else - require("lazy").load { plugins = plugin } - end - end - end, - }) + end, + }) end return M diff --git a/lua/plugins/configs/lazy_nvim.lua b/lua/plugins/configs/lazy_nvim.lua index 8ac2a20..967b0cf 100644 --- a/lua/plugins/configs/lazy_nvim.lua +++ b/lua/plugins/configs/lazy_nvim.lua @@ -1,70 +1,49 @@ return { - defaults = { - lazy = true, - }, + defaults = { + lazy = true, + }, - -- install = { + -- install = { -- try to load one of these colorschemes when starting an installation during startup -- colorscheme = { "rose-pine" }, - -- }, + -- }, - ui = { - icons = { - cmd = " ", - config = "", - event = "", - ft = " ", - init = " ", - import = " ", - keys = " ", - lazy = "鈴 ", - loaded = "", - not_loaded = "", - plugin = " ", - runtime = " ", - source = " ", - start = "", - task = "✔ ", - list = { - "●", - "➜", - "★", - "‒", - }, + ui = { + icons = { + ft = "", + lazy = "鈴 ", + loaded = "", + not_loaded = "", + }, }, - }, - -- performance = { - -- rtp = { - -- disabled_plugins = { - -- "2html_plugin", - -- "tohtml", - -- "getscript", - -- "getscriptPlugin", - -- "gzip", - -- "logipat", - -- -- "netrw", - -- -- "netrwPlugin", - -- -- "netrwSettings", - -- -- "netrwFileHandlers", - -- "matchit", - -- "tar", - -- "tarPlugin", - -- "rrhelper", - -- "spellfile_plugin", - -- "vimball", - -- "vimballPlugin", - -- "zip", - -- "zipPlugin", - -- "tutor", - -- "rplugin", - -- "syntax", - -- "synmenu", - -- "optwin", - -- "compiler", - -- "bugreport", - -- "ftplugin", - -- }, - -- }, - -- }, + performance = { + rtp = { + disabled_plugins = { + "2html_plugin", + "tohtml", + "getscript", + "getscriptPlugin", + "gzip", + "logipat", + "matchit", + "tar", + "tarPlugin", + "rrhelper", + "spellfile_plugin", + "vimball", + "vimballPlugin", + "zip", + "zipPlugin", + "tutor", + "rplugin", + "syntax", + "synmenu", + "optwin", + "compiler", + "bugreport", + "ftplugin", + }, + }, + }, } diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 2510e51..23321e1 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -48,7 +48,7 @@ local plugins = { -- lsp stuff ["williamboman/mason.nvim"] = { - cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" }, + cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" }, config = function() require "plugins.configs.mason" end, @@ -82,40 +82,40 @@ local plugins = { -- load luasnips + cmp related in insert mode only - ["hrsh7th/nvim-cmp"] = { - event = "InsertEnter", - dependencies = { - { - -- snippet plugin - "L3MON4D3/LuaSnip", - dependencies = "rafamadriz/friendly-snippets", - config = function() - require("plugins.configs.others").luasnip() - end, - }, + ["hrsh7th/nvim-cmp"] = { + event = "InsertEnter", + dependencies = { + { + -- snippet plugin + "L3MON4D3/LuaSnip", + dependencies = "rafamadriz/friendly-snippets", + config = function() + require("plugins.configs.others").luasnip() + end, + }, - -- autopairing of (){}[] etc - { - "windwp/nvim-autopairs", - config = function() - require("plugins.configs.others").autopairs() - end, - }, + -- autopairing of (){}[] etc + { + "windwp/nvim-autopairs", + config = function() + require("plugins.configs.others").autopairs() + end, + }, - -- cmp sources plugins - { - "saadparwaiz1/cmp_luasnip", - "hrsh7th/cmp-nvim-lua", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - }, + -- cmp sources plugins + { + "saadparwaiz1/cmp_luasnip", + "hrsh7th/cmp-nvim-lua", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + }, + }, + + config = function() + require "plugins.configs.cmp" + end, }, - - config = function() - require "plugins.configs.cmp" - end, - }, -- misc ['vimwiki/vimwiki'] = { @@ -198,7 +198,7 @@ plugins = require("core.utils").format_plugins(plugins) -- pin commits for all default plugins for _, value in pairs(plugins) do - value.pin = true + value.pin = true end -- load lazy.nvim options