Created
September 26, 2023 20:59
-
-
Save seandewar/b2c38367eaa06b1e39704f9a916a7432 to your computer and use it in GitHub Desktop.
π Emojimode for Neovim 0.10+ π (Run with `:Emojimode`)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local api = vim.api | |
local is_on = false | |
local emoji_width = api.nvim_strwidth "π" | |
local ns = api.nvim_create_namespace "emojimode" | |
api.nvim_create_user_command("Emojimode", function() | |
is_on = not is_on | |
api.nvim_set_decoration_provider(ns, { | |
on_win = is_on and function(_, win, buf, topline, botline) | |
for line = topline, botline do | |
local line_display_len = vim.fn.virtcol({ line + 1, "$" }, 0, win) | |
api.nvim_buf_set_extmark(buf, ns, line, 0, { | |
ephemeral = true, | |
virt_text_pos = "overlay", | |
virt_text = { { ("π"):rep(line_display_len / emoji_width) } }, | |
}) | |
end | |
end or nil, | |
}) | |
end, {}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment