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

Feature Suggestion: also set listchars depending on tabs/spaces #12

Closed
chrisgrieser opened this issue Apr 26, 2023 · 0 comments
Closed

Comments

@chrisgrieser
Copy link

I find it useful to only show tab via listchars when using spaces and vice versa, since that allows me to quickly identify the use of the wrong type of indention in a file.

Currently, I run a simple autocommand like this to adjust listchars depending whether the buffer uses tabs or spaces:

autocmd("BufReadPost", {
	callback = function()
		-- defered, to ensure it runs after `:GuessIndent`
		vim.defer_fn(function()
			opt_local.listchars = vim.opt_global.listchars:get() -- copy the global
			if bo.expandtab then
				opt_local.listchars:append { tab = "? " }
				opt_local.listchars:append { lead = " " }
			else
				opt_local.listchars:append { tab = "  " }
				opt_local.listchars:append { lead = "" }
			end
		end, 5)
	end,
})

I was thinking that adjusting listchars would actually make a lot of sense for in the context of this plugin (and would also save one from using hacky solutions like deferring that autocmd)

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

No branches or pull requests

1 participant