Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Letters are hidden when indenting with tabs and having listchars #241

Closed
luissolanodev opened this issue Sep 28, 2021 · 7 comments · Fixed by #242
Closed

Letters are hidden when indenting with tabs and having listchars #241

luissolanodev opened this issue Sep 28, 2021 · 7 comments · Fixed by #242

Comments

@luissolanodev
Copy link

Hey! Sorry if the title sounds kinda confusing. I have files indented with tabs looking like this (first described here):

image

I have this nvim config:

local opt = vim.opt

opt.history = 1000
opt.swapfile = false
opt.updatetime = 750
opt.undofile = true
opt.guicursor = ''
opt.cursorline = true
opt.cursorcolumn = true
opt.number = true
opt.relativenumber = true
opt.wrap = false
opt.splitbelow = true
opt.splitright = true
opt.colorcolumn = { '80' }
opt.showtabline = 2
opt.encoding = 'utf-8'
opt.hidden = true
opt.termguicolors = true
vim.g.mapleader = ','
require("plugins")

Indent-blankline config:

vim.opt.list = true
vim.opt.listchars = {
   eol = "$"
}
require('indent_blankline').setup {
   show_end_of_line = true,
   filetype_exclude = {'text', 'help', 'markdown', 'dashboard'},
   show_trailing_blankline_indent = false,
   char_highlight_list = {
      'IndentBlanklineIndent1',
      'IndentBlanklineIndent2',
      'IndentBlanklineIndent3',
      'IndentBlanklineIndent4',
      'IndentBlanklineIndent5',
      'IndentBlanklineIndent6'
   }
}

As you can see I have a simple setup. If I remove vim.opt.listchars it works:

image

Any help?:( The solution may be simple but at this point I don't know what it could be.

@Daxtorim
Copy link
Contributor

If I remove vim.opt.listchars it works:

This is because you were overwriting the listchars without specifying replacements for tabs. Without anything set for tabs, vim will display ^I, which is only two columns wide regardless of your tabstop setting. Since the plugin still creates the virtual text based on tabstop it will be too long and override actual text.

The vim defaults for listchars are:

vim.opt.listchars = {
    tab = "> ",
    trail = "-",
    nbsp = "+",
}

So just add your eol to that table and it should work as expected again.

Alternatively you could also just set vim.opt.tabstop = 2.

@luissolanodev
Copy link
Author

Hey that worked! thanks! I was a bit confusing thinking that "tab" option was somehow set by this plugin and thus showing the indentation marks even when I didn't have it in my listchars. But it seems to be a different functionality, right? Although I read the help and couldn't figured out too much what > is...

						*lcs-tab*
  tab:xy[z]	Two or three characters to be used to show a tab.
		The third character is optional.

  tab:xy	The 'x' is always used, then 'y' as many times as will
		fit.  Thus "tab:>-" displays:
			>
			>-
			>--
			etc.

  tab:xyz	The 'z' is always used, then 'x' is prepended, and
		then 'y' is used as many times as will fit.  Thus
		"tab:<->" displays:
			>
			<>
			<->
			<-->
			etc.

		When "tab:" is omitted, a tab is shown as ^I.

Thank you again!

@lukas-reineke
Copy link
Owner

Although I read the help and couldn't figured out too much what > is

> doesn't have any meaning. It is just the character Neovim displays for tabs by default.

I'll open this issue again, the plugin should handle this more gracefully.
And I also need to update the readme, the examples there should not overwrite all listchars.

@lukas-reineke lukas-reineke reopened this Sep 29, 2021
lukas-reineke added a commit that referenced this issue Sep 29, 2021
* update the README to not overwrite all listchars
* handle listchars without a tab character

fix #241
@luissolanodev
Copy link
Author

luissolanodev commented Sep 29, 2021

Hey @lukas-reineke thanks for the improvement. I'm getting this error when entering neovim though: packer.nvim: Error running config for indent-blankline.nvim: /usr/share/nvim/runtime/lua/vim/_meta.lua:170: E474: Invalid argument

config is as follows:

vim.opt.list = true
vim.opt.listchars:append("eol:$")

require('indent_blankline').setup {
   show_end_of_line = true,
   filetype_exclude = {'text', 'help', 'markdown', 'dashboard'},
   show_trailing_blankline_indent = false,
   char_highlight_list = {
      'IndentBlanklineIndent1',
      'IndentBlanklineIndent2',
      'IndentBlanklineIndent3',
      'IndentBlanklineIndent4',
      'IndentBlanklineIndent5',
      'IndentBlanklineIndent6'
   }
}

@lukas-reineke
Copy link
Owner

vim.opt.listchars:append("eol:$") is standard Neovim. That has nothing to do with this plugin.
Not sure why it is broken for you. Maybe try updating Neovim?

@Daxtorim
Copy link
Contributor

It should be

vim.opt.listchars:append({ eol = "$" })

and only works since Neovim v0.5.1, which was released 2 days ago.

@lukas-reineke
Copy link
Owner

vim.opt.listchars:append("eol:$") works fine for me on 0.5.0, 0.5.1 and latest master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants