nvim: only run colorcolumn function on tw change
This commit is contained in:
parent
0e14ee24f2
commit
b72fab5c29
|
@ -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
|
||||
})
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user