Skip to content

Commit

Permalink
Merge pull request #37 from junegunn/antonyms
Browse files Browse the repository at this point in the history
Added antonyms
  • Loading branch information
beloglazov committed Jan 21, 2017
2 parents b27ecc3 + fcb0b75 commit 09787bb
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
9 changes: 5 additions & 4 deletions plugin/online-thesaurus.vim
Expand Up @@ -55,14 +55,15 @@ function! s:Lookup(word)
1,$d
echo "Requesting thesaurus.com to look up \"" . l:word . "\"..."
exec ":silent 0r !" . s:path . " " . shellescape(l:word)
exec ":silent! g/\\vrelevant-\\d+/,/^$/!" . s:sort . " -t ' ' -k 1,1r -k 2,2"
exec ':silent! g/^relevant /,/^$/-!' . s:sort . " -t ' ' -k 2nr -k 3"
if has("win32")
silent! %s/\r//g
silent! normal! gg5dd
endif
silent g/\vrelevant-\d+ /s///
silent! g/^Synonyms/+;/^$/-2s/$\n/, /
silent g/^Synonyms:/ normal! JVgq
silent g/\vrelevant \d+ /s///
silent! g/^\%(Syn\|Ant\)onyms:/+;/^$/-2s/$\n/, /
silent g/^\%(Syn\|Ant\)onyms:/ normal! JVgq
silent g/^Antonyms:/-d
0
1d
exec 'resize ' . (line('$') - 1)
Expand Down
11 changes: 10 additions & 1 deletion plugin/thesaurus-lookup.sh
Expand Up @@ -37,8 +37,17 @@ if ! grep -q 'no thesaurus results' "$OUTFILE" && grep -q 'html' "$OUTFILE"; the
printf "\nDefinition: %s", $3
else if (index($0, "ttl\">"))
printf " %s\nSynonyms:\n", $3
else if (index($0, "thesaurus.com"))
else if (index($0, "thesaurus.com")) {
sub(/-/, " ", $7)
printf "%s %s\n", $7, $15
}
} /container-info antonyms/,/\/section/ {
if (index($0, "container-info antonyms"))
print "\nAntonyms:"
else if (index($0, "thesaurus.com/browse")) {
sub(/--/, " ", $7)
printf "%s %s\n", $7, $15
}
}' "$OUTFILE"
else
echo "The word \"${1}\" has not been found on thesaurus.com!"
Expand Down
2 changes: 2 additions & 0 deletions syntax/thesaurus.vim
Expand Up @@ -15,6 +15,7 @@ setlocal iskeyword+=:
syntax match thesMainEntry /Main entry: */ contained
syntax keyword thesDefinition Definition:
syntax keyword thesSynonyms Synonyms:
syntax keyword thesAntonyms Antonyms:
syntax keyword thesPartOfSpeech noun pron verb adj adv prep conj interj

" Entry contents rules
Expand All @@ -24,6 +25,7 @@ syntax region thesMainWord start=/Main entry:/ end=/$/ contains=CONTAINED keepe
hi link thesMainEntry Keyword
hi link thesDefinition Keyword
hi link thesSynonyms Keyword
hi link thesAntonyms Keyword
hi thesMainWord term=bold cterm=bold gui=bold
hi thesPartOfSpeech term=italic cterm=italic gui=italic

Expand Down

0 comments on commit 09787bb

Please sign in to comment.