This Neovim plugin provides the user with the capability to select a Unicode character to be added to the current buffer.
This is helpful for entering:
- Non-breaking spaces
- Non-breaking hyphens
- word joiners
- zero-width spaces
- Footnote markers (✝)
- Arrows (→ ↣)
- Fleurons (𐡸 𐫱 𐡷)
- Symbols (❖ »)
- Math Symbols (𝛀 𝚫 ≠ ∑ ∫)
- Emoji (with Fitzpatrick modifier sequences) (👍👍🏻)
The plugin creates a list of characters from data/UnicodeData.txt that is provided to vim.ui.select. The plugin assumes that the user has replaced this with telescope's ui-select extension or fzf-lua.
Warning
Neovim's default UI requires the user to scroll through too many pages of characters before making a selection which is painful.
-- function is required so that require('unicode') will only execute when key
-- is pressed after lua is initialized.
local function SelectUnicode()
require('unicode').select_unicode()
end
return {
enabled = true,
'cskeeters/unicode.nvim',
lazy = false, -- Not lazy so that categories and characters can be loaded asynchronously
keys = {
{ mode = {"n", "i"}, "<C-S-u>", SelectUnicode, desc = "Select Unicode" },
},
opts = {
notify_min_level = vim.log.levels.INFO,
},
}return {
"ibhagwan/fzf-lua",
config = function()
require("fzf-lua").setup({
winopts = {
fullscreen = true,
},
})
-- Replace vim.ui.select menu
require("fzf-lua").register_ui_select()
end
}return {
'nvim-telescope/telescope.nvim',
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-telescope/telescope-ui-select.nvim',
},
init = function()
require("telescope").setup({
defaults = {
layout_strategy = 'horizontal',
layout_config = {
height = 0.99,
width = 0.99,
},
sorting_strategy = "ascending",
},
})
-- Replace vim.ui.select menu
require('telescope').load_extension('ui-select')
end
}This plugin depends on starwing/luautf8, which can be installed via LuaRocks.
Important
Neovim uses Lua 5.1, so you have to pass that flag to luarocks.
What I do is install the rock on the command line and then make sure package.cpath is set properly in Neovim's configuration (init.lua).
luarocks install luautf8 --lua-version=5.1 --local CFLAGS="$(CFLAGS) -std=c99 -fPIC" [--local]Note
CFLAGS is not necessary unless your compiling on gnu < 5.0.
local HOME = os.getenv("HOME")
package.cpath = package.cpath .. ";" .. HOME .. "/.luarocks/lib/lua/5.1/?.so" -- macOS
package.cpath = package.cpath .. ";" .. HOME .. "/.luarocks/lib64/lua/5.1/?.so" -- Linuxpackage.cpath = package.cpath .. ";/usr/lib64/lua/5.1/?.so" -- LinuxTip
The path may vary by OS/Distribution. You can check your path with
luarocks path --lua-version=5.1