gruber-darker.nvim/lua/gruber-darker.lua

72 lines
1.7 KiB
Lua
Raw Normal View History

local config = require("gruber-darker.config")
2023-01-10 21:11:37 +01:00
local M = {}
2023-01-10 21:11:37 +01:00
---Delete GruberDarker autocmds when the
---theme changes to something else
---@package
function M.on_colorscheme()
2023-03-14 03:09:44 +01:00
vim.cmd([[autocmd! GruberDarker]])
vim.cmd([[augroup! GruberDarker]])
2023-01-10 21:11:37 +01:00
end
2023-03-26 03:58:47 +02:00
local function create_autocmds()
local gruber_darker_group = vim.api.nvim_create_augroup("GruberDarker", { clear = true })
vim.api.nvim_create_autocmd("ColorSchemePre", {
group = gruber_darker_group,
pattern = "*",
callback = function()
require("gruber-darker").on_colorscheme()
end,
})
vim.api.nvim_create_autocmd("FileType", {
2023-03-26 16:04:41 +02:00
group = gruber_darker_group,
pattern = "qf,help",
callback = function()
vim.cmd.setlocal("winhighlight=Normal:NormalSB,SignColumn:SignColumnSB")
end,
2023-03-26 03:58:47 +02:00
})
2023-04-10 19:22:47 +02:00
-- This is a mitigation for new Nvim v0.9.0 lsp semantic highlights
-- overriding treesitter highlights. Need to link these to relevant
-- treesitter groups in the future. See :h lsp-semantic-highlight
vim.api.nvim_create_autocmd("ColorScheme", {
group = gruber_darker_group,
pattern = "*",
callback = function()
-- Hide all semantic highlights
for _, group in ipairs(vim.fn.getcompletion("@lsp", "highlight")) do
vim.api.nvim_set_hl(0, group, {})
end
end,
})
2023-03-26 03:58:47 +02:00
end
---Clear current highlights and set Neovim global `colors_name`
function M.load()
local highlights = require("gruber-darker.highlights")
2023-03-14 03:09:44 +01:00
if vim.g.colors_name then
vim.cmd.hi("clear")
end
vim.opt.termguicolors = true
vim.g.colors_name = "gruber-darker"
2023-03-14 03:09:44 +01:00
2023-03-25 23:43:49 +01:00
highlights.setup()
2023-03-14 03:09:44 +01:00
2023-03-26 16:04:41 +02:00
create_autocmds()
end
2023-01-10 21:11:37 +01:00
---Change colorscheme to GruberDarker
2023-03-14 03:09:44 +01:00
function M.colorscheme() end
---GruberDarker configuration bootstrapper
---@param opts? GruberDarkerOpts
function M.setup(opts)
config.setup(opts)
end
return M