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' },
|
pattern = { 'gitcommit', 'gitrebase' },
|
||||||
callback = function()
|
callback = function()
|
||||||
-- FIXME: why does the autocmd in settings.lua not set it?
|
-- 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]])
|
vim.cmd([[startinsert | 1]])
|
||||||
end
|
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
|
-- 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_augroup('config_settings', { clear = true })
|
||||||
vim.api.nvim_create_autocmd(
|
vim.api.nvim_create_autocmd(
|
||||||
{ 'BufWinEnter', 'OptionSet' },
|
{ 'OptionSet' },
|
||||||
{
|
{
|
||||||
group = 'config_settings',
|
group = 'config_settings',
|
||||||
pattern = { 'textwidth' },
|
pattern = { 'textwidth' },
|
||||||
callback = function()
|
callback = function()
|
||||||
if vim.o.textwidth > 0 then
|
if vim.o.textwidth > 0 then
|
||||||
vim.wo.colorcolumn = tostring(vim.o.textwidth)
|
vim.opt_local.colorcolumn = tostring(vim.o.textwidth)
|
||||||
else
|
else
|
||||||
vim.wo.colorcolumn = ''
|
vim.opt_local.colorcolumn = ''
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user