aboutsummaryrefslogtreecommitdiff
path: root/spellcheck.lua
diff options
context:
space:
mode:
Diffstat (limited to 'spellcheck.lua')
-rw-r--r--spellcheck.lua20
1 files changed, 13 insertions, 7 deletions
diff --git a/spellcheck.lua b/spellcheck.lua
index ff2db5e..84f2ef5 100644
--- a/spellcheck.lua
+++ b/spellcheck.lua
@@ -15,19 +15,23 @@ spellcheck.get_lang = function()
or spellcheck.default_lang
end
-local supress_stdout = ' >/dev/null'
-local supress_stderr = ' 2>/dev/null'
-local supress_output = supress_stdout .. supress_stderr
-if os.execute('type enchant' .. supress_output) then
+local which do
+ local path = os.getenv"PATH":gsub(":","/?;") .. "/?"
+ function which(executable)
+ return package.searchpath(executable, path, "", "")
+ end
+end
+
+if which"enchant" then
spellcheck.cmd = 'enchant -d %s -a'
spellcheck.list_cmd = 'enchant -l -d %s'
-elseif os.execute('type enchant-2' .. supress_output) then
+elseif which"enchant-2" then
spellcheck.cmd = 'enchant-2 -d %s -a'
spellcheck.list_cmd = 'enchant-2 -l -d %s'
-elseif os.execute('type aspell' .. supress_output) then
+elseif which"aspell" then
spellcheck.cmd = 'aspell pipe -l %s'
spellcheck.list_cmd = 'aspell list -l %s'
-elseif os.execute('type hunspell' .. supress_output) then
+elseif which"hunspell" then
spellcheck.cmd = 'hunspell -d %s'
spellcheck.list_cmd = 'hunspell -l -d %s'
else
@@ -55,6 +59,8 @@ if vis.lexers then
end
end
+local supress_stderr = ' 2>/dev/null'
+
-- Return nil or a sequence of misspelled words in a specific file range or text
-- by calling the spellchecker's list command.
-- If given a range we will use vis:pipe to get our typos from the spellchecker.