Created
November 2, 2021 20:23
-
-
Save jonvaldes/6729602ad7f79957cae984208b30f670 to your computer and use it in GitHub Desktop.
Neovide font switching snippet
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 fonts | |
if (jit.os == 'Windows') then | |
fonts = { | |
'DejaVuSansMono Nerd Font Mono', | |
'CaskaydiaCove NF', | |
'Hack NF', | |
'Monofur NF', | |
'VictorMono NF', -- Doesn't work well with telescope | |
'Hurmit NF', -- Doesn't work well with telescope | |
'DroidSansMono NF', -- Doesn't work well with telescope | |
} | |
else | |
fonts = { | |
'Borg Sans Mono', | |
'Droid Sans Mono Dotted for Powerline', | |
'Cascadia Code', | |
'DaddyTimeMono', | |
'Hack', | |
'Hermit', | |
'Lekton', | |
'Hasklig', | |
'monofur', | |
'Victor Mono', | |
'TeX Gyre Cursor', | |
'Fira Code Retina', | |
'Consolas' | |
} | |
end | |
local fontSize = 24 | |
if (jit.os == 'Windows') then | |
fontSize = 18 | |
end | |
local currentFont = 0 | |
function setCurrentFont() | |
vim.o.guifont = fonts[(currentFont % #fonts) + 1] .. ':h' .. fontSize | |
vim.cmd[[sleep 200m]] | |
vim.cmd[[redraw]] | |
print(vim.o.guifont) | |
end | |
setCurrentFont() | |
function nextFont() | |
currentFont = currentFont + 1 | |
setCurrentFont() | |
end | |
function biggerFont() | |
fontSize = fontSize + 1 | |
setCurrentFont() | |
end | |
function smallerFont() | |
fontSize = fontSize - 1 | |
setCurrentFont() | |
end | |
bind('', '<A-S-F>', '<cmd>lua nextFont()<cr>') | |
bind('', '<C-=>', '<cmd>lua biggerFont()<cr>') | |
bind('', '<C-->', '<cmd>lua smallerFont()<cr>') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment