From c0940a870c6d9d6681284e2660be85ec368c210d Mon Sep 17 00:00:00 2001 From: krolyxon Date: Thu, 19 Jan 2023 14:32:38 +0530 Subject: [PATCH 1/7] migrate to lazy.nvim --- init.lua | 55 ++++-------- lazy-lock.json | 28 ++++++ lua/core/bootstrap.lua | 28 ++++++ lua/core/lazy_load.lua | 79 ----------------- lua/core/options.lua | 26 ------ lua/core/packer.lua | 41 --------- lua/core/utils.lua | 37 ++++++++ lua/plugins/configs/lazy_nvim.lua | 70 +++++++++++++++ lua/plugins/configs/others.lua | 44 ++++----- lua/plugins/init.lua | 142 +++++++++++++++--------------- 10 files changed, 271 insertions(+), 279 deletions(-) create mode 100644 lazy-lock.json create mode 100644 lua/core/bootstrap.lua delete mode 100644 lua/core/lazy_load.lua delete mode 100644 lua/core/packer.lua create mode 100644 lua/plugins/configs/lazy_nvim.lua diff --git a/init.lua b/init.lua index 52db41c..a781263 100644 --- a/init.lua +++ b/init.lua @@ -1,49 +1,24 @@ -vim.defer_fn(function() - pcall(require, "impatient") -end, 0) +require "core.options" +require("core.utils").load_mappings() +-- require("colors").core_setup() --- setup packer + plugins -local fn = vim.fn -local install_path = fn.stdpath "data" .. "/site/pack/packer/opt/packer.nvim" - -if fn.empty(fn.glob(install_path)) > 0 then - vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#1e222a" }) - print "Cloning packer .." - fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path } - - -- install plugins + compile their configs - vim.cmd "packadd packer.nvim" - require "plugins" - vim.cmd "PackerSync" - - -- install binaries from mason.nvim & tsparsers - vim.api.nvim_create_autocmd("User", { - pattern = "PackerComplete", - callback = function() - vim.cmd "bw | silent! MasonInstallAll" -- close packer window - require("packer").loader "nvim-treesitter" - end, - }) +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, + }) end - -local modules = { - "core.options", - "core.packer", -} +vim.opt.rtp:prepend(lazypath) +require "plugins" -- add binaries installed by mason.nvim to path vim.env.PATH = vim.env.PATH .. ":" .. vim.fn.stdpath "data" .. "/mason/bin" -for _, module in ipairs(modules) do - local ok, err = pcall(require, module) - if not ok then - error("Error loading " .. module .. "\n\n" .. err) - end -end - -require("core.utils").load_mappings() --- require("colors").core_setup() - require('rose-pine').setup({ disable_background = true }) diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..c10e1a0 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,28 @@ +{ + "Comment.nvim": { "branch": "master", "commit": "eab2c83a0207369900e92783f56990808082eac2" }, + "LuaSnip": { "branch": "master", "commit": "af60ac12fa1349dbad479fc1e95d5aea977c0c37" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "59224771f91b86d1de12570b4070fe4ad7cd1eeb" }, + "cmp-nvim-lua": { "branch": "main", "commit": "f3491638d123cfd2c8048aefaf66d246ff250ca6" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" }, + "crates.nvim": { "branch": "main", "commit": "707ed7d6f8927a5ec0c241aa793f694f1b05f731" }, + "friendly-snippets": { "branch": "main", "commit": "046e4d3491baf664e0eef5231d28beb49333578b" }, + "gitsigns.nvim": { "branch": "main", "commit": "addd6e174a85fc1c4007ab0b65d77e6555b417bf" }, + "indent-blankline.nvim": { "branch": "master", "commit": "c4c203c3e8a595bc333abaf168fcb10c13ed5fb7" }, + "kterm": { "branch": "main", "commit": "91bd6e3750a4c9302abe87260256cca97f71666b" }, + "lazy.nvim": { "branch": "main", "commit": "4739c2d95af17acb786ed33445f59b7b13671417" }, + "lualine.nvim": { "branch": "master", "commit": "0050b308552e45f7128f399886c86afefc3eb988" }, + "mason.nvim": { "branch": "main", "commit": "d825d3d1612c31caaff60901e0a6600cab8624d3" }, + "neovim": { "branch": "main", "commit": "845a6ad5443e3559dde42910c4523a5835c9233b" }, + "nvim-autopairs": { "branch": "master", "commit": "f00eb3b766c370cb34fdabc29c760338ba9e4c6c" }, + "nvim-cmp": { "branch": "main", "commit": "11a95792a5be0f5a40bab5fc5b670e5b1399a939" }, + "nvim-colorizer.lua": { "branch": "master", "commit": "760e27df4dd966607e8fb7fd8b6b93e3c7d2e193" }, + "nvim-lspconfig": { "branch": "master", "commit": "d228bcf7cd94611929482a09e114a42c41fe81a8" }, + "nvim-treesitter": { "branch": "master", "commit": "42c3a3c51e8fef027655e7facd293aae7c6984bb" }, + "plenary.nvim": { "branch": "master", "commit": "1c7e3e6b0f4dd5a174fcea9fda8a4d7de593b826" }, + "rust-tools.nvim": { "branch": "master", "commit": "df584e84393ef255f5b8cbd709677d6a3a5bf42f" }, + "telescope.nvim": { "branch": "master", "commit": "2f32775405f6706348b71d0bb8a15a22852a61e4" }, + "vimwiki": { "branch": "dev", "commit": "fea8bee382b2051b0137fd2cacf0862823ee69b3" }, + "which-key.nvim": { "branch": "main", "commit": "e4fa445065a2bb0bbc3cca85346b67817f28e83e" } +} \ No newline at end of file diff --git a/lua/core/bootstrap.lua b/lua/core/bootstrap.lua new file mode 100644 index 0000000..97ae008 --- /dev/null +++ b/lua/core/bootstrap.lua @@ -0,0 +1,28 @@ +local M = {} + +M.lazy = function(install_path) + 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.opt.rtp:prepend(install_path) + + -- install plugins + compile their configs + require "plugins" + + 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) +end + +return M diff --git a/lua/core/lazy_load.lua b/lua/core/lazy_load.lua deleted file mode 100644 index 9ce6ad4..0000000 --- a/lua/core/lazy_load.lua +++ /dev/null @@ -1,79 +0,0 @@ -local M = {} -local autocmd = vim.api.nvim_create_autocmd - --- require("packer").loader(tb.plugins) --- This must be used for plugins that need to be loaded just after a file --- ex : treesitter, lspconfig etc -M.lazy_load = function(tb) - autocmd(tb.events, { - group = vim.api.nvim_create_augroup(tb.augroup_name, {}), - callback = function() - if tb.condition() then - vim.api.nvim_del_augroup_by_name(tb.augroup_name) - - -- dont defer for treesitter as it will show slow highlighting - -- This deferring only happens only when we do "nvim filename" - if tb.plugin ~= "nvim-treesitter" then - vim.defer_fn(function() - require("packer").loader(tb.plugin) - if tb.plugin == "nvim-lspconfig" then - vim.cmd "silent! do FileType" - end - end, 0) - else - require("packer").loader(tb.plugin) - end - end - end, - }) -end - --- load certain plugins only when there's a file opened in the buffer --- if "nvim filename" is executed -> load the plugin after nvim gui loads --- This gives an instant preview of nvim with the file opened - -M.on_file_open = function(plugin_name) - M.lazy_load { - events = { "BufRead", "BufWinEnter", "BufNewFile" }, - augroup_name = "BeLazyOnFileOpen" .. plugin_name, - plugin = plugin_name, - condition = function() - local file = vim.fn.expand "%" - return file ~= "[packer]" and file ~= "" - end, - } -end - -M.packer_cmds = { - "PackerSnapshot", - "PackerSnapshotRollback", - "PackerSnapshotDelete", - "PackerInstall", - "PackerUpdate", - "PackerSync", - "PackerClean", - "PackerCompile", - "PackerStatus", - "PackerProfile", - "PackerLoad", -} - -M.treesitter_cmds = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSEnable", "TSDisable", "TSModuleInfo" } -M.mason_cmds = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" } - -M.gitsigns = function() - autocmd({ "BufRead" }, { - group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }), - callback = function() - vim.fn.system("git -C " .. vim.fn.expand "%:p:h" .. " rev-parse") - if vim.v.shell_error == 0 then - vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad" - vim.schedule(function() - require("packer").loader "gitsigns.nvim" - end) - end - end, - }) -end - -return M diff --git a/lua/core/options.lua b/lua/core/options.lua index d7feafc..74dd8d0 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -42,29 +42,3 @@ opt.timeoutlen = 400 -- interval for writing swap file to disk, also used by gitsigns opt.updatetime = 250 - --- disable some builtin vim plugins -local default_plugins = { - "2html_plugin", - "getscript", - "getscriptPlugin", - "gzip", - "logipat", - -- "netrw", - -- "netrwPlugin", - -- "netrwSettings", - -- "netrwFileHandlers", - "matchit", - "tar", - "tarPlugin", - "rrhelper", - "spellfile_plugin", - "vimball", - "vimball_plugin", - "zip", - "zipPlugin", -} - -for _, plugin in pairs(default_plugins) do - g["loaded_" .. plugin] = 1 -end diff --git a/lua/core/packer.lua b/lua/core/packer.lua deleted file mode 100644 index f8d7d11..0000000 --- a/lua/core/packer.lua +++ /dev/null @@ -1,41 +0,0 @@ -local M = {} - -M.run = function(plugins) - local present, packer = pcall(require, "packer") - - if not present then - return - end - - - local final_table = {} - for key, _ in pairs(plugins) do - plugins[key][1] = key - final_table[#final_table + 1] = plugins[key] - end - - - packer.init({ - auto_clean = true, - compile_on_sync = true, - git = { clone_timeout = 6000 }, - display = { - working_sym = "ﲊ", - error_sym = "✗ ", - done_sym = " ", - removed_sym = " ", - moved_sym = "", - open_fn = function() - return require("packer.util").float { border = "single" } - end, - } - }) - - packer.startup(function(use) - for _, v in pairs(final_table) do - use(v) - end - end) -end - -return M diff --git a/lua/core/utils.lua b/lua/core/utils.lua index d9085f3..8c9890d 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -1,6 +1,15 @@ local M = {} local merge_tb = vim.tbl_deep_extend +M.format_plugins = function(plugins) local final_table = {} + for key, _ in pairs(plugins) do + plugins[key][1] = key + final_table[#final_table + 1] = plugins[key] + end + + return final_table +end + M.close_buffer = function(bufnr) if vim.bo.buftype == "terminal" then vim.cmd(vim.bo.buflisted and "set nobl | enew" or "hide") @@ -43,4 +52,32 @@ M.load_mappings = function(section, mapping_opt) end 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 ~= "" + + 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 } + + if plugin == "nvim-lspconfig" then + vim.cmd "silent! do FileType" + end + end, 0) + else + require("lazy").load { plugins = plugin } + end + end + end, + }) +end + return M diff --git a/lua/plugins/configs/lazy_nvim.lua b/lua/plugins/configs/lazy_nvim.lua new file mode 100644 index 0000000..8ac2a20 --- /dev/null +++ b/lua/plugins/configs/lazy_nvim.lua @@ -0,0 +1,70 @@ +return { + defaults = { + lazy = true, + }, + + -- 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 = { + "●", + "➜", + "★", + "‒", + }, + }, + }, + + -- 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", + -- }, + -- }, + -- }, +} diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index c28b89b..023efd3 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -20,30 +20,31 @@ M.autopairs = function() end M.luasnip = function() - local present, luasnip = pcall(require, "luasnip") + local present, luasnip = pcall(require, "luasnip") - if not present then - return - end + if not present then + return + end - local options = { - history = true, - updateevents = "TextChanged,TextChangedI", - } + local options = { + history = true, + updateevents = "TextChanged,TextChangedI", + } - luasnip.config.set_config(options) - require("luasnip.loaders.from_vscode").lazy_load() - require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" } + luasnip.config.set_config(options) + require("luasnip.loaders.from_vscode").lazy_load { paths = vim.g.luasnippets_path or "" } + require("luasnip.loaders.from_vscode").lazy_load() - vim.api.nvim_create_autocmd("InsertLeave", { - callback = function() - if require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] - and not require("luasnip").session.jump_active - then - require("luasnip").unlink_current() - end - end, - }) + vim.api.nvim_create_autocmd("InsertLeave", { + callback = function() + if + require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()] + and not require("luasnip").session.jump_active + then + require("luasnip").unlink_current() + end + end, + }) end M.gitsigns = function() @@ -99,7 +100,7 @@ M.blankline = function() "help", "terminal", "alpha", - "packer", + "lazy", "lspinfo", "TelescopePrompt", "TelescopeResults", @@ -136,6 +137,7 @@ M.colorizer = function() css = false, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB css_fn = false, -- Enable all CSS *functions*: rgb_fn, hsl_fn mode = "background", -- Set the display mode. + tailwind = true, }, } diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index a7f84ef..4ae9491 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,42 +1,46 @@ +-- All plugins have lazy = true by default, to load a plugin on startup just lazy=false local plugins = { - ["wbthomason/packer.nvim"] = { - cmd = require("core.lazy_load").packer_cmds, - config = function() - require "plugins" - end, - }, + ['nvim-lua/plenary.nvim'] = {}, ["nvim-treesitter/nvim-treesitter"] = { - module = "nvim-treesitter", - setup = function() - require("core.lazy_load").on_file_open "nvim-treesitter" + init = function() + require("core.utils").lazy_load "nvim-treesitter" end, - cmd = require("core.lazy_load").treesitter_cmds, + cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSEnable", "TSDisable", "TSModuleInfo" }, run = ":TSUpdate", config = function() require "plugins.configs.treesitter" end, }, - -- git ["lewis6991/gitsigns.nvim"] = { ft = "gitcommit", - setup = function() - require("core.lazy_load").gitsigns() + init = function() + -- load gitsigns only when a git file is opened + vim.api.nvim_create_autocmd({ "BufRead" }, { + group = vim.api.nvim_create_augroup("GitSignsLazyLoad", { clear = true }), + callback = function() + vim.fn.system("git -C " .. vim.fn.expand "%:p:h" .. " rev-parse") + if vim.v.shell_error == 0 then + vim.api.nvim_del_augroup_by_name "GitSignsLazyLoad" + vim.schedule(function() + require("lazy").load { plugins = "gitsigns.nvim" } + end) + end + end, + }) end, config = function() require("plugins.configs.others").gitsigns() end, }, - ['nvim-lua/plenary.nvim'] = {}, - ["nvim-telescope/telescope.nvim"] = { cmd = "Telescope", config = function() require "plugins.configs.telescope" end, - setup = function() + init = function() require("core.utils").load_mappings "telescope" end, }, @@ -44,16 +48,15 @@ local plugins = { -- lsp stuff ["williamboman/mason.nvim"] = { - cmd = require("core.lazy_load").mason_cmds, + cmd = { "Mason", "MasonInstall", "MasonInstallAll", "MasonUninstall", "MasonUninstallAll", "MasonLog" }, config = function() require "plugins.configs.mason" end, }, ["neovim/nvim-lspconfig"] = { - opt = true, - setup = function() - require("core.lazy_load").on_file_open "nvim-lspconfig" + init = function() + require("core.utils").lazy_load "nvim-lspconfig" end, config = function() require "plugins.configs.lspconfig" @@ -77,43 +80,40 @@ local plugins = { -- load luasnips + cmp related in insert mode only - ["rafamadriz/friendly-snippets"] = {}, - - ["hrsh7th/nvim-cmp"] = { - event = "InsertEnter", + ["hrsh7th/nvim-cmp"] = { + event = "InsertEnter", + dependencies = { + { + -- snippet plugin + "L3MON4D3/LuaSnip", + dependencies = "rafamadriz/friendly-snippets", config = function() - require "plugins.configs.cmp" + require("plugins.configs.others").luasnip() end, - }, + }, - ["L3MON4D3/LuaSnip"] = { - requires = "friendly-snippets", - after = "nvim-cmp", + -- autopairing of (){}[] etc + { + "windwp/nvim-autopairs", config = function() - require("plugins.configs.others").luasnip() + 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", + }, }, - ["saadparwaiz1/cmp_luasnip"] = { - after = "LuaSnip", - }, - - ["hrsh7th/cmp-nvim-lua"] = { - after = "cmp_luasnip", - }, - - ["hrsh7th/cmp-nvim-lsp"] = { - after = "cmp-nvim-lua", - }, - - ["hrsh7th/cmp-buffer"] = { - after = "cmp-nvim-lsp", - }, - - ["hrsh7th/cmp-path"] = { - after = "cmp-buffer", - }, - + config = function() + require "plugins.configs.cmp" + end, + }, -- misc ['vimwiki/vimwiki'] = { @@ -128,30 +128,21 @@ local plugins = { end, }, - ["windwp/nvim-autopairs"] = { - after = "nvim-cmp", - config = function() - require("plugins.configs.others").autopairs() - end, - }, - ["numToStr/Comment.nvim"] = { - module = "Comment", - keys = { "gc", "gb" }, + -- keys = { "gc", "gb" }, config = function() require("plugins.configs.others").comment() end, - setup = function() + init = function() require("core.utils").load_mappings "comment" end, }, ["krolyxon/kterm"] = { - module = "kterm", config = function() require "plugins.configs.kterm" end, - setup = function() + init = function() require("core.utils").load_mappings "kterm" end, }, @@ -163,15 +154,16 @@ local plugins = { config = function() require("plugins.configs.others").blankline() end, - setup = function() + init = function() + require("core.utils").lazy_load "indent-blankline.nvim" require("core.utils").load_mappings "blankline" end, }, ["nvchad/nvim-colorizer.lua"] = { opt = true, - setup = function() - require("core.lazy_load").on_file_open "nvim-colorizer.lua" + init = function() + require("core.utils").lazy_load "nvim-colorizer.lua" end, config = function() require("plugins.configs.others").colorizer() @@ -186,20 +178,26 @@ local plugins = { -- Only load whichkey after all the gui ["folke/which-key.nvim"] = { - disable = false, - module = "which-key", + enabled = true, keys = { "", "\"", "'", "`" }, config = function() require "plugins.configs.whichkey" end, - setup = function() + init = function() require("core.utils").load_mappings "whichkey" end, }, ["rose-pine/neovim"] = {}, - - -- speed up deffered plugins - ["lewis6991/impatient.nvim"] = {}, } -require("core.packer").run(plugins) + +plugins = require("core.utils").format_plugins(plugins) + +-- pin commits for all default plugins +for _, value in pairs(plugins) do + value.pin = true +end + +-- load lazy.nvim options +local lazy_config = require "plugins.configs.lazy_nvim" +require("lazy").setup(plugins, lazy_config) From ee16bd0072563cfe4680b766694bf4689e6c6f75 Mon Sep 17 00:00:00 2001 From: krolyxon Date: Thu, 19 Jan 2023 15:38:12 +0530 Subject: [PATCH 2/7] rust-tools: lazy loading done perfectly --- init.lua | 2 ++ lua/plugins/init.lua | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/init.lua b/init.lua index a781263..7708774 100644 --- a/init.lua +++ b/init.lua @@ -19,6 +19,8 @@ require "plugins" -- add binaries installed by mason.nvim to path vim.env.PATH = vim.env.PATH .. ":" .. vim.fn.stdpath "data" .. "/mason/bin" + +-- Set colorscheme require('rose-pine').setup({ disable_background = true }) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 4ae9491..3e09c2f 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -64,7 +64,9 @@ local plugins = { }, ["simrat39/rust-tools.nvim"] = { - after = "nvim-lspconfig", + -- after = "nvim-lspconfig", + event = "BufEnter *.rs", + dependencies = "neovim/nvim-lspconfig", config = function() require("plugins.configs.rust-tools") require("core.utils").load_mappings "rust" From a1919bafc774f4db5484a654c71ee41f08049b9f Mon Sep 17 00:00:00 2001 From: krolyxon Date: Thu, 19 Jan 2023 15:59:14 +0530 Subject: [PATCH 3/7] lualine: disable lazyloading --- lua/plugins/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 3e09c2f..2510e51 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -173,6 +173,7 @@ local plugins = { }, ["nvim-lualine/lualine.nvim"] = { + lazy = false, config = function() require("plugins.configs.statusline") end, From 8b437e4177655342a052b67b0e03cfe8e8e8c6c3 Mon Sep 17 00:00:00 2001 From: krolyxon Date: Thu, 19 Jan 2023 16:06:21 +0530 Subject: [PATCH 4/7] 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 From ac90c1943a0d32bd0b64a1c068436fb6ec177057 Mon Sep 17 00:00:00 2001 From: krolyxon Date: Thu, 19 Jan 2023 16:18:04 +0530 Subject: [PATCH 5/7] some formatting --- init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 4a75fc1..6906674 100644 --- a/init.lua +++ b/init.lua @@ -2,6 +2,10 @@ require "core.options" require("core.utils").load_mappings() -- require("colors").core_setup() +-- add binaries installed by mason.nvim to path +vim.env.PATH = vim.env.PATH .. ":" .. vim.fn.stdpath "data" .. "/mason/bin" + + local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ @@ -16,10 +20,6 @@ end vim.opt.rtp:prepend(lazypath) require "plugins" --- add binaries installed by mason.nvim to path -vim.env.PATH = vim.env.PATH .. ":" .. vim.fn.stdpath "data" .. "/mason/bin" - - -- Set colorscheme require('rose-pine').setup({ disable_background = true From 306cb2a309244cd0fae714365acd06abd83a1039 Mon Sep 17 00:00:00 2001 From: krolyxon Date: Thu, 19 Jan 2023 16:42:07 +0530 Subject: [PATCH 6/7] vimwiki: lazyloading setup --- lua/plugins/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 23321e1..6793f48 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -119,7 +119,8 @@ local plugins = { -- misc ['vimwiki/vimwiki'] = { - config = function() + event = "VeryLazy", + init = function () vim.g.vimwiki_list = { { path = '~/dox/notes', From 514cf7a19dab4641489d566d22d1ab2f035a632a Mon Sep 17 00:00:00 2001 From: krolyxon Date: Thu, 19 Jan 2023 16:45:06 +0530 Subject: [PATCH 7/7] README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..30a6057 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +## Special Thanks +- [NvChad](https://github.com/nvchad/nvchad)