From 355178a7bb6a6bddcdc1ed723119d17ee7fb5281 Mon Sep 17 00:00:00 2001 From: Pocco81 Date: Tue, 20 Jul 2021 13:19:31 -0500 Subject: [PATCH] feat: secure calls + disabled all builtin plugins --- init.lua | 19 ++++++++++++++----- lua/options.lua | 33 +++++++++++++++++++++++---------- lua/utils.lua | 13 ++----------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/init.lua b/init.lua index a1ac6ef..b8a7a3d 100644 --- a/init.lua +++ b/init.lua @@ -1,15 +1,24 @@ require "options" +local chad_modules = { + "pluginList", + "plugins.bufferline", + "mappings", + "utils", +} + local async async = vim.loop.new_async( vim.schedule_wrap( function() - require "pluginList" - require "plugins.bufferline" - require "mappings" - require("utils").hideStuff() - + for i = 1, #chad_modules, 1 do + local ok, res = xpcall(require, debug.traceback, chad_modules[i]) + if not (ok) then + print("NvChad [E0]: There was an error loading the module '" .. chad_modules[i] .. "' -->") + print(res) -- print stack traceback of the error + end + end async:close() end ) diff --git a/lua/options.lua b/lua/options.lua index 2210681..2cdf24e 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -46,16 +46,29 @@ g.mapleader = " " g.auto_save = false -- disable builtin vim plugins -g.loaded_gzip = 0 -g.loaded_tar = 0 -g.loaded_tarPlugin = 0 -g.loaded_zipPlugin = 0 -g.loaded_2html_plugin = 0 -g.loaded_netrw = 0 -g.loaded_netrwPlugin = 0 -g.loaded_matchit = 0 -g.loaded_matchparen = 0 -g.loaded_spec = 0 +local disabled_built_ins = { + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "gzip", + "zip", + "zipPlugin", + "tar", + "tarPlugin", + "getscript", + "getscriptPlugin", + "vimball", + "vimballPlugin", + "2html_plugin", + "logipat", + "rrhelper", + "spellfile_plugin" +} + +for _, plugin in pairs(disabled_built_ins) do + vim.g["loaded_" .. plugin] = 1 +end local M = {} diff --git a/lua/utils.lua b/lua/utils.lua index cf915ed..c245340 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -1,14 +1,5 @@ -local M = {} - -- hide line numbers , statusline in specific buffers! -M.hideStuff = function() - vim.api.nvim_exec( - [[ +vim.api.nvim_exec([[ au TermOpen term://* setlocal nonumber laststatus=0 au BufEnter,BufWinEnter,WinEnter,CmdwinEnter * if bufname('%') == "NvimTree" | set laststatus=0 | else | set laststatus=2 | endif -]], - false - ) -end - -return M +]], false)