Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/preservim/vim-lexical
Build on Vim’s spell/thes/dict completion
https://github.com/preservim/vim-lexical
prose vim vim-plugin writing
Last synced: 29 days ago
JSON representation
Build on Vim’s spell/thes/dict completion
- Host: GitHub
- URL: https://github.com/preservim/vim-lexical
- Owner: preservim
- License: other
- Created: 2014-01-01T06:05:00.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2022-02-11T22:37:05.000Z (almost 3 years ago)
- Last Synced: 2024-11-03T05:30:33.616Z (about 1 month ago)
- Topics: prose, vim, vim-plugin, writing
- Language: Vim script
- Homepage:
- Size: 24.4 KB
- Stars: 272
- Watchers: 9
- Forks: 8
- Open Issues: 10
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
- writingvim - vim-lexical
README
# vim-lexical
> Building on Vim’s spell-check and thesaurus/dictionary completion
Features of this plugin:
* Specify the languages to be used in spell-check
* Specify a list of thesauruses for synonym completion
* Specify a list of dictionaries for word completion
* Specify a list of spellfiles for custom word-check additions
* Opt-in key mappings for _Normal_ mode thesaurus and dictionary completion
* Buffer-scoped configuration (leaves your global settings alone)Though principally used as a editor for code, Vim flirts with those of us
editing documentation and prose by providing spell-check as well as
completion capabilities using both dictionary and thesaurus files.While we can configure these settings in our `.vimrc` files, we often need
more granular control, where defaults are leveraged and configuration is
applied by file type to the current buffer. This plugin fills that gap.## Installation
You can install using your favorite Vim package manager. (E.g.,
[Pathogen][pathogen], [Vundle][vundle], or [Plug][plug].) If you are using
a recent version of vim or neovim, you can also use native package
support. (See [:help packages][packages].)[pathogen]: https://github.com/tpope/vim-pathogen
[vundle]: https://github.com/VundleVim/Vundle.vim
[plug]: https://github.com/junegunn/vim-plug
[packages]: https://vimhelp.org/repeat.txt.html#packages## Configuration
Because spell-check, thesaurus, etc. isn’t needed for all file types, you can
configure it per file type in your `.vimrc`:```vim
set nocompatible
filetype plugin on " may already be in your .vimrcaugroup lexical
autocmd!
autocmd FileType markdown,mkd call lexical#init()
autocmd FileType textile call lexical#init()
autocmd FileType text call lexical#init({ 'spell': 0 })
augroup END
```In the last `autocmd` statement above, dictionaries and thesauruses are
configured for the `text` file type, but spell-check is disabled by
default._lexical_ enables spell-check by default for buffers in which it is
initialized. You can change that default setting in your `.vimrc`:```vim
let g:lexical#spell = 1 " 0=disabled, 1=enabled
```### Spell-check language configuration
Vim’s global `spelllang` (note three `l`s) may already specify a default
language. You can query it with a simple command:```vim
:echo &spelllang
=> ‘en’
```If desired, you can be more specific, overriding the global `spelllang` in
your `.vimrc`:```vim
let g:lexical#spelllang = ['en_us','en_ca',]
```Available spell files can be found at [ftp.vim.org][sf]. Vim will attempt
to download those which are not installed locally. For more detail see```vim
:help spellfile.vim
```[sf]: http://ftp.vim.org/vim/runtime/spell
### Thesaurus configuration
If you don’t have one already, download a thesaurus, such as Grady Ward’s
Moby Thesaurus at Zeke's [moby thesaurus][1], or on [Project Gutenberg][2]
and extract the `mthesaur.txt` file. By default _lexical_ will look for it
at the following path:```vim
let g:lexical#thesaurus = ['~/.vim/thesaurus/mthesaur.txt',]
```You can specify multiple paths to thesauruses in the list.
[1]: https://raw.githubusercontent.com/zeke/moby/master/words.txt "On moby-thesaurus site"
[2]: https://www.gutenberg.org/ebooks/3202 "Moby Thesaurus List by Grady Ward"### Dictionary configuration
On Unix-based systems (including OS X) the dictionary will default to:
```vim
let g:lexical#dictionary = ['/usr/share/dict/words',]
```You can specify multiple paths to dictionaries in the list.
### Spellfile configuration
On Unix-based systems (including OS X) the spellfile will default to:```vim
let g:lexical#spellfile = ['~/.vim/spell/en.utf-8.add',]
```You can specify a single path for spellfile in the list.
## Commands
Vim offers many standard key mappings for spell-checking and completion.
### Spell-check
These are the _Normal_ mode commands:
* `]s` - Move to next misspelled word after the cursor.
* `[s` - Like `]s` but search backwards
* `]S` - Like `]s` but only stop at bad words, not at rare words or words
for another region.
* `[S` - Like `]S` but search backwards.With the following key mappings you can use Visual mode selection to select the
characters (including whitespace). Otherwise the word under the cursor is used.* `zg` - Mark as a good word
* `zw` - Like `zg` but mark the word as a wrong (bad) word.
* `zug` - Unmark as good word
* `zuw` - Unmark as wrong (bad) word* `z=` - For the word under/after the cursor suggest correctly spelled words
* `1z=` - Use the first suggestion, without prompting
* `.` - Redo - repeat last word replacement* `:spellr` - Repeat the replacement done by `z=` for all matches with the
replaced word in the current windowFor spelling suggestions while in _Insert_ mode:
* `«CTRL-X» «CTRL-S»` (or `«CTRL-X» «s»` for terminal users) - suggest spelling, using `«CTRL-P»` and `«CTRL-N»` to navigate.
For a convenient pop-up list of suggestions from _Normal_ mode, you can map an
available key of your choice in your `.vimrc`:```vim
let g:lexical#spell_key = 's'
```This buffer-scoped mapping is strictly opt-in. No key is mapped by default.
### Thesaurus lookup
For thesaurus lookup while in _Insert_ mode:
* `«CTRL-X» «CTRL-T»` - thesaurus lookup, using `«CTRL-P»` and `«CTRL-N»` to navigate.
For convenient _Normal_ mode thesaurus lookup from the cursor position,
you can map an available key of your choice in your `.vimrc`:```vim
let g:lexical#thesaurus_key = 't'
```This buffer-scoped mapping is strictly opt-in. No key is mapped by default.
### Dictionary completion
For dictionary completion while in _Insert_ mode:
* `«CTRL-X» «CTRL-K»` - dictionary completion, using `«CTRL-P»` and `«CTRL-N»` to navigate.
For convenient _Normal_ mode dictionary lookup from the cursor position,
you can map an available key of your choice in your `.vimrc`:```vim
let g:lexical#dictionary_key = 'k'
```This buffer-scoped mapping is strictly opt-in. No key is mapped by default.
### Define your own commands
Sometimes you need a highly-customized environment for spell-check and
completion. You can define your own commands in your `.vimrc` to meet that
need. For example:```vim
command! -nargs=0 LexMed call lexical#init({
\ 'spell': 1,
\ 'spelllang': ['en', 'medical'],
\ 'dictionary': ['~/.vim/dictionary/medical_terms.txt',
\ '/usr/share/dict/words',
\ ],
\ 'thesaurus': ['~/.vim/dictionary/medical_synonyms.txt',
\ '~/.vim/thesaurus/mthesaur.txt',
\ ],
\ 'spellfile': ['~/.vim/spell/en.add'],
\ })
```Then to quickly configure Vim for the current buffer, enter the command:
```vim
:LexMed
```Where you are providing an explicit value, it will use that. Where you do
not, it will fall back to your specified defaults or global settings.## See also
The [ervandew/supertab][st] plugin will make these _Insert_ mode
completions available via the `«tab»` key.If you find this plugin useful, you may want to check out these others
originally by [@reedes][re]:* [vim-colors-pencil][cp] - color scheme for Vim inspired by IA Writer
* [vim-litecorrect][lc] - lightweight auto-correction for vim
* [vim-pencil][pn] - rethinking Vim as a tool for writers
* [vim-textobj-quote][qu] - extends Vim to support typographic (‘curly’) quotes
* [vim-textobj-sentence][ts] - improving on Vim's native sentence motion command
* [vim-thematic][th] - modify Vim’s appearance to suit your task and environment
* [vim-wheel][wh] - screen-anchored cursor movement for Vim
* [vim-wordy][wo] - uncovering usage problems in writing
* [vim-wordchipper][wc] - power tool for shredding text in Insert mode[st]: https://github.com/ervandew/supertab
[re]: https://github.com/reedes
[cp]: https://github.com/preservim/vim-colors-pencil
[lc]: https://github.com/preservim/vim-litecorrect
[pn]: https://github.com/preservim/vim-pencil
[qu]: https://github.com/preservim/vim-textobj-quote
[ts]: https://github.com/preservim/vim-textobj-sentence
[th]: https://github.com/preservim/vim-thematic
[wh]: https://github.com/preservim/vim-wheel
[wo]: https://github.com/preservim/vim-wordy
[wc]: https://github.com/preservim/vim-wordchipper## Future development
If you’ve spotted a problem or have an idea on improving this plugin,
please post it to the [GitHub project issue page][issues].[issues]: https://github.com/preservim/vim-lexical/issues