From b72fab5c29ce33be55551eb5353354e947bd7703 Mon Sep 17 00:00:00 2001 From: tastytea Date: Thu, 11 Aug 2022 01:04:28 +0200 Subject: [PATCH] nvim: only run colorcolumn function on tw change --- .config/nvim/lua/coding.lua | 2 +- .config/nvim/lua/settings.lua | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.config/nvim/lua/coding.lua b/.config/nvim/lua/coding.lua index e5fa3a3..b5ff9fb 100644 --- a/.config/nvim/lua/coding.lua +++ b/.config/nvim/lua/coding.lua @@ -28,7 +28,7 @@ vim.api.nvim_create_autocmd( pattern = { 'gitcommit', 'gitrebase' }, callback = function() -- FIXME: why does the autocmd in settings.lua not set it? - vim.wo.colorcolumn = tostring(vim.o.textwidth) + vim.opt_local.colorcolumn = tostring(vim.o.textwidth) vim.cmd([[startinsert | 1]]) end }) diff --git a/.config/nvim/lua/settings.lua b/.config/nvim/lua/settings.lua index 57fca54..2bd261e 100644 --- a/.config/nvim/lua/settings.lua +++ b/.config/nvim/lua/settings.lua @@ -32,15 +32,15 @@ packer.use 'https://github.com/editorconfig/editorconfig-vim' -- set colorcolumn to textwidth after buffer is displayed or option is changed vim.api.nvim_create_augroup('config_settings', { clear = true }) vim.api.nvim_create_autocmd( - { 'BufWinEnter', 'OptionSet' }, + { 'OptionSet' }, { group = 'config_settings', pattern = { 'textwidth' }, callback = function() if vim.o.textwidth > 0 then - vim.wo.colorcolumn = tostring(vim.o.textwidth) + vim.opt_local.colorcolumn = tostring(vim.o.textwidth) else - vim.wo.colorcolumn = '' + vim.opt_local.colorcolumn = '' end end }