1 个不稳定版本
0.2.0 | 2024年1月1日 |
---|
#20 in #rendered
7KB
Neophyte
Neophyte 是使用 WebGPU 和 Rust 编写的 Neovim 图形用户界面。它比默认的基于终端的 UI 提供了多项便利功能
- 由 Swash 进行文本形状和光栅化,提供高质量的字体渲染功能,如连字符、备用字体和表情符号
- 平滑滚动
- 光标动画
- 像素级窗口定位
安装
可以从 发行版 中获取二进制文件,或者使用 Rust 工具链 进行安装
cargo install neophyte
配置
脚本
Neophyte 可以使用 Lua 脚本化。API 已使用 LuaLS 类型注释,以便于发现。
-- lazy.nvim example:
{
'tim-harding/neophyte',
event = 'VeryLazy',
opts = {
-- Same as neophyte.setup({ ... })
},
}
-- API usage example:
local neophyte = require('neophyte')
neophyte.setup({
fonts = {
{
name = 'Cascadia Code PL',
features = {
{
name = 'calt',
value = 1,
},
-- Shorthand to set a feature to 1
'ss01',
'ss02',
},
},
-- Fallback fonts
{
name = 'Monaspace Argon Var',
-- Variable font axes
variations = {
{
name = 'slnt',
value = -11,
},
},
},
-- Shorthand for no features or variations
'Symbols Nerd Font',
'Noto Color Emoji',
},
font_size = {
kind = 'width', -- 'width' | 'height'
size = 10,
},
-- Multipliers of the base animation speed.
-- To disable animations, set these to large values like 1000.
cursor_speed = 2,
scroll_speed = 2,
-- Increase or decrease the distance from the baseline for underlines.
underline_offset = 1,
-- For transparent window effects, use this to set the default background color.
-- This is because most colorschemes in transparent mode unset the background,
-- which normally defaults to the terminal background, but we don't have that here.
-- You must also pass --transparent as a command-line argument to see the effect.
-- Channel values are in the range 0-255.
bg_override = {
r = 48,
g = 52,
b = 70,
a = 128,
},
})
-- Alternatively, the guifont option is supported:
vim.opt.guifont = "Cascadia Code PL:w10, Symbols Nerd Font, Noto Color Emoji"
-- There are also freestanding functions to set these options as desired.
-- Below is a keymap for increasing and decreasing the font size:
-- Increase font size
vim.keymap.set('n', '<c-+>', function()
neophyte.set_font_width(neophyte.get_font_width() + 1)
end)
-- Decrease font size
vim.keymap.set('n', '<c-->', function()
neophyte.set_font_width(neophyte.get_font_width() - 1)
end)
-- Neophyte can also record frames to a PNG sequence.
-- You can convert to a video with ffmpeg:
--
-- ffmpeg -framerate 60 -pattern_type glob -i '/my/frames/location/*.png'
-- -pix_fmt yuv422p -c:v libx264 -vf
-- "colorspace=all=bt709:iprimaries=bt709:itrc=srgb:ispace=bt709:range=tv:irange=pc"
-- -color_range 1 -colorspace 1 -color_primaries 1 -crf 23 -y /my/output/video.mp4
-- Start rendering
neophyte.start_render('/directory/to/output/frames/')
-- Stop rendering
neophyte.end_render()
Noice
建议使用 Neophyte 与 Noice 配合使用,以获得最佳效果,除非您选择禁用光标动画。这是因为 Noice 将多个 UI 功能外部化,使得 Neovim 负责渲染它们,特别是命令行和信息。没有这个,光标会以令人不适的方式跳跃。最终我们可能会在不使用插件的情况下支持外部化这些 UI 元素(这已经部分实现),但在此期间,Noice 是最佳选择。如果您想尝试 Noice 而不选择弹出通知或弹出命令行,可以尝试以下设置
-- lazy.nvim
{
'folke/noice.nvim',
event = 'VeryLazy',
opts = {
presets = {
bottom_search = true,
command_palette = true,
long_message_to_split = true,
},
lsp = {
message = {
view = 'mini',
},
},
messages = {
view = 'mini',
view_search = false,
},
cmdline = {
view = 'cmdline',
},
},
dependencies = {
"MunifTanjim/nui.nvim",
},
}
依赖
~280–730KB
~17K SLoC