Skip to content

Instantly share code, notes, and snippets.

@mengwangk
Last active November 3, 2023 06:06
Show Gist options
  • Save mengwangk/0eb2bf4b1151bafc476db2b4a69f2be9 to your computer and use it in GitHub Desktop.
Save mengwangk/0eb2bf4b1151bafc476db2b4a69f2be9 to your computer and use it in GitHub Desktop.
Neovim Plugins and Configuration Recipes | 5
local function update_lead()
local lcs = vim.opt_local.listchars:get()
local tab = vim.fn.str2list(lcs.tab)
local space = vim.fn.str2list(lcs.multispace or lcs.space)
local lead = { tab[1] }
for i = 1, vim.bo.tabstop - 1 do
lead[#lead + 1] = space[i % #space + 1]
end
vim.opt_local.listchars:append { leadmultispace = vim.fn.list2str(lead) }
end
local function indent_listchars()
opt.list = true
opt.listchars = {
tab = "⟩ ",
trail = "+",
precedes = "<",
extends = ">",
space = "·",
nbsp = "␣",
leadmultispace = "│ ",
multispace = "│ ",
}
vim.api.nvim_create_autocmd("OptionSet", { pattern = { "listchars", "tabstop", "filetype" }, callback = update_lead })
vim.api.nvim_create_autocmd("VimEnter", { callback = update_lead, once = true })
end
indent_listchars()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment