Compare commits
10
Commits
c87fc414c5
...
97f3962d46
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97f3962d46
|
||
|
|
357580127c
|
||
|
|
c542d26de1
|
||
|
|
1977a65cb0
|
||
|
|
f61e0a1419
|
||
|
|
c00f1ae51e
|
||
|
|
93f4128beb
|
||
|
|
9f327d4f0e
|
||
|
|
e1ce2a385f
|
||
|
|
bc4d162b63
|
No files matched your search
+11
@@ -0,0 +1,11 @@
|
||||
image: alpine/edge
|
||||
secrets:
|
||||
- 88cce185-d2ec-4573-9546-e33f36f79bbf
|
||||
sources:
|
||||
- git+ssh://git@git.sr.ht/~swaits/thethethe.nvim
|
||||
tasks:
|
||||
- mirror-to-github: |
|
||||
cd ~/thethethe.nvim
|
||||
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
|
||||
git remote add github git@github.com:swaits/thethethe.nvim.git
|
||||
git push --mirror github
|
||||
@@ -0,0 +1,3 @@
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
column_width = 100
|
||||
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Stephen Waits <steve@waits.net>
|
||||
Copyright © 2023 Stephen Waits <steve@waits.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
# thethethe
|
||||
# thethethe.nvim
|
||||
|
||||
This is a Neovim plugin to autocorrect common misspellings and typos. If you
|
||||
type _teh_, neovim will automatically correct it to _the_.
|
||||
|
||||
It's based on [vim-autocorrect](https://github.com/panozzaj/vim-autocorrect),
|
||||
but designed for Neovim and written in pure Lua. Unlike that plugin, this loads
|
||||
the dictionary in the background, so it doesn't delay startup time.
|
||||
but designed for Neovim and written in pure Lua. It also loads the dictionary
|
||||
in the background, so it doesn't delay startup time.
|
||||
|
||||
## Demo
|
||||
|
||||
[](https://asciinema.org/a/WtUg846Z7wNiMrzPgjod1picV)
|
||||
|
||||
## Installing
|
||||
|
||||
@@ -14,11 +18,13 @@ the dictionary in the background, so it doesn't delay startup time.
|
||||
```lua
|
||||
{
|
||||
"https://git.sr.ht/~swaits/thethethe.nvim",
|
||||
lazy = true,
|
||||
event = "VeryLazy",
|
||||
opts = { },
|
||||
}
|
||||
```
|
||||
|
||||
### [packer](https://github.com/wbthomason/packer.nvim)
|
||||
### [pckr](https://github.com/lewis6991/pckr.nvim)
|
||||
|
||||
```lua
|
||||
{
|
||||
@@ -49,7 +55,29 @@ opts = {
|
||||
|
||||
## Future Directions
|
||||
|
||||
- Allow specifying a custom dictionary files
|
||||
- Allow specifying custom dictionary files
|
||||
- List custom dictionary entries directly in `opts {}`
|
||||
- Split current (large!) dictionary into something like small, medium, large
|
||||
- Recategorize current dictionary "English" and add options to include non-English dictionaries
|
||||
|
||||
## MIT License
|
||||
|
||||
Copyright © 2023 Stephen Waits <steve@waits.net>
|
||||
|
||||
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.
|
||||
@@ -1,6 +0,0 @@
|
||||
local M = {}
|
||||
|
||||
-- Time (milliseconds) to wait before loading abbreviations
|
||||
M.delay_ms = 2000
|
||||
|
||||
return M
|
||||
+9
-31
@@ -1,37 +1,15 @@
|
||||
local M = {}
|
||||
|
||||
-- load our default configuration
|
||||
local config = require("thethethe.config")
|
||||
|
||||
-- load abbreviations.dict
|
||||
local function load_abbreviations()
|
||||
-- load our dictionary string
|
||||
local s = require("thethethe.dictionary")
|
||||
|
||||
-- split dictionary by lines
|
||||
for line in s:gmatch("([^\n]*)\n?") do
|
||||
-- split each line by the colon
|
||||
local parts = {}
|
||||
for part in line:gmatch("[^:]+") do
|
||||
table.insert(parts, part)
|
||||
end
|
||||
|
||||
if #parts == 2 and parts[1] and parts[2] then
|
||||
-- Add abbreviation via `iabbrev` (through vim.cmd)
|
||||
vim.cmd(string.format("iabbrev %s %s", parts[1], parts[2]))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- create our exported setup() function
|
||||
function M.setup(opts)
|
||||
-- check for default overrides passed in
|
||||
if opts then
|
||||
config.delay_ms = opts.delay_ms or config.delay_ms
|
||||
end
|
||||
|
||||
-- execute the function after config.delay_ms
|
||||
vim.defer_fn(load_abbreviations, config.delay_ms)
|
||||
opts = opts or {}
|
||||
vim.defer_fn(function()
|
||||
for line in require("thethethe.dictionary"):gmatch("[^\n]+") do
|
||||
local typo, fix = line:match("^([^:]+):(.+)$")
|
||||
if typo and fix then
|
||||
vim.cmd.iabbrev(typo, fix)
|
||||
end
|
||||
end
|
||||
end, opts.delay_ms or 2000)
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in new issue
Block a user