0

I'm looking for a dictionary (as in the wikitionary; not the data structure) plugin for vim.

One where I could put my cursor on pyrolysis, type a command such as :Dictionary and get something like:

noun, Chemistry.  
1.  
the subjection of organic compounds to very high temperatures.  
2.  
the resulting decomposition.

I have found this dictionary.vim, but it provides no detailed instructions on how to install it.

  • 1
    I don't know if such a plugin exists but you can easily use one of the dictionary command line application from this question and create a simple command which will call this external command from vim. You can also try to ask the plugin author for help about installation via the plugin issue tracker – statox Dec 11 '17 at 16:43
  • @moneiro Which OS/terminal/vim are you using? Are you using a plugin manager? If you are not using a plugin-manager, I would suggest to read this or that first. – mike Dec 11 '17 at 16:47
  • If you have a plugin manager you should be able to give it the github URL to install it. If you don't have a plugin manager, you should be able to go to your vim installation and find the folders "autoload", "plugin", "doc", and "syntax", and simply copy the files from the project. Then restart vim. (On a Windows machine, Vim is usually installed under "Program Files (x86)\Vim\vimxx"; shere xx is a number.) – Tumbler41 Dec 11 '17 at 17:09
  • I'll probably add my own vimscript for this. I'll let you guys know. – fmv1992 Dec 11 '17 at 18:22
  • 1
    Obligatory xkcd reference. Why use a plugin when you can write your own... – mike Dec 11 '17 at 19:08
1

Put your cursor on a word then do...

:r http://services.aonaware.com/DictService/DictService.asmx/De‌​fine?word=<cword> | %s/<\_.\{-}>//g | %s/^M//g

You'll want to do a little bit more sophisticated post-processing to remove the XML. :)

I was just fooling around with this at first. It started as an exercise for myself to see how quickly I could come up with something.1 But it actually, generally works and it demonstrates a couple less familiar features (netrw and <cword>) so I figured I'd post. A little better filtering and you could have something. Here's a sample using exactly the command above...

playful

  playful

    gcide
    The Collaborative International Dictionary of English v.0.44

  Playful \Play"ful\, a.
Sportive; gamboling; frolicsome; indulging a sportive fancy;
humorous; merry; as, a playful child; a playful writer. --
{Play"ful*ly}, adv. -- {Play"ful*ness}, n.
[1913 Webster]


  playful

    wn
    WordNet (r) 2.0

  playful
 adj : full of fun and high spirits; "playful children sjust let
       loose from school" [ant: {unplayful}]

1. 15-20 minutes, most of which was spent searching for a free, simple, usable API.

  • Great trade-off between simplicity and effectiveness! Nevertheless I'm on my way with this little plugin :) – fmv1992 Dec 12 '17 at 18:03
  • No worries. Do you mean the dictionary.vim you mention in your question? What does that use as its source dictionary? Just curious... – B Layer Dec 13 '17 at 7:13
  • 1
    The dictionary is <dictionary.com>. I have searched for an open API dictionary but could not find one. Also the plugin would be unusable when offline which happens from time to time. I'm resorting to one of Gutteberg's project dictionary. The plugin will be finished in ~2 days. I'm pretty happy with its development, having a lot of fun =) – fmv1992 Dec 13 '17 at 15:42
0

As the vim community did not have such a plugin I have then developed it.

It is available at:

https://github.com/fmv1992/vim_dictionary

Features

  1. Works offline (downloads a dictionary during the install).
  2. Is asynchronous: one instance of the plugin launches a server which serves all your vim instances (memory efficient).
  3. Is simple: just one command is defined: :Dictionary. Usage:

    • Simple to install: make install.
    • Simple to use:

      :Dictionary rodent
      

      Yields:

      RODENT
      Ro"dent, a. Etym: [L. rodens, -entis, p. pr. of rodere to gnaw. See
      Rase, v. t., and cf. Rostrum.]
      
      1. Gnawing; biting; corroding; (Med.) applied to a destructive
      variety of cancer or ulcer.
      
      2. (Zoöl.)
      (a) Gnawing.
      (b) Of or pertaining to the Rodentia.
      
      RODENT
      Ro"dent, n. (Zoöl.)
      
      Defn: One of the Rodentia.
      
  4. Has highlightings for ease of reading.

  5. Has a battery of tests and is passing on TravisCI (therefore it meets a good coding standard).

Requirements

  • vim8
  • +channel feature
  • python3 feature

Screencasting

asciicast

Any feedback is appreciated. Made for the vim community.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.