From 684bdf6ff8a0d438a774429ccd88dbe02f5b79e3 Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Mon, 15 Mar 2021 17:56:13 +0000 Subject: [PATCH] add vim-spell --- vim-spell/README.md | 80 ++++++++++++++++++++++++++++++++++++++++++++ vim-spell/install.sh | 36 ++++++++++++++++++++ vim-spell/spell.vim | 6 ++++ 3 files changed, 122 insertions(+) create mode 100644 vim-spell/README.md create mode 100644 vim-spell/install.sh create mode 100644 vim-spell/spell.vim diff --git a/vim-spell/README.md b/vim-spell/README.md new file mode 100644 index 0000000..07635ce --- /dev/null +++ b/vim-spell/README.md @@ -0,0 +1,80 @@ +--- +title: vim-spell +homepage: https://webinstall.dev/vim-spell +tagline: | + vim spell is Vim's built-in spellcheck +--- + +To update (replacing the current version) run `webi vim-spell`. + +## Cheat Sheet + +Vim has a built-in spell checker. It is turned off by default and when turned on +will do whole-word highlighting - which does not look good in any of the themes +a I use. + +This vim-spell plugin turns on the spell checker and sets it to use underline +rather than background coloring. + +### How to add new words + +The vim command to add words to your user's dictionary is `:spell `. For +example: + +```vim +:spell JSON +:spell HTML +``` + +### How to remove words + +You can remove a word from your custom dictionary with `:spellundo `, like +so: + +```vim +:spellundo referer +``` + +You can blacklist word (mark it as an incorrect spelling) with +`:spellwrong `, like this: + +```vim +:spellwrong writeable + +" use X11/HTML-defined 'gray', not the proper English 'grey' +:spellwrong grey +``` + +This is particularly useful if you want to make sure that you're consintent in +spelling words that have multiple spellings. + +### Where are the custom files? + +Your user-specific spell files in in `~/.vim/spell`. One is in binary form and +the other in text form, likely: + +- `~/.vim/spell/en.utf-8.add` +- `~/.vim/spell/en.utf-8.add.spl` + +### How to install manually + +Create the file `~/.vim/plugins/spell.vim`. Add the same contents as +. + +That will look something like this: + +```vim +" turn on spellcheck +set spell + +" set spellcheck highlight to underline +hi clear SpellBad +hi SpellBad cterm=underline +``` + +You'll then need to update `~/.vimrc` to source that plugin: + +```vim +" Spell Check: reasonable defaults from webinstall.dev/vim-spell +source ~/.vim/plugins/spell.vim +``` diff --git a/vim-spell/install.sh b/vim-spell/install.sh new file mode 100644 index 0000000..65e1a1c --- /dev/null +++ b/vim-spell/install.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +function __init_vim_spell() { + set -e + set -u + + mkdir -p "$HOME/.vim/plugins" + rm -rf "$HOME/.vim/plugins/spell.vim" + + echo "" + + if [ ! -e "$HOME/.vimrc" ]; then + touch "$HOME/.vimrc" + fi + + if ! [ -f "$HOME/.vim/plugins/spell.vim" ]; then + mkdir -p ~/.vim/plugins + WEBI_HOST=${WEBI_HOST:-"https://webinstall.dev"} + curl -fsS -o ~/.vim/plugins/spell.vim "$WEBI_HOST/packages/vim-spell/spell.vim" + fi + + if ! grep 'source.*plugins.spell.vim' -r ~/.vimrc > /dev/null 2> /dev/null; then + set +e + mkdir -p ~/.vim/plugins + printf '\n" Spell Check: reasonable defaults from webinstall.dev/vim-spell\n' >> ~/.vimrc + printf 'source ~/.vim/plugins/spell.vim\n' >> ~/.vimrc + set -e + echo "added ~/.vim/plugins/spell.vim" + echo "updated ~/.vimrc with 'source ~/.vim/plugins/spell.vim'" + echo "" + fi + + echo "vim-spell enabled with reasonable defaults" +} + +__init_vim_spell diff --git a/vim-spell/spell.vim b/vim-spell/spell.vim new file mode 100644 index 0000000..7b33a98 --- /dev/null +++ b/vim-spell/spell.vim @@ -0,0 +1,6 @@ +" turn on spellcheck +set spell + +" set spellcheck highlight to underline +hi clear SpellBad +hi SpellBad cterm=underline -- 2.25.1