[Bug] deadcolumn works only in the first file
Closed this issue · 6 comments
Hi, thanks for this nice plugin.
Describe the bug
-
Context
When I open a file, it just works. But after moving to other files (eg. when opening multiple files, moving to a definition of a function in another file, etc.) it doesn't work in them. It works again when I come back to the first one.
-
Expected behavior
I expect it to work on any file, regardless of the number or sequence of file opens.
-
Actual behavior
It works only in the first file.
To Reproduce
-
Minimal
init.lua
-- Lazy local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' if not vim.loop.fs_stat(lazypath) then vim.fn.system({ 'git', 'clone', '--filter=blob:none', 'https://github.com/folke/lazy.nvim.git', '--branch=stable', -- latest stable release lazypath, }) end vim.opt.rtp:prepend(lazypath) require'lazy'.setup({ { 'Bekaboo/deadcolumn.nvim' }, }, {}) -- options local opt = vim.opt opt.colorcolumn = '80' opt.termguicolors = true
-
Steps to reproduce the behavior
- Save the above config as
minimal.lua
- Start Neovim using
nvim --clean -u minimal.lua
- Open multiple files and check if it works in them.
- Save the above config as
Environment
-
Neovim version: NVIM v0.9.0-dev-1338+g9e7426718
-
Operating system: Ubuntu 22.04
Additional context
Add any other context about the problem here.
Hi, thanks for reporting this issue. Please use the standard minimal config provided (don't use any package manager, e.g. lazy.nvim) and use /tmp/...
as the installation path, or it will be hard for me to track this issue (for example, I have to manually remove all my plugins under .local/share/nvim/lazy/...
to test this without other plugins.
@Bekaboo Sorry for the minimal lua file!
Actually, it works ok with your minimal init.lua file,
but doesn't work with lazy.nvim, so I think it may be due to the lazy loads of the package manager.
I understand. That could be the case. What is the behavior if you call require('deadcolumn').setup()
explicitly?
I tried :lua require('deadcolumn').setup()
in non-working opened files, and there's no notable change.
@meinside The problem is that you set vim.opt.colorcolumn
after loading this plugin. For deadcolumn.nvim to catch the settings of vim.opt.cc
, you should set it before loading the plugin. It is currently impossible to detect an option change during startup in nvim, so there's little thing that deadcolumn.nvim can do to fix this issue.
The following minimal.lua
works for me:
-- options
local opt = vim.opt
opt.colorcolumn = "80"
opt.termguicolors = true
-- Lazy
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
{
"Bekaboo/deadcolumn.nvim",
},
}, {})
Thank you! It now works as expected.