From eda821bf5e251a77dc67cf9e7016afd9559ae64c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Wed, 9 Jul 2025 10:07:40 +0200 Subject: [PATCH] nvim: small refactor --- .config/nvim/plugin/autocommands.lua | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.config/nvim/plugin/autocommands.lua b/.config/nvim/plugin/autocommands.lua index fc114051..648a0c1d 100644 --- a/.config/nvim/plugin/autocommands.lua +++ b/.config/nvim/plugin/autocommands.lua @@ -16,24 +16,23 @@ vim.api.nvim_create_autocmd("OptionSet", { for _ = c:len(), vim.o.shiftwidth + 1 do c = c .. " " end - return vim.opt.lcs:append("leadmultispace:" .. c) - else - return nil + vim.opt.listchars:append("leadmultispace:" .. c) end end, }) local auto_colorcolumn = vim.api.nvim_create_augroup("auto_colorcolumn", {}) +local set_colorcolumn_from_textwidth = function() vim.wo.colorcolumn = tostring(vim.bo.textwidth) end vim.api.nvim_create_autocmd("OptionSet", { group = auto_colorcolumn, pattern = "textwidth", - callback = function() vim.wo.colorcolumn = tostring(vim.bo.textwidth) end, + callback = set_colorcolumn_from_textwidth, }) vim.api.nvim_create_autocmd("BufEnter", { group = auto_colorcolumn, callback = function() if vim.bo.textwidth then - vim.wo.colorcolumn = tostring(vim.bo.textwidth) + set_colorcolumn_from_textwidth() end end, })