Disable `trimwhitespace` and `drawwhitespace` via their configs (#1446)
Instead of completely disabling them, we now use their internal toggle. Also moved `drawwhitespace` commands inside the plugin. --- * Fixed bug where commands would show even when plugin was disbled. Also removed antiquated way of disabling. * Fixed typos. * Also moved trimwhitespace out of config, if it already has a default enabled value of false. * Changed documentation. * Clarified comments.
This commit is contained in:
parent
b005454652
commit
1becf35508
|
@ -107,7 +107,7 @@ end
|
||||||
function command.add_defaults()
|
function command.add_defaults()
|
||||||
local reg = {
|
local reg = {
|
||||||
"core", "root", "command", "doc", "findreplace",
|
"core", "root", "command", "doc", "findreplace",
|
||||||
"files", "drawwhitespace", "dialog", "log", "statusbar"
|
"files", "dialog", "log", "statusbar"
|
||||||
}
|
}
|
||||||
for _, name in ipairs(reg) do
|
for _, name in ipairs(reg) do
|
||||||
require("core.commands." .. name)
|
require("core.commands." .. name)
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
local command = require "core.command"
|
|
||||||
local config = require "core.config"
|
|
||||||
|
|
||||||
command.add(nil, {
|
|
||||||
["draw-whitespace:toggle"] = function()
|
|
||||||
config.draw_whitespace = not config.draw_whitespace
|
|
||||||
end,
|
|
||||||
|
|
||||||
["draw-whitespace:disable"] = function()
|
|
||||||
config.draw_whitespace = false
|
|
||||||
end,
|
|
||||||
|
|
||||||
["draw-whitespace:enable"] = function()
|
|
||||||
config.draw_whitespace = true
|
|
||||||
end,
|
|
||||||
})
|
|
|
@ -101,8 +101,5 @@ setmetatable(config.plugins, {
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Disable these plugins by default.
|
|
||||||
config.plugins.trimwhitespace = false
|
|
||||||
config.plugins.drawwhitespace = false
|
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
|
@ -531,12 +531,9 @@ local style = require "core.style"
|
||||||
|
|
||||||
------------------------------ Plugins ----------------------------------------
|
------------------------------ Plugins ----------------------------------------
|
||||||
|
|
||||||
-- enable or disable plugin loading setting config entries:
|
-- disable plugin loading setting config entries:
|
||||||
|
|
||||||
-- enable plugins.trimwhitespace, otherwise it is disabled by default:
|
-- disable plugin detectindent, otherwise it is enabled by default:
|
||||||
-- config.plugins.trimwhitespace = true
|
|
||||||
--
|
|
||||||
-- disable detectindent, otherwise it is enabled by default
|
|
||||||
-- config.plugins.detectindent = false
|
-- config.plugins.detectindent = false
|
||||||
|
|
||||||
---------------------------- Miscellaneous -------------------------------------
|
---------------------------- Miscellaneous -------------------------------------
|
||||||
|
|
|
@ -4,11 +4,12 @@ local core = require "core"
|
||||||
local style = require "core.style"
|
local style = require "core.style"
|
||||||
local DocView = require "core.docview"
|
local DocView = require "core.docview"
|
||||||
local common = require "core.common"
|
local common = require "core.common"
|
||||||
|
local command = require "core.command"
|
||||||
local config = require "core.config"
|
local config = require "core.config"
|
||||||
local Highlighter = require "core.doc.highlighter"
|
local Highlighter = require "core.doc.highlighter"
|
||||||
|
|
||||||
config.plugins.drawwhitespace = common.merge({
|
config.plugins.drawwhitespace = common.merge({
|
||||||
enabled = true,
|
enabled = false,
|
||||||
show_leading = true,
|
show_leading = true,
|
||||||
show_trailing = true,
|
show_trailing = true,
|
||||||
show_middle = true,
|
show_middle = true,
|
||||||
|
@ -43,7 +44,7 @@ config.plugins.drawwhitespace = common.merge({
|
||||||
description = "Disable or enable the drawing of white spaces.",
|
description = "Disable or enable the drawing of white spaces.",
|
||||||
path = "enabled",
|
path = "enabled",
|
||||||
type = "toggle",
|
type = "toggle",
|
||||||
default = true
|
default = false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label = "Show Leading",
|
label = "Show Leading",
|
||||||
|
@ -342,3 +343,18 @@ function DocView:draw_line_text(idx, x, y)
|
||||||
|
|
||||||
return draw_line_text(self, idx, x, y)
|
return draw_line_text(self, idx, x, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
command.add(nil, {
|
||||||
|
["draw-whitespace:toggle"] = function()
|
||||||
|
config.plugins.drawwhitespace.enabled = not config.drawwhitespace.enabled
|
||||||
|
end,
|
||||||
|
|
||||||
|
["draw-whitespace:disable"] = function()
|
||||||
|
config.plugins.drawwhitespace.enabled = false
|
||||||
|
end,
|
||||||
|
|
||||||
|
["draw-whitespace:enable"] = function()
|
||||||
|
config.plugins.drawwhitespace.enabled = true
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ local Doc = require "core.doc"
|
||||||
---@field enabled boolean
|
---@field enabled boolean
|
||||||
---@field trim_empty_end_lines boolean
|
---@field trim_empty_end_lines boolean
|
||||||
config.plugins.trimwhitespace = common.merge({
|
config.plugins.trimwhitespace = common.merge({
|
||||||
enabled = true,
|
enabled = false,
|
||||||
trim_empty_end_lines = false,
|
trim_empty_end_lines = false,
|
||||||
config_spec = {
|
config_spec = {
|
||||||
name = "Trim Whitespace",
|
name = "Trim Whitespace",
|
||||||
|
@ -17,7 +17,7 @@ config.plugins.trimwhitespace = common.merge({
|
||||||
description = "Disable or enable the trimming of white spaces by default.",
|
description = "Disable or enable the trimming of white spaces by default.",
|
||||||
path = "enabled",
|
path = "enabled",
|
||||||
type = "toggle",
|
type = "toggle",
|
||||||
default = true
|
default = false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label = "Trim Empty End Lines",
|
label = "Trim Empty End Lines",
|
||||||
|
|
Loading…
Reference in New Issue