From ef5e431a8b123f2713a54a414cd490abbea9f7b2 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Wed, 13 Jan 2021 14:50:24 +0100 Subject: [PATCH] New feature to disable plugins from config Disable trimwhitespace by default --- changelog.md | 5 +++++ data/core/config.lua | 4 ++++ data/core/init.lua | 34 +++++++++++++++++++++++++++------- data/user/init.lua | 19 ++++++++++++++++++- 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/changelog.md b/changelog.md index bd7c780d..5925a724 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,11 @@ Lite XL is following closely [rxi/lite](https://github.com/rxi/lite) but with so This files document the differences between Lite XL and rxi/lite for each version. +### 1.16 + +Add config mechanism to disable loading of specific plugins by setting +`config. = false`. + ### 1.15 **Project directories** diff --git a/data/core/config.lua b/data/core/config.lua index d6f87bcd..56a1c0dc 100644 --- a/data/core/config.lua +++ b/data/core/config.lua @@ -19,4 +19,8 @@ config.line_limit = 80 config.max_symbols = 4000 config.max_project_files = 2000 +-- Disable plugin loading setting to false the config entry +-- of the same name. +config.trimwhitespace = false + return config diff --git a/data/core/init.lua b/data/core/init.lua index f022f5e2..42b7b8e3 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -252,17 +252,24 @@ local keymap = require "core.keymap" local config = require "core.config" local style = require "core.style" +------------------------------ Themes ---------------------------------------- + -- light theme: -- core.reload_module("colors.summer") +--------------------------- Key bindings ------------------------------------- + -- key binding: -- keymap.add { ["ctrl+escape"] = "core:quit" } + +------------------------------- Fonts ---------------------------------------- + -- customize fonts: -- style.font = renderer.font.load(DATADIR .. "/fonts/font.ttf", 14 * SCALE) -- style.code_font = renderer.font.load(DATADIR .. "/fonts/monospace.ttf", 13.5 * SCALE) -- --- fonts used by the editor: +-- font names used by lite: -- style.font : user interface -- style.big_font : big text in welcome screen -- style.icon_font : icons @@ -275,6 +282,16 @@ local style = require "core.style" -- possible values are: -- antialiasing: grayscale, subpixel -- hinting: none, slight, full + +------------------------------ Plugins ---------------------------------------- + +-- enable or disable plugin loading setting config entries: + +-- enable trimwhitespace, otherwise it is disable by default: +-- config.trimwhitespace = true +-- +-- disable detectindent, otherwise it is enabled by default +-- config.detectindent = false ]]) init_file:close() end @@ -483,12 +500,15 @@ function core.load_plugins() for _, root_dir in ipairs {DATADIR, USERDIR} do local files = system.list_dir(root_dir .. "/plugins") for _, filename in ipairs(files or {}) do - local modname = "plugins." .. filename:gsub(".lua$", "") - local ok = core.try(require, modname) - if ok then - core.log_quiet("Loaded plugin %q", modname) - else - no_errors = false + local basename = filename:gsub(".lua$", "") + if config[basename] ~= false then + local modname = "plugins." .. basename + local ok = core.try(require, modname) + if ok then + core.log_quiet("Loaded plugin %q", modname) + else + no_errors = false + end end end end diff --git a/data/user/init.lua b/data/user/init.lua index ab4a62a7..7f2364a6 100644 --- a/data/user/init.lua +++ b/data/user/init.lua @@ -7,17 +7,24 @@ local keymap = require "core.keymap" local config = require "core.config" local style = require "core.style" +------------------------------ Themes ---------------------------------------- + -- light theme: -- core.reload_module("colors.summer") +--------------------------- Key bindings ------------------------------------- + -- key binding: -- keymap.add { ["ctrl+escape"] = "core:quit" } + +------------------------------- Fonts ---------------------------------------- + -- customize fonts: -- style.font = renderer.font.load(DATADIR .. "/fonts/font.ttf", 14 * SCALE) -- style.code_font = renderer.font.load(DATADIR .. "/fonts/monospace.ttf", 13.5 * SCALE) -- --- fonts used by the editor: +-- font names used by lite: -- style.font : user interface -- style.big_font : big text in welcome screen -- style.icon_font : icons @@ -30,3 +37,13 @@ local style = require "core.style" -- possible values are: -- antialiasing: grayscale, subpixel -- hinting: none, slight, full + +------------------------------ Plugins ---------------------------------------- + +-- enable or disable plugin loading setting config entries: + +-- enable trimwhitespace, otherwise it is disable by default: +-- config.trimwhitespace = true +-- +-- disable detectindent, otherwise it is enabled by default +-- config.detectindent = false