artify.nvim
artify.nvim copied to clipboard
Yet another implementation of sainnhe/artify.vim
artify.nvim
Yet another fork of sainnhe/artify.vim.
Motivation
The original artify.vim is written by Vimscript and runs too slowly to use heavily. I have rewritten it with Lua on Neovim and achieved blazingly fast speed.
Run 10000 times both to compare
A simple benchmark
local s = os.clock()
for i = 1, 10000 do
vim.cmd[[call artify#convert('foo', 'bold')]]
end
print(os.clock() - s)
local artify = require'artify'
s = os.clock()
local result = {}
for i = 1, 10000 do
table.insert(result, artify('foo', 'bold'))
end
print(os.clock() - s)
artify.vim | artify.nvim |
---|---|
6.314065 s | 0.0061699999999973 s |
~~Simply x1000 speed!!~~
UPDATED
@sainnhe updated the original implementation (this commit) and it shows extremely improvement. I again benchmarked with more precisely with this Dockerfile.
artify.vim | artify.nvim |
---|---|
0.220149 | 0.009719 |
artify.nvim achieves x20~ speed!!
Usage
artyfy.nvim has almost the same interface as artify.vim.
local artify = require'artify'
artify('foo', 'bold') --> ππ¨π¨
artify('foo', 'italic') --> πππ
artify('foo', 'monospace') --> πππ
Example
lualine.nvim
hoob3rt/lualine.nvim is a pure Lua plugin to show fully-customizable statusline. You can integrate it with artify.nvim.
local artify = require'artify'
local lualine = require'lualine'
lualine.sections.lualine_a = {
{
'mode',
format = function(value)
return artify(value, 'monospace')
end,
},
}

It is showing special characters for the mode: π½πΎππΌπ°π»