-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhlgroups.lua
152 lines (145 loc) · 6.6 KB
/
hlgroups.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
--stylua: ignore start
local hlgroups = {
WinBarCurrentContext = { link = 'Visual' },
WinBarHover = { link = 'Visual' },
WinBarIconKindDefault = { link = 'Special' },
WinBarIconKindArray = { link = 'Operator' },
WinBarIconKindBoolean = { link = 'Boolean' },
WinBarIconKindBreakStatement = { link = 'Error' },
WinBarIconKindCall = { link = 'Function' },
WinBarIconKindCaseStatement = { link = '@keyword.conditional' },
WinBarIconKindClass = { link = 'Type' },
WinBarIconKindConstant = { link = 'Constant' },
WinBarIconKindConstructor = { link = '@constructor' },
WinBarIconKindContinueStatement = { link = 'Repeat' },
WinBarIconKindDeclaration = { link = 'WinBarIconKindDefault' },
WinBarIconKindDelete = { link = 'Error' },
WinBarIconKindDoStatement = { link = 'Repeat' },
WinBarIconKindElement = { link = 'WinBarIconKindDefault' },
WinBarIconKindElseStatement = { link = '@keyword.conditional' },
WinBarIconKindEnum = { link = 'Constant' },
WinBarIconKindEnumMember = { link = 'WinBarIconKindEnumMember' },
WinBarIconKindEvent = { link = '@lsp.type.event' },
WinBarIconKindField = { link = 'WinBarIconKindDefault' },
WinBarIconKindFile = { link = 'WinBarIconKindFolder' },
WinBarIconKindFolder = { link = 'Directory' },
WinBarIconKindForStatement = { link = 'Repeat' },
WinBarIconKindFunction = { link = 'Function' },
WinBarIconKindH1Marker = { link = 'markdownH1' },
WinBarIconKindH2Marker = { link = 'markdownH2' },
WinBarIconKindH3Marker = { link = 'markdownH3' },
WinBarIconKindH4Marker = { link = 'markdownH4' },
WinBarIconKindH5Marker = { link = 'markdownH5' },
WinBarIconKindH6Marker = { link = 'markdownH6' },
WinBarIconKindIdentifier = { link = 'WinBarIconKindDefault' },
WinBarIconKindIfStatement = { link = '@keyword.conditional' },
WinBarIconKindInterface = { link = 'Type' },
WinBarIconKindKeyword = { link = '@keyword' },
WinBarIconKindList = { link = 'Operator' },
WinBarIconKindMacro = { link = 'Macro' },
WinBarIconKindMarkdownH1 = { link = 'markdownH1' },
WinBarIconKindMarkdownH2 = { link = 'markdownH2' },
WinBarIconKindMarkdownH3 = { link = 'markdownH3' },
WinBarIconKindMarkdownH4 = { link = 'markdownH4' },
WinBarIconKindMarkdownH5 = { link = 'markdownH5' },
WinBarIconKindMarkdownH6 = { link = 'markdownH6' },
WinBarIconKindMethod = { link = 'Function' },
WinBarIconKindModule = { link = '@module' },
WinBarIconKindNamespace = { link = '@lsp.type.namespace' },
WinBarIconKindNull = { link = 'Constant' },
WinBarIconKindNumber = { link = 'Number' },
WinBarIconKindObject = { link = 'Statement' },
WinBarIconKindOperator = { link = 'Operator' },
WinBarIconKindPackage = { link = '@module' },
WinBarIconKindPair = { link = 'WinBarIconKindDefault' },
WinBarIconKindProperty = { link = 'WinBarIconKindDefault' },
WinBarIconKindReference = { link = 'WinBarIconKindDefault' },
WinBarIconKindRepeat = { link = 'Repeat' },
WinBarIconKindRuleSet = { link = '@lsp.type.namespace' },
WinBarIconKindScope = { link = '@lsp.type.namespace' },
WinBarIconKindSpecifier = { link = '@keyword' },
WinBarIconKindStatement = { link = 'Statement' },
WinBarIconKindString = { link = '@string' },
WinBarIconKindStruct = { link = 'Type' },
WinBarIconKindSwitchStatement = { link = '@keyword.conditional' },
WinBarIconKindTable = { link = 'WinBarIconKindDefault' },
WinBarIconKindType = { link = 'Type' },
WinBarIconKindTypeParameter = { link = 'WinBarIconKindDefault' },
WinBarIconKindUnit = { link = 'WinBarIconKindDefault' },
WinBarIconKindValue = { link = 'Number' },
WinBarIconKindVariable = { link = 'WinBarIconKindDefault' },
WinBarIconKindWhileStatement = { link = 'Repeat' },
WinBarIconUIIndicator = { link = 'SpecialChar' },
WinBarIconUIPickPivot = { link = 'Error' },
WinBarIconUISeparator = { link = 'Comment' },
WinBarIconUISeparatorMenu = { link = 'WinBarIconUISeparator' },
WinBarMenuCurrentContext = { link = 'PmenuSel' },
WinBarMenuFloatBorder = { link = 'FloatBorder' },
WinBarMenuHoverEntry = { link = 'IncSearch' },
WinBarMenuHoverIcon = { reverse = true },
WinBarMenuHoverSymbol = { bold = true },
WinBarMenuNormalFloat = { link = 'NormalFloat' },
WinBarMenuSbar = { link = 'PmenuSbar' },
WinBarMenuThumb = { link = 'PmenuThumb' },
WinBarPreview = { link = 'Visual' },
}
--stylua: ignore end
---Set WinBar & WinBarNC background to Normal background
---@return nil
local function clear_winbar_bg()
---@param name string
---@return nil
local function _clear_bg(name)
local hl = require('utils.hl').get(0, {
name = name,
winhl_link = false,
})
if hl.bg or hl.ctermbg then
hl.bg = nil
hl.ctermbg = nil
vim.api.nvim_set_hl(0, name, hl)
end
end
_clear_bg('WinBar')
_clear_bg('WinBarNC')
end
---Set winbar highlight groups
---@return nil
local function set_hlgroups()
for hl_name, hl_settings in pairs(hlgroups) do
hl_settings.default = true
vim.api.nvim_set_hl(0, hl_name, hl_settings)
end
end
---Initialize highlight groups for winbar
local function init()
local groupid = vim.api.nvim_create_augroup('WinBarHlGroups', {})
set_hlgroups()
vim.api.nvim_create_autocmd('ColorScheme', {
group = groupid,
callback = set_hlgroups,
})
-- See https://github.com/Bekaboo/dropbar.nvim/issues/118
-- https://github.com/neovim/neovim/issues/26037#issuecomment-1838548013
-- https://github.com/Bekaboo/dropbar.nvim/pull/195
if vim.fn.has('nvim-0.11.0') == 0 then
clear_winbar_bg()
vim.api.nvim_create_autocmd('UIEnter', {
once = true,
group = groupid,
callback = clear_winbar_bg,
})
vim.api.nvim_create_autocmd('ColorScheme', {
group = groupid,
callback = clear_winbar_bg,
})
vim.api.nvim_create_autocmd('OptionSet', {
group = groupid,
pattern = 'background',
callback = clear_winbar_bg,
})
end
end
return {
init = init,
}