Faster Neovim Plugin Development with plenary.nvim
Overview
In this article, let’s walk through plenary.nvim
which is a Neovim Lua library that provides essential Lua functions we need to develop Neovim plugins.
Popup
A popup menu can be easily created using the library.
Default Popup
local popup = require "plenary.popup"local function create_default_popup()
local win_id = popup.create({ "menu item 1", "menu item 2", "menu item 3" }, {})
print(win_id)
endcreate_default_popup()
Custom Popup
I can also specify the line, column, minimum width, border, and highlight.
vim.cmd [[highlight PopupColor ctermbg=black ctermfg=blue guifg=blue guibg=green]]local function create_highlight_popup()
local win_id = popup.create({ "item 1", "item 2", "item 3" }, {
line = 15,
col = 45,
minwidth = 20,
border = true,
highlight = "PopupColor",
})
print(win_id)
endcreate_highlight_popup()