nvim: small refactor

This commit is contained in:
Primrose 2025-07-09 10:07:40 +02:00
parent 841d371dd0
commit eda821bf5e
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

View file

@ -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,
})