aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/autowrap.lua14
1 files changed, 13 insertions, 1 deletions
diff --git a/plugins/autowrap.lua b/plugins/autowrap.lua
index 0f34eec..e318fd3 100644
--- a/plugins/autowrap.lua
+++ b/plugins/autowrap.lua
@@ -2,9 +2,13 @@
require "plugins.reflow"
local config = require "core.config"
local command = require "core.command"
+local common = require "core.common"
local DocView = require "core.docview"
-config.plugins.autowrap = common.merge({ files = { "%.md$", "%.txt$" } }, config.plugins.autowrap)
+config.plugins.autowrap = common.merge({
+ enable = false,
+ files = { "%.md$", "%.txt$" }
+}, config.plugins.autowrap)
local on_text_input = DocView.on_text_input
@@ -12,6 +16,8 @@ local on_text_input = DocView.on_text_input
DocView.on_text_input = function(self, ...)
on_text_input(self, ...)
+ if not config.plugins.autowrap.enable then return end
+
-- early-exit if the filename does not match a file type pattern
local filename = self.doc.filename or ""
local matched = false
@@ -35,3 +41,9 @@ DocView.on_text_input = function(self, ...)
command.perform("doc:move-to-end-of-line")
end
end
+
+command.add(nil, {
+ ["auto-wrap:toggle"] = function()
+ config.plugins.autowrap.enable = not config.plugins.autowrap.enable
+ end
+})