Last active
November 3, 2023 06:06
-
-
Save mengwangk/0eb2bf4b1151bafc476db2b4a69f2be9 to your computer and use it in GitHub Desktop.
Neovim Plugins and Configuration Recipes | 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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