aboutsummaryrefslogtreecommitdiff
path: root/plugins/spellcheck.lua
diff options
context:
space:
mode:
authorjgmdev <jgmdev@gmail.com>2022-03-11 05:12:10 -0400
committerjgmdev <jgmdev@gmail.com>2022-05-22 13:16:10 -0400
commit198252c258b3313d941ce9d53c6ed73430bf811d (patch)
tree916d74b0d4544a2d15ee01b87ead82f7d47fc814 /plugins/spellcheck.lua
parent9aa8654d206e22c1162adc0bfd91c6b197c91b7b (diff)
downloadlite-xl-plugins-198252c258b3313d941ce9d53c6ed73430bf811d.tar.gz
lite-xl-plugins-198252c258b3313d941ce9d53c6ed73430bf811d.zip
spellcheck: added context menu
Diffstat (limited to 'plugins/spellcheck.lua')
-rw-r--r--plugins/spellcheck.lua23
1 files changed, 19 insertions, 4 deletions
diff --git a/plugins/spellcheck.lua b/plugins/spellcheck.lua
index 190087a..30e16c9 100644
--- a/plugins/spellcheck.lua
+++ b/plugins/spellcheck.lua
@@ -9,7 +9,9 @@ local Doc = require "core.doc"
config.plugins.spellcheck = common.merge({
files = { "%.txt$", "%.md$", "%.markdown$" },
- dictionary_file = (PLATFORM == "Windows" and EXEDIR .. "/words.txt" or "/usr/share/dict/words")
+ dictionary_file = PLATFORM == "Windows"
+ and EXEDIR .. "/words.txt"
+ or "/usr/share/dict/words"
}, config.plugins.spellcheck)
local last_input_time = 0
@@ -28,7 +30,10 @@ core.add_thread(function()
end
words = t
core.redraw = true
- core.log_quiet("Finished loading dictionary file: \"%s\"", config.plugins.spellcheck.dictionary_file)
+ core.log_quiet(
+ "Finished loading dictionary file: \"%s\"",
+ config.plugins.spellcheck.dictionary_file
+ )
end)
@@ -60,8 +65,11 @@ local draw_line_text = DocView.draw_line_text
function DocView:draw_line_text(idx, x, y)
draw_line_text(self, idx, x, y)
- if not words
- or not matches_any(self.doc.filename or "", config.plugins.spellcheck.files) then
+ if
+ not words
+ or
+ not matches_any(self.doc.filename or "", config.plugins.spellcheck.files)
+ then
return
end
@@ -175,3 +183,10 @@ command.add("core.docview", {
end,
})
+
+local contextmenu = require "plugins.contextmenu"
+contextmenu:register("core.docview", {
+ contextmenu.DIVIDER,
+ { text = "View Suggestions", command = "spell-check:replace" },
+ { text = "Add to Dictionary", command = "spell-check:add-to-dictionary" }
+})