From 198252c258b3313d941ce9d53c6ed73430bf811d Mon Sep 17 00:00:00 2001 From: jgmdev Date: Fri, 11 Mar 2022 05:12:10 -0400 Subject: spellcheck: added context menu --- plugins/spellcheck.lua | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'plugins/spellcheck.lua') 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" } +}) -- cgit v1.2.3