First cut of experimental ring of dictionaries

This commit is contained in:
Reed Esau
2014-03-10 22:17:23 -06:00
parent 8ef787e58a
commit fa9a2faf9c
3 changed files with 104 additions and 14 deletions

View File

@@ -15,6 +15,7 @@
* Includes 16 dictionaries covering different types of word usage
* Buffer-scoped configuration (leaves your global settings alone)
* Unicode-friendly, including support for typographic quotes
* User-configurable ring of dictionaries
## What is _wordy_?
@@ -55,6 +56,8 @@ package manager.
## Configuration
### On demand
Youll typically use this plugin on-demand. It does not require any
special configuration.
@@ -74,6 +77,30 @@ Press ENTER or type command to continue
As instructed, press the enter key and it will disturb you no longer, at
least until _wordy_ feels the urge to build again.
### Ring
Optionally map a key in your `.vimrc` to rapidly cycle among available dictionaries:
```
nnoremap <silent> K :NextWordy<cr>
```
In addition, you can define your own ring of dictionaries. This is the
default, which you can override in your `.vimrc`:
```
let g:wordy#ring = [
\ 'jargon' ,
\ 'passive' ,
\ 'puffery' ,
\ 'redundant' ,
\ 'to-be' ,
\ 'trite' ,
\ 'weak' ,
\ 'weasel' ,
\ ]
```
## Using _wordy_
Youll use the commands that follow to enable _wordy_. To disable it and

View File

@@ -61,4 +61,48 @@ function! wordy#init(...) abort
endif
endfunction
function! wordy#jump(mode)
let g:wordy = s:wordy_get(a:mode)
let l:entry = get(g:wordy#data, g:wordy, [])
if len(l:entry) > 0
call wordy#init({ 'd': l:entry[0] })
echo g:wordy . ': ' . l:entry[1]
endif
endfunction
function! s:wordy_get(mode)
let l:avail_count = len(g:wordy#ring)
let l:new_n = -1
if a:mode == '#first'
let l:new_n = 0
elseif a:mode == '#last'
let l:new_n = l:avail_count - 1
elseif a:mode == '#random'
let l:new_n =
\ str2nr(matchstr(reltimestr(reltime()), '\v\.@<=\d+')[1:])
\ % l:avail_count
elseif a:mode == '#next' || a:mode == '#previous'
let l:current_n = index(g:wordy#ring, g:wordy)
if a:mode == '#next'
if l:current_n == -1 || l:current_n == l:avail_count - 1
let l:new_n = 0
else
let l:new_n = l:current_n + 1
endif
elseif a:mode == '#previous'
if l:current_n <= 0
let l:new_n = l:avail_count - 1
else
let l:new_n = l:current_n - 1
endif
endif
endif
if l:new_n == -1
return a:mode
else
return g:wordy#ring[l:new_n]
endif
endfunction
" vim:ts=2:sw=2:sts=2

View File

@@ -39,21 +39,40 @@ command -nargs=0 OpineWordy call wordy#init({ 'd': ['opinion',] })
command -nargs=0 SaidWordy call wordy#init({ 'd': ['said-synonyms',] })
command -nargs=0 AintWordy call wordy#init({ 'd': ['contractions',] })
" tools for creative writing
command -nargs=0 CreativeWordy call wordy#init({ 'd': [ 'being',
\ 'colloquial',
\ 'idiomatic',
\ 'business-jargon',
\ 'art-jargon',
\ 'weasel',
\ 'opinion',
\ 'passive-voice',
\ 'puffery',
\ 'redundant',
\ 'similies',
\ 'weak',
\ ]})
command -nargs=0 NextWordy call wordy#jump('#next')
command -nargs=0 PrevWordy call wordy#jump('#prev')
let g:wordy = ''
" ordered list of keys into s:wordy#data; user configurable
if !exists('g:wordy#ring')
let g:wordy#ring = [
\ 'jargon' ,
\ 'passive' ,
\ 'puffery' ,
\ 'redundant' ,
\ 'to-be' ,
\ 'trite' ,
\ 'weak' ,
\ 'weasel' ,
\ ]
endif
if !exists('g:wordy#data')
let g:wordy#data = {
\ 'to-be' : [['being' ], 'Subject-verb agreement' ],
\ 'trite' : [['colloquial' ,
\ 'idiomatic' ,
\ 'similies' ], 'colloquialisms, idioms, and similes' ],
\ 'jargon' : [['business-jargon' ], 'insidery jargon for business' ],
\ 'weasel' : [['weasel' ], 'manipulative and equivocating words and phrases' ],
\ 'passive' : [['being' ,
\ 'passive-voice' ], 'can be used to avoid responsibility for actions taken' ],
\ 'puffery' : [['puffery' ], 'statements and claims that express subjective rather than objective views' ],
\ 'redundant' : [['redundant' ], 'redundant phrasings' ],
\ 'weak' : [['weak' ], 'weak and lazy language' ],
\ }
endif
let &cpo = s:save_cpo
unlet s:save_cpo