Skip to content

Instantly share code, notes, and snippets.

@seandewar
Created September 26, 2023 20:59
Show Gist options
  • Save seandewar/b2c38367eaa06b1e39704f9a916a7432 to your computer and use it in GitHub Desktop.
Save seandewar/b2c38367eaa06b1e39704f9a916a7432 to your computer and use it in GitHub Desktop.
πŸ˜‚ Emojimode for Neovim 0.10+ πŸ˜‚ (Run with `:Emojimode`)
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