lukas-reineke / indent-blankline.nvim

Indent guides for Neovim
MIT License
4.22k stars 105 forks source link

Some trail chars on empty lines are blue #514

Closed ivanesmantovich closed 1 year ago

ivanesmantovich commented 1 year ago

image

Config:

vim.opt.list = true
vim.opt.listchars = "eol:↵,trail:·,tab:  "

require("indent_blankline").setup {
    char = '┊',
    space_char_blankline = " ",
    show_trailing_blankline_indent = false,
    use_treesitter = true,
    use_treesitter_scope = true,
    show_current_context = true,
    show_current_context_start = true,
}

If i remove last four lines related to treesitter functionality then all of trail characters become blue, not just some of them. Trail characters at the end of the line are ok! Please help, and this will become my fav plugin... Thanks!

lukas-reineke commented 1 year ago

I can't reproduce this. Can you make a complete init.lua file that causes this?

ivanesmantovich commented 1 year ago

Sure, i hope there is everything

vim.cmd [[packadd packer.nvim]]

return require("packer").startup(function(use)
    use "wbthomason/packer.nvim"

    use { -- TPOPE
        "tpope/vim-vinegar",
        "tpope/vim-commentary",
        "tpope/vim-surround",
        "tpope/vim-fugitive",
        "tpope/vim-rhubarb"
    }

    use "mbbill/undotree"
    use "ThePrimeagen/harpoon"

    use {
        "nvim-telescope/telescope.nvim", tag = "0.1.0",
        requires = { { "nvim-lua/plenary.nvim" } }
    }
    use { 'nvim-telescope/telescope-fzf-native.nvim', run = 'make' }

    use("nvim-treesitter/nvim-treesitter", { run = ":TSUpdate" })
    use { -- Additional text objects via treesitter
        'nvim-treesitter/nvim-treesitter-textobjects',
        after = 'nvim-treesitter',
    }
    use("nvim-treesitter/playground")

    use('lewis6991/gitsigns.nvim')

    -- Colorscheme
    use {
        "mcchrish/zenbones.nvim",
        requires = "rktjmp/lush.nvim",
    }

    -- <3
    use "lukas-reineke/indent-blankline.nvim"

    use {
        'VonHeikemen/lsp-zero.nvim',
        requires = {
            -- LSP Support
            { 'neovim/nvim-lspconfig' },
            { 'williamboman/mason.nvim' },
            { 'williamboman/mason-lspconfig.nvim' },
            -- Autocompletion
            { 'hrsh7th/nvim-cmp' },
            { 'hrsh7th/cmp-buffer' },
            { 'hrsh7th/cmp-path' },
            { 'saadparwaiz1/cmp_luasnip' },
            { 'hrsh7th/cmp-nvim-lsp' },
            { 'hrsh7th/cmp-nvim-lua' },
            -- Snippets
            { 'L3MON4D3/LuaSnip' },
            { 'rafamadriz/friendly-snippets' },
        }
    }
    -- LSP loading animation
    use 'j-hui/fidget.nvim'
end)

require("indent_blankline").setup {
    char = '┊',
    space_char_blankline = " ",
    show_trailing_blankline_indent = false,
    use_treesitter = true,
    use_treesitter_scope = true,
    show_current_context = true,
    show_current_context_start = true,
}

vim.g.zenbones = { lightness = 'bright' }
vim.cmd.colorscheme("zenbones")

