aboutsummaryrefslogtreecommitdiff
path: root/plugins/spellcheck.lua
diff options
context:
space:
mode:
authorFrancesco <francesco.bbt@gmail.com>2021-08-17 22:44:17 +0200
committerGitHub <noreply@github.com>2021-08-17 22:44:17 +0200
commit49d3d21c987645b448184a752043946ed90d6031 (patch)
treeb187286f2ed78fa9317f288dc0c5144840bcdad9 /plugins/spellcheck.lua
parenta42a0d57b08a9080ed9fd8fa84f1269e3847980f (diff)
parent9689846686f77dc0aa1e6f4d31fbfc42998c2085 (diff)
downloadlite-xl-plugins-49d3d21c987645b448184a752043946ed90d6031.tar.gz
lite-xl-plugins-49d3d21c987645b448184a752043946ed90d6031.zip
Merge pull request #45 from lite-xl/2.0
2.0 Merge
Diffstat (limited to 'plugins/spellcheck.lua')
-rw-r--r--plugins/spellcheck.lua17
1 files changed, 9 insertions, 8 deletions
diff --git a/plugins/spellcheck.lua b/plugins/spellcheck.lua
index 975ef91..db58606 100644
--- a/plugins/spellcheck.lua
+++ b/plugins/spellcheck.lua
@@ -1,4 +1,4 @@
--- mod-version:1 -- lite-xl 1.16
+-- mod-version:2 -- lite-xl 2.0
local core = require "core"
local style = require "core.style"
local config = require "core.config"
@@ -7,11 +7,12 @@ local common = require "core.common"
local DocView = require "core.docview"
local Doc = require "core.doc"
-config.spellcheck_files = { "%.txt$", "%.md$", "%.markdown$" }
+config.plugins.spellcheck = {}
+config.spellcheck.files = { "%.txt$", "%.md$", "%.markdown$" }
if PLATFORM == "Windows" then
- config.dictionary_file = EXEDIR .. "/words.txt"
+ config.plugins.spellcheck.dictionary_file = EXEDIR .. "/words.txt"
else
- config.dictionary_file = "/usr/share/dict/words"
+ config.plugins.spellcheck.dictionary_file = "/usr/share/dict/words"
end
@@ -22,7 +23,7 @@ local words
core.add_thread(function()
local t = {}
local i = 0
- for line in io.lines(config.dictionary_file) do
+ for line in io.lines(config.plugins.spellcheck.dictionary_file) do
for word in line:gmatch(word_pattern) do
t[word:lower()] = true
end
@@ -31,7 +32,7 @@ core.add_thread(function()
end
words = t
core.redraw = true
- core.log_quiet("Finished loading dictionary file: \"%s\"", config.dictionary_file)
+ core.log_quiet("Finished loading dictionary file: \"%s\"", config.plugins.spellcheck.dictionary_file)
end)
@@ -64,7 +65,7 @@ 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.spellcheck_files) then
+ or not matches_any(self.doc.filename or "", config.plugins.spellcheck.files) then
return
end
@@ -120,7 +121,7 @@ command.add("core.docview", {
return
end
if word then
- local fp = assert(io.open(config.dictionary_file, "a"))
+ local fp = assert(io.open(config.plugins.spellcheck.dictionary_file, "a"))
fp:write("\n" .. word .. "\n")
fp:close()
words[word] = true