A simple Neovim plugin for the Linux command dict which shows the definitions in a popup
  • Lua 82.4%
  • Vim Script 17.1%
  • Makefile 0.5%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2024-07-01 19:42:25 -04:00
after/syntax Initial commit 2024-02-19 19:24:22 -05:00
doc Removed default bindings. New buffer_mappings opts 2024-07-01 19:42:25 -04:00
lua/dict-popup Removed default bindings. New buffer_mappings opts 2024-07-01 19:42:25 -04:00
.editorconfig Makefile, luacheck, README 2024-02-21 16:35:04 -05:00
.gitignore Rewrite. Ability to call dict inside of a dict popup 2024-05-06 15:33:59 -04:00
.luacheckrc Makefile, luacheck, README 2024-02-21 16:35:04 -05:00
.stylua.toml :Dict {word} now opens a centered popup 2024-03-09 18:50:44 -05:00
CHANGELOG.md Removed default bindings. New buffer_mappings opts 2024-07-01 19:42:25 -04:00
LICENSE Added LICENSE 2024-04-30 22:39:30 -04:00
Makefile :Dict {word} now opens a centered popup 2024-03-09 18:50:44 -05:00
README.md Removed default bindings. New buffer_mappings opts 2024-07-01 19:42:25 -04:00
screenshot.png Initial commit 2024-02-19 19:24:22 -05:00

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 pseudo 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