From 8fad9a5ecddc88d57a531e4b0084544984f23d25 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Sat, 16 Jul 2022 18:13:16 -0400 Subject: Added profile and other missing configs --- .config/micro/plug/wc/CHANGELOG.md | 6 ++++++ .config/micro/plug/wc/LICENSE | 21 +++++++++++++++++++++ .config/micro/plug/wc/README.md | 4 ++++ .config/micro/plug/wc/help/wc.md | 25 +++++++++++++++++++++++++ .config/micro/plug/wc/info.json | 10 ++++++++++ .config/micro/plug/wc/repo.json | 22 ++++++++++++++++++++++ .config/micro/plug/wc/wc.lua | 37 +++++++++++++++++++++++++++++++++++++ 7 files changed, 125 insertions(+) create mode 100644 .config/micro/plug/wc/CHANGELOG.md create mode 100644 .config/micro/plug/wc/LICENSE create mode 100644 .config/micro/plug/wc/README.md create mode 100644 .config/micro/plug/wc/help/wc.md create mode 100644 .config/micro/plug/wc/info.json create mode 100644 .config/micro/plug/wc/repo.json create mode 100644 .config/micro/plug/wc/wc.lua (limited to '.config/micro/plug/wc') diff --git a/.config/micro/plug/wc/CHANGELOG.md b/.config/micro/plug/wc/CHANGELOG.md new file mode 100644 index 0000000..b36e4df --- /dev/null +++ b/.config/micro/plug/wc/CHANGELOG.md @@ -0,0 +1,6 @@ +Version 1.2.1 +* Fixed utf8 character count + +Version 1.2.0 ++ Now counts lines ++ Added Support for counting lines, words and characters in selection diff --git a/.config/micro/plug/wc/LICENSE b/.config/micro/plug/wc/LICENSE new file mode 100644 index 0000000..8c58ad0 --- /dev/null +++ b/.config/micro/plug/wc/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 bananaapple + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/.config/micro/plug/wc/README.md b/.config/micro/plug/wc/README.md new file mode 100644 index 0000000..78ff3c6 --- /dev/null +++ b/.config/micro/plug/wc/README.md @@ -0,0 +1,4 @@ +# Micro Word Count Plugin + +Word, character and line counter for micro editor. +(forked from https://github.com/adamnpeace/micro-wc-plugin) \ No newline at end of file diff --git a/.config/micro/plug/wc/help/wc.md b/.config/micro/plug/wc/help/wc.md new file mode 100644 index 0000000..ad36643 --- /dev/null +++ b/.config/micro/plug/wc/help/wc.md @@ -0,0 +1,25 @@ +# WordCount (wc) Plugin # + +The wc plugin provides the user with the ability to count either +characters or strings in any text being edited with micro. + +A word is defined as a string of characters delimited by white +space characters. White space characters are the set of characters +for which the iswspace(3) function returns true. + +A line is defined as a string of characters delimited by \n +characters, or by the beginning or end of the file. \r\n line +endings will be counted correctly as well, since there is only +one \n per \r\n. + +Character count includes white space and newline characters. + +To initiate the function, you can either: + +Press "F5" + +Or run: + +``` +> wc +``` diff --git a/.config/micro/plug/wc/info.json b/.config/micro/plug/wc/info.json new file mode 100644 index 0000000..b5b8886 --- /dev/null +++ b/.config/micro/plug/wc/info.json @@ -0,0 +1,10 @@ +{ + "name": "wc", + "description": "Word count plugin", + "website": "", + "install": "", + "version": "1.2.1", + "require": [ + "micro >= 2.0.0" + ] +} diff --git a/.config/micro/plug/wc/repo.json b/.config/micro/plug/wc/repo.json new file mode 100644 index 0000000..3f6a05d --- /dev/null +++ b/.config/micro/plug/wc/repo.json @@ -0,0 +1,22 @@ +[{ + "Name": "wc", + "Description": "Plugin to count words/characters in micro", + "Tags": ["wc", "word", "character", "count"], + "Website": "https://github.com/adamnpeace/micro-wc-plugin", + "Versions": [ + { + "Version": "1.1.0", + "Url": "https://github.com/adamnpeace/micro-wc-plugin/archive/v1.1.0.zip", + "Require": { + "micro": ">=2.0.0-1" + } + }, + { + "Version": "1.0.1", + "Url": "https://github.com/adamnpeace/micro-wc-plugin/archive/v1.0.1.zip", + "Require": { + "micro": ">=1.1.0" + } + } + ] +}] diff --git a/.config/micro/plug/wc/wc.lua b/.config/micro/plug/wc/wc.lua new file mode 100644 index 0000000..0e13677 --- /dev/null +++ b/.config/micro/plug/wc/wc.lua @@ -0,0 +1,37 @@ +VERSION = "1.2.1" + +local micro = import("micro") +local config = import("micro/config") +local util = import("micro/util") +local utf8 = import("unicode/utf8") + +function init() + config.MakeCommand("wc", wordCount, config.NoComplete) + config.AddRuntimeFile("wc", config.RTHelp, "help/wc.md") + config.TryBindKey("F5", "lua:wc.wordCount", false) +end + +function wordCount(bp) + -- Buffer of selection/whole document + local buffer + --Get active cursor (to get selection) + local cursor = bp.Buf:GetActiveCursor() + --If cursor exists and there is selection, convert selection byte[] to string + if cursor and cursor:HasSelection() then + buffer = util.String(cursor:GetSelection()) + else + --no selection, convert whole buffer byte[] to string + buffer = util.String(bp.Buf:Bytes()) + end + --length of the buffer/selection (string), utf8 friendly + charCount = utf8.RuneCountInString(buffer) + --Get word/line count using gsub's number of substitutions + -- number of substitutions, pattern: %S+ (more than one non-whitespace characters) + local _ , wordCount = buffer:gsub("%S+","") + -- number of substitutions, pattern: \n (number of newline characters) + local _, lineCount = buffer:gsub("\n", "") + --add one to line count (since we're counting separators not lines above) + lineCount = lineCount + 1 + --display the message + micro.InfoBar():Message("Lines:" .. lineCount .. " Words:"..wordCount.." Characters:"..charCount) +end -- cgit v1.2.3