bekaboo / deadcolumn.nvim Goto Github PK
View Code? Open in Web Editor NEWA neovim plugin that shows colorcolumn dynamically
License: GNU General Public License v3.0
A neovim plugin that shows colorcolumn dynamically
License: GNU General Public License v3.0
Hi there,
Would you please consider uploading git tags to this repo to denote stable releases? Thanks!
can shihua gg teach me how to install linux and use nvim?
Hi, thanks for working on this cool plugin. I decided to give it a try, because it seemed to have the most features, but can't make it work, even in vanilla vim.
repro.lua:
local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
local plugins = {
-- "Bekaboo/deadcolumn.nvim"
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd[[hi ColorColumn guibg=red]]
vim.cmd[[set textwidth=20]]
vim.cmd[[set colorcolumn=-10,25,+2]]
When I run nvim -u repro.lua test.txt
, it works as expected
but when I uncomment the line with the plugin, install it and start typing, nothing happens
Firstly, I want to express my sincere thanks for this plugin.
Description:
I've encountered an issue where the cursor loses its column position when scrolling down with the plugin active. This problem persists in nightly builds (I've tried multiple recent versions), but it doesn't occur in stable builds.
While I understand nightly builds may have issues, I wanted to report this problem for consideration.
To Reproduce:
mkdir ~/.config/testcolumn
cd ~/.config/testcolumn
touch init.lua
NVIM_APPNAME=testcolumn nvim
init.lua file
vim.opt.number = true
vim.opt.relativenumber = true
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",
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({
"Bekaboo/deadcolumn.nvim",
event = { "InsertEnter" },
config = function()
vim.opt.colorcolumn = "80"
local opts = {
modes = { "n", "i" },
blending = {
threshold = 0.75,
},
warning = {
alpha = 0.1,
},
}
require("deadcolumn").setup(opts)
end,
})
The video demonstrates that the issue does not exist before activating the plugin. However, after inserting and saving the file, the problem occurs when scrolling down a long line.
Video:
OS: MacOS
term: wezterm
neovim version:
NVIM v0.10.0-dev-2355+g1c7b0b9d5
Build type: RelWithDebInfo
LuaJIT 2.1.1707061634
Thank you
This plugin looks awesome! It would be great if it had support for virtual text custom character for the column like virtcolumn.nvim and virt-column.nvim do.
It looks like the way you use columns is that the text must finish before the column. I like to allow text on the column but not beyond it. Do you think there could be an option to allow text on the column?
Thanks for writing and releasing deadcolumn. I have a feature request if it fits in with your plans.
I like the concept of deadcolumn but I want to see the columns permanently. Do you think there could be an option such that when the columns aren't currently shown they could be shown is the default fashion?
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
minimal.lua
nvim --clean -u minimal.lua
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.
Was previously using this: https://github.com/xiyaowong/virtcolumn.nvim?tab=readme-ov-file
Just tested it and it seems to override the functionality of this plugin. Would be nice if we can combine the two or get such an option as part of this. (single pixel column looks really nice)
Hi and thanks for the great plugin! One small bug I noticed: when using this plugin, my horizontal cursor position is not saved in normal mode, same problem found here or here. I really like this plugin but this issue bugs me so hopefully it can be fixed, thank you!! (P.S. when disabling the plugin, horizontal cursor position is again saved correctly)
I get the following error, when scope
and modes
are setup, and theme is changed programatically afterwards:
Error detected while processing ./minimal.lua:
E5113: Error while calling lua chunk: ./minimal.lua:28: /Users/simon.mandlik/Downloads/test_deadcolumn/minimal.lua..ColorScheme Autocommands for "*": Vim(append):Erro
r executing lua callback: ...column/.repro/plugins/deadcolumn.nvim/lua/deadcolumn.lua:154: bad argument #1 to 'scope' (number expected, got no value)
stack traceback:
[C]: in function 'scope'
...column/.repro/plugins/deadcolumn.nvim/lua/deadcolumn.lua:154: in function <...column/.repro/plugins/deadcolumn.nvim/lua/deadcolumn.lua:140>
[C]: in function 'nvim_command'
./minimal.lua:28: in main chunk
stack traceback:
[C]: in function 'nvim_command'
./minimal.lua:28: in main chunk
minimal.lua
:
local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
local plugins = {
"Bekaboo/deadcolumn.nvim",
opts = {
scope = "buffer",
modes = function(mode)
return mode:find('^[nictRss\x13]') ~= nil
end,
}
}
vim.cmd[[set termguicolors]]
vim.cmd[[set colorcolumn=20]]
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.api.nvim_command("colorscheme default")
Hi, I wanted to achieve a simple colorcolumn, that would behave like vanilla colorcolumn, but would start appearing once the cursor is getting closer to it.
What I need from deadcolumn
is to show "standard" colorcolumn when the text is longer than textwidth, and only slowly "fade in" and "fade out".
But I can't even make colorcolumn have the same background color as ColorColumn
highlight group.
This is my minimal.lua
:
local root = vim.fn.fnamemodify("./.repro", ":p")
for _, name in ipairs({ "config", "data", "state", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
local lazypath = root .. "/plugins/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", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)
local plugins = {
{
"Bekaboo/deadcolumn.nvim",
init = function()
require('deadcolumn').setup {
blend = { hlgroup = { "ColorColumn", "bg" }, },
warning = { hlgroup = { "ColorColumn", "bg" }, },
}
end
}
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
vim.cmd[[set termguicolors]]
vim.cmd[[hi ColorColumn guibg=blue]]
vim.cmd[[set colorcolumn=20]]
And this is the behavior:
Color column has red color instead of blue, and once the text length exceeds the column, it turns into brown.
Can I somehow make the colorcolumn have the same color as the ColorColumn
highlight group and basically "turn off" the warning functionality, only display fully opaque color column?
Thanks!
I wanted to change behavior to be more proactive at alerting me to long lines of code. So my current setup is:
require('deadcolumn').setup{
scope = 'visible',
modes = { "n", "i", "ic", "ix", "R", "Rc", "Rx", "Rv", "Rvc", "Rvx" }
}
I changed scope to visible
to widen the scope.
I added n
for normal mode so deadcolumn is shown in normal mode, which is a bit spicy.
I think something nice that would make it a little bit less spicy is if I could e.g. change the threshold for normal mode, and only make deadcolumn appear if a line is longer than the limit, just in normal mode.
Sorry for the low-quality bug report, but sometimes this plugin just... doesn't work. I enter insert mode and see no color column, despite there being a long line visible on my screen (I'm using scope 'visible'
). Restarting vim fixes the issue.
I peeked at the implementation, and I see it's incredibly involved and complicated. So thanks for packaging this up into a plugin and trying to maintain all of the complexity behind an interface, but unfortunately, it seems something so far was missed.
Has anyone else experienced this issue? I'm afraid I don't have a reliable repro.
It throws below error:
Error detected while processing /Users/username/.config/nvim/init.lua:
E5113: Error while calling lua chunk: vim/_editor.lua:0: /Users/username/.config/nvim/init.lua..nvim_exec2() called at /Users/username/.config/nvim/init.lua:0..ColorScheme Autocommands for "*": Vim(append):Error executing lua callback: ...re/nvim/lazy/deadcolumn.nvim/lua/deadcolumn/autocmds.lua:73: bad argument 1 to '?' (number expected, got no value)
stack traceback:
[builtin#61]: at 0x0103a18aa4
...re/nvim/lazy/deadcolumn.nvim/lua/deadcolumn/autocmds.lua:73: in function <...re/nvim/lazy/deadcolumn.nvim/lua/deadcolumn/autocmds.lua:58>
[C]: in function 'nvim_exec2'
vim/_editor.lua: in function 'cmd'
/Users/username/.config/nvim/init.lua:57: in main chunk
stack traceback:
[C]: in function 'nvim_exec2'
vim/_editor.lua: in function 'cmd'
/Users/username/.config/nvim/init.lua:57: in main chunk
Press ENTER or type command to continue
This plugin works really freaking well, I'm always a fan of reducing visual noise, but one this I miss is that I can no longer tell of a line in the current view crosses the column.
If I set scope
to "visible"
, then the point of the plugin is largely lost, I don't want to see the colorcolumn as long as nothing crosses it.
What would be perfect is if the plugin did exactly what it currently does, but if a currently visible line crosses the colorcolumn, it should be displayed no matter what.
Unless I've misunderstood the documentation, this isn't currently possible. Is there a elegant way this can be implemented?
Maybe something like:
warningscope = "buffer" | "visible"
Works like scope, but overrides it if a line actually crosses the colorcolumn. My ideal behavior would be scope = "line"
and warningscope = "visible"
. I would also probably like warningscope = "buffer"
so I would immediately know if any line in the current file was too long.
After upgrading my nvim packages, I got this:
Error detected while processing /home/mort/.config/nvim/init.lua:
E5113: Error while calling lua chunk: /home/mort/.config/nvim/lua/theme.lua:3: /home/mort/.config/nvim/init.lua..ColorScheme Autocommands for "*": Vim(append):Error executing lua callback:
...hare/nvim/lazy/deadcolumn.nvim/lua/deadcolumn/colors.lua:41: invalid key: create
stack traceback:
[C]: in function 'nvim_get_hl'
...hare/nvim/lazy/deadcolumn.nvim/lua/deadcolumn/colors.lua:41: in function 'get'
...local/share/nvim/lazy/deadcolumn.nvim/lua/deadcolumn.lua:17: in function 'get_hl_hex'
...local/share/nvim/lazy/deadcolumn.nvim/lua/deadcolumn.lua:24: in function <...local/share/nvim/lazy/deadcolumn.nvim/lua/deadcolumn.lua:23>
[C]: in function 'colorscheme'
/home/mort/.config/nvim/lua/theme.lua:3: in main chunk
[C]: in function 'require'
/home/mort/.config/nvim/init.lua:8: in main chunk
stack traceback:
[C]: in function 'colorscheme'
/home/mort/.config/nvim/lua/theme.lua:3: in main chunk
[C]: in function 'require'
/home/mort/.config/nvim/init.lua:8: in main chunk
Just installing the package without any config.
My system:
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1693350652
In a nutshell winhighlight
conflicts with vim.api.nvim_win_set_hl_ns
. The documentation says that either way of setting highlights takes precedence over another way. In practice, it means that if a highlight is set by winhighlight
, it completely disables all highlights that were set by nvim_win_set_hl_ns
.
*'winhighlight'* *'winhl'*
'winhighlight' 'winhl' string (default "")
local to window
Window-local highlights. Comma-delimited list of highlight
|group-name| pairs "{hl-from}:{hl-to},..." where each {hl-from} is
a |highlight-groups| item to be overridden by {hl-to} group in
the window.
Note: highlight namespaces take precedence over 'winhighlight'.
See |nvim_win_set_hl_ns()| and |nvim_set_hl()|.
nvim_win_set_hl_ns({window}, {ns_id}) *nvim_win_set_hl_ns()*
Set highlight namespace for a window. This will use highlights defined
with |nvim_set_hl()| for this namespace, but fall back to global
highlights (ns=0) when missing.
This takes precedence over the 'winhighlight' option.
Parameters: ~
• {ns_id} the namespace to use
Snippet to test:
local ns = vim.api.nvim_create_namespace("UserTestHighlight")
vim.api.nvim_set_hl(ns, "Function", { fg = "#00FF66" })
vim.keymap.set("n", "<C-w>", function()
vim.api.nvim_win_set_hl_ns(0, ns)
end)
vim.api.nvim_create_autocmd({ 'CursorMoved', 'TextChanged', }, {
callback = function()
vim.wo[0].winhl = "String:"
end
})
ccc.nvim is one of the plugin that is in conflict with the current plugin.
I think that sticking to the lua api is a good way to solve the problem
I have the setting vim.o.colorcolumn = '100'
, which normally works and sets the value.
When running the plugin with lazy.nvim
, and then running :set colorcolumn?
to verify the value, the setting appears empty. Setting the value to 100 in the buffer makes the plugin work normally afterwards.
Uninstalling and then verifying the value of the setting, the setting has the correct value.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.