From 355178a7bb6a6bddcdc1ed723119d17ee7fb5281 Mon Sep 17 00:00:00 2001 From: Pocco81 Date: Tue, 20 Jul 2021 13:19:31 -0500 Subject: [PATCH 1/3] 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) From 5531edf8e46e4d805acab5075ec5bc628538e150 Mon Sep 17 00:00:00 2001 From: Pocco81 Date: Tue, 20 Jul 2021 23:20:00 -0500 Subject: [PATCH 2/3] fix: formatted code with luafmt --- init.lua | 4 ++-- lua/utils.lua | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index b8a7a3d..0ff438b 100644 --- a/init.lua +++ b/init.lua @@ -3,8 +3,8 @@ require "options" local chad_modules = { "pluginList", "plugins.bufferline", - "mappings", - "utils", + "mappings", + "utils" } local async diff --git a/lua/utils.lua b/lua/utils.lua index c245340..9765f54 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -1,5 +1,8 @@ -- hide line numbers , statusline in specific buffers! -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) +]], + false +) From b54c4ca5de0df81c57543a8210ca1dc342b09541 Mon Sep 17 00:00:00 2001 From: siduck76 Date: Wed, 21 Jul 2021 23:00:19 +0530 Subject: [PATCH 3/3] better error message --- init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.lua b/init.lua index 0ff438b..13b4fe9 100644 --- a/init.lua +++ b/init.lua @@ -15,7 +15,7 @@ async = 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("Error loading module : " .. chad_modules[i]) print(res) -- print stack traceback of the error end end