lukas-reineke / indent-blankline.nvim

Indent guides for Neovim
MIT License
4.2k stars 104 forks source link

Context Colour #380

Closed karimlevallois closed 2 years ago

karimlevallois commented 2 years ago

Just trying to change the context highlight colour (Treesitter) from white to blue. Tried adding 'char_highlight' under my config, but that doesn't seem to be working.

Any help greatly received.

Screenshot 2022-03-26 at 11 04 22
karimlevallois commented 2 years ago
local M = {}

M.config = function()
  local status_ok, bl = pcall(require, "indent_blankline")
  if not status_ok then
    return
  end

  bl.setup {
    enabled = true,
    bufname_exclude = { "README.md" },
    buftype_exclude = { "terminal", "nofile" },
    filetype_exclude = {
      "alpha",
      "log",
      "gitcommit",
      "dapui_scopes",
      "dapui_stacks",
      "dapui_watches",
      "dapui_breakpoints",
      "dapui_hover",
      "LuaTree",
      "dbui",
      "UltestSummary",
      "UltestOutput",
      "vimwiki",
      "markdown",
      "json",
      "txt",
      "vista",
      "NvimTree",
      "git",
      "TelescopePrompt",
      "undotree",
      "flutterToolsOutline",
      "org",
      "orgagenda",
      "help",
      "startify",
      "dashboard",
      "packer",
      "neogitstatus",
      "NvimTree",
      "Outline",
      "Trouble",
      "lspinfo",
      "", -- for all buffers without a file type
    },
    -- char = "▏",
    char_list = { "", "", "", "", "", "", "", "", "" },
    char_highlight_list = {
      "IndentBlanklineIndent1",
      "IndentBlanklineIndent2",
      "IndentBlanklineIndent3",
      "IndentBlanklineIndent4",
      "IndentBlanklineIndent5",
      "IndentBlanklineIndent6",
    },
    show_trailing_blankline_indent = false,
    show_first_indent_level = false,
    space_char_blankline = " ",
    use_treesitter = true,
    show_foldtext = false,
    show_current_context = true,
    show_current_context_start = false,
    context_patterns = {
      "class",
      "return",
      "function",
      "method",
      "^if",
      "^do",
      "^switch",
      "^while",
      "jsx_element",
      "^for",
      "^object",
      "^table",
      "block",
      "arguments",
      "if_statement",
      "else_clause",
      "jsx_element",
      "jsx_self_closing_element",
      "try_statement",
      "catch_clause",
      "import_statement",
      "operation_type",
    },
  }
  -- HACK: work-around for https://github.com/lukas-reineke/indent-blankline.nvim/issues/59
  vim.wo.colorcolumn = "99999"
end

return M
karimlevallois commented 2 years ago

Ah, fixed it with vim.cmd[[highlight IndentBlanklineContextChar guifg=#F8BD96 gui=nocombine]]

karimlevallois commented 2 years ago

OK, so Python files seem to be highlighting correctly. Grey indentations being shown and peach while in context. However, HTML aren't being highlighted while in context, just grey indentations showing?

lukas-reineke commented 2 years ago

If you don't have context for HTML, it probably means your context_patterns are missing the patterns for HTML. You can check how they look like with ::TSPlaygroundToggle

karimlevallois commented 2 years ago

Fixed it by just removing my context_patterns list.

Soooda commented 2 years ago

Ah, fixed it with vim.cmd[[highlight IndentBlanklineContextChar guifg=#F8BD96 gui=nocombine]]

Sorry for adding on a closed issue, I wanna modify the colour as well but the command doesn't change anything somehow 😕

local M = {}

function M.setup()
    local status_ok, indent_blankline = pcall(require, "indent_blankline")
    if not status_ok then
        return
    end

    indent_blankline.setup {
        show_trailing_blankline_indent = false,
        space_char_blankline = " ",
        use_treesitter = true,
        show_current_context = true,
        show_current_context_start = true,
    }

    vim.cmd[[highlight IndentBlanklineContextChar guifg=#62646C gui=nocombine]]
end

return M

Any clues? Cheers~

lukas-reineke commented 2 years ago

Your code looks correct. Maybe the highlight group gets overwritten somewhere? You can check if and where it was set with :verbose highlight IndentBlanklineContextChar

Soooda commented 2 years ago

Thank you very much! Indeed, it looks like I config the new context indent colour before setting my color scheme so it got overwritten. Resolved!