mirror of
https://github.com/preservim/vim-wordy.git
synced 2025-11-10 02:43:48 -05:00
simplified ring; multiple types
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
* Includes 16 dictionaries covering different types of word usage
|
* Includes 16 dictionaries covering different types of word usage
|
||||||
* Buffer-scoped configuration (leaves your global settings alone)
|
* Buffer-scoped configuration (leaves your global settings alone)
|
||||||
* Unicode-friendly, including support for ‘typographic quotes’
|
* Unicode-friendly, including support for ‘typographic quotes’
|
||||||
* User-configurable ring of dictionaries
|
* Supports a user-configurable ring of dictionaries
|
||||||
|
|
||||||
## What is _wordy_?
|
## What is _wordy_?
|
||||||
|
|
||||||
@@ -79,28 +79,35 @@ least until _wordy_ feels the urge to build again.
|
|||||||
|
|
||||||
### Ring
|
### Ring
|
||||||
|
|
||||||
Optionally map a key in your `.vimrc` to rapidly cycle among available dictionaries:
|
Define your own ring of dictionaries, overriding the default one in your
|
||||||
|
`.vimrc`:
|
||||||
```
|
|
||||||
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 = [
|
let g:wordy#ring = [
|
||||||
\ 'jargon' ,
|
\ 'weak',
|
||||||
\ 'passive' ,
|
\ ['being', 'passive-voice', ],
|
||||||
\ 'puffery' ,
|
\ 'business-jargon',
|
||||||
\ 'redundant' ,
|
\ 'weasel',
|
||||||
\ 'to-be' ,
|
\ 'puffery',
|
||||||
\ 'trite' ,
|
\ ['problematic', 'redundant', ],
|
||||||
\ 'weak' ,
|
\ ['colloquial', 'idiomatic', 'similies', ],
|
||||||
\ 'weasel' ,
|
|
||||||
\ ]
|
\ ]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can navigate the ring with the following commands:
|
||||||
|
|
||||||
|
```
|
||||||
|
:NextWordy
|
||||||
|
:PrevWordy
|
||||||
|
```
|
||||||
|
|
||||||
|
Optionally create a key map in your `.vimrc` to rapidly cycle through the
|
||||||
|
ring:
|
||||||
|
|
||||||
|
```
|
||||||
|
nnoremap <silent> K :NextWordy<cr>
|
||||||
|
```
|
||||||
|
|
||||||
## Using _wordy_
|
## Using _wordy_
|
||||||
|
|
||||||
You’ll use the commands that follow to enable _wordy_. To disable it and
|
You’ll use the commands that follow to enable _wordy_. To disable it and
|
||||||
@@ -119,7 +126,7 @@ go to those words flagged by _wordy_.
|
|||||||
### Weak and lazy usage
|
### Weak and lazy usage
|
||||||
|
|
||||||
```
|
```
|
||||||
:WeakWordy
|
:WeakWordy (weak)
|
||||||
```
|
```
|
||||||
|
|
||||||
Weak and lazy words are common in first drafts.
|
Weak and lazy words are common in first drafts.
|
||||||
@@ -147,8 +154,8 @@ asking whether it detracts from the point you are trying to make.
|
|||||||
### Redundant and problematic usage
|
### Redundant and problematic usage
|
||||||
|
|
||||||
```
|
```
|
||||||
:WordyWordy
|
:WordyWordy (redundant)
|
||||||
:ProblemWordy
|
:ProblemWordy (problematic)
|
||||||
```
|
```
|
||||||
|
|
||||||
Did you ever receive an ‘advance warning’ when a mere warning would do?
|
Did you ever receive an ‘advance warning’ when a mere warning would do?
|
||||||
@@ -165,15 +172,16 @@ targeted by _ProblemWordy_.
|
|||||||
|
|
||||||
[1]: http://www.dailywritingtips.com/50-problem-words-and-phrases/
|
[1]: http://www.dailywritingtips.com/50-problem-words-and-phrases/
|
||||||
|
|
||||||
### Puffery and Jargonese
|
### Puffery and Jargon
|
||||||
|
|
||||||
> “The man embodies _authenticity_; his _disruptive_ ideas on
|
> “The man embodies _authenticity_; his _disruptive_ ideas on
|
||||||
> _self-actualization_ reflect his _dynamic_ and _transformative_
|
> _self-actualization_ reflect his _dynamic_ and _transformative_
|
||||||
> personality.” (puffery and jargonese)
|
> personality.” (puffery and jargon)
|
||||||
|
|
||||||
```
|
```
|
||||||
:PuffWordy
|
:PuffWordy (puffery)
|
||||||
:JargonWordy
|
:JargonWordy (business-jargon)
|
||||||
|
:ArtJargonWordy (art-jargon)
|
||||||
```
|
```
|
||||||
|
|
||||||
Instead of puffery, demonstrate through details.
|
Instead of puffery, demonstrate through details.
|
||||||
@@ -185,7 +193,7 @@ Instead of puffery, demonstrate through details.
|
|||||||
### Manipulative language
|
### Manipulative language
|
||||||
|
|
||||||
```
|
```
|
||||||
:WeaselWordy
|
:WeaselWordy (weasel)
|
||||||
```
|
```
|
||||||
|
|
||||||
Words can be used to hide or obscure a weak position, or to cast doubt on
|
Words can be used to hide or obscure a weak position, or to cast doubt on
|
||||||
@@ -202,8 +210,8 @@ will seek to purge such loaded language from your writing.
|
|||||||
### To be and the passive voice
|
### To be and the passive voice
|
||||||
|
|
||||||
```
|
```
|
||||||
:BeingWordy
|
:BeingWordy (being)
|
||||||
:PassiveWordy (includes BeingWordy)
|
:PassiveWordy (being, passive-voice)
|
||||||
```
|
```
|
||||||
|
|
||||||
You may find this dictionary useful in avoiding overuse of the many forms
|
You may find this dictionary useful in avoiding overuse of the many forms
|
||||||
@@ -212,7 +220,7 @@ of the verb to be, often found in overly-passive sentences.
|
|||||||
### Colloquialisms, Idioms, and Similies
|
### Colloquialisms, Idioms, and Similies
|
||||||
|
|
||||||
```
|
```
|
||||||
:TriteWordy
|
:TriteWordy (colloquial, idiomatic, similies)
|
||||||
```
|
```
|
||||||
|
|
||||||
Dictionaries for uncovering the tired cliché, including colloquial and
|
Dictionaries for uncovering the tired cliché, including colloquial and
|
||||||
@@ -221,10 +229,10 @@ idiomatic phrases scraped from Wiktionary and Wikipedia.
|
|||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
|
||||||
```
|
```
|
||||||
:SaidWordy
|
:SaidWordy (said-synonyms)
|
||||||
:OpineWordy
|
:OpineWordy (opinion)
|
||||||
:AintWordy
|
:AintWordy (contractions)
|
||||||
:VagueTimeWordy (renamed from TimeWordy)
|
:VagueTimeWordy (vague-time)
|
||||||
```
|
```
|
||||||
|
|
||||||
A few dictionaries to serve specific needs.
|
A few dictionaries to serve specific needs.
|
||||||
|
|||||||
@@ -22,7 +22,8 @@ function! wordy#init(...) abort
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" switch to usage dictionaries, building if needed
|
" switch to usage dictionaries, building if needed
|
||||||
let l:dicts = get(l:args, 'd', [])
|
let l:d = get(l:args, 'd', []) " may be string or list
|
||||||
|
let l:dicts = (type(l:d) == type([])) ? l:d : [l:d]
|
||||||
if len(l:dicts)
|
if len(l:dicts)
|
||||||
let l:dst_paths = []
|
let l:dst_paths = []
|
||||||
" TODO &spelllang)
|
" TODO &spelllang)
|
||||||
@@ -58,51 +59,25 @@ function! wordy#init(...) abort
|
|||||||
exe 'setlocal spelllang=' . l:lang . ',' . join(l:dst_paths, ',')
|
exe 'setlocal spelllang=' . l:lang . ',' . join(l:dst_paths, ',')
|
||||||
setlocal spell
|
setlocal spell
|
||||||
endif
|
endif
|
||||||
|
echohl ModeMsg | echo 'wordy: ' . join(l:dicts, ', ') | echohl NONE
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! wordy#jump(mode)
|
function! wordy#jump(mode)
|
||||||
let g:wordy = s:wordy_get(a:mode)
|
" mode=1 next in ring
|
||||||
let l:entry = get(g:wordy#data, g:wordy, [])
|
" mode=-1 prev in ring
|
||||||
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:avail_count = len(g:wordy#ring)
|
||||||
let l:new_n = -1
|
if l:avail_count == 0 | return | endif
|
||||||
if a:mode == '#first'
|
if g:wordy_ring_index < 0
|
||||||
let l:new_n = 0
|
" ring navigation not initialized; start at begin or end
|
||||||
elseif a:mode == '#last'
|
let g:wordy_ring_index =
|
||||||
let l:new_n = l:avail_count - 1
|
\ a:mode == 1
|
||||||
elseif a:mode == '#random'
|
\ ? 0
|
||||||
let l:new_n =
|
\ : (l:avail_count - 1)
|
||||||
\ 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
|
else
|
||||||
return g:wordy#ring[l:new_n]
|
let g:wordy_ring_index = (g:wordy_ring_index + a:mode) % l:avail_count
|
||||||
endif
|
endif
|
||||||
|
call wordy#init({ 'd': g:wordy#ring[ g:wordy_ring_index ]})
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" vim:ts=2:sw=2:sts=2
|
" vim:ts=2:sw=2:sts=2
|
||||||
|
|||||||
@@ -18,62 +18,46 @@ let g:wordy_dir = fnamemodify(resolve(expand('<sfile>:p')), ':h:h')
|
|||||||
|
|
||||||
command -nargs=0 NoWordy call wordy#init({})
|
command -nargs=0 NoWordy call wordy#init({})
|
||||||
|
|
||||||
command -nargs=0 BeingWordy call wordy#init({ 'd': ['being',] })
|
command -nargs=0 BeingWordy call wordy#init({ 'd': 'being' })
|
||||||
command -nargs=0 PassiveWordy call wordy#init({ 'd': ['passive-voice', 'being',] })
|
command -nargs=0 PassiveWordy call wordy#init({ 'd': ['passive-voice', 'being',] })
|
||||||
|
|
||||||
command -nargs=0 WeakWordy call wordy#init({ 'd': ['weak',] })
|
command -nargs=0 WeakWordy call wordy#init({ 'd': 'weak' })
|
||||||
command -nargs=0 LazyWordy call wordy#init({ 'd': ['weak',] })
|
command -nargs=0 LazyWordy call wordy#init({ 'd': 'weak' })
|
||||||
|
|
||||||
command -nargs=0 ProblemWordy call wordy#init({ 'd': ['problematic',] })
|
command -nargs=0 ProblemWordy call wordy#init({ 'd': 'problematic' })
|
||||||
command -nargs=0 WordyWordy call wordy#init({ 'd': ['redundant',] })
|
command -nargs=0 WordyWordy call wordy#init({ 'd': 'redundant' })
|
||||||
|
|
||||||
command -nargs=0 JargonWordy call wordy#init({ 'd': ['business-jargon', 'art-jargon',] })
|
command -nargs=0 JargonWordy call wordy#init({ 'd': 'business-jargon' })
|
||||||
command -nargs=0 PuffWordy call wordy#init({ 'd': ['puffery',] })
|
command -nargs=0 ArtJargonWordy call wordy#init({ 'd': 'art-jargon' })
|
||||||
command -nargs=0 WeaselWordy call wordy#init({ 'd': ['weasel',] })
|
command -nargs=0 PuffWordy call wordy#init({ 'd': 'puffery' })
|
||||||
|
command -nargs=0 WeaselWordy call wordy#init({ 'd': 'weasel' })
|
||||||
|
|
||||||
command -nargs=0 TriteWordy call wordy#init({ 'd': [ 'colloquial', 'idiomatic', 'similies',] })
|
command -nargs=0 TriteWordy call wordy#init({ 'd': ['colloquial', 'idiomatic', 'similies',] })
|
||||||
|
|
||||||
" tools for formal and objective writing
|
" tools for formal and objective writing
|
||||||
command -nargs=0 VagueTimeWordy call wordy#init({ 'd': ['vague-time',] })
|
command -nargs=0 VagueTimeWordy call wordy#init({ 'd': 'vague-time' })
|
||||||
command -nargs=0 OpineWordy call wordy#init({ 'd': ['opinion',] })
|
command -nargs=0 OpineWordy call wordy#init({ 'd': 'opinion' })
|
||||||
command -nargs=0 SaidWordy call wordy#init({ 'd': ['said-synonyms',] })
|
command -nargs=0 SaidWordy call wordy#init({ 'd': 'said-synonyms' })
|
||||||
command -nargs=0 AintWordy call wordy#init({ 'd': ['contractions',] })
|
command -nargs=0 AintWordy call wordy#init({ 'd': 'contractions' })
|
||||||
|
|
||||||
command -nargs=0 NextWordy call wordy#jump('#next')
|
command -nargs=0 NextWordy call wordy#jump(1)
|
||||||
command -nargs=0 PrevWordy call wordy#jump('#prev')
|
command -nargs=0 PrevWordy call wordy#jump(-1)
|
||||||
|
|
||||||
let g:wordy = ''
|
let g:wordy_ring_index = -1 " start at beginning
|
||||||
|
|
||||||
" ordered list of keys into s:wordy#data; user configurable
|
" user configurable ring of dictionaries
|
||||||
if !exists('g:wordy#ring')
|
if !exists('g:wordy#ring')
|
||||||
let g:wordy#ring = [
|
let g:wordy#ring = [
|
||||||
\ 'jargon' ,
|
\ 'weak',
|
||||||
\ 'passive' ,
|
\ ['being', 'passive-voice', ],
|
||||||
\ 'puffery' ,
|
\ 'business-jargon',
|
||||||
\ 'redundant' ,
|
\ 'weasel',
|
||||||
\ 'to-be' ,
|
\ 'puffery',
|
||||||
\ 'trite' ,
|
\ ['problematic', 'redundant', ],
|
||||||
\ 'weak' ,
|
\ ['colloquial', 'idiomatic', 'similies', ],
|
||||||
\ 'weasel' ,
|
|
||||||
\ ]
|
\ ]
|
||||||
endif
|
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
|
let &cpo = s:save_cpo
|
||||||
unlet s:save_cpo
|
unlet s:save_cpo
|
||||||
" vim:ts=2:sw=2:sts=2
|
" vim:ts=2:sw=2:sts=2
|
||||||
|
|||||||
Reference in New Issue
Block a user