diff --git a/etc/skel/.config/micro/plug/aspell/aspell.lua b/etc/skel/.config/micro/plug/aspell/aspell.lua index 4e7ae78..736e4ec 100644 --- a/etc/skel/.config/micro/plug/aspell/aspell.lua +++ b/etc/skel/.config/micro/plug/aspell/aspell.lua @@ -1,4 +1,4 @@ -VERSION = "1.2.0" +VERSION = "1.2.1" local micro = import("micro") local shell = import("micro/shell") @@ -38,36 +38,36 @@ local lock = false local next = nil function runAspell(buf, onExit, ...) - local text = util.String(buf:Bytes()) - - -- Escape for aspell (it interprets lines that start - -- with % @ ^ ! etc.) - text = text:gsub("\n", "\n^"):gsub("^", "^") - -- Enable terse mode - text = "!\n" .. text - -- Escape for shell - text = "'" .. text:gsub("'", "'\\''") .. "'" - - local options = "" - -- FIXME: we should support non-utf8 encodings with '--encoding' + local options = {"pipe", "--encoding=utf-8"} if filterModes[buf:FileType()] then - options = options .. " --mode=" .. filterModes[buf:FileType()] + options[#options + 1] = "--mode=" .. filterModes[buf:FileType()] end if buf.Settings["aspell.lang"] ~= "" then - options = options .. " --lang=" .. buf.Settings["aspell.lang"] + options[#options + 1] = "--lang=" .. buf.Settings["aspell.lang"] end if buf.Settings["aspell.dict"] ~= "" then - options = options .. " --master=" .. buf.Settings["aspell.dict"] + options[#options + 1] = "--master=" .. buf.Settings["aspell.dict"] end if buf.Settings["aspell.sugmode"] ~= "" then - options = options .. " --sug-mode=" .. buf.Settings["aspell.sugmode"] + options[#options + 1] = "--sug-mode=" .. buf.Settings["aspell.sugmode"] end - if buf.Settings["aspell.args"] ~= "" then - options = options .. " " .. buf.Settings["aspell.args"] + for _, argument in ipairs(split(buf.Settings["aspell.args"], " ")) do + options[#options + 1] = argument end - shell.JobStart("printf %s " .. text .. " | aspell pipe" .. options, nil, + local job = shell.JobSpawn("aspell", options, nil, nil, onExit, buf, unpack(arg)) + -- Enable terse mode + shell.JobSend(job, "!\n") + for i=0, buf:LinesNum() - 1 do + local line = util.String(buf:LineBytes(i)) + -- Escape for aspell (it interprets lines that start + -- with % @ ^ ! etc.) + line = "^" .. line .. "\n" + + shell.JobSend(job, line) + end + job.Stdin:Close() end function spellcheck(buf) @@ -196,23 +196,23 @@ function addpersonal(bp, args) local wordInBuf = util.String(buf:Substr(misspell.mstart, misspell.mend)) if loc:GreaterEqual(misspell.mstart) and loc:LessEqual(misspell.mend) and wordInBuf == misspell.word then - local options = "" + local options = {"pipe", "--encoding=utf-8"} if buf.Settings["aspell.lang"] ~= "" then - options = options .. " --lang=" - .. buf.Settings["aspell.lang"] + options[#options + 1] = "--lang=" .. buf.Settings["aspell.lang"] end if buf.Settings["aspell.dict"] ~= "" then - options = options .. " --master=" - .. buf.Settings["aspell.dict"] + options[#options + 1] = "--master=" .. buf.Settings["aspell.dict"] end - if buf.Settings["aspell.args"] ~= "" then - options = options .. " " .. buf.Settings["aspell.args"] + for _, argument in ipairs(split(buf.Settings["aspell.args"], " ")) do + options[#options + 1] = argument end - shell.ExecCommand("sh", "-c", "echo '*" .. misspell.word - .. "\n#\n' | aspell pipe" .. options) + local job = shell.JobSpawn("aspell", options, nil, nil, function () + spellcheck(buf) + end) + shell.JobSend(job, "*" .. misspell.word .. "\n#\n") + job.Stdin:Close() - spellcheck(buf) if args then return end diff --git a/etc/skel/.config/micro/plug/aspell/help/aspell.md b/etc/skel/.config/micro/plug/aspell/help/aspell.md index c3a028a..10b2a8e 100644 --- a/etc/skel/.config/micro/plug/aspell/help/aspell.md +++ b/etc/skel/.config/micro/plug/aspell/help/aspell.md @@ -5,7 +5,8 @@ of XML, HTML, TeX and Markdown. On C++, C and Perl only comments and string literals will be checked. You need to have Aspell installed and available in your PATH. It does not come -with this plugin. This plugin also currently doesn't work on Windows. +with this plugin. If you are on Windows, you can install Aspell through +[MSYS2](https://www.msys2.org/). ## Options diff --git a/etc/skel/.config/micro/plug/aspell/repo.json b/etc/skel/.config/micro/plug/aspell/repo.json index baa1289..2fa3c1b 100644 --- a/etc/skel/.config/micro/plug/aspell/repo.json +++ b/etc/skel/.config/micro/plug/aspell/repo.json @@ -4,6 +4,13 @@ "Tags": ["spellchecking", "spelling", "aspell", "spellchecker"], "Website": "https://github.com/priner/micro-aspell-plugin", "Versions": [ + { + "Version": "1.2.1", + "Url": "https://github.com/priner/micro-aspell-plugin/archive/v1.2.1.zip", + "Require": { + "micro": ">=2.0.7" + } + }, { "Version": "1.2.0", "Url": "https://github.com/priner/micro-aspell-plugin/archive/v1.2.0.zip", diff --git a/etc/skel/.config/micro/plug/misspell/README.md b/etc/skel/.config/micro/plug/misspell/README.md new file mode 100644 index 0000000..7c452c3 --- /dev/null +++ b/etc/skel/.config/micro/plug/misspell/README.md @@ -0,0 +1,7 @@ +# Misspell Plugin for Micro + +This repository holds the misspell plugin for micro. + +Install with `> plugin install misspell`, +https://github.com/client9/misspell needs to be in your PATH. +This plugin will lint text for spelling mistakes. diff --git a/etc/skel/.config/micro/plug/misspell/misspell.lua b/etc/skel/.config/micro/plug/misspell/misspell.lua new file mode 100644 index 0000000..924bbce --- /dev/null +++ b/etc/skel/.config/micro/plug/misspell/misspell.lua @@ -0,0 +1,9 @@ +VERSION = "0.2.0" + +local config = import("micro/config") + +function init() + -- uses the default linter plugin + -- matches any filetype + linter.makeLinter("misspell", "", "misspell", {"%f"}, "%f:%l:%c: %m", {}, false, true) +end \ No newline at end of file diff --git a/etc/skel/.config/micro/plug/misspell/repo.json b/etc/skel/.config/micro/plug/misspell/repo.json new file mode 100644 index 0000000..3208340 --- /dev/null +++ b/etc/skel/.config/micro/plug/misspell/repo.json @@ -0,0 +1,22 @@ +[{ + "Name": "misspell", + "Description": "plugin that corrects commonly misspelled words", + "Tags": ["spell", "check", "misspell"], + "Website": "https://github.com/onodera-punpun/micro-misspell-plugin", + "Versions": [ + { + "Version": "0.2.0", + "Url": "https://github.com/micro-editor/updated-plugins/releases/download/v1.0.0/misspell-0.2.0.zip", + "Require": { + "micro": ">=2.0.0-1" + } + }, + { + "Version": "0.1.0", + "Url": "https://github.com/onodera-punpun/micro-misspell-plugin/archive/0.1.0.zip", + "Require": { + "micro": ">=1.0.3" + } + } + ] +}] diff --git a/etc/skel/.config/micro/settings.json b/etc/skel/.config/micro/settings.json index cb79748..7551ae9 100644 --- a/etc/skel/.config/micro/settings.json +++ b/etc/skel/.config/micro/settings.json @@ -1,4 +1,5 @@ { "autosu": true, + "colorscheme": "geany", "mkparents": true }