/dict-popup.nvim

A simple Neovim plugin for the Linux command `dict` which shows the definitions in a popup

Primary LanguageLuaApache License 2.0Apache-2.0

dict-popup.nvim

Neovim Lua

A simple plugin for the Linux command dict which shows the definitions in a popup. (vim9script version)

Screenshot

Features

  • center and cursor popups
  • ex command: :Dict {word} (center)
  • normal mode: lookup current word (cursor)
  • visual mode: lookup selection (cursor)
  • dict filetype and accompanying syntax
  • in-buffer sudo jumplist

Install

Command

sudo apt install dictd
# or
sudo dnf install dictd
# extra dictionaries
sudo apt install dict-jargon dict-vera

Note: Syntax tested with gcide (default), jargon and vera

Plugin

{
    "Nealium/dict-popup.nvim",
    opts = {
        normal_mapping = nil, -- disable
        visual_mapping = "<Leader>h",
        visual_reg = "*",
        stack = false,
    },
}

Notes:

  • Setting normal_mapping or visual_mapping to nil (actual nil, not a string), or leaving the keys out all together, will disable the mapping.
  • Setting stack to true will open up a cursor popup on top of a center popup instead of the default behavior which is to overwrite the center popup's contents. This may lead you with the center popup open and unfocused, to refocus do <C-w><C-w>- in some situations this won't work and you are on your own!

Dict buffer keymaps

  • <ESC> and q close popup
  • } next definition
  • { previous definition
  • <C-O> next in search jumplist
  • <C-I> and <TAB> previous in search jumplist
  • <C-]> search current word
  • if stacked, <C-W> close popup

Keymaps can be changed through the opts key buffer_mappings:

{
    "Nealium/dict-popup.nvim",
    opts = {
        normal_mapping = "<Leader>h",
        visual_mapping = "<Leader>h",
        visual_reg = "*",
        stack = false,
        buffer_mappings = { -- defaults
            close = { "<Esc>", "q" },
            next_definition = { "}" },
            previous_definition = { "{" },
            jump_back = { "<C-o>" },
            jump_forward = { "<C-i>", "<Tab>" },
            jump_definition = { "<C-]>" },
        },
    },
}

TODO

  • Proper config & setup
  • Center popup for :Dict command
  • Ability to call dict.Cursor inside of a dict popup and have it overwrite the current contents
  • Colors set in config