Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use nvim_set_hl to speed up startup time #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion lua/onedark/highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@ local util = require("onedark.util")
local M = {}
local hl = {langs = {}, plugins = {}}

local function vim_highlights(highlights)
local function vim_highlights_nvim070(highlights)
for group_name, group_settings in pairs(highlights) do
local settings = {
fg = group_settings.fg or "none",
bg = group_settings.bg or "none",
sp = group_settings.sp or "none",
}
if group_settings.fmt and group_settings.fmt ~= "none" then
for _, setting in pairs(vim.split(group_settings.fmt, ",")) do
settings[setting] = 1
end
end
vim.api.nvim_set_hl(0, group_name, settings)
end
end

local function vim_highlights_prior_to_nvim070(highlights)
for group_name, group_settings in pairs(highlights) do
vim.api.nvim_command(string.format("highlight %s guifg=%s guibg=%s guisp=%s gui=%s", group_name,
group_settings.fg or "none",
Expand All @@ -15,6 +31,11 @@ local function vim_highlights(highlights)
end
end

local vim_highlights = vim_highlights_prior_to_nvim070
if vim.fn.has('nvim-0.7.0') then
vim_highlights = vim_highlights_nvim070
end

local colors = {
Fg = {fg = c.fg},
LightGrey = {fg = c.light_grey},
Expand Down