Skip to content

cskeeters/unicode.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This Neovim plugin provides the user with the capability to select a Unicode character to be added to the current buffer.

unicode.nvim UI Screenshot

This is helpful for entering:

How it works

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.

Configuration

-- 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,
    },
}

fzf-lua

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
}

telescope

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
}

Dependencies

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.

Neovim Configuration for Local Installation

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" -- Linux

Neovim Configuration for Global installation

package.cpath = package.cpath .. ";/usr/lib64/lua/5.1/?.so" -- Linux

Tip

The path may vary by OS/Distribution. You can check your path with

luarocks path --lua-version=5.1

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages