summaryrefslogtreecommitdiff
path: root/stowables-dotlocal/share/nvim/site/pack/manual/start/nvim-cmp-v0.0.1/lua/cmp/utils/highlight.lua
blob: 867632a0cd11add7fc6e495c743ca829fc3ae37b (plain)
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
local highlight = {}

highlight.keys = {
  'fg',
  'bg',
  'bold',
  'italic',
  'reverse',
  'standout',
  'underline',
  'undercurl',
  'strikethrough',
}

highlight.inherit = function(name, source, settings)
  for _, key in ipairs(highlight.keys) do
    if not settings[key] then
      local v = vim.fn.synIDattr(vim.fn.hlID(source), key)
      if key == 'fg' or key == 'bg' then
        local n = tonumber(v, 10)
        v = type(n) == 'number' and n or v
      else
        v = v == 1
      end
      settings[key] = v == '' and 'NONE' or v
    end
  end
  vim.api.nvim_set_hl(0, name, settings)
end

return highlight