vim.cmd [[highlight IndentBlanklineContextChar guifg=#7e7774 gui=nocombine]]

require('fidget').setup()

vim.keymap.set("n", "<leader>gs", vim.cmd.Git)

require('gitsigns').setup {
    signs = {
        add = { text = '+' },
        change = { text = '~' },
        delete = { text = '_' },
        topdelete = { text = '‾' },
        changedelete = { text = '~' },
    },
}

local mark = require("harpoon.mark")
local ui = require("harpoon.ui")

vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<leader>h", ui.toggle_quick_menu)

-- Moving between Harpoon files with qwerty
vim.keymap.set("n", "<C-q>", function() ui.nav_file(1) end)
vim.keymap.set("n", "<C-w>", function() ui.nav_file(2) end)
vim.keymap.set("n", "<C-e>", function() ui.nav_file(3) end)
vim.keymap.set("n", "<C-r>", function() ui.nav_file(4) end)
vim.keymap.set("n", "<C-t>", function() ui.nav_file(5) end)
vim.keymap.set("n", "<C-y>", function() ui.nav_file(6) end)

vim.cmd("set termguicolors")

local lsp = require("lsp-zero")

lsp.preset("recommended")

lsp.ensure_installed({
    'tsserver',
    'eslint',
    'sumneko_lua',
})

-- Fix Undefined global 'vim'
lsp.configure('sumneko_lua', {
    settings = {
        Lua = {
            diagnostics = {
                globals = { 'vim' }
            }
        }
    }
})

local cmp = require('cmp')
local cmp_select = { behavior = cmp.SelectBehavior.Select }
local cmp_mappings = lsp.defaults.cmp_mappings({
    -- Previous suggestion
    ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
    -- Next suggestion
    ['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
    -- Select suggestion
    ['<C-y>'] = cmp.mapping.confirm({ select = true }),
    ["<C-Space>"] = cmp.mapping.complete(),
})

-- UNCOMMENT TO DISABLE COMPLETION WITH TAB
-- disable completion with tab
-- this helps with copilot setup
-- cmp_mappings['<Tab>'] = nil
-- cmp_mappings['<S-Tab>'] = nil

lsp.setup_nvim_cmp({
    mapping = cmp_mappings
})

lsp.set_preferences({
    suggest_lsp_servers = false,
    sign_icons = {}
})

lsp.on_attach(function(client, bufnr)
    local opts = { buffer = bufnr, remap = false }

    if client.name == "eslint" then
        vim.cmd.LspStop('eslint')
        return
    end

    vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
    vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, opts)
    vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
    vim.keymap.set("n", "[d", vim.diagnostic.goto_next, opts)
    vim.keymap.set("n", "]d", vim.diagnostic.goto_prev, opts)
    vim.keymap.set("n", "<leader>vrr", vim.lsp.buf.references, opts)
    vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, opts)
    vim.keymap.set("i", "<C-h>", vim.lsp.buf.signature_help, opts)
end)

lsp.setup()

vim.diagnostic.config({
    virtual_text = true,
})

local builtin = require('telescope.builtin')
vim.keymap.set('n', '<leader>f', builtin.find_files, {})
vim.keymap.set('n', '<leader>t', builtin.live_grep, {})
vim.keymap.set('n', '<leader>b', builtin.buffers, {})
vim.keymap.set('n', '<leader>d', builtin.diagnostics, {})

require('telescope').setup {
    defaults = {
        layout_config = {
            horizontal = { height = 0.95, width = 0.95, preview_width = 0.7 }
        },
        show_line = false,
        prompt_title = '',
        results_title = '',
        preview_title = '',
        prompt_prefix = '',
        path_display = { "smart" },
        borderchars = {
            prompt = { '', '', '', '', '', '', '', '' },
            results = { '', '', '', '', '', '', '', '' },
            preview = { '', '', '', '', '', '', '', '' },
        },

        -- Default configuration for telescope goes here:
        -- config_key = value,
        mappings = {
            i = {
                ["<C-h>"] = "which_key"
            },
            n = {
                ["d"] = "delete_buffer"
            }
        }
    },
    pickers = {
        -- Default configuration for builtin pickers goes here:
        -- picker_name = {
        --   picker_config_key = value,
        --   ...
        -- }
        -- Now the picker_config_key will be applied every time you call this
        -- builtin picker
    },
    extensions = {
        -- Your extension configuration goes here:
        -- extension_name = {
        --   extension_config_key = value,
        -- }
        -- please take a look at the readme of the extension you want to configure
    }
}
require('telescope').load_extension('fzf')

require 'nvim-treesitter.configs'.setup {
    -- A list of parser names, or "all"
    ensure_installed = { "help", "html", "css", "javascript", "typescript", "go", "lua", "rust" },

    -- Install parsers synchronously (only applied to `ensure_installed`)
    sync_install = false,

    -- Automatically install missing parsers when entering buffer
    -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally
    auto_install = true,

    highlight = {
        -- `false` will disable the whole extension
        enable = true,

        -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
        -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
        -- Using this option may slow down your editor, and you may see some duplicate highlights.
        -- Instead of true it can also be a list of languages
        additional_vim_regex_highlighting = false,
    },

    indent = {
        enable = true,
    },

    -- Pressing C-space selects syntactic region under cursor, press multiple times to select bigger region
    incremental_selection = {
        enable = true,
        keymaps = {
            init_selection = '<c-space>',
            node_incremental = '<c-space>',
            scope_incremental = '<c-s>',
            node_decremental = '<c-backspace>',
        },
    },
}

vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)

