Compare commits
12
Commits
c87fc414c5
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3926d5f6c
|
||
|
|
5e4dc431f0
|
||
|
|
97f3962d46
|
||
|
|
357580127c
|
||
|
|
c542d26de1
|
||
|
|
1977a65cb0
|
||
|
|
f61e0a1419
|
||
|
|
c00f1ae51e
|
||
|
|
93f4128beb
|
||
|
|
9f327d4f0e
|
||
|
|
e1ce2a385f
|
||
|
|
bc4d162b63
|
No files matched your search
@@ -0,0 +1,3 @@
|
|||||||
|
indent_type = "Spaces"
|
||||||
|
indent_width = 2
|
||||||
|
column_width = 100
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
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
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
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
|
This is a Neovim plugin to autocorrect common misspellings and typos. If you
|
||||||
type _teh_, neovim will automatically correct it to _the_.
|
type _teh_, neovim will automatically correct it to _the_.
|
||||||
|
|
||||||
It's based on [vim-autocorrect](https://github.com/panozzaj/vim-autocorrect),
|
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
|
but designed for Neovim and written in pure Lua. It also loads the dictionary
|
||||||
the dictionary in the background, so it doesn't delay startup time.
|
in the background, so it doesn't delay startup time.
|
||||||
|
|
||||||
|
## Demo
|
||||||
|
|
||||||
|
[](https://asciinema.org/a/WtUg846Z7wNiMrzPgjod1picV)
|
||||||
|
|
||||||
## Installing
|
## Installing
|
||||||
|
|
||||||
@@ -13,16 +17,18 @@ the dictionary in the background, so it doesn't delay startup time.
|
|||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
"https://git.sr.ht/~swaits/thethethe.nvim",
|
"https://git.swaits.com/swaits/thethethe.nvim",
|
||||||
|
lazy = true,
|
||||||
|
event = "VeryLazy",
|
||||||
opts = { },
|
opts = { },
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### [packer](https://github.com/wbthomason/packer.nvim)
|
### [pckr](https://github.com/lewis6991/pckr.nvim)
|
||||||
|
|
||||||
```lua
|
```lua
|
||||||
{
|
{
|
||||||
"https://git.sr.ht/~swaits/thethethe.nvim",
|
"https://git.swaits.com/swaits/thethethe.nvim",
|
||||||
config = function()
|
config = function()
|
||||||
require("thethethe").setup()
|
require("thethethe").setup()
|
||||||
end
|
end
|
||||||
@@ -32,7 +38,7 @@ the dictionary in the background, so it doesn't delay startup time.
|
|||||||
### [vim-plug](https://github.com/junegunn/vim-plug)
|
### [vim-plug](https://github.com/junegunn/vim-plug)
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
Plug 'https://git.sr.ht/~swaits/thethethe.nvim'
|
Plug 'https://git.swaits.com/swaits/thethethe.nvim'
|
||||||
lua require("thethethe").setup()
|
lua require("thethethe").setup()
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -49,7 +55,29 @@ opts = {
|
|||||||
|
|
||||||
## Future Directions
|
## Future Directions
|
||||||
|
|
||||||
- Allow specifying a custom dictionary files
|
- Allow specifying custom dictionary files
|
||||||
- List custom dictionary entries directly in `opts {}`
|
- List custom dictionary entries directly in `opts {}`
|
||||||
- Split current (large!) dictionary into something like small, medium, large
|
- Split current (large!) dictionary into something like small, medium, large
|
||||||
- Recategorize current dictionary "English" and add options to include non-English dictionaries
|
- 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 = {}
|
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)
|
function M.setup(opts)
|
||||||
-- check for default overrides passed in
|
opts = opts or {}
|
||||||
if opts then
|
vim.defer_fn(function()
|
||||||
config.delay_ms = opts.delay_ms or config.delay_ms
|
for line in require("thethethe.dictionary"):gmatch("[^\n]+") do
|
||||||
end
|
local typo, fix = line:match("^([^:]+):(.+)$")
|
||||||
|
if typo and fix then
|
||||||
-- execute the function after config.delay_ms
|
vim.cmd.iabbrev(typo, fix)
|
||||||
vim.defer_fn(load_abbreviations, config.delay_ms)
|
end
|
||||||
|
end
|
||||||
|
end, opts.delay_ms or 2000)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
Reference in new issue
Block a user