summaryrefslogtreecommitdiff
path: root/.config/nvim/plugin-settings/indent-blankline.lua
blob: 279715649f86a20ce2792602a1176451b392d389 (plain) (blame)
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
local highlight = {
  "RainbowRed",
  "RainbowYellow",
  "RainbowBlue",
  "RainbowOrange",
  "RainbowGreen",
  "RainbowViolet",
  "RainbowCyan",
}

--- Replace undercurls with underlines as tmux does not show undercurls
local function replace_undercurl_with_underline()
  local hlg = vim.api.nvim_get_hl(0, { link = true })
  for name, attributes in pairs(hlg) do
    if attributes.undercurl then
      attributes.undercurl = false
      attributes.underline = true
      vim.api.nvim_set_hl(0, name, attributes)
    end
  end
end

--- Remove the background attribute from the given highlight group
-- @param name string
local function remove_background(name)
  local attributes = vim.api.nvim_get_hl(0, { name = name })
  if attributes.bg then
    local without_bg = {}
    for k, v in pairs(attributes) do
      if k ~= "bg" then
        without_bg[k] = v
      end
    end
    vim.api.nvim_set_hl(0, name, without_bg)
  end
end

local hooks = require("ibl.hooks")
-- create the highlight groups in the highlight setup hook, so they are reset
-- every time the colorscheme changes
hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
  remove_background("Normal")
  remove_background("EndOfBuffer")
  replace_undercurl_with_underline() -- as tmux does not show undercurls
  vim.api.nvim_set_hl(0, "NonText",       { fg = "DarkGray" })
  vim.api.nvim_set_hl(0, "Whitespace",    { fg = "DarkGray" })
  vim.api.nvim_set_hl(0, "RainbowRed",    { fg = "#E06C75" })
  vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" })
  vim.api.nvim_set_hl(0, "RainbowBlue",   { fg = "#61AFEF" })
  vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" })
  vim.api.nvim_set_hl(0, "RainbowGreen",  { fg = "#98C379" })
  vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" })
  vim.api.nvim_set_hl(0, "RainbowCyan",   { fg = "#56B6C2" })
end)

vim.g.rainbow_delimiters = { highlight = highlight }

hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark)

require("ibl").setup { indent = { char = "›", highlight = highlight, }, }

vim.opt.list = true
vim.opt.listchars = {
  tab = "» ⇥",
  lead = "·",
  trail = "␣",
  nbsp = "⍽",
  extends = "❯",
  precedes = "❮",
  eol = "↴",
}