mirror of
https://github.com/neovim/neovim.git
synced 2026-07-30 20:38:03 +00:00
feat(api): nvim_set_hl can set "font" #37668
Problem: Cannot set highlight group fonts via API, only via :highlight command. Solution: Add font parameter in nvim_set_hl().
This commit is contained in:
@@ -334,6 +334,29 @@ describe('API: set highlight', function()
|
||||
eq(nil, hl.underdouble)
|
||||
eq(true, hl.bold)
|
||||
end)
|
||||
|
||||
it('can set font', function()
|
||||
local ns = api.nvim_create_namespace('test_font')
|
||||
api.nvim_set_hl(ns, 'TestFont', { fg = '#ff0000', font = 'Courier New 10' })
|
||||
local hl = api.nvim_get_hl(ns, { name = 'TestFont' })
|
||||
eq('Courier New 10', hl.font)
|
||||
eq(16711680, hl.fg)
|
||||
|
||||
api.nvim_set_hl(ns, 'TestFont', { font = 'Monaco' })
|
||||
hl = api.nvim_get_hl(ns, { name = 'TestFont' })
|
||||
eq('Monaco', hl.font)
|
||||
|
||||
-- Clear font with "NONE"
|
||||
api.nvim_set_hl(ns, 'TestFont', { font = 'NONE' })
|
||||
hl = api.nvim_get_hl(ns, { name = 'TestFont' })
|
||||
eq(nil, hl.font)
|
||||
|
||||
-- global namespace
|
||||
api.nvim_set_hl(0, 'TestFontGlobal', { bg = '#00ff00', font = 'JetBrains Mono' })
|
||||
hl = api.nvim_get_hl(0, { name = 'TestFontGlobal' })
|
||||
eq('JetBrains Mono', hl.font)
|
||||
eq(65280, hl.bg)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('API: get highlight', function()
|
||||
|
||||
Reference in New Issue
Block a user