vim.opt.termguicolors = true
vim.opt.background = "light"

vim.opt.fileencoding = "utf-8"
vim.opt.clipboard = "unnamedplus"

vim.opt.list = true
vim.opt.listchars = "eol:↵,trail:·,tab:  "

vim.opt.nu = true
vim.opt.relativenumber = true

vim.opt.tabstop = 4
vim.opt.softtabstop = 4
vim.opt.shiftwidth = 4
vim.opt.expandtab = true

vim.opt.smarttab = true
vim.opt.smartindent = true

vim.opt.wrap = false

vim.opt.swapfile = false
vim.opt.backup = false
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"

vim.opt.hlsearch = false
vim.opt.incsearch = true

vim.opt.scrolloff = 8
vim.opt.sidescrolloff = 8
vim.opt.signcolumn = "yes"

-- force all horizontal splits to go below current window
vim.opt.splitbelow = true
-- force all vertical splits to go to the right of current window
vim.opt.splitright = true

vim.opt.updatetime = 50

-- Better cmp
vim.opt.completeopt = { "menuone", "noselect" }
lukas-reineke commented 1 year ago

Can you please remove the things that are not necessary for this? Sorry, but I don't have time to debug your whole personal config. Also, this config is broken. You return with the second statement, most of this is not even run.

neolooong commented 1 year ago

I have a similar problem. I tried to load indent-blankline after set colorscheme, then it fixed.

Rishabh672003 commented 1 year ago

@lukas-reineke heres a minimal config with lazy.nvim that replicates the issue

local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "https://github.com/folke/lazy.nvim.git",
        "--branch=stable", -- latest stable release
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

-- example using a list of specs with the default options
vim.g.mapleader = " " -- make sure to set `mapleader` before lazy so your mappings are correct

require("lazy").setup({
  {
        "lukas-reineke/indent-blankline.nvim",
        config = function()
            vim.g.indent_blankline_buftype_exclude = { "terminal", "nofile" }
            vim.g.indent_blankline_filetype_exclude = {
                "help",
                "startify",
                "dashboard",
                "packer",
                "neogitstatus",
                "NvimTree",
                "Trouble",
            }
            vim.g.indentLine_enabled = 1
            vim.g.indent_blankline_char = "▏"
            vim.g.indent_blankline_show_trailing_blankline_indent = false
            vim.g.indent_blankline_show_first_indent_level = true
            vim.g.indent_blankline_show_current_context = true
            vim.wo.colorcolumn = "99999"
            require("indent_blankline").setup({
                show_current_context = true,
            })
        end,
    },
  { 
        "nvim-treesitter/nvim-treesitter",
        dependencies = {
            "nvim-treesitter/playground",
            "JoosepAlviste/nvim-ts-context-commentstring",
            "kyazdani42/nvim-web-devicons",
        },
        config = function()
      require("nvim-treesitter.configs").setup({
          ensure_installed = { "lua", "markdown", "markdown_inline", "bash", "python" }, -- put the language you want in this array
          sync_install = false, -- install languages synchronously (only applied to `ensure_installed`)
          ignore_install = {}, -- List of parsers to ignore installing
          autopairs = {
            enable = true,
          },
          highlight = {
            enable = true, -- false will disable the whole extension
            disable = {}, -- list of language that will be disabled
          },
          indent = { enable = true, disable = { "python" } },
          context_commentstring = {
            enable = true,
            enable_autocmd = false,
          },
      })
        end,
    },
  {

        "catppuccin/nvim",
        name = "catppuccin",
        lazy = false, -- make sure we load this during startup if it is your main colorscheme
        priority = 1000, -- make sure to load this before all the other start plugins
        config = function()
            require("catppuccin").setup({
                flavour = "mocha", -- latte, frappe, macchiato, mocha
                background = { -- :h background
                    light = "latte",
                    dark = "mocha",
                },
                term_colors = false,
                dim_inactive = {
                    enabled = false,
                    shade = "dark",
                    percentage = 0.15,
                },
                no_italic = false, -- Force no italic
                no_bold = false, -- Force no bold
                styles = {
                    comments = { "italic" },
                    conditionals = { "italic" },
                },
                integrations = {
                    cmp = true,
                    gitsigns = true,
                    nvimtree = true,
                    telescope = true,
                    notify = true,
                    mini = false,
                },
            })
            vim.api.nvim_set_hl(0, "IlluminatedWordText", { link = "Visual" })
            vim.api.nvim_set_hl(0, "IlluminatedWordRead", { link = "Visual" })
            vim.api.nvim_set_hl(0, "IlluminatedWordWrite", { link = "Visual" })
        end,
    },
})

vim.cmd("colorscheme catppuccin")

image

dzintars commented 1 year ago

image IDK... i tried so many things... Disabled most of the options and plugins. Switched several themes, but this issue still persists. And strangely, sometimes on buffer open it is not there. And once i start to navigate, it just shows up.

dzintars commented 1 year ago

image I think I found something. I should rise the color scheme priority in order for those blue guides to go away. (for non-lazy loaded plugins)

Yeah. Seems it is it. As far as i see for now, the issue for me is gone. If so, documentation could be improved. Will start to enable my plugins and see, how it goes from there.

image

Rishabh672003 commented 1 year ago

i dont know how but i fixed it by doing it like this

    {
        "catppuccin/nvim",
        name = "catppuccin",
        lazy = false, -- make sure we load this during startup if it is your main colorscheme
        priority = 1000, -- make sure to load this before all the other start plugins
        config = function()
            require("rj.plugins.catppuccin")
        end,
        dependencies = {},
    },
    {
        "lukas-reineke/indent-blankline.nvim",
        event = "BufReadPre",
        config = function()
            require("rj.plugins.indentline")
        end,
    },

image

lukas-reineke commented 1 year ago

indent-blankline generates highlight groups from existing highlight groups. It looks like it just uses the colors from the default color scheme. But generation is triggered when the color scheme changes, so the order of loading should not matter. Not really sure what is happening. There might be some race condition with how Neovim loads things.

The easiest workaround is either load the color scheme first, or just explicitly set the indent-blankline highlight groups.

vqvw commented 1 year ago

i dont know how but i fixed it by doing it like this

  {
      "catppuccin/nvim",
      name = "catppuccin",
      lazy = false, -- make sure we load this during startup if it is your main colorscheme
      priority = 1000, -- make sure to load this before all the other start plugins
      config = function()
          require("rj.plugins.catppuccin")
      end,
      dependencies = {},
  },
  {
      "lukas-reineke/indent-blankline.nvim",
      event = "BufReadPre",
      config = function()
          require("rj.plugins.indentline")
      end,
  },

image

This fixed it for me too, but all that is needed for the fix is event = "VeryLazy" when importing the indent-blankline plugin.